Dc voltmeter 0-55v

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

Moderator: Benj

Post Reply
Derrihj
Posts: 277
Joined: Mon Jul 09, 2018 12:43 pm
Contact:

Dc voltmeter 0-55v

Post by Derrihj »

Hi there i dont have much knowledge on pic programing but a trying as much i can to learn.Ive made a simple programe to read dc voltage from 0-55v please take a look at it and advise me were i may be wrong and if neccesary change my program and make it beter then ppst it again here sothat i see were i may have gone wrong before i build the circuit in real time.All you need to know about this project should be found under Project Description, just click on BUILD tab then select project options and then click on project description,there ive tried to explain the project go thru it and correct me were am wrong u can even change it and re post here.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 9014
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Contact:

Re: Dc voltmeter 0-55v

Post by medelec35 »

You have not got any attachments.
Martin

Derrihj
Posts: 277
Joined: Mon Jul 09, 2018 12:43 pm
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

It has refused to upload it says error with some numbers when i try to upload but in simulation the code works perfecrly thats why i wanted to send it to u first before i build it coz sometime codes work well in flowcode simulation but when u build the circuit in real time it show inperfections and some time refuses to work yet in flowcode simulation it works pefectly as required.

Derrihj
Posts: 277
Joined: Mon Jul 09, 2018 12:43 pm
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

Maybe u send me an email on: jjumba.derrick@gmail.com i send the file to u direct

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 9014
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Contact:

Re: Dc voltmeter 0-55v

Post by medelec35 »

As your starting post is not a feature request, I have move the topic to a more appropriate part of the forums.
Can you post a screen shot of the error and of the file name + extension of the file you are trying to upload?
Martin

Derrihj
Posts: 277
Joined: Mon Jul 09, 2018 12:43 pm
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

There is the sreen shot
Attachments
Screenshot_20190402-235701.jpg
Screenshot_20190402-235701.jpg (24.41 KiB) Viewed 5199 times

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 9014
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Contact:

Re: Dc voltmeter 0-55v

Post by medelec35 »

The Extension of your flowchart should be fcfx.
Is that what you tried to upload?
I have uploaded a typical flowchart from the Flowcode Wiki site, just so you can see the extension and files are uploading ok.
Its called PWMDemo.fcfx
You are best using a PC rather than mobile as that could be the issue?
Attachments
PWMDemo.fcfx
(5.72 KiB) Downloaded 127 times
Martin

Derrihj
Posts: 277
Joined: Mon Jul 09, 2018 12:43 pm
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

Yes u are right am using a mobile but ive seen one of your 0-15 voltmeter and there is were u did the math may u can help me from here 920 *5/(1023/100)*3 = 1380 am failing to know were u get the 100 in your calculation what is it please my math is not all that good

Derrihj
Posts: 277
Joined: Mon Jul 09, 2018 12:43 pm
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

Ok now i get it from your 0-15 voltmeter wawo u have introduced me to a new idea of using the wonderful Right$ and Left$ and ive edited my voltmeter were i had used floating values and now to integers how help me here i would love to add a 5k variable pot to my circut as a voltage calibration pot this 5k should be connected to vdd (5v)as its maximum input on one side, the midle pin to ADC and the other pin to GND remember my voltmeter is a 0-55v so in my calculation i have voltage=(ADC * 5) / (1023 / 100) * dvF NOTE: dvF = 11 which is division factor from the voltage divider because at maximum input voltage of 55v the voltage divider output will be 5v so this divided by Vin max equals 11, that is to say (55/5=11) which is the dvF(division factor) i made this with two resistors in series,the one to Vin 55v = 1M and the one to GND = 100k having an impendence of 1.1M ohms which i think is sufficient for voltages between 0-55v.So the 5k variable pot should change the value of dvF to work as calibration so this is what i want the program to do. On start up the microntroller reads the voltage that it thinks is right.there is a push button connected to RB0 of pic say pic18f442 in my example this when pressed causes Interrupt on INTO and the microcontroller enters calibration mode now i should use my trusted digital meter to measure the real voltage,now i should turn the 5k variable pot to change dvF until the voltage on the 16x2 LCD matches with the voltage on my trusted digital meter Now my quetion is according to my calculator (ADC*5) / (1023 / 100) * dvF how do i add calculation for this 5k variable pot inorder to calibrate values of dvF?

Derrihj
Posts: 277
Joined: Mon Jul 09, 2018 12:43 pm
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

Am trying to upload the flowcode 8v file on my computer.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 9014
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Contact:

Re: Dc voltmeter 0-55v

Post by medelec35 »

I will take a look at your flowchart when it's uploaded.
Martin

Derrihj
Posts: 277
Joined: Mon Jul 09, 2018 12:43 pm
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

Here is my flowchat you can click on BUILD tab then project option and click project description for more info but on the real flowchat ADCkal and CALbutton are not yet activated coz that is the code am looking for.
Attachments
ADC.fcfx
(28.51 KiB) Downloaded 92 times

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 9014
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Contact:

Re: Dc voltmeter 0-55v

Post by medelec35 »

Do you want to see how you get on with the attached Flowchart.
We can work of the calibration side after as it may not even require it.
It's a bit basic so you will need to add LCD formatting to make it look better.
For the most accurate result, measure the MCU supply and alter the 5.0 with the correct voltage.
E.g.MCU = 4.93V.
Then the formula should be:

Code: Select all

MeasuredVoltage = 4.93 / 1024.0 * IntADC * 55.0 /4.93 
As you can see, I have created the formula in such a way the the external voltage is within the equation.
This makes it much easier if the voltage max is different to 55V.
Attachments
ADC2.fcfx
(17.17 KiB) Downloaded 87 times
Martin

Derrihj
Posts: 277
Joined: Mon Jul 09, 2018 12:43 pm
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

I must say its intresting having you here on thos forum for u teach us new tricks all da time and i must say thank u foe alwaying being here for us asnwering everything we ask i like the way uve turned it around and thank u for showing me how to take samples the advanced way i like it but agin for learning purposes please i beg you show me how to go about the calibration part with the 5k variable as am planing to include it in my coming project i really want to see how its done the right way please help

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 9014
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Contact:

Re: Dc voltmeter 0-55v

Post by medelec35 »

What value Range do you want the pot to equal?
E.g if pot is 0 to 1023 you want it to equal 0 to 11 for example.
Martin

Derrihj
Posts: 277
Joined: Mon Jul 09, 2018 12:43 pm
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

Yes it must be from 0-11 but remeber the 5k variable pot on real circuit has a maximum input of 5v(VDD)

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 9014
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Contact:

Re: Dc voltmeter 0-55v

Post by medelec35 »

As ReadAsBytye has a range from 0 to 255, then just divide the ADC by 25
Just read the with ADCkal as return value.
Then use ADCkal = ADCkal/25
Martin

Derrihj
Posts: 277
Joined: Mon Jul 09, 2018 12:43 pm
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

Then how will it affect the value of ADCvolt coz it needs to be that when ever an active low button is placed it enter calibration mode then turn 5k to affect values of measuredVoltage,after a required value is read on LCD,turn off the active low button and chip exits calibration mode and saves the value say dvF to eeprom which value is called when ever the program starts in order to affect the value of measuredvoltage.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 9014
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Contact:

Re: Dc voltmeter 0-55v

Post by medelec35 »

That will be easy to do.
Before the main loop, Reed the EEPROM contents where ADCKal will be stored.
If its value is 255 then assign ADCkal with 0
If is not = 255 the ADCkal = EEPROM read data.

Within Main there will be an input to the Calibration switch.
Place an input and assign it to something like SwitchValue.
Just before the input place a variable e.g

Code: Select all

PreviousSwitchValue = SwitchValue
.
Just after the input place a decision branch with If: PreviousSwitchValue = SwitchValue
False: Save ADCka to EEPROM

If you are using active low then don't forget to assign both PreviousSwitchValue & SwitchValue with 1 just before the main loop.

Give that a try and post the flowchart if you are stuck.
Martin

Derrihj
Posts: 277
Joined: Mon Jul 09, 2018 12:43 pm
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

I will give it a try when i get back home on my computer.

Derrihj
Posts: 277
Joined: Mon Jul 09, 2018 12:43 pm
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

I think ive failed to put calibration part the right way please help me edit my flowchat the right way and repost here sothat i see how its done the right way and if you can use Interrupt at INTO for into calibration mode would be double advantage for me i see how its done too coz ive always been having trouble to have interrupt work the proper way even cant understand raising and fallin age thing but am ready to learn.Thanks again for your efforts helping us.
Attachments
0-55v Voltmeter with calibration.fcfx
(27.65 KiB) Downloaded 75 times

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 9014
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Contact:

Re: Dc voltmeter 0-55v

Post by medelec35 »

I have made corrections to your flowchart.
You can't x dvF if dvF is 0 as result will always be 0.
So dvF is now from 1 to 11, rather than 0 to 11
Removed unecessary variables etc..
Hopefully should work as intended?
Attachments
0-55v Voltmeter with calibration.fcfx
(22.86 KiB) Downloaded 117 times
Martin

Derrihj
Posts: 277
Joined: Mon Jul 09, 2018 12:43 pm
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

Thanks allot a million times i will go thru it when i get back home.

Derrihj
Posts: 277
Joined: Mon Jul 09, 2018 12:43 pm
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

Ok it works fine in simulation but when i built it in real time and connected a 9v battery to be measured it showed me arround 4v and when i switched to calibration mode it could only go upto 4.99v and dvf did not go above 1 yet its supposed to go up to 11 and when i disconnected the 9v battery from the probes i expected it to show zero volts now but it still showed me 4.99v on the lcd but when i measure the same 9v battery with the first meter setting that i built without calibration it shows 8.734v which is the correct value.What do u think is wrong here.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 9014
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Contact:

Re: Dc voltmeter 0-55v

Post by medelec35 »

Fault with hardware?
I have tried it today with 16F18877 and working as expected:
0 to 55 Voltmeter.jpg
0 to 55 Voltmeter.jpg (39.18 KiB) Viewed 4903 times
After removing power and connecting back up to a supply I got the same reading on the LCD so the 11 was saved.
Have you measured the voltage on both pins 7 & 2?
Martin

Post Reply