Voltmeter question

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Voltmeter question

Post by Jordy101091 »

He guys,
its been a while busy with school and work but I started a new project to learn more about electronic components such as op amps and other stuff.
I'm planning to make a micro controlled power supply.

I started with a simple voltage meter from 0-5V and it works great. the only wired thing is that it never actually measures 5.04 volt its always 4.992V I thinks that its has something to do with the reference voltage.

anyway,

I have made a setup that takes the 12V supply from the EB006 board into an pot. meter to regulate from 0 to 12V (for simulation only) and by a resistor divider network scale this down to an 0 to 5V level. so 0V represents 0V and 5V represents 12V. this working greet. I have also used a low pass filter to eliminate noise so the reading wont jump all over the place.

In my program I read the ADC as a voltage or floating point number.
Therefrom do some calculations and have the corresponding voltage. that works fine but this reading is not constant it jumps ad the last two digits fast resolutions is 0.000V or 00.00V depends on how many volts. What I think that I need to do is sample the incoming data take the average of that and this hopefully will have a stable reading.

The only problem I have is that in the simulation its works very nice but in the real world it won't display the calculated average.
Can somebody help me out.

Thanks,

Regards Jordy Kleian
Attachments
Flowcode1.fcf
(11 KiB) Downloaded 292 times
the will to learn, should not be stopped by any price

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

Re: Voltmeter question

Post by medelec35 »

Hi Jordy,
I believe I know why your flowchart is not working with your hardware, but I'm not sure what the best solution would be.
Problem is I don't think you can add multiple floats together. You can add two at a time using fadd function.
I Have started the process for you. So far the modified flowchart adds 4 samples up and divide by 4 as that's all the time I had left to do. Each calculation is on in separate calculation box to make it easier to follow.
Unfortunately you won't be able to rely on the simulation to be correct where floats are concerned.
TBH if it was me, I would just sample 10bit ADC, then use integers. Reason being ADC sampling have an error tolerance anyway, so may not be worth the precision of using 12 float variables.
There are also errors introduced if supply is not exactly 5.00V which they rarely are.

Perhaps a better way to stop display from constantly changing when i/p voltage remains stable would be store ADC as temp varable, Sample ADC. is difference of temp and sample ADC >1 bit?
if so display updated ADC, otherwise don't.

Hope this helps.

Martin
Attachments
Voltmeter Floats Modified1.fcf
(11 KiB) Downloaded 367 times
Martin

Spanish_dude
Posts: 594
Joined: Thu Sep 17, 2009 7:52 am
Location: Belgium
Has thanked: 63 times
Been thanked: 102 times
Contact:

Re: Voltmeter question

Post by Spanish_dude »

If your conversion algorithm from ADC value to voltage is correct, it should never measure Vcc.

Say you have a 10 bit ADC.
1024 "steps" for measuring the voltage on the ADC pin.
A 10 bits value starts at 0 and ends at 1023.
So the conversion algorithm would be like this : (5V / 1024) * ADC_value
Knowing that ADC_value can only go to 1023, the highest measurable voltage would be 4.995V.

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

Re: Voltmeter question

Post by medelec35 »

Perhaps take a look here:
http://www.matrixmultimedia.com/mmforum ... 99&p=20326
I posted A voltmeter that reads 0 - 15.00V (to two decimal places.)
It can be adapted for different scales. E.g remove *3 to read 0 - 5.00V
because its using int and with pic maths, there is small tolerance error.

Martin
Martin

Post Reply