ADC VALUE ISSUES

An area to discuss 8-bit PIC specific problems and examples

Moderator: Benj

Post Reply
siliconchip
Posts: 392
Joined: Wed Jan 05, 2011 11:24 am
Has thanked: 101 times
Been thanked: 24 times

ADC VALUE ISSUES

Post by siliconchip »

Hi all
ive added my flowchart and im having issues with the value of the adc regards what it shows on the display. ive got the variable DISPLAY[4] as a string therefore to my understanding i should only show the 4 segments of the selected display ie 2.04V but im getting for instance 2.043256, four extra digits, my code has been scaled down by eliminating certain macros etc to try to find the issue but as yet the problem remains, ive tried adding print string "" at various points in the VOLTAGE macro with no joy. also ive only added the loop in the VOLTAGE macro to constantly show the issue.

if i build the same VOLTAGE macro in a new code on its own it shows the correct number of digits ie 2.04v and not 2.045612, so theres something in my code its not liking but its hidden deeper than i can find, i would appreciate any help once again

cheers bob
Attachments
DEMO.fcfx
(19.46 KiB) Downloaded 134 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

Re: ADC VALUE ISSUES

Post by medelec35 »

Hi, Bob.
Instead of

Code: Select all

DISPLAY = FloatToString$ (SHOW)
use

Code: Select all

DISPLAY = FloatToString$ (SHOW,2)
The 2 is the number of decimal places.
Martin

siliconchip
Posts: 392
Joined: Wed Jan 05, 2011 11:24 am
Has thanked: 101 times
Been thanked: 24 times

Re: ADC VALUE ISSUES

Post by siliconchip »

hi martin,

as always thanks for the reply, you were spot on this now works a treat, however i dont understand how the program runs correctly if the voltage macro is built on its own and then in my program acts the way it does ?? however your solution is brill, ive never seen this done before but its one to remember, massive thanks for your advice cheers

regards bob

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

Re: ADC VALUE ISSUES

Post by medelec35 »

Hi, Bob.
You're welcome.
I'm glad my suggestion works for you.
Thanks for keeping us updated.
Martin

Post Reply