ADC input conversion using PIC16F690

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

Moderator: Benj

Post Reply
TedO
Posts: 79
Joined: Sat Mar 14, 2015 7:52 am
Has thanked: 46 times
Been thanked: 26 times
Contact:

ADC input conversion using PIC16F690

Post by TedO »

Good day
I have used the ADC example on Flowcode V6 which I have modified to read the input voltage of a fuel gauge which uses the reed switch/resistor ladder system and outputting the result on an LCD display. The program works well, but what I have discovered is that it only outputs 2 bits (4 options)
How does one go about telling the PIC16F690 ADC control section to read the input voltage and convert using 3 bits to give 8 options in Flowcode V6, so instead of 1/4, 1/2, 3/4 and full tank readings, I can then have more accurate readings from the fuel sensor as it contains 8 switches.

Thanks
Ted

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: ADC input conversion using PIC16F690

Post by kersing »

Can you post (attach) your Flowchart so we can check what might be the issue/need to be changed?
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

TedO
Posts: 79
Joined: Sat Mar 14, 2015 7:52 am
Has thanked: 46 times
Been thanked: 26 times
Contact:

Re: ADC input conversion using PIC16F690

Post by TedO »

Hi Kersing

As you will see that I have used the 4 outputs to label the position of the fuel gauge float. I would however like to have a full scale reading between 0 and 5 volts outputting 0, 1/8, 1/4, 3/8, 1/2, 5/8, 3/4, 7/8 and Full positions.

The example that I copied from Matrix only gives one 4 options, so I need to know how to select the ADC bits so that it reads 3 bits which give one 8 options if that is possible?

Rgds
Ted
Attachments
16F690 FUEL GAUGE 2 WIRE OP.fcfx
(9.42 KiB) Downloaded 294 times

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: ADC input conversion using PIC16F690

Post by medelec35 »

Hi Ted,
Perhaps the simplest way is to use GetInt instead of GetByte with ADC component.
Then Just add more decision branches.
What I would do is use line 1 of LCD to display Button Value.
Then if you know that when tank is say 1/8 full and button value is 3 then you can either use a decision branch if Button = 3 then Print 1/8 Tank.
Or
I have attached a bit of an experiment for you to try.
It acts more like a fuel gauge with a digital read out.
(16F690 FUEL GAUGE 2 WIRE OP V3.fcfx)
If you like the idea, between us we can make it work.
Simulation will show ??? for 3 but on the LCD I have it shows as 3 rectangles.

The other flowchart takes care of things if the readings are more sensitive.
E.g if button = 1 to 18 and you don't want 18 different statuses (16F690 FUEL GAUGE 2 WIRE OP V2.fcfx)

Hope this helps.

Martin
Attachments
16F690 FUEL GAUGE 2 WIRE OP V2.fcfx
(11.02 KiB) Downloaded 260 times
16F690 FUEL GAUGE 2 WIRE OP V3.fcfx
(9.59 KiB) Downloaded 286 times
Martin

TedO
Posts: 79
Joined: Sat Mar 14, 2015 7:52 am
Has thanked: 46 times
Been thanked: 26 times
Contact:

Re: ADC input conversion using PIC16F690

Post by TedO »

Hi Martin

Thank you very much for your input regarding my fuel gauge flowchart as posted. I tweaked both of them to read the fuel gauge that I have and it is now pretty accurate according to the gauge's dial. Version 2 now reads from: EMPTY, 1/8, 1/4, 3/8, 1/2, 5/8, 3/4, 7/8, and FULL very accurately, the version 3 (bar graph) just needed to fill the top row of the LCD but otherwise it gives one a fair quantity readout at a glance.
Thanks once again for your help, I now realize that I needed to use the GetInt instruction rather than the GetByte one as found in the Flowcode Example. It puzzled me as I saw that the ADC was only giving me 4 outputs (only one byte of the ADCON register instead of both ADRESH and ADRESL bytes)

Regards
Ted

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: ADC input conversion using PIC16F690

Post by medelec35 »

Hi Ted,
Your welcome.
TedO wrote:Version 2 now reads from: EMPTY, 1/8, 1/4, 3/8, 1/2, 5/8, 3/4, 7/8, and FULL very accurately
If you post the very accurate version,
I will modify the bar graph version to make just as accurate (hopefully :p).

Martin
Martin

TedO
Posts: 79
Joined: Sat Mar 14, 2015 7:52 am
Has thanked: 46 times
Been thanked: 26 times
Contact:

Re: ADC input conversion using PIC16F690

Post by TedO »

Hi Martin,

Sorry, I have been so busy with work, only saw your request today. This version is as accurate as the bought gauges.

Rgds
Ted
Attachments
16F690 FUEL GAUGE 2 WIRE OP V2.fcfx
(11.08 KiB) Downloaded 234 times

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: ADC input conversion using PIC16F690

Post by medelec35 »

Hi Ted,
No problem.
Can you give this a try please.

Martin
Attachments
16F690 FUEL GAUGE 2 WIRE OP V4.fcfx
(9.72 KiB) Downloaded 258 times
Martin

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: ADC input conversion using PIC16F690

Post by medelec35 »

Hi Ted,
Did it work ok?
Martin

TedO
Posts: 79
Joined: Sat Mar 14, 2015 7:52 am
Has thanked: 46 times
Been thanked: 26 times
Contact:

Re: ADC input conversion using PIC16F690

Post by TedO »

Hi Martin

Yes it works even better now, thank you. Will eventually get the hang of this program.

Rgds
Ted :D

Post Reply