I am using the following code to get a variable delay up to 60 seconds to control a sound board
in model railroad applications. As i know nothing about Readadc10 is the following code efficient.
In max delay I get 63.1 to 63.8 seconds which is accurate enough for my application - seems like
the +/- 1 bit showing up. I go from 08M2 vcc(4.5 volts) through a 3.9k resistor and a 5 kohm pot
to ground with the pot wiper connected to ADC input pin C.1.
I found that any voltage above 2.56 volts gave random readings. Is this normal?
Ps. I found the answer, my step of 100 was going to 102300, way over the limit of 65000+.
thanks
Al
in model railroad applications. As i know nothing about Readadc10 is the following code efficient.
In max delay I get 63.1 to 63.8 seconds which is accurate enough for my application - seems like
the +/- 1 bit showing up. I go from 08M2 vcc(4.5 volts) through a 3.9k resistor and a 5 kohm pot
to ground with the pot wiper connected to ADC input pin C.1.
I found that any voltage above 2.56 volts gave random readings. Is this normal?
Ps. I found the answer, my step of 100 was going to 102300, way over the limit of 65000+.
thanks
Al
Code:
;Picaxe 08M2 program for Sound board adapter
start:
pause 1000 ;ensure that train detection is captured.
if pinc.3 <> 0 then ;lcheck to see if controller has detected
;a train. if so
high c.2 ;pass +12 Vdc to sound board to activate
readadc10 C.1,w1
w1 = w1 * 100
debug w1 ; wait for crossing gates to come down
pause w1
endif
cont:
low c.2 ;deactivate sound board
if pinc.3 = 1 then cont ;keep sound board deactivated until
;gates go up and another train is detected
goto start ;go back to check for another train
Last edited: