Hello all,
I have an RPi 3 and am pretty new to Python, Pi's, and Arduinos...I'll get right to it:
I have an Adafruit PCA9685 (16 channel, 12-bit PWM output device) and an MCP3008 (8 channel, 10-bit, ADC input). At the moment I have three Python 3 scripts that I wrote to test each aspect of my program: analog input reading, CSV file reading to generate PWM lookup tables, and PWM outputs. The analog inputs and PWM outputs share some pins and some communication code but since I've tested each setup separately I'm not sure how to proceed.
How do I:
a) Wire up two SPI devices so I can use both "simultaneously" (not really, but at least without requiring changes to wiring each time)?
b) Use Python to communicate with each device every 100 milliseconds while the program is running(for example, read the value from a potentiometer, do some math, and write out a value to the PWM board)?
bonus) I'd like a Tkinter window to show me the 'real-time' potentiometer value and current PWM value. Every attempt I've made at this ends 1 of 3 ways:
- tkinter window redraws itself infinitely and the CPU goes to 100%
- tkinter window shows the value that was present when it was drawn and doens't update
- Or the window draws fine and is "live", but it halts the rest of my Python script and my 100 millisecond math calculations stop happening
Any help would be greatly appreciated! Thanks!
Dylan
Also, yes I know I didn't post any code but that's because I'm currently using blatant copy-paste code for communication on both devices, and I don't think my CSV file handling or math is holding me up. I'm just very new to SPI, and can't find many examples of using two SPI devices at once. I'm also new to tkinter and haven't found any other GUI that's easier for me or clearly solves my problem.