
Originally Posted by
Acetronics
Your program With the Config Header ... as always !!!
Alain
Right, of cource...
Code:
'Define ADCIN parameters
ANSEL = %00000011 'GP0 = AN0, GP1 = AN1
DEFINE ADC_BITS 10 'Set number of bits in result
DEFINE ADC_CLOCK 3 'Set clock source
DEFINE ADC_SAMPLEUS 50 'Set sampling time in us
time1 VAR WORD 'First time in seconds
time2 VAR WORD 'Second time in seconds
time3 VAR WORD 'Third time in seconds
involt1 VAR word 'Value for ADC0 (temp)
involt2 VAR word 'Value for ADC1 (adjust)
ut4 var bit 'Status for LED 4
ut5 var bit 'Status for LED 5
trip1 var word
trip1 = 13300 'Default value
trip2 var word
trip2 = 13300 'Default value
TRISIO = %11001011 'Defining PORT
GPIO = %00111000 'Turn off all LEDs
time1 = 0 'Zero time 1
time2 = 0 'Zero time 2
time3 = 0 'Zero time 3
ut4 = 1 'LED 4 = off (inversed)
ut5 = 1 'LED 5 = off (inversed)
loop1:
ADCIN 0, involt1 'Read channel 0 to involt1
ADCIN 1, involt2 'Read channel 0 to involt2
pause 100 'Wait 100 ms
IF involt1 >= trip1 THEN
GPIO.4 = 0 'Turn on LED4
else
GPIO.4 = 1 'Turn off LED4
endif
IF involt2 >= trip2 THEN
GPIO.5 = 0 'Turn on LED5
else
GPIO.5 = 1 'Turn off LED5
endif
goto loop1 'Go back to loop1
END
trip1 = 13300 gives exactly 1V trip level. I don't mind having this kind of resolution, but it doesn't seem realistic.
Bookmarks