Page 2 of 10

Re: Dc voltmeter 0-55v

Posted: Sun Apr 07, 2019 2:58 pm
by Derrihj
Eh! i have to double check my hardware i think it must be were the problem is.

Re: Dc voltmeter 0-55v

Posted: Sat Nov 23, 2019 3:07 pm
by Derrihj
Thanks Medelec35 for all your help in this project it was successful.

Re: Dc voltmeter 0-55v

Posted: Sat Nov 23, 2019 11:56 pm
by medelec35
I'm glad your project was successful.
Thanks for letting us know.

Re: Dc voltmeter 0-55v

Posted: Wed Feb 05, 2020 2:39 pm
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.

Re: Dc voltmeter 0-55v

Posted: Wed Feb 05, 2020 3:24 pm
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

Re: Dc voltmeter 0-55v

Posted: Wed Feb 05, 2020 4:21 pm
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

Re: Dc voltmeter 0-55v

Posted: Wed Feb 05, 2020 4:25 pm
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.

Re: Dc voltmeter 0-55v

Posted: Wed Feb 05, 2020 4:35 pm
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.

Re: Dc voltmeter 0-55v

Posted: Wed Feb 05, 2020 4:36 pm
by Derrihj
one more

Re: Dc voltmeter 0-55v

Posted: Wed Feb 05, 2020 5:20 pm
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.

Re: Dc voltmeter 0-55v

Posted: Wed Feb 05, 2020 6:15 pm
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.

Re: Dc voltmeter 0-55v

Posted: Wed Feb 05, 2020 8:43 pm
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

Re: Dc voltmeter 0-55v

Posted: Thu Feb 06, 2020 11:27 am
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.

Re: Dc voltmeter 0-55v

Posted: Thu Feb 06, 2020 7:34 pm
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.

Re: Dc voltmeter 0-55v

Posted: Fri Feb 07, 2020 12:07 am
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.

Re: Dc voltmeter 0-55v

Posted: Fri Feb 07, 2020 3:12 pm
by Derrihj
And some time i measure 8.80v and instead it shows 88.0v

Re: Dc voltmeter 0-55v

Posted: Fri Feb 07, 2020 3:25 pm
by Benj
Hello,

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

Re: Dc voltmeter 0-55v

Posted: Fri Feb 07, 2020 11:16 pm
by Derrihj
Here it is.

Re: Dc voltmeter 0-55v

Posted: Mon Feb 10, 2020 12:52 pm
by Derrihj
Am still here dear friends

Re: Dc voltmeter 0-55v

Posted: Mon Feb 10, 2020 12:58 pm
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

Re: Dc voltmeter 0-55v

Posted: Mon Feb 10, 2020 1:59 pm
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.

Re: Dc voltmeter 0-55v

Posted: Mon Feb 10, 2020 2:15 pm
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.

Re: Dc voltmeter 0-55v

Posted: Mon Feb 10, 2020 2:27 pm
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.

Re: Dc voltmeter 0-55v

Posted: Mon Feb 10, 2020 3:52 pm
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

Re: Dc voltmeter 0-55v

Posted: Mon Feb 10, 2020 7:03 pm
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