I'm new to 'real' coding I used to program plc and is currently working whit cnc, I have a few question about how you code for Reading different channels.
I'm currently using a R pi 3, have a set up of 2 x type k running thru amp's (ad8495) in to a mcp3208.
After about a day at banking my head against other peoples awesome code I managed to figure out the basic of Reading a channel, converting incoming bit's to volt/temp and then how to Wright this to a log.
Now my project is a Data Logger for a racecar http://www.rawvalley.se, I'm going to need quite a few sensors to read, I require 15 analog signals in for 2 mcp3208 on separate SPI channels.
This is the code I now use to read my mcp3208 in python.
Code: Select all
# Open SPI bus
spi = spidev.SpiDev()
spi.open(0,0)
# Function to read SPI data from MCP3208 chip
# Channel must be an integer 0-7
def ReadChannel(channel):
adc = spi.xfer2([6+((4&channel)>>2),(3&channel)<<6,0])
data = ((adc[1]&15) << 8) + adc[2]
return data
I also have a Quick question, i require reasonably fast samplings per seconds on all channels at least 100 samples per second.
I plan to use two mcp3208 read 11 analog temp signals, 4 analog pressure signals, 3 incoming pulse signals and an accelerometer.
Can i run two mcp3208 on spi and run the accelerometer on a non spi channel? and still get 100sps?
Thanks for any sugestions ovservations or moments of facepalming on my ineptitude
Jonas Ljungberg