Shop OBEX P1 Docs P2 Docs Learn Events
Batteries running SX28 don't last all night? — Parallax Forums

Batteries running SX28 don't last all night?

eagletalontimeagletalontim Posts: 1,399
edited 2012-07-29 08:51 in General Discussion
I have a project that requires batteries to run an SX28 through out the night, then during the day, the batteries recharge from solar panels. The batteries are 1.2V 2500mAh rechargeable NI-MH AA's. I have 8 run in series to make 9.6V. The power is then sent though a 7805 5 volt regulator then to the chip. The chip does nothing through out the night as far as running anything from any pins. The SX's only purpose is to listen for a pin to go high or low then activate 1 of 2 pins for 1 second to control an H-Bridge which turns on an electric water valve. Current draw of the entire circuit is about 30mA in "stand-by" mode, and a max of 280mA for 1 second when activating or deactivating the water valve. From what I figured, the batteries should last over 24 hours without a charge but maybe I did my math wrong or something is just not right. I can draw up a schematic if needed but it will take quite awhile and I can post my code if needed. Does 30mA sound too high for just running an SX28 DIP? I did not configure any pins except for the ones I am using if that matters any.

If I posted this in the wrong place, please feel free to move it to the correct area :)
«13

Comments

  • RDL2004RDL2004 Posts: 2,554
    edited 2012-07-25 19:10
    Your 7805 regulator is burning off 0.138 watts of power dropping the 9.6 volts to 5 volts at 30 mA. That might be the problem.
  • ZootZoot Posts: 2,227
    edited 2012-07-25 19:38
    You can drop your voltage down to 7.2 for a 7805 or even lower (6v) if you use an LDO. That said, your SX program should use SLEEP and WAKE ON INTERRUPT. This way the SX will draw hardly any power until you hav the pin state change (the low or high), then the SX "wakes" up, does what it needs to do based on what the pin state is, then goes back to sleep. This might get you through the night. Naturally, the slower your clock (resonator/crystal) the less power you will draw as well. 20MHZ-50MHZ uses a lot more current than 4MHZ.

    Between reducing the SX current draw except when it's needed and reducing the quiescent current it could work out.
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-07-25 19:45
    I have learned that reducing the clock speed to 32K is a step towards lowering power consumption. I have implemented that into my code as of right now along with using the TRIS_* commands to make all pins outputs except for 1 which is the button detecting pin. It has a 100K pull down resistor.

    I am trying to find good documentation on the SLEEP command and how to use it for what I am needing. It appears, from what I have read so far, that my button pin must be on one of the B pins in order for the wake up to happen. I know I can put the SX to sleep, but can't figure out how to wake it back up with RB.0
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-07-25 20:13
    Maybe I am doing something wrong, but the SX is not acting the way I am expecting. I am trying to put the SX to sleep when the water valve is turned off and wait till the next cycle it should turn on.

    Here is what I have so far.
    DEVICE          SX28, OSC32KHZ, BOROFF, TURBO, STACKX, OPTIONX
    FREQ            32_000
    ID         	"WATERVLV"
    
    ' -------------------------------------------------------------------------
    ' IO Pins
    ' -------------------------------------------------------------------------
    Switch		VAR	RB.0
    On_Pin  	PIN     RC.0    OUTPUT    ' LED pin
    Off_Pin		PIN	RC.1	OUTPUT
    TRIS_C_pins	VAR	TRIS_C
    TRIS_B_pins	VAR	TRIS_B
    TRIS_A_pins	VAR	TRIS_A
    
    ' -------------------------------------------------------------------------
    ' Constants
    ' -------------------------------------------------------------------------
    water_running	VAR	Byte
    temp1		VAR	Byte
    Water_On	CON	1
    Water_Off	CON	0
    
    wait		FUNC	1, 2
    Set_State	SUB	1, 1
    ' =========================================================================
     PROGRAM Start NOSTARTUP
    ' =========================================================================
    
    ' -------------------------------------------------------------------------
    ' Program Code
    ' -------------------------------------------------------------------------
    
    Start: 
        TRIS_C_pins = %00000011
        TRIS_B_pins = %00000001
        TRIS_A_pins	= %0000
        water_running = 0
        Set_State Water_Off
    
    Main:
        DO
    	if Switch <> 0 then
    	    if water_running <> 1 then
    		Set_State Water_On
    	    endif
    	else
    	    if water_running <> 0 then
    		wait 1000
    		if water_running <> 0 then
    		    Set_State Water_Off
    		endif
    	    endif
    	endif
    	wait 500
        LOOP
    
    wait:
      PAUSE __WPARAM12
      RETURN
    
    Set_State:
        temp1 = __PARAM1
        if temp1 <> 0 then
    	HIGH On_Pin
    	wait 700
    	LOW On_Pin
    	water_running = 1
        else
    	HIGH Off_Pin
    	wait 700
    	LOW Off_Pin
    	water_running = 0
    	WKED_B = %1111_1110
    	WKPND_B = 0
    	NOP              
    	WKEN_B = %1111_1110
    	NOP
    	SLEEP
        endif
        RETURN
    
  • ZootZoot Posts: 2,227
    edited 2012-07-25 20:13
    See the docs under "wake on interrupt". Both assembly and SX/B support this. Basically the pin is set to be an input and an interrupt pin with the appropriate edge (high-to-low or low-to-high). When the SX wakes (after a sleep command), the register can be read to see if indeed the pin you are monitoring caused the interrupt. If yes, then do your stuff with the valve. If not, then back to sleep.

    FWIW, this would let you run the SX at 4MHZ, as the quiescent current would be quite low during sleep, but if you don't need tight timing, the internal 32khz RC clock is even lower power.
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-07-25 20:26
    I have found all kinds of information on the wake on interrupt in ASM which I do not understand :p I am hoping to find documentation in SPIN since I am fair at understanding it.
  • FranklinFranklin Posts: 4,747
    edited 2012-07-25 21:59
    The sx chips do not use spin, only asm and sx/b
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-07-26 03:27
    The 'wake on interrupt' presentation is a bit unclear.

    Essentially there are two ways - an external interrupt to port B or an internal interrupt via a reset by the Watchdog Timer doing a rollover. The watchdog timer seems to be doing a reset in its normal role and a wake up when in Sleep mode. The wake up may be preceded by a reset with a delay - I am still trying to sort this out.

    If you want to explore the internal interrupt, you have to turn on the Watchdog timer and set an appropriate interval (up to 2.2 seconds). Of course, once the Watchdog timer is in play, you also have to prevent it from rolling over and causing an unintentional reset.

    Actually, I found the SX documentation of the feature so incomplete that I ended up reading up on the same feature in the PIC16F57 and PIC16F84 to fully understand it.

    But and a very big BUT, you require a low quiescence Voltage regulator to take advantage of this. That means a regulator that provides 500ma or less and consumes less that 1ma when power is not required. Using a conventional 7805 or a 78L05 is going to use 5-6ma even when nothing is on AND a heck of a lot when on (about 30% waste).

    LDO or low drop out regulators are a bit of a deception as they consume huge amounts of power as they get into the region below which a 7805 operates.

    So you likely need the 3rd option - a low-quiescent regulator. If the H-Bridge can take unregulated power, a 100ma low-quiescent regulator would be idea as they use about 50uA in idle mode. Maybe you should use a dual voltage set up.
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-07-26 04:36
    I found a big problem which I don't know how to fix. I am using an LM317 adjustable regulator to charge the solar panel but the way I have it wired can't be right. The Adjust pin is wired to ground through a POT which is actually a huge drain. Going to have to figure out a better wiring to charge the batteries with the solar panels.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-07-26 05:36
    Well, you are right in checking everything when there is a problem with efficiency - every little bit adds up.

    In the past, there has been a lot of discussion here about correct solar panel configuration as it is a bit counter-intuitive. There is a big difference with output under load from output without load - and this needs to be taken into consideration.

    From what I can gather, you want to use the external wake up feature. You have to choose to trigger on a rise or a fall in the Port B pins that are active. That means that a positive pull would need a rise configuration and a fall from +5 to zero would need the falling configuration. Pull up or pull down resistors might be required also.

    This is an interrupt that goes to $000 or a reset that goes to $fff for redirection to enter the main program. This may or may not be an issue. It depends of where you are starting your program and whether you are using an Interrupt Service Routine with the RTCC.
  • David BDavid B Posts: 592
    edited 2012-07-26 08:09
    Do you need a voltage regulator at all? The SX28 is rated at 3.0 to 5.5 volts, so 4 NiMH cells at about 4.8 volts should run the SX with plenty of margin on both sides for a higher voltage while charging and a lower voltage when running through the night.

    Apart from that, why not do an independent load test - connect a resistor load to the batteries to draw a known current, around 30 ma, and let it run for a few days to test a few charge and discharge cycles independently from the SX.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-07-26 08:58
    I took a look at the references I have for SLEEP again and this needs to be sorted out. What happens when a 'wake up interrupt' occurs?

    The problem is the term 'interrupt'. Is it a true interrupt that vectors to $000, is it s true reset that vectors to the reset vector (this goes usually to where Main starts the program - without an ISR this can also be $000, but it can be different by designation), or does a 'wake up interrupt' just go the next command after SLEEP?

    These 3 situations depend on the watchdog counter NOT being active. When the watchdog counter is enabled, SLEEP has its behavior and wake up entangled with the WDT which may issue a reset vector that overrides SLEEP's normal behavior.

    Also, I see you have Brown Out turned off. In theory, the voltage could go to near zero and never reset. Is that really what you want. My impression is it is better to enable it at least on a low setting rather than to completely disable it.

    BTW, Clocking at 32Mhz requires the higher 5 volts to keep the oscillator going. Since you are NOT using RS232 that requires a crystal, the internal 4Mhz rc is likely to be better for low power, and 32Khz would be even better -- micropower.
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-07-26 16:24
    From what I have read about the SLEEP command, it basically restarts the SX program when there is a change on the B pin keeping variable values intact when it restarts. Program start NOSTARTUP is required for this though. I was able to get the sleep and wake working properly. With the LM317 disconnected from the circuit, I cannot read the mA's with my meter. I would need a more sensitive one.

    Do I have the correct FREQ set in the header for 32Khz? I thought I had it correct. There is no need for special timing so the slower the clock, the more "juice" I save. I have also set brown out to 2.2V. The brown out off in the above posted code was a check to see if the circuitry was causing a brownout.

    I do need a regulator since the batteries are 1.2V and I have 8 of them in series. I need that much power to activate and deactivate the water valve when needed. I tried just 4 batteries but it was not enough.

    If anyone has any ideas on how to set up the LM317 to charge the batteries without putting a drain on them when there is no or not enough solar light to push current into them?
  • RDL2004RDL2004 Posts: 2,554
    edited 2012-07-26 16:31
    Wire in a tap after the first 4 batteries just to power the SX. How powerful are the solar cells? Do you really need current regulation? You probably need to draw up some kind of schematic and provide some specs for the parts before this will get figured out.
  • ZootZoot Posts: 2,227
    edited 2012-07-26 16:37
    You can WAKE from SLEEP a number of ways -- on interrupt on port B, on reset/power-up, on RTCC, etc.

    In any case, you generally check the pin state in the interrupt service routine. I'm also not sure about having the sleep in subroutine --- probably it's OK but seems like a less than ideal form.

    If you need more battery power for the valve, you could put a tap in after the 5th battery for an LDO regulator (drop-in replacement for the 7805).

    You could also use a "power-on" circuit if the sensor generates enough voltage. Then the SX could actually shut itself off completely when not in use.

    The attached is an example -- this shows a pushbutton from the battery + supply, but a positive swing from a sensor would do it too. The first line of the program needs to set the "power on" pin high; the program can make that pin low at any time to shut the whole thing down. I believe Beau Schwabe first posted this.
    881 x 627 - 46K
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-07-26 16:48
    Are you saying to simply tap into my battery packs (2 of them, each hold 4 batteries) and run them in series like I am now but splice into the wire between the 2 packs and run directly to the chip? If so, that sounds easy enough since that should be 4.8V going to the SX, and still 9.6 going to the H-Bridge which powers the water valve.

    The solar panels that I have are 2 each 6 volt 1.5 watt panels they had at RadioShack. They are run in series to give me "12V" full power. I have read that connecting the solar panels directly to NI-MH batteries, even with a resistor is a bad idea since trickle charging those batteries can cause excessive heat which can cause permanent damage to the batteries. I need to be able to shut off charging if the batteries are fully charged. I don't think my existing circuit did that anyways though.
  • RDL2004RDL2004 Posts: 2,554
    edited 2012-07-26 17:09
    Do you have a blocking diode in the circuit or do you know for certain the solar cells have one built in? At night the solar cells will "run in reverse" and drain the batteries if there's no blocking diode. I looked at radioshack.com and the only 6v 1.5 watt cell I saw didn't say one way or another.
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-07-26 17:10
    I have a blocking diode in place between the solar panel and the circuit board to prevent that from happening.
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-07-26 17:25
    Out of curiosity, would this set up be what I need?

    http://www.reuk.co.uk/Solar-Battery-Charger-With-LM317T.htm

    It appears to not regulate the voltage, but it regulates the current. Since I am using 2800 mAh batteries, I could charge them with a maximum of 280mA correct? If this is the case, I have 4.7K resistors handy and could rewire the LM317 to limit current. I just want to be safe and have fun without spending a bunch of money :p Instead of directly connecting the solar cells to the batteries with a blocking diode, I feel more comfortable having some safety measure there. If the above link would be what I should do, then I can get that set up quickly :)
  • RDL2004RDL2004 Posts: 2,554
    edited 2012-07-26 19:13
    Yes, that's the basic LM317 current regulator circuit. For the LM317 the formula is I=1.2V/R so you'll need kind of a small resistor for a decent amount of current, and be careful of the resistor's power dissipation, P= I 2 x R

    You can always parallel several larger resistors to get a smaller value with higher power handling.
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-07-26 19:35
    I wound up trying the circuit anyways to see if there was a drain on the batteries or if it even worked charging the batteries. I think I have done something wrong because I am getting voltage out of the Vout at 11.38V but there is no readable current.

    Here is the schematic I went off of :
    battery-charger-complete.jpg

    I have my meter's negative lead connected to the common ground of the circuit and the positive lead is touched to the Adjust of the LM317T. The meter is properly set to read up to 10A. I know it is a direct short when doing this, but there is 0.00 showing on my display. The resistor value I went with is 4.7ohm which should give me 266mA output according to the website posted above.

    Here is the catch..... if I touch the meter to the Vout (center pin) of the LM317, I get 0.26mA but the regulator gets extremely hot within a matter of a second or 2. I have checked the wiring 10 times to ensure it matches the above circuit to the T. Not sure what I am doing wrong :(
  • Peter KG6LSEPeter KG6LSE Posts: 1,383
    edited 2012-07-26 20:01
    I wound up trying the circuit anyways to see if there was a drain on the batteries or if it even worked charging the batteries. I think I have done something wrong because I am getting voltage out of the Vout at 11.38V but there is no readable current.

    this is right ! .
    Let me guess are your batts charged ? If so you should read NO amps ..


    Try discharging them and then try again .

    as for your resistor . If you short a PV panel you have NO volts .
    NO volts = no input to Run a reg so you need some voltage to make the 317 run . its just part of the game .

    EG a 7805 needs 8 V or more to work ..
    by shorting the output you are inside the GRegs shuting them down to a OFF condition .

    if you want to test your 317 I reg use a Real bench power supply and dial in the specs of your panel and Sim it .
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-07-26 20:06
    I tested the output with the batteries disconnected from the circuit and with them connected. No change :(


    EDIT : The batteries are at 6.28V currently. Full charge is 9.6V
  • Peter KG6LSEPeter KG6LSE Posts: 1,383
    edited 2012-07-26 20:10
    then
    A) blown fuse in meter
    B) you have full batts .

    unhooked what does the bat pack read ?
    ?

    EDIT good meter fuse?
    If your batts are at anything less then your V out then you Will have curent flow of Some kind ..
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-07-26 20:16
    i don't think it is a blown fuse since I can consistenly touch the Vout pin directly and get 0.26A reading on the meter. If I touch it to that pin too long, the regulator gets extremely hot since that is a direct short across the regulator.
  • RDL2004RDL2004 Posts: 2,554
    edited 2012-07-26 20:18
    You can't just touch the meter's probes to the existing circuit and measure amps.You have to either break the connection and insert the meter in current measuring mode or insert a resistor inline and measure the voltage drop across it and calculate the current from that. You could measure the voltage across your 4.7 ohm resistor but there will be error due to the 317's adjust pin current.
    600 x 380 - 58K
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-07-26 20:23
    I did as shown in the image you posted several times but still got 0.00 on the meter. I even connected a completely dead battery pack that I used yesterday for testing (Brand new rechargeable batteries). Still got 0.00 connected the way you have shown in the image. But.... if I connect the Positive lead to the center pin of the LM317, I get 0.26 amps.
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-07-26 20:43
    I put some brand new fully charged batteries in the holders and checked the amperage again. It was at 0.03 when connected to the center pin of the LM317. The regulator did not get hot during any of the testing. Question is, the batteries are at 10.16V when checked with a meter and no load. They are supposed to be 9.6V. Does this mean they were over charged?
  • Peter KG6LSEPeter KG6LSE Posts: 1,383
    edited 2012-07-26 21:04
    I put some brand new fully charged batteries in the holders and checked the amperage again. It was at 0.03 when connected to the center pin of the LM317. The regulator did not get hot during any of the testing. Question is, the batteries are at 10.16V when checked with a meter and no load. They are supposed to be 9.6V. Does this mean they were over charged?


    more then 9,6 is Fresh charge .. By law of chem you cant have a 12V bat read 20 and the same is with a 9.6V pack .
    The OCV is more then 1.2V per cell.. AKA surface charge... run a load on it Like a 500 mA load for a few min . you will eat that charge right off.

    Note you dont need to remove it in real life, the above was a way to show what small the surface charge is
  • RDL2004RDL2004 Posts: 2,554
    edited 2012-07-26 21:11
    No, that's normal for a properly charged NiMH cells. My AAs will measure about 1.4v fresh out of the charger.
    I can consistenly touch the Vout pin directly and get 0.26A reading on the meter. If I touch it to that pin too long, the regulator gets extremely hot since that is a direct short across the regulator

    It's not a short, you're just bypassing the current limit programming resistor and drawing full current from the cells through the LM317.
    6 volt 1.5 watt panels they had at RadioShack

    6 volts at 1.5 watts is 250 mA (0.25 A). The LM317, if it's a TO-220 type, shouldn't get very hot with only 250 mA running through it.
Sign In or Register to comment.