With the hardware ready (as far I as knew) the next step was to start on the PIC MCU code that interfaces to the Raspberry Pi. In essence, there are really three tasks to be handled by the PIC:
- Pi Power controller - orderly power-down in particular!
- I2C slave to provide tuning, band, and volume potentiometer readings to the Pi
- RGB WS2811 pixel control
I was able to tackle the first item, and I'm quite satisfied with the result. As I've mentioned previously, my power controller is heavily based upon the work of James Lewis, aka the Bald Engineer. I didn't use an Arduino, of course, and I ended up implementing a slightly different state machine - but for the most part it's the same idea. In short:
- STANDBY state = PIC waits for the power switch to be turned "on"
- BOOTING state = PIC has applied power to the Pi and is waiting for D17 to be asserted by the Pi during the bootup sequence
- OPERATE state = PIC has observed D17 asserted by Pi (booted) and is holding D27 asserted to keep the Pi from shutting down
- SHUTDOWN state = PIC has found the power switch to be "off" and negates D27 to cause the Pi to shutdown
- PI_CONTROL state = PIC has found that D17 has negated (Pi-initated shutdown/restart) and waits an appropriate amount of time for restart or a shutdown
I've tested this quite a bit with various scenarios - I won't say it's bulletproof, but for the most part seems to be working well. Again, not my idea, so I'm more worried about my implementation than the whole concept itself!
I have implemented the second item, I2C slave, but yet to test it. I need to play with the Pi now to send some I2C messages and see if (how?) the PIC responds. In the meantime I've read a ton of stuff on the intrawebs about how the microchip I2C slave code is perhaps not-so-great, and/or how the I2C peripheral itself isn't so perfect when in slave mode. Oh joy.
The third task, WS2811 pixel control, should have been easy - as I did this already in my Rubidium Timebase project. However, for some reason it's not working... Grrrrrrrr!
But for now, I'm happy that I have a Pi that powers up and down (safely) when I turn the "power switch" on the old tube set.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.