Thank you verry much !
Indeed, my mistake was the overriding of defines ...I didn't know until today the things You've posted. Hm ... so much to learn ! I'm glad I met people like You and other kindly members of this forum !
Best regards !
Thank you verry much !
Indeed, my mistake was the overriding of defines ...I didn't know until today the things You've posted. Hm ... so much to learn ! I'm glad I met people like You and other kindly members of this forum !
Best regards !
Me, again ...with something strange (at least for me) !
I try to use ADC for reading a couple of buttons. I have two situations :
- three buttons, with 82 ohms, 164 ohms, 1448 ohms resistors ; ADC reading = 1023 nothing pressed ; 78 with button 1 pressed ; 144 with button 2 ; 605 with button 3 ;
- three buttons, with 300 ohms, 1300 ohms, 3110 ohms AND 100 Kohms in parallel ; ADC reading = 1013 nothing pressed ; 236 with button 1 pressed; 575 with button 2 ; 768 with button 3.
I tried with 2 version of code (for both situations):
andCode:ADCON0.1 = 1 WHILE ADCON0.1 = 1 : WEND adval.HighByte = ADRESH adval.LowByte = ADRESL if adval > 10 and adval < 300 then gosub LED1 ...etc....
For first situation everything works fine, with both version of reading ADC !Code:ADCIN 3, adval if adval > 10 and adval < 300 then gosub LED1 ...etc...
BUT ... for second situation, NOTHING HAPPENS !!! I really not understand what I do wrong ... Can me point to the right direction ? Thanks in advance !
![]()
![]()
Note : In Proteus both schematic work, so I made it on PCB. First variant works just fine, second none...
For the code using ADCIN, is the left/right justification set correctly? I can never remember which way around it wants it so whatever you have it set to, try changing it. And, do you have DEFINE ADCBITS 10 in there?
/Henrik.
Thanks for reply !
I don't change anything in code (except values for actions) ... just the resistors from "chain" command.Code:CMCON = 7 OPTION_REG = %10000110 TRISIO = %00001100 GPIO = %00000001 ANSEL = %00010100 ADCON0 = %10001001
With first chain work ; with second not. It's because of 100 kOhms ?!?
In your very first post, I couldn't find any clear description of your problem or goal....
Resistor coupling is apparently not the same in those two posts - is this okay?
Try this:
Button 1 = 0 Volt => ADC 8 bits = +/-0 , ADC 10 bits = +/-0
Button 2 = 1,25 Volts => ADC 8 bits = +/-64 , ADC 10 bits = +/-320
Button 3 = 2,5 Volts => ADC 8 bits = +/-128 , ADC 10 bits = +/-640
Button 4 = 3,75 Volts => ADC 8 bits = +/-192 , ADC 10 bits = +/-960
I didn't built the circuit above; if ADC values are not stable, try with all R values ( :10) => 10k becomes 1k, 3k3 becomes 300Ohms and so on.
As an alternative, you may want to have a look here "Compiled Tips ‘N Tricks Guide".![]()
Last edited by flotulopex; - 17th April 2015 at 23:28.
Roger
Bookmarks