Analog to Digital ADC0838
Archiver
Posts: 46,084
The well known and published prgm to run the ADC08038
A/D chip Ad0838.bs2 with the Stamp2 is INCORRECT. The "shiftin" line
should either be:
SHIFTIN ADCOut,CLK,MSBPRE,[noparse][[/noparse]ADCRes(channel)\9]
or
SHIFTIN ADCOut,CLK,MSBPOST,[noparse][[/noparse]ADCRes(channel)\8]
but NOT as per the prgm
SHIFTIN ADCOut,CLK,MSBPOST,[noparse][[/noparse]ADCRes(channel)\9]
As pointed out elsewhere in the 0838 jungle if you use the original
prgm you get a divide by 2. This means that for inputs up to 2.5 volts
the output in DEC will be equal to the voltage/100. BUT once the
voltage goes over 2.5 the output will start again from 0 and go to
255. This means that if you have inputs from 0-5 volts only inputs
under 2.5 will be OK. It is much better to use either of the first 2
versions and get the output to go from 0-255 for inputs from 0-5
volts, as most of us would expect.
The reason for the "error" may be seen by looking at the data sheet
and the timing.
I can vouch for the first 2 as I have tested both.
If anyone wants the complete code for a STAMP2 for this please email
me off-line at rdoctors@h...
A/D chip Ad0838.bs2 with the Stamp2 is INCORRECT. The "shiftin" line
should either be:
SHIFTIN ADCOut,CLK,MSBPRE,[noparse][[/noparse]ADCRes(channel)\9]
or
SHIFTIN ADCOut,CLK,MSBPOST,[noparse][[/noparse]ADCRes(channel)\8]
but NOT as per the prgm
SHIFTIN ADCOut,CLK,MSBPOST,[noparse][[/noparse]ADCRes(channel)\9]
As pointed out elsewhere in the 0838 jungle if you use the original
prgm you get a divide by 2. This means that for inputs up to 2.5 volts
the output in DEC will be equal to the voltage/100. BUT once the
voltage goes over 2.5 the output will start again from 0 and go to
255. This means that if you have inputs from 0-5 volts only inputs
under 2.5 will be OK. It is much better to use either of the first 2
versions and get the output to go from 0-255 for inputs from 0-5
volts, as most of us would expect.
The reason for the "error" may be seen by looking at the data sheet
and the timing.
I can vouch for the first 2 as I have tested both.
If anyone wants the complete code for a STAMP2 for this please email
me off-line at rdoctors@h...
Comments
>
> SHIFTIN ADCOut,CLK,MSBPOST,[noparse][[/noparse]ADCRes(channel)\8]
should read
SHIFTIN ADCOut,CLK,MSBPOST,[noparse][[/noparse]ADCRes\8]
sorry about that...