More Robotics Club
… aww, that was sweet of Kyra, I think. (In case I delete the post, I left my computer unattended on the table and she wrote a little blog post about it.)
I do kinda wish people wouldn’t call me “guy.” Not sure why… It might be because it’s weirdly informal? But I don’t really mind people calling me similarly informal things.
Anyways onto brass tacks.
What a SPIghtmare
I found a Python library to work with SPI on the Raspi called spidev, which seems to work.
But of course, the devil’s in the details.
The documentation for the MCP3008 is very dense, but here’s what I think happens.
- Raspi activates the MCP3008 by pulling
chip selectlow. - Raspi sends 4 bits over
MOSIindicating which pin to gather data from and whether it’s in “single-ended” or “differential” mode. I don’t really understand differential mode so I’ll stick with single-ended. (I think differential is for noise smoothing?) - MCP3008 sends 10 bits over
MISOwith the signal it reads off from the specified pin. - MCP3008 continually sends 0 until it’s deactivated by the Raspi pulling
chip selecthigh.
All of this is great except for step 2. spidev operate on bytes, not bits. If I send one byte,
even if I only set 4 of the bits, I’ll have missed 4 of the bits the MCP3008 sent.
There is an advanced xfer method with a word_size parameter but I’m not amazingly sure if I’m using it right.
Ugh. I might just cop out and go ask RZTD if they have any tips.