Dc voltmeter 0-55v

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

Moderator: Benj

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

Eh! i have to double check my hardware i think it must be were the problem is.

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

Thanks Medelec35 for all your help in this project it was successful.

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: Dc voltmeter 0-55v

Post by medelec35 »

I'm glad your project was successful.
Thanks for letting us know.
Martin

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

Now i wonder whats the problem with this circuit coz it works well in simulaton but on real board it doesnt it only displays Digit0 and Digit1 but also with random numbers as it wishes. Digit2 doesnot show-up at-all wonder why please check my flow chat may be am doing some thing wrong.
Attachments
3Digit 7seg 0-55v voltmeter and Battery Charge Cut Off.fcfx
(46.96 KiB) Downloaded 222 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Dc voltmeter 0-55v

Post by Benj »

Hello,

With 7-segs you need to be spending an equal amount of time outputting each character or one character will appear much brighter then the other. In your program you were outputting digit0 and then immediatley digit1 and then onto digit2.

I have tweaked your program so it now uses a timer interrupt to take care of the output to the seven segs with equal time spent outputting to each character. Hopefully it will work better for you now.
I've also tweaked your seg calculations to hopefully force the compilers hand when doing the floating point maths.

For example using integer maths
0.1 * 10 = 0

but forcing the integer to be a float makes the compiler use a floating point calculation instead.
0.1 * 10.0 = 1.0

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

I tried to compile this but these errors came up: using updated 32-bit floating-point libraries; improved accuracy might increase code size

C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\internals.c: 77: (1090) variable "_FCI_TMP_INT" is not used (warning)
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\internals.c: 76: (1090) variable "_FCI_TMP_STR" is not used (warning)
3Digit 7seg 0-55v voltmeter and Battery Charge Cut Off.c: 1651: (1393) possible hardware stack overflow detected; estimated stack depth: 9 (warning)
0: (1347) can't find 0x1A3 words (0x1a3 withtotal) for psect "text12" in class "CODE" (largest unused contiguous range 0xDA)
updated 32-bit floating-point routines might trigger "can't find space" messages appearing after updating to this release; consider using the smaller 24-bit floating-point types
0: (1347) can't find 0x113 words (0x113 withtotal) for psect "text35" in class "CODE" (largest unused contiguous range 0xDA)
0: (1347) can't find 0x7 words (0x7 withtotal) for psect "text31" in class "CODE" (largest unused contiguous range 0x2)
0: (1347) can't find 0x7 words (0x7 withtotal) for psect "text33" in class "CODE" (largest unused contiguous range 0x2)
0: (1347) can't find 0x5 words (0x5 withtotal) for psect "text32" in class "CODE" (largest unused contiguous range 0x2)
0: (1347) can't find 0x5 words (0x5 withtotal) for psect "text34" in class "CODE" (largest unused contiguous range 0x2)
(908) exit status = 1
(908) exit status = 1

Error returned from [xc8.exe]

C:\Program Files (x86)\Flowcode\Common\Compilers\pic\batch\pic_xc8_comp.bat reported error code 1



FINISHED

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Dc voltmeter 0-55v

Post by Benj »

Hello,

It's saying your out of ROM Flash memory, can you move to a chip with larger amoutn of Flash?

It could be the changes I made to the seg calculations to force the floating point calculations, these will be a lot bigger then the integer calculations. Maybe try putting these back to 10 instead of 10.0 and see what difference this makes.

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

Yes mr Benj you must be right i also get such messages some time and some time i reduce on the code then after that am good to go but as you see am in a poor country and getting a number of MCUs to play around with is really had and i really want to see your code work coz am going to study it really slow and get to learn new tricks from it.Thanks allot Mr Benj let me see what i can do to reduce the code may be remove some i will get back to you after in a mean time, below is my PCB design for this small project please look and advise me were i place components wrongly i really love to learn.
Attachments
20200205_180828.jpg
20200205_180828.jpg (73.03 KiB) Viewed 17169 times
20200205_180818.jpg
20200205_180818.jpg (80.32 KiB) Viewed 17169 times
20200205_180811.jpg
20200205_180811.jpg (76.09 KiB) Viewed 17169 times

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

one more
Attachments
20200205_180840.jpg
20200205_180840.jpg (68.08 KiB) Viewed 17169 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Dc voltmeter 0-55v

Post by Benj »

Looks really nice.

It should be possible to tweak the code so there is no floating point maths required and just using integer maths instead.

To do this you would have to read the adc value as an integer and then scale this to get a voltage.

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

Ok i reduced the code and now it can fit in there,i had to remove all the calibration part of the code and also the battery sense part coz i really wanted to see how the code works and i didn't want to remove the floating numbers as am also interested in the half volts or so... also .I loaded the code into the MCU and now i can display numbers on all digits but still in a funny way.When you first power it on it displays two zeros and there decimal points on digit1 and digit2 like this: 0.0. then after a zero on digit0 and a zero on digit2 then numbers like 44 and so on inter-changeably.
Attachments
3Digit 7seg 0-55v voltmeter and Battery Charge Cut Reduced.fcfx
(28.38 KiB) Downloaded 208 times

User avatar
Steve001
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Wed Dec 31, 2008 3:37 pm
Has thanked: 460 times
Been thanked: 523 times
Contact:

Re: Dc voltmeter 0-55v

Post by Steve001 »

Hi Derrihj,

Looks like a nice project, looking at the title of your flowcode project name. "Battery Charge Cut Out"

Are you cutting off the DC charge current ? or using to offer "deep Discharge protection" of your batteries ?
I must admit that i have not opened your project to look so see what is going on and what you are doing with it.

One thing to be aware of and dose catch people out - look at the contact ratings of the relay especially at "Breaking DC" part
looking at the relay in the pictures (by your fingers) it says 10 Amps @250 Vac . I am assuming the relay under this is the same i cannot see the markings on the case.

When breaking a DC load this contact will more than likely be mA when the relay opens the contacts draw an arc then eventually burn away. Fitting suppression doesn't help much as the contacts are trying to break current under load and unlike when switching AC the arc lasts longer until the contact gap is sufficient to extinguish the arc.
With AC the arc self extinguishes as the waveform passes through zero volts.

Have a look at "Automotive relays" they are more suited to braking DC loads but again look at the Breaking current capacity you may find that this is shown in a graph form plotted against voltage follow the de-rating curves.

Looking at the attached data sheet first impressions the relay is rated at 75 VDC and will make 100 A break 60 Amps

if you look at page 2 this tells a whole different story.

@75 VDC the switching current is approx. 750mA
@60 VDC the switching current is approx. 1A
@24 VDC the switching current is approx. 25A

I have personally destroyed the contacts of this relay on a set of fully charged 48 V batteries switching off a 5 Amp restive load performing a battery load test.

If you want to go one step further have a look at MBO relays (Magnetic Blow Out) these have magnets fitted internally and are designed for breaking DC loads the magnets extinguish the arc that is drawn - These are expensive though and follow the orientation show in the data sheet one contact will have a " + " marked on it somewhere.

You don't have to remake your PCB you can simply use the relay on the PCB to power another higher power relay.

Steve
Attachments
Automotive Relay SRK.pdf
(166.5 KiB) Downloaded 170 times
Success always occurs in private and failure in full view.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Dc voltmeter 0-55v

Post by Benj »

Hello Derrihj,

Looking at your program you are using the internal oscillator at 8MHz but have not configured it to run at this speed. To do this simply add the following line of code in a C icon at the start of your program.

Code: Select all

OSCCON = 0x70;
This should hopefully help with things running on the hardware.

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

Thanks Steve001 for all the details about the relays, but as you see am not going to switch DC through those relays but rather AC.I designed that circuit to control charging for my 17AH battery and i will not control the DC part no i will control AC power to the transformer tapings,Yes i will have two tapings of a transformer one for High charge and another for low charge to help me do the absorption part before i move on to float in bits to keep the battery between 13v and 13.5v when its fully charged.

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

Thanks Benj for all the efforts,now after adding the C code it started working and displaying numbers though it still has some isues like it displays a decimal point of the Digit2 yet it shouldn't at-all at any point from 0 - 55v,it shows number 2 and 3 as letter a and i think it reads wrong voltage ok i measured a 9v battery and it showed me 8.80v which is true but after a few seconds it showed 0.71v when ever i tried to measure the 9v battery.

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

And some time i measure 8.80v and instead it shows 88.0v

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Dc voltmeter 0-55v

Post by Benj »

Hello,

Please can you post your latest program and I'll have another look through for you.

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

Here it is.
Attachments
My Latest Prog.fcfx
(28.51 KiB) Downloaded 152 times

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

Am still here dear friends

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: Dc voltmeter 0-55v

Post by LeighM »

i measured a 9v battery and it showed me 8.80v which is true but after a few seconds it showed 0.71v
I think we need your circuit diagram too, if you have one

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

Hi LeighM here is my PCB image its in PDF any help for this circuit to work as required is highly welcome and also if anyone has a better charger code maybe by use of pulse width control will also be of an added advantage.
Attachments
Basic Battery Chage CUT Full Color.pdf
(146.29 KiB) Downloaded 156 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: Dc voltmeter 0-55v

Post by LeighM »

I’ve no experience with that particular PIC device, but based on others, I would suggest that you try reducing the resistance of the potential divider by a factor of 10. i.e. 100K/10k and 100R series resistors. Also might help to increase the Acquisition cycles of the ADC component.

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

Ok LeighM i will also try that and see the out-come tho i've been using that same config in quiet a number of circuits with a division factor of 11 and it has been making wonders measuring voltages accurately compared with good multi meters.because i prefer dealing with the noise than dealing with consumption.
Last edited by Derrihj on Mon Feb 10, 2020 4:12 pm, edited 1 time in total.

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
Contact:

Re: Dc voltmeter 0-55v

Post by Derrihj »

Ok LeighM just did your config and i think its the same way recommended in the datasheet of most MCUs to use 10K but as u can see i got the same results as before.Measured 12v battery with 13 volts on it says the multi meter but this one showed me only 8.90.v, ok i always calibrate the voltage to match the multi meter but in this case i disabled the calibration part so that the code could fit in there for testing.Again ive measured a 9v battery with your config and it showed me 88.0.v and then changed to 56.5.v and its not a typing mistake it also shows the decimal points as ive written them most so the one on the last digit which is not supposed to show up any where say from 0-55v

User avatar
Steve001
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Wed Dec 31, 2008 3:37 pm
Has thanked: 460 times
Been thanked: 523 times
Contact:

Re: Dc voltmeter 0-55v

Post by Steve001 »

Sorry to jump back a bit

Are these Lead acid batteries ?
that circuit to control charging for my 17AH battery and i will not control the DC part no i will control AC power to the transformer tapings,Yes i will have two tapings of a transformer one for High charge and another for low charge to help me do the absorption part before i move on to float in bits to keep the battery between 13v and 13.5v when its fully charged.

Steve
Success always occurs in private and failure in full view.

Post Reply