Page 1 of 1

ADC VALUE ISSUES

Posted: Tue Jul 13, 2021 8:20 am
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

Re: ADC VALUE ISSUES

Posted: Tue Jul 13, 2021 9:50 am
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.

Re: ADC VALUE ISSUES

Posted: Tue Jul 13, 2021 12:26 pm
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

Re: ADC VALUE ISSUES

Posted: Tue Jul 13, 2021 5:48 pm
by medelec35
Hi, Bob.
You're welcome.
I'm glad my suggestion works for you.
Thanks for keeping us updated.