Giter VIP home page Giter VIP logo

Comments (18)

kashimAstro avatar kashimAstro commented on July 16, 2024

Hi, I will make a couple of quick questions, to understand the problem...

  1. you have enabled SPI? There are many ways to do it, simple mode:
      raspi-config -> Advanced Option -> SPI

  2. to have a confirmation on the operation of SPI do:
    lsmod | grep bcm

  3. you can make a photo at the cable connection?

  4. since the last update and 'added a SPI2 class that I have not tested adc3008, you are using SPI or SPI2?

thanks for the tip :)

from ofxgpio.

urbanpixellab avatar urbanpixellab commented on July 16, 2024
  1. spi is already enabled
  2. snd_bcm2835 20511 1
    snd_pcm 75698 1 snd_bcm2835
    snd 51844 5 snd_bcm2835,snd_timer,snd_pcm
    bcm2835_wdt 3225 0
    bcm2835_gpiomem 3040 0
    spi_bcm2835 7286 0
  3. i am using spi, not spi2

3 pictures are in a few minutes

from ofxgpio.

urbanpixellab avatar urbanpixellab commented on July 16, 2024

20160613_184823

from ofxgpio.

kashimAstro avatar kashimAstro commented on July 16, 2024

you can publish your program setup that contain the "new = SPI()" ?

from ofxgpio.

urbanpixellab avatar urbanpixellab commented on July 16, 2024

#include "ofMain.h"
#include "ofAppNoWindow.h"
#include "ofxGPIO.h"

class noWin : public ofBaseApp{
public:
SPI * spi;
int i;
int a2dVal;
int a2dChannel;
unsigned char data[3];

    void setup(){
            i = 20;
            a2dVal = 0;
            a2dChannel = 0;
            spi = new SPI("/dev/spidev0.0", SPI_MODE_0, 1000000, 8);
    }

    void update(){
        data[0] = 1;
            data[1] = 0b10000000 |( ((a2dChannel & 7) << 4));
            data[2] = 0;

            spi->spiWriteRead(data, sizeof(data) );
            a2dVal = 0;
                a2dVal = (data[1]<< 8) & 0b1100000000;
                a2dVal |=  (data[2] & 0xff);
            sleep(2);
            ofLog()<<"Result: " << a2dVal;
    }

};

int main( ){
ofAppNoWindow window;
ofSetupOpenGL(&window, 0,0, OF_WINDOW);
ofRunApp( new noWin() );
}

from ofxgpio.

urbanpixellab avatar urbanpixellab commented on July 16, 2024

This is your spi example, which i am using.

from ofxgpio.

kashimAstro avatar kashimAstro commented on July 16, 2024

you've tried to use interface: /dev/spidev0.1 ?

from ofxgpio.

urbanpixellab avatar urbanpixellab commented on July 16, 2024

i tried now
spi = new SPI("/dev/spidev0.1", SPI_MODE_0, 1000000, 8);

but the same error.

from ofxgpio.

kashimAstro avatar kashimAstro commented on July 16, 2024

I'm trying MCP3008 in the laboratory, short update you

from ofxgpio.

kashimAstro avatar kashimAstro commented on July 16, 2024

ok the problem exists, but appears to be closely tied to 9.x of openFrameworks paired with a combination of reading from SPI.

In fact, if you try to run this example outside openFrameworks or with a version of openFrameworks < 9.x running fine.

I am attaching an example in C ++ to use without openFrameworks.
extract the zip file in the /home/pi/
cd mcp3008/
make
./main

mcp3008.zip

let me know if this example outside openFrameworks works for you.
in a while I try to figure out the problem, I leave this open.

from ofxgpio.

urbanpixellab avatar urbanpixellab commented on July 16, 2024

wow, thank you for this example, this is working.

from ofxgpio.

xumo avatar xumo commented on July 16, 2024

Have you solved this issue yet?

from ofxgpio.

kashimAstro avatar kashimAstro commented on July 16, 2024

hello @xumo , I'm sorry I fix this in September I am now out for work.

from ofxgpio.

xumo avatar xumo commented on July 16, 2024

Do you have any hints, I need deliver earlier? I'l try with OF 8.4, but cannot seem to find the release tar in the main site.
Thanks anyway, this is an awesome addons.

from ofxgpio.

kashimAstro avatar kashimAstro commented on July 16, 2024

kit_mcp.zip

Hi @xumo

a simple solution without changing the version is to use the demon that you find in the zip writing in a socket are also an example openFrameworks to read socket.

Good day

from ofxgpio.

xumo avatar xumo commented on July 16, 2024

Yei, thanks a lot.

from ofxgpio.

kashimAstro avatar kashimAstro commented on July 16, 2024

Hi guys @urbanpixellab @xumo,

I think I've solved the problem with SPI.

good day

from ofxgpio.

xumo avatar xumo commented on July 16, 2024

That's great. I'll test it as soon as I can.

from ofxgpio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.