Help
solistics
Posts: 3
Hi all.
I'm trying to make a little program for my robot that uses a ADXL150 accelerometer with an ADC (ADC0804 most likely since I have only one analog output). The only problem I have is that I need to find the highest value that comes in. I was thinking of adding the 8 inputs toghther but would I still get a binary result?? PLZ help!!
THX
I'm trying to make a little program for my robot that uses a ADXL150 accelerometer with an ADC (ADC0804 most likely since I have only one analog output). The only problem I have is that I need to find the highest value that comes in. I was thinking of adding the 8 inputs toghther but would I still get a binary result?? PLZ help!!
THX
Comments
highestValue := 0
repeat 8
value := ReadADC
if value > highestValue
highestValue := value
John Abshier
THX
P.S. thanks for the quick reply.
1) You pull the 'Chip Select' pin on the ADC low to tell it you want a reading
2) You toggle the 'Clock' pin on the ADC from high to low and back again while either sending or receiving bits to/from it (with a single channel ADC you shouldn't have to send it anything)
3) Whether you're sending or receiving, before you pull the 'Clock' pin from high to low (or low to high - check the ADC's data sheet) you set the 'data in' pin or read the 'data out' pin to send/receive the next bit of the value to/from the ADC. As you receive the bits, you use the or and shift operators to concatenate them into a result.
There are many examples of this kind of code in the publicly available objects in the object exchange. Look at the code for 'SHIFTIN' and 'SHIFTOUT' in the 'BS2 Functions' object. You might even be able to just use it as is.
Jason