Analogue input always reading 255

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
Dave Squibb
Flowcode v5 User
Posts: 104
Joined: Fri Oct 10, 2014 11:15 am
Has thanked: 27 times
Been thanked: 22 times
Contact:

Analogue input always reading 255

Post by Dave Squibb »

Hi all,
I am trying to read an analogue input on AN3 on a PIC18F45K22 .
Whatever voltage I put on the input, 0 to 5 V, always reads 255.
(Macro "initialise" is part of a larger project but this bit won't work at all without it)
I've tried a new PIC.
Can someone have a look please?
Thanks,
Dave.
ADC.fcfx
(73.54 KiB) Downloaded 197 times
(sorry, forgot file!)

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Analogue input always reading 255

Post by Benj »

Hi Dave,

I've just looked at the code for the ADC on the K22 devices and it looks to be ok. The ADC component in your project is pointed to AN0 though I'm guessing this isn't the cause of the issue.

Maybe try a conversion rate other then the FRC setting.

Might also be worth getting rid of the C code ADCON and ANSEL bits, the ADC component should take care of all this for you.

Dave Squibb
Flowcode v5 User
Posts: 104
Joined: Fri Oct 10, 2014 11:15 am
Has thanked: 27 times
Been thanked: 22 times
Contact:

Re: Analogue input always reading 255

Post by Dave Squibb »

Hi Benj,
I've spent hours on this, adding bits in like the ADCON and ANSEL bits, trying to get it to work. It was definately pointing to AN3 originally.
I removed the ADCON and ANSEL bits, pointed it back to AN3 and it all works!
I'll add it back to the original program very carefully.
Thanks for your help.
Dave

Post Reply