3

I've connected an MCP3008 to a raspberry pi. First on a solderless breadboard, where everything worked correctly. Then on a prototyping board, where the only difference is that the chip is externally powered. The problem is now that the response from the slave is occasionally missing bits (the slave fails to pull the signal up for every bit that it should). Here is a series of readings taken at a 0.01 s interval:

[3.4, 3.39, 3.29, 0.0, 3.4, 3.4, 3.4, 2.55, 0.0, 2.98, 3.39, 0.0, 3.39, 3.3, 3.19, 3.4, 2.98, 3.4, 3.4, 0.58]

The readings are normalized for Vref = Vin = 3.4.

I've tried:

  • Redoing the soldering,
  • replacing the MCP3008,
  • adjusting the SPI frequency (currently at 1.35 MHz),
  • checking the connections and voltages using a multimeter
  • using the piscope to examine the serial communication (tricky, because if I set the frequency low enough to get a good reading, the chip rarely returns any values at all)
  • grounding unused inputs

The PCB has copper wire from the header to the chip for the SPI interface, about 5cm long. As far as I can see, that should be fine for SPI. SpiDev is set to use mode 0.

Any other ideas as to what might be going wrong would be hugely appreciated.

Update:

Connecting the Raspberry Pi ground to the external ground solved the issue, so it looks like the lack of common reference voltage caused the mcu to sometimes not pull high above the necessary threshold.

  edit    flag 
  • 2
    Time for a real scope ... – Tom L. Aug 6 at 22:17
  • 4
    Decoupling caps? – DKNguyen Aug 6 at 22:20
  • 1
    I have caps on all the inputs, same as on the breadboard. – boileau Aug 6 at 22:26
  • 1
    @TomL. Yeah, I think I'll finally have to bite the bullet and pick up an oscilloscope. But in this case it will only rule out bad wiring, I think. – boileau Aug 6 at 22:28
  • 1
    @boileau It could show a noise issue, connection instability, or brownout. You said in your post that you're missing bits, but your 3.4V readings show that you're missing entire bytes. Which is it? – DKNguyen Aug 6 at 23:10 
  • 1
    do you have components available to go back to solderless breadboard? ... if you do have the components, then go back to a working version and switch to external power supply – jsotola Aug 7 at 0:14 
  • 1
    @DKNguyen if an entire byte is missing, then bits are necessarily missing (8 to be precise). – boileau Aug 7 at 6:40
  • @jsotola I don't because I managed to short 24V through the first mcu. That would have been my next step otherwise. – boileau Aug 7 at 11:51
  • @boileau They are different problems. Failing to assert an entire random bytes is different than failing to assert random individual bits. – DKNguyen Aug 7 at 13:09