SPI errors with Controllino and Pixy CMUcam5

Hello everyone,

I would like to ask for your support on this topic:

BACKGROUND

I have a Pixy CMUcam5 sensor (Information about Pixy CMUcam5) wired to an Arduino-based PLC named Controllino MAXI (Information about Controllino).

My wiring is like this:

Pixy SPI and power pins are connected to a small protoboard which supplies the power to Pixy (measured 5.25V from my 5V power supply), and takes the SPI pins (SCK, MISO, MOSI) to the corresponding pins in the Controllino pin header. The Controllino is powered by a different, 12V power supply (measured 12.15V).

The GND pins in both power supplies are connected to each other.

I’m using the “hello world” example from the Pixy library:

#include <SPI.h>  
#include <Pixy.h>

Pixy pixy;

void setup()
{

  Serial.begin(9600);
  Serial.print("Starting...\n");

  pixy.init();
}

void loop()
{ 
  static int i = 0;
  int j;
  uint16_t blocks;
  char buf[32]; 
  
  blocks = pixy.getBlocks();
  
  if (blocks)
  {
    i++;
    
    if (i%50==0)
    {
      sprintf(buf, "Detected %d:\n", blocks);
      Serial.print(buf);
      for (j=0; j<blocks; j++)
      {
        sprintf(buf, "  block %d: ", j);
        Serial.print(buf); 
        pixy.blocks[j].print();
      }
    }
  }  
}

PROBLEM

Sometimes the Pixy will not send any blocks to the Controllino, and the Serial Monitor will only read “Starting…” and no blocks. I’ve checked that the reason for this is that blocks never changes from 0, although Pixy shows through its LED indicator that it is actually detecting objects.

If this problem appears, it will never work even when restarting the Controllino and the Pixy several times.

The problem is sometimes solved by uploading the program again to the Controllino. If this happens, the Pixy will communicate correctly with Controllino most of the time (the error still happens sometimes when turning off/on the system, but it is fixed by turning on/off again).

The issue sometimes appears again if the program is uploaded to the Controllino again.

ADDITIONAL DETAILS

  • This issue NEVER happens if I replace the Controllino with a USB-powered Arduino MEGA (1280). Pixy will ALWAYS send blocks to Arduino regardless of how many times I turn on/off or re-upload the program.

  • This issue doesn’t happen as often if I keep the 12V power supply off and power the Controllino via USB instead, but it does happen sometimes.

  • In all of these situations I used the same cable, same connections, same protoboard, and in the connection to the Arduino MEGA (1280) I used the same pins for the communication (50, 51, 52), not the ICSP header.

  • When testing with Arduino MEGA (1280) I select that board in the IDE and the port information only shows “COM8”.

  • When testing with Controllino MAXI, I select Controllino MAXI board in the IDE, and the port information says “COM9 (Arduino MEGA 1280 or 2560)”. I think this is kind of strange, but I don’t know if it has anything to do with the issue.

Thank you in advance for your support. If you need additional details I’ll be happy to provide them.

Do you have schematics for that Controllino MAXI? Maybe there is some other circuit also connected to the SPI pins that cause a higher pin capacitance so you might have to lower SPI speed.

Hello pylon,

Thanks for your quick answer. I just checked the documentation (unfortunately I didn't find schematics) and found out that the Controllino MAXI has an Ethernet connector, using the same SPI bus, that works with an Ethernet WIZnet Chip W5100.

It also has an RTC chip (RV-2123-C2-TA-QC-020) connected to that SPI bus. According to the documentation, they had to implement a chip select (did they mean Slave Select? I don't know) internally (manipulated automatically when using Ethernet functions with the Controllino Library). I also don't know if this keeps the same pins the Ethernet shield uses for slave select (pin 4 for SD card and 10 for Ethernet), but the Controllino MAXI doesn't have SD.

There's no documentation that explains if there are any restrictions or special procedures for using that same SPI bus with other devices, and the Pixy CMUcam5 doesn't have a Slave Select pin, I think.

What would be your recommendation? I will start by lowering the SPI speed, but other suggestions would be very appreciated.

Thanks again!

According to the documentation, they had to implement a chip select (did they mean Slave Select? I don't know) internally

Chip select and slave select usually means the same. Chip select is often used with sensors and the like while slave select is what the pin usually is called when the microcontroller is the SPI slave.

There's no documentation that explains if there are any restrictions or special procedures for using that same SPI bus with other devices, and the Pixy CMUcam5 doesn't have a Slave Select pin, I think.

The SPI bus needs a CS pin or SS if you like otherwise it's not actually an SPI interface. You can use the SPI hardware to do other interfaces that synchronously outputs a serial signal very fast. The Pixy CMUcam5 has the SS signal on pin 7 of the communication header. To which pin of your Controllino is that pin connected?