PixyCam port initial trial

I finally decided to try doing something with the PixyCam. It’s been kicking around in my office for over a year.

I find the documentation for Pixy to be quite poor relying mainly on Arduino code examples.

This port is using the SPI Interface but means that the functionality is limited as the full API is only available via USB.

There’s still a lot of tweaking to do as this is just a port of the Arduino at present and the PID Terms are set deliberately slow and far from optimal but at least I’m getting block data back and can drive the LED and servo pins.

ps - Please ignore the state of my desk - it’s a man cave. :-[

10 Likes

Great work, are you going to make a driver or share the snippet? I’ve been searching for this for months as I couldn’t get my pixy to communicate with a raptor.

Once I have finished it I will put it on CodeShare.

Sounds great. I’ve been trying to do the same thing all day today. I’ve created a cable that works, and got the Raptor talking over SPI to the Pixycam/CMUcam5. I’ve modified the Arduino code and it ‘works’ to some extent. However, while I do see data coming from the cam (I cover the lens an I get no data, I uncover it and I get data), but I don’t get a start of frame or block marker (AA 55 hex or 170 85 decimal). When I use PixyMon on my PC, I see an object detected and its signature 1. On the Raptor I do get bytes 170 170 regularly and here’s an example of the bytes that follows, any ideas???

170
170
5
48
0
32
39
128
115
0
152
1
84
85
82
80
45
64
0
0
62
1
160
2
224
11

Happy to post some of my code, maybe you could share yours if you are seeing a 170 85 frame/block marker data coming from your cam?

Any updates? cant wait to get my raptor talk to pixy. ANy planned beta version :slight_smile: ?

I am also waiting. Just noticed a new firmware from charmed… :hand:

Sorry guys but I’m currently stuck on a project for the boss (the wife in other words) so haven’t been able to refine the code.

From my initial trials I started to think that the SPI interface wasn’t the best way to go with this as the usb interface would really open up more possibilities but is currently way outside my comfort zone.

So, I finally got it working, using SPI! Although I was getting data through I could not find the frame start marker, but when I changed the clock idle state flag from false to true, I get good data!

I will post full code once I get all the bugs ironed out (hopefully this week), but in the meantime, the code to create the SPI is this…


        public PixyCam(int socketNumber)
        {
            //raptor sockets 1,3, 11 support spi
            Socket spiSocket = Socket.GetSocket(socketNumber, true, this, null);

            spiSocket.EnsureTypeIsSupported('S', this);
            SPI.SPI_module spiModule = spiSocket.SPIModule;

            SPI.Configuration PixyCamSPIConfig = new SPI.Configuration(
                Cpu.Pin.GPIO_NONE,  //chip select port - not required for ICSPI like Arduino no slave select
                false,              //chip select active state - If true, the chip select port will be set to high when accessing the chip; if false, the chip select port will be set to low when accessing the chip
                0,                  //chip select setup time - amount of time that will elapse between the time at which the device is selected and the time at which the clock and the clock data transmission will start
                0,                  //chip select hold time -  specifies the amount of time that the chip select port must remain in the active state before the device is unselected
                true,              //clock idle state - If true, the SPI clock signal will be set to high while the device is idle; if false, the SPI clock signal will be set to low while the device is idle
                true,               //clock edge - If true, data is sampled on the SPI clock rising edge; if false, the data is sampled on the SPI clock falling edge
                1000,               //clock kHz (1mhz) - 1000=1Mhz sampling rate
                spiModule           //SPI module defined above
                );

               SPI PixyCamSPI = new SPI(PixyCamSPIConfig);
        }

Got it working and debugged. I have posted full code solution on codeshare:

https://www.ghielectronics.com/community/codeshare/entry/1017

Welcome to 50fps robot vision and object detection using .NET MF 4.3!

Enjoy!

4 Likes

This is awesome!

Is that a Holey board cut in half in the video?

Did you post a new video with 50fps?

CMUcam5 is on sale this black friday…

did you ever create a video using your improved code?

I’d like to see

@ mtylerjr - where did you see Pixy on sale? I have somewhat of a hankering…

@ Brett - I have a hankering as well and asked about this so here is the location RobotShop Newsletter

Unfortunately at only 10% off its not getting my Scottish blood all that excited.