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
ADC input conversion using PIC16F690
Moderator: Benj
-
- 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
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
― C.S. Lewis
-
- 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
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
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
-
- 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
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
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
-
- 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
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
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
-
- 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
Hi Ted,
Your welcome.
I will modify the bar graph version to make just as accurate (hopefully :p).
Martin
Your welcome.
If you post the very accurate version,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
I will modify the bar graph version to make just as accurate (hopefully :p).
Martin
Martin
-
- 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
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
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
-
- 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
Hi Ted,
No problem.
Can you give this a try please.
Martin
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
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
-
- 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
Hi Martin
Yes it works even better now, thank you. Will eventually get the hang of this program.
Rgds
Ted![Very Happy :D](./images/smilies/icon_biggrin.gif)
Yes it works even better now, thank you. Will eventually get the hang of this program.
Rgds
Ted
![Very Happy :D](./images/smilies/icon_biggrin.gif)