rkjohnsonsr@gmail.com
New Member
Hi my name is Robert Johnson... Bought a Picaxe 40X2 Kit from RK Education, a RKPT40 seems to work and I wanted to use it as a master controller...
So I wrote a bit of code for a test. The code worked and then I modified it to get a more usable A/D value for scaling to the correct value.
The Code is as follows:
What did I do incorrectly?
So I wrote a bit of code for a test. The code worked and then I modified it to get a more usable A/D value for scaling to the correct value.
The Code is as follows:
Code:
'****************************************************************************************************************
' Simple Temperature Monitor With an LM34 and a Serial LCD as a test for later code :
' 25-2-2012 for use with 4 X 16 line display to display Raw ADC Data on ADC
'
'****************************************************************************************************************
'
'
#picaxe 40X2 ; Define for 40X2 Chip
#no_table ; Define for No Lookup Tables
#no_data ; Define for No Data Tables
' ; Blank Line
fvrsetup FVR1024 ; set FVR as 1.024V makes 4 MV per step @ 256 steps
adcconfig %1000 ; set FVR as ADC Vref+, 0V Vref- (%1000) page 28 picaxe manual 2 ;
main: ; Every Program has a Main
' ; White Space
do ; All Set, begin loop
low b.1 ; Led on Port b.1, Start of Data Out (everyone loves blinking lights)
readadc 0,b0 ; Get the Analog Voltage on ADC 0
serout b.0,N2400,("Temp ",#b0,13,10) ; transmit Label "Temp " and raw ADC data to Serial LCD Display
wait 1 ; Wait long enough to read Serial LCD Display
High b.1 ; Led Off Port b.1, End of Data Out
' ; More white space
loop ; Go do some more
'
#rem
; I am a Nooob with the Picaxe but I have used the Parallax devices and Basic both commercially and for my own uses
; Since the Late '90's. I am a retired engineer with no small experience. The supply is bypassed at the device.
; Note the device (40X2) is powered from a 5.00V PSU from an old cell phone, 40X2 Vcc is 4.47Vdc
; (The cell phone chargers make great little sources for 4-6 VDC @ 100 - 500 Ma)
; If I remove lines 10&11 the device works as normal The Vcc is 4.47V so 4.47/256 = .0174 V per step and the value
; displayed (W/o lines 10&11) is 42 - 44 changeing slowly as the ambient temp changes.
; When I enable (remove the comment) the first value is correct for a reference of 4.5 V (42-44) 43 *.0174 = .753V
; that is corrrect as my room temp and the measured voltage at the LM34 agree @ 75.3 Deg F.(measures .753 Volts)
; all the rest of the data is 255 and unchanging. Where is my error?
#endrem
Last edited by a moderator: