Bruce:
Thanks var word
loop:
thanks=$FFFF '
it works, now I need to adjust the code because the led dont work as expected, but I put a serout after the adcin and the terminal reads the different values OK!!!
goto loop
Bruce:
Thanks var word
loop:
thanks=$FFFF '
it works, now I need to adjust the code because the led dont work as expected, but I put a serout after the adcin and the terminal reads the different values OK!!!
goto loop
Code:DEFINE ADC_BITS 10 DEFINE ADC_CLOCK 3 DEFINE ADC_SAMPLEUS 50 number VAR word CMCON = 7 ' Comparators off ANSEL = %00000001 ' GPIO.0 A/D in, rest digital ADCON0.7 = 1 ' Right justify for 10-bit GPIO = %00000000 ' Initialize outputs TRISIO = %00000001 ' GPIO.0 = input, rest outputs PAUSE 100 Loop: ADCIN 0, number ' (0-1023) IF (number > 0) AND (number < 400) Then GPIO = %00000010 'GPIO.1=1 'GPIO.2=0 'GPIO.4=0 EndIF IF (number > 401) AND (number < 800) Then GPIO = %00000100 'GPIO.1=0 'GPIO.2=1 'GPIO.4=0 EndIF IF (number > 801) AND (number < 1024) Then GPIO = %00010000 'GPIO.1=0 'GPIO.2=0 'GPIO.4=1 EndIF number = 0 GoTo loop
MASTER !
I trully appreciate your prompt answers, thank you very much !!!![]()
Hi
After looking to the examples above I have the following I want to do
As this is my first ADC code I need some tips and maybe some help
I want to do the following
ADC on GPIO.0 8 bit
I have a DC voltage between 0.5V and 2V approx
Which is varying all the time
I need to encode the DC variation by a tone between 67hz and 250hz
with 2-4 hertz incremental/value
The DC values needs to be stored in EEprom at setup
(example button is pushed at powerup to enter setup)
30 DC values should correspond to 30 tones (30 tone's might be set fix in the code)
So example:
0.55V = 67hz
0.64V = 71hz
0.71V = 74hz
etc...
Once setup and running: if a DC value is between or equal next value it has to
output the tone ( set in the code)
with a kind of hysteresis for the tone duration and before next sample)
and a Serout to check the values
Can anyone help me ?
Walter
Bookmarks