Trouble with ADC0831 and ASCII
Paul Thompson
Posts: 5
I am experimenting with a pot and a ADC0831 chip in order to read voltage and convert the analog to digital and display in on screen using the DEBUG commands. This works fine, but I now want to go a step further and compare the output of the ADC (ASCII) with a number (integer). I want to use different reading from the pot in order to control the speeds of a motor using PWM. I have the set-up, but I cannot seem to compare numbers (ASCII given by the ADC and integers) in order to do this. What can I do?
Comments
Run_Motor:
result = adcBits
FOR result = 1 TO 25
speed = 750
NEXT
FOR result = 26 TO 50
speed = 820
NEXT
FOR result = 51 TO 75
speed = 835
NEXT
FOR result = 76 TO 100
speed = 850
NEXT
FOR result = 101 TO 125
speed = 875
NEXT
FOR result = 126 TO 150
speed = 900
NEXT
FOR result = 151 TO 175
speed = 925
NEXT
FOR result = 176 TO 200
speed = 950
NEXT
FOR result = 201 TO 225
speed = 975
NEXT
FOR result = 226 TO 255
speed = 1000
NEXT
PAUSE 20
PULSOUT HB25, speed '750=stop, 1100 full fwd, 400 full reverse
PAUSE 7
RETURN
where 'adcBits' is the raw results of the ADC chip and 'result' is the variable that I want to compare the numbers to. When I throw in DEC in front of 'adcBits' the compiler throws an error. Don't know what the deal is... hope that clarifies my question.
You can always add a specific check for zero and the 1000 is duplicated for the values from 251-255.
-Paul