Skip to content
cwm9cwm9 edited this page Mar 15, 2023 · 5 revisions

RoboRio SPI overview:

  • There is a minor voltage incompatibility concern between the RoboRio output and Arduino
    • Turn on the Arduino pull-up resistors on CS, SCLK, COPI
    • Add appropriate (60-100 ohm typical) impedance matching resistors to CS, SCLK, and COPI near the Roborio to prevent reflections
      • (The combination will help compensate for the RoboRio's low output voltage by raising the voltage at the Arduino input pin)
  • Add appropriate (60-100 ohm typical) impedance matching resistors to CIPO near the Arduino to prevent reflections
  • Fast 4 Mhz transfer rate (vs 400 Khz I2C transfer rate)
  • Supports up to 4 devices using a chip select line to choose which device to communicate with.
  • 3 wires are required for one-way communication, 4 for two-way communication.
    • A clock select line which both selects a device and indicates the transmission of the first bit
    • A clock line synchronizes the transfer of data
    • Possibly a COPI - "Controller Out Peripheral In" line (synonymous and preferred to MOSI - "Master Out Slave In")
    • Possibly a CIPO - "Controller In Peripheral Out" line (synonymous and preferred to MISO - "Master In Slave Out")
      • The STEM community has widely discontinued the use of master/slave terminology. Many terms across the industry have changed as a result.

Hardware details:

  • RoboRio

  • Arduino Uno Rev3 (And probably applies to many other Arduinos, but it is your responsibility to check)

    • COIP/SCLK/CS input voltage levels
      • VIL ("input low" voltage range, optional pull-up resistor to Vcc guaranteed between 20k-50k ohms)
        • -0.5v min
        • 1.35v max (actually 0.3 * Vcc, assuming minimum Vcc of 4.5v for 16 Mhz parts)
      • VIH ("input high" voltage range, optional pull-up resistor to Vcc guaranteed between 20k-50k ohms)
        • 2.7v min (actually 0.6 * Vcc, assuming minimum Vcc of 4.5v for 16 Mhz parts)
        • 3.15v min (actually 0.6 * Vcc, assuming maximum Vcc of 5.25v for 16 Mhz parts and RoboRio compatibility)
        • 6.0v max (actually Vcc + 0.5v)
          • THE ROBORIO ONLY GUARANTEES VOH = 2.4v, BUT ARDUINO VIH REQUIRES 3.15v!
      • VOL ("output low" volage range)
        • 0.0v min (implied, no actual value given)
        • 0.5v max (when sinking 5ma or less)
        • 0.8v max (when sinking 20ma or less)
      • VOH ("output high" voltage range, guaranteed only when sourcing 4ma or less)
        • 4.1v min (when sourcing 20ma or less and Vcc is 5v --- no value given at Vcc = 4.5v)
        • Vcc max (implied, no actual value given)

Note that the VOH (Logic high output voltage) of the Robio Rio is only guaranteed to be at least 2.4v, but the Arduino VIH (Logic high input voltage) requires at least 2.7v (at Vcc=4.5v) to 3.15v (at Vcc=5.25v) to work properly.

The RoboRio output SCLK and COPI (and CIPO, but that isn't important) pins have a PULL-DOWN 40k ohm resistor. The Arduno input lines have an optional PULL-UP 20k-50k ohm resistor. The RoboRio documentation states "You can add a stronger resistor to a DIO line to cause it to float in the opposite direction" but does not give specific details about what the output stage of the pins actually looks like.

Let's see if we can reverse engineer some details.

We know that the output stage is probably a CMOS FET transistor connected between the output pin and the 3.3V input rail. We also know there is a 40k pulldown resistor, and that with an external 4ma sink, the output voltage is guaranteed to be 2.4v.

If we treat the transistor as an unknown resistor between the 3.3v supply and the 2.4v output pin with a 40k ohm resistor to ground in parallel with a -4ma current source attached to the pin, we can calculate an effective resistance for the output transistor of about 220 ohms.

The output voltage assumes a current draw of -4ma, but the Arduino input impedance is high, and the device sinks little current. We can simulate what happens to the pin when the Arduino is attached if we remove the current sink and rerun the simulation with a transistor resistance of 220 ohms. The pin voltage rises to 3.28V, above the Arduinos required VIN of 3.15v.

This result implies, but does not guarantee, that the Arduino's inputs are compatible with the RoboRio's outputs. However, the addition of a 100 ohm impedance matching resistor to the output of the RoboRio (close to the RoboRio, not close to the Arduino) in addition to turning on the Arduino input pull-up resistor will cause the voltage at the Arudio to rise several mV and help ensure compatibility.

Clone this wiki locally