Hi, Mike
How do you want us to give you any idea ???
PLEASE ...
Your program With the Config Header ... as always !!!
Alain
Hi, Mike
How do you want us to give you any idea ???
PLEASE ...
Your program With the Config Header ... as always !!!
Alain
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Right, of cource...
trip1 = 13300 gives exactly 1V trip level. I don't mind having this kind of resolution, but it doesn't seem realistic.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
Last edited by Acetronics2; - 21st September 2010 at 14:20.
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Is this specific for 10 bit ADC, or should it be there for 8 bit conversion as well?
And how? -CMON0 something?
Hm, the example programs that I have (for 16F877A) do not have such an instruction, does that PIC not need it?
ADCON0.7 = 1 seems to have have cured the problem, thanks guys.![]()
have a look to datasheet ... Comparator section !!!
some pins share the comparator and ADC functions ... you HAVE to verify which function is deactivated and which is to activate. ( one at a time ... )Hm, the example programs that I have (for 16F877A) do not have such an instruction, does that PIC not need it?
Depends on the chip used - and the ports used ...
Full config done = NO suprise ...ADCON0.7 = 1 seems to have have cured the problem, thanks guys.![]()
sometimes, the pic defaults @ reset are the ones you want ... sometimes not. so you have to verify everything with the pic Datasheet !!!![]()
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Just guessing with your code, It looks like your result is left justified (or right) but in any event, you appear to be reading the the 2 LSB as bit 6,7 of your answer. since the 10 bit result is a word, you seem to have result high as valid 8 bits. but your result low is ddxxxxxx. So your LSB is really = dec128 and not 1!
How do i guess this? if you right shift your 13300 6 times, you get ~207. Assuming you are testing 0-5V you expect 1024/5=204 per volt. Pretty close.
If you need help understanding or fixing this, post code!
Sorry, we posted together
Last edited by cncmachineguy; - 21st September 2010 at 14:24. Reason: code posted while I was postng
-Bert
The glass is not half full or half empty, Its twice as big as needed for the job!
http://foamcasualty.com/ - Warbird R/C scratch building with foam!
Bookmarks