Quote Originally Posted by london alex View Post
Hi everyone,
Hoping you might be able to help me with a little project I’ve been working on….
I’ve been trying to create a code that reads in a value (b0) from an
a/d converter, this then goes to a timer routine which loops ‘b0’ amount of times and then sends PORTB.3 high. I’ve programmed the following onto a pic16f628a and then added it to the circuit…. from first impressions it all looks great! However…. By watching the LED’s attached to pins 5,6,7 and 8 I can see that it’s adding up a different amount each time, even though the value from the A/D converter should be the same. Can anyone spot where I’m going wrong here as it’s left me pretty confused!
Many thanks, Alex
Where's the ADC code?
The output from the ADC should be the same...key word is 'should'.
Is your ADC input varying at all?
Are you sampling it slow enough as the datasheet suggests?
Are your parameters for the ADC (sample time, etc.) correct?
What is the input impedance to your ADC pin?
For all I know, there's a nuclear fission reactor power generating station connected to AN0 on the PIC, or it could be a small butterfly. I don't know.