Trying to determine dc current - 12v lead acid battery charger


Closed Thread
Results 1 to 32 of 32

Hybrid View

  1. #1
    Join Date
    Dec 2011
    Location
    IO93ok
    Posts
    190


    Did you find this post helpful? Yes | No

    Default Re: Trying to determine dc current - 12v lead acid battery charger

    pedja089, thanks for info I will check that Max chip out.

    Meanwhile,

    Hmmm interesting one http://http://electronics-diy.com/70v_pic_voltmeter_amperemeter.php

    This uses a .047 in ground line. I've just been out and bought a .047 3W resistor anyway, so will try a mod to my board and see if I can re-configure things around.

    Rob
    Last edited by tasmod; - 22nd June 2012 at 18:04. Reason: typos and edit link but it won't

  2. #2
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default Re: Trying to determine dc current - 12v lead acid battery charger

    ...and this is the original code from this schematic :
    Code:
    '****************************************************************
    '*  Name    : VOLTMETRE.BAS                                      *
    '*  Author  : [Erol Tahir Erdal]                                *
    '*  Notice  : Copyright (c) 2005 [ETE]                          *
    '*          : All Rights Reserved                               *
    '*  Date    : 01.03.2005                                        *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
    DEFINE LCD_DREG		PORTB	'LCD data bacakları hangi porta bağlı?
    DEFINE LCD_DBIT		4		'LCD data bacakları hangi bitten başlıyor?
    DEFINE LCD_RSREG	PORTB	'LCD RS Bacağı Hangi Porta bağlı ?
    DEFINE LCD_RSBIT	1		'LCD RS bacağı Hangi Bite bağlı ?
    DEFINE LCD_EREG		PORTB	'LCD Enable Bacağı Hangi Porta bağlı?
    DEFINE LCD_EBIT		3		'LCD Enable Bacağı Hangi bite bağlı ?
    define lcd_RWREG    PORTB
    define LC_RWBIT     2
    DEFINE LCD_BITS		4		'LCD 4 bit mi yoksa 8 bit olarak bağlı?
    DEFINE LCD_LINES	2		'LCD Kaç sıra yazabiliyor
    	 
    DEFINE	ADC_BITS	10	    ' Set number of bits in result
    DEFINE	ADC_CLOCK	3	    ' Set clock source (3=rc)
    DEFINE	ADC_SAMPLEUS 50	    ' Set sampling time in uS
         
    @ DEVICE pic16F877
    @ DEVICE pic16F877, WDT_off
    @ DEVICE pic16F877, PWRT_ON
    @ DEVICE pic16F877, PROTECT_OFF
    @ DEVICE pic16F877, XT_OSC
    
    ADCON1=%10001110
    TRISA=%00010011
    TRISB=0
    TRISC=0
    
    VOLT    VAR  WORD
    HAM     VAR  WORD
    HVD     var  word
    AMPER   var  word
    
    
    MV      VAR  BYTE
    MA      VAR BYTE
    
    PORTB=0
    PORTA=0
    VOLT=0
    PAUSE 100
    LCDOUT $FE,1
    
    
    BASLA:
           ADCIN 0,HAM
    BAK:   IF ADCON0.2=1 THEN BAK
           PAUSE 5
           GOSUB HESAPV
           
           ADCIN 1,HAM
           PAUSE 5
           GOSUB HESAPA
           
           GOSUB EKRAN
           PAUSE 1500
           GOTO BASLA       
           
           
    EKRAN:
    '       LCDOUT$FE,2,"HAM=",#HAM  'gerekirse okanan ham değerini görmek için
           LCDOUT $FE,$02,"VOLT =",DEC VOLT,",",DEC1 MV 'dec2 yazdık çünki virgülden sonra 2 hane hassasiyetimiz var.
           LCDOUT $FE,$C0,"AMPER=",DEC2 AMPER,",",DEC2 MA 
    '       LCDOUT $FE,$C0,"AMPER=",DEC HVD
           RETURN
           
    HESAPV: '0-25V değerlerini oukuyup göstermek içindir
           HVD=((HAM+1)*/875)/10 'bu ifade aslında (HAM+1)*625/256 nın karşılığıdır
    'CARPAN=625  yani ((25x10)/1024)*256 sonuç 62,5 çıktığı için 625 almak için 
    ' 10 yerine 100 ile çarpıyoruz. yani CARPAN=((25*100)/1024)*256
           VOLT=HVD/10  'başlangıçta 100 ile çarpılmış halini hesaplamış idik ohalde 100 e böleceğiz
           MV=(HVD)//10 'seaplanan sayını 100 bölünmesinden kalan sayı ondalık hanesidir
          RETURN
    '      Formül;
    '      Okunacak Maksimum Volt=OMV olsun
    '      CARPAN= ((OMV*10)/1024) * 256   veya ((OMV*100)/1024)*256
    '      CARPAN değerini 3 haneli rakam olarak kullanmaya gayret edin.
    '      şayet  62,5 gibi 2 haneli bir rakam çıkar ise bunu 625 kabul edin ve
    '      (OMV * 10) değerini (OMV * 100) olarak kullanın. Sonuçta hesaplanan volt değerini 
    '      10 yerine 100'e bölmeniz gerekecek tabiiki. OV hesabında da Yine 100 bölünmüş
    '      değerden kalanı hesaplamak gerekecek. Yukarıdaki örnekte olduğu gibi. 
    '      Hesaplanacak Volt Değeri =HVD olsun 
    '      ADC den okunan Değer HAM olsun
    '      HVD=(HAM+1)*/CARPAN    bulunacak değer gerçek volt değerinin 10 ile çarpılmış halidir.
    '      Tamsayı VOLT (TV)= HVD/10      veya TV=HVD/100  
    '      Ondalık VOLT (OV)= HVD//10     veya OV=HVD//100
    'Ekrana yazdırırken;
    '      LCDOUT $FE,2,"VOLT:", DEC TV,",",DEC1 OV   veya DEC2 OV olacaktır
    HESAPA:
           HVD=(HAM+1)*/250
           AMPER=HVD/100
           MA=HVD//100
           RETURN
    Credits to 320volts.com !

  3. #3
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: Trying to determine dc current - 12v lead acid battery charger

    Quote Originally Posted by tasmod View Post
    pedja089, thanks for info I will check that Max chip out.

    This uses a .047 in ground line. I've just been out and bought a .047 3W resistor anyway, so will try a mod to my board and see if I can re-configure things around.

    Rob
    Whilst that higher resistor will give you 4x the ADC reading vs a 0.1R resistor, that's still only an ADC variance of about 60 steps between 1000mA & 300mA for a PIC supply of 5V....like I say, if you use a PIC where the ADC positive reference can be tied to it's internal 1.024V fixed reference (eg 16f1824), you'll then get a variance of about 240 steps between 1000mA & 300mA current draw ...which is starting to become useable.

  4. #4
    Join Date
    Dec 2011
    Location
    IO93ok
    Posts
    190


    Did you find this post helpful? Yes | No

    Default Re: Trying to determine dc current - 12v lead acid battery charger

    fratello. Yes I saw that one but it isn't this one, this one had various calibration routines etc in the code. Notice the defines for xtal osc. I do remember the author for mine came from India.

    Hank,
    I'm getting old I just don't get this. I've modded the board to have the .47 (not.047 as i put above) in series to the ground line and put a 100k to the adc input as per the schematic from the link above. This uses a 16f876 and I've duplicated the adc input circuit. They are claiming up to 10amp and with 10mA resolution.
    Attached Images Attached Images  
    Last edited by tasmod; - 22nd June 2012 at 22:35.

  5. #5
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: Trying to determine dc current - 12v lead acid battery charger

    Quote Originally Posted by tasmod View Post
    Hank,
    I'm getting old I just don't get this. I've modded the board to have the .47 (not.047 as i put above) in series to the ground line and put a 100k to the adc input as per the schematic from the link above. This uses a 16f876 and I've duplicated the adc input circuit. They are claiming up to 10amp and with 10mA resolution.
    It's pretty simple...let me try & explain.

    If your PIC is running at 5V, then you're ADC resolution becomes 5V/1024 (the 1024 being 10 bits)...this results in a resolution of 0.0048828125V (4.9mV) per ADC bit, which sounds great, but not if your sense resitor is very small & therefore the maximum voltage drop will be very small. So at 1000mA & a .47 ohm resistor, your maximum voltage drop will be .47V across it (V=IR). ) .....so if you PIC has the aformentioned resolution of 0.0048828125V, then the maximum ADC reading you'll get is .47V/0.0048828125V ...or a max reading of 96 ...that's with 1A flowing (that's an awful lot of wasted bits, bearing in mind you've got 1024 bits available in your PIC).

    To get more resolution, if the PIC is modern & has a P-ref register for the ADC module (16f1828 etc)....you tell the PIC that rather than use 5V as the upper limit for the ADC, to use an internally generated fixed 1.024V instead (again the PIC needs to be up to date & have one onboard) - there are no more components involved, you just need to set a register in the PIC & you're off to the races.

    Now your ADC resolution becomes 1.204V/1024 bits ....or 1mV per ADC bit, therefore with 1A flowing through the sense resistor, your maximum ADC reading will be 470 which is a lot healthier amount of 'reading' to play with.

    Of course if you want up to 10A, then this is not the way to go (but I thought you were talking of 1A max?)

  6. #6
    Join Date
    Dec 2011
    Location
    IO93ok
    Posts
    190


    Did you find this post helpful? Yes | No

    Default Re: Trying to determine dc current - 12v lead acid battery charger

    Thanks Hank,

    That all makes perfect sense and is what I believed and kinda saw all along.

    I'm therefore puzzled by the circuit and claims for the above of 10A and 10ma resolution. This using a 16f876 which is the smaller brother of the 16f877 I have in the circuit.

    I've read the datasheets. Looked at the circuit, there's nothing different to what I'm doing. I see no offset input, it has no internal 1.024v ref, I'm also now in the ground line with the .47.

    This isn't the first circuit I've seen setup this way which claims 10A measurement with 10ma resolution but also using a 16f877. With 1023 bits to play with "it does not compute Captain"

  7. #7
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: Trying to determine dc current - 12v lead acid battery charger

    Quote Originally Posted by tasmod View Post
    Thanks Hank,
    This isn't the first circuit I've seen setup this way which claims 10A measurement with 10ma resolution but also using a 16f877. With 1023 bits to play with "it does not compute Captain"
    It is kind of correct..... 10mA through a 0.47R resistor = 0.0047V drop across it (which, if you look back above the above posts, with a 5V ADC reference & 1024 bits, you can resolve 0.0048828125V per ADC bit)

    the spec seems to have changed a little though ...I'd thought earlier on you were speaking of 1000mA being your maximum anticipated current ...if that were the case, then 10mA resolution didn't strike me as being that granular....however if 10A is to be your max current, then 10mA of resolution is just dandy! So I guess you need to bottom out your requirements & take it from there.....

  8. #8
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    173


    Did you find this post helpful? Yes | No

    Default Re: Trying to determine dc current - 12v lead acid battery charger

    Hi Rob,

    If you plan to increase the maximum current from 1 Amp to 10 Amps then I would suggest that you change the value of the shunt resistor due to power handling ratings. 10 amps flowing through a 0R47 shunt resistor will need a hi power resistor (P=I^2 x R = 47 Watts).

    Your circuit shows the original 0R1 shunt resistor power rating as only 3 watts which has a theoretical limitation of just under 5.5 amps.

    Cheers
    Barry
    VK2XBP

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts