Question for MAX1270 A2D converter
Edmond
Posts: 7
Folks :
I am writing a cod for the BS2 to read the digital output from the MAX1270 A2D converter.
My sensor is a position transducer that varies from 0 to 5 (max) volts.
Here is my code :
=====================================
AdcDOUT···· CON 1
SSTRB······ CON 2
AdcDIN····· CON 4
AdcCS······ CON 5
clockpin··· CON 6
controlbyte CON %10000001
sensordata· VAR Word
sensordata = 0
DO
· GOSUB Read_ADC
· GOSUB Display
LOOP
Read_ADC :
· LOW AdcCS
· SHIFTOUT AdcDIN , clockpin, MSBFIRST, [noparse][[/noparse]controlbyte]
· SHIFTIN· AdcDOUT, clockpin, MSBPOST , [noparse][[/noparse]sensordata\12]
· HIGH AdcCS
RETURN
Display :
DEBUG HOME
DEBUG "12-bit binary value : ", BIN12 sensordata, CR
DEBUG "decmial value······ : ", DEC4· sensordata
RETURN
===================================================
For some reason, I don't know why that when my sensor reaches the maximum output (5 volt),
the digital output read only up to 246 (dec), not 4096 (2^16) which I expect to see as this is a 12 bit A2D converter.
I don't know what I did wrong in this.
If any of you have experience on this A2D converter, or this kind of problems, I will appreciate for your input. Thanks !
I am writing a cod for the BS2 to read the digital output from the MAX1270 A2D converter.
My sensor is a position transducer that varies from 0 to 5 (max) volts.
Here is my code :
=====================================
AdcDOUT···· CON 1
SSTRB······ CON 2
AdcDIN····· CON 4
AdcCS······ CON 5
clockpin··· CON 6
controlbyte CON %10000001
sensordata· VAR Word
sensordata = 0
DO
· GOSUB Read_ADC
· GOSUB Display
LOOP
Read_ADC :
· LOW AdcCS
· SHIFTOUT AdcDIN , clockpin, MSBFIRST, [noparse][[/noparse]controlbyte]
· SHIFTIN· AdcDOUT, clockpin, MSBPOST , [noparse][[/noparse]sensordata\12]
· HIGH AdcCS
RETURN
Display :
DEBUG HOME
DEBUG "12-bit binary value : ", BIN12 sensordata, CR
DEBUG "decmial value······ : ", DEC4· sensordata
RETURN
===================================================
For some reason, I don't know why that when my sensor reaches the maximum output (5 volt),
the digital output read only up to 246 (dec), not 4096 (2^16) which I expect to see as this is a 12 bit A2D converter.
I don't know what I did wrong in this.
If any of you have experience on this A2D converter, or this kind of problems, I will appreciate for your input. Thanks !
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
controlbyte CON %10000000 ' internal clocking, 5 volt single ended on channel 0
The problem with external clocking is twofold. It requires 4 additional conversion clock pulses not present in your code, after the control byte and before the data. Furthermore, the BS2 SHIFTOUT clock is not fast enough to do the external clocking, due to charge leakage from the 1270's internal sampling capacitor. With internal clocking, the '1270 supplies a fast internal clock to do the conversion itself, and your code only has to send the command and read out the data.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
I did what you suggested and the mystery is solved !! You are awesome.
Now the digital output (dec) read up to 3950 when the analog signal close to 5 v (max).
So the actual voltage measurement is : 5*3950/4960 = 4.82 which is very close to what I measured from the multimeter.
My question is that when I use internal clock mode, should I keep using the command "SHIFTOUT" & "SHIFTIN" as this command will
generat the clock pulse and send it to the A2D converter.
I am confused why my program works when I only change to internal clock mode (" %10000000 " ) while the "SHIFTOUT" and "SHIFTIN"
command keep sending the clock pulse to the A2D converter?
Anyway, great thanks for your help !
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com