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

Batteries running SX28 don't last all night?

2

Comments

  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-07-26 21:22
    So from what I gather, the image I posted which is from the website tutorial on how to build a simple solar charger is actually incorrect base on the pin assignment. The Vin pin is correct, but the Adj and the Vout are switched. With the meter attached to the center pin then to the open positive lead of the battery packs, they actually charge and I can read amperage. If it is connected as shown in the image, nothing happens since there is 0.00 amps.

    With this cleared up and the batteries are charging, would this be safe to use with my NI-MH batteries for long periods of time like several months never being disconnected? If the output of the solar panels is around 12 volts, do I need to regulate the voltage as well current to ensure I don't overcharge the batteries. The circuit above is just current limiting so do I need to lower the voltage somehow?
  • Peter KG6LSEPeter KG6LSE Posts: 1,383
    edited 2012-07-26 21:32
    Yes you need to limit your voltage too, a 2ed 317 as a V reg will do fine .

    Unless you are charging at a Obscene low current . EG 20 mA in a 2 AH pack .

    C/30-40 is safe for most uses for longgggggg term trickle ..

    NiMH Hates trickle . NiCd's are more robust for this ..


    edit

    what is the open circuit voltage on those PVs?
  • RDL2004RDL2004 Posts: 2,554
    edited 2012-07-26 21:45
    Their picture shows the hook up correctly. The view is from the front, with the metal tab to the rear. The pin out is different from the 78xx series though.


    attachment.php?attachmentid=94522&d=1343364224
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-07-26 21:56
    That is how I have it connected, with the metal tab facing backwards. I even tried a brand new LM317 which acted the same way. Only got a current reading from the center pin when in line with the batteries. The Vout pin showed voltage, but no readable current even with dead batteries run in series with the meter and the output as shown above.

    I am not sure what the exact charge rate will be since the solar panels don't always output an exact amount. I limited the regulator to 266mA which is pretty much max for the solar panels anyways. Is there a way to adjust voltage without another LM317 or without tying the Adj to a POT then ground? This seems to be a HUGE drain on my batteries when there is no voltage present.
  • RDL2004RDL2004 Posts: 2,554
    edited 2012-07-26 22:08
    Only got a current reading from the center pin when in line with the batteries. The Vout pin showed voltage, but no readable current even with dead batteries

    I don't understand what you mean, the center pin is the Vout pin.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-07-27 02:16
    Left to right view from above the LM317 pins are Vadj - Vout - Vin.

    Well, there seem to be lots of suggestions here. I think a battery tap in lieu of a power hungry regulator might be helpful and the battery pack itself would limit the maximum voltage to the SX.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    I have done more reading and research on SLEEP as it has been a question that I wanted to answer for myself.

    Essentially, the only reasonable way out of SLEEP is a reset of the microcontroller, though it seems that an interrupt is available on Port B. Port B can do either a reset or an interrupt. But the interrupt feature would store key registers - including the Program Counter - for a RETI and that would seem to put you back to your original SLEEP instruction. This is an unnecessary complexity. In other words, Port B interrupts are better exploited if they are NOT used with SLEEP, use only Port B reset configuration.

    Why use PORT B at all, if you can use the RESET pin? You save yourself a lot of code if you can just use the RESET pin and skip configuration and management of Port B resets. But the RESET pin will only respond to being pulled LOW.

    So there are reasons you cannot use the RESET pin. A. You have the wrong transition direction. B. You want to have multiple pins doing different transition sensing. C. You want to know the origin of different resets so that they can be tracked and related to a particular response.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    You say the SLEEP and Wakeup are working properly, so the issues are really in your power supply and not about the above discussion.

    On one side, you need to optimize your solar charging. Maybe you were too optimistic as cloudy days may require the system to be battery dependent for a week or more. Lithium cells charge faster and hold about 6 times the power over NiMH. A couple of 18650s offer a peak of about 8.2Volts with nominal 7.4 Volts. Tapping one cell for the SX is feasible. Three Lithiums might be a better fit for the solar panel at 12.3 volt peak and 11.1 volts nominal.

    And maybe you have too much waste in the unnecessary devices - power hungry regulators, LEDs, and so on. I am not sure what you are using for an H-bridge, but the Tilden H-Bridge that was created for tiny Beam projects can handle 300ma when built with 2n2222 and 2n2907 transistors. That may reduce your power overhead. I've built about a half-dozen of these and am quite happy with them.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-07-27 02:55
    BTW, it seems that you have your current limiting circuit set up correctly. I believe there might be a bit of a voltage drop due to the internal transistors of the regulalor - either .7 or 1.4volts.

    Why did the regulator get extremely hot? You are using the amp meter wrong and by-passed the resistor that limits the current out put. Amp meters are always used inserted in series, almost never in parallel

    And, usually there is an internal fuse on the lower amp meter functions to protect the meter. But the 10amp function is NOT fused and wrong usage will destroy the meter. You might have to buy a new one.

    A dead meter may just require changing the fuse depending what scale you used.

    Trickle charge is a whole separate issue. Lead acid batteries seem to be best suited for it. NiCads maybe. NiMH and Lithium might best avoid such. How do you avoid a trickle charge, using a relay with hysteresis to charge and disconnect.
  • Peter KG6LSEPeter KG6LSE Posts: 1,383
    edited 2012-07-27 03:23
    BTW, using a relay with hysteresis to charge and disconnect.

    If it can be made to work . bloody genius !
    this way you can charge at a VERY fast rate and just shut off after
    or a Op amp with hysteresis and a N chan MOSFET on the PV-Lead .


    Peter..
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-07-27 04:14
    Since 2004, recharging batteries have been driving me crazy.

    It appears that NiMH will tolerate a c/30 rate trickle charge and prefer a c/10 charge rate, though they will fast charge at higher rates.

    Current limiting is the critical factor to assure a long battery life and with a trickle charge you would have to provide at least two different current limiting rates.

    The alternative is what I like to call 'yo-yo charging' and this is ideal for lithium as they absolutely dislike trickle charging but love to yo-yo.

    One can use a relay and set up hysteresis. Or one can do it with a Comparator -- forget the Op Amp as it is intended for linear use, not full on/off toggles. If one uses the Comparator and a power MOSfet, it is a rather nice solid-state solution, but there are many examples of stand-by batteries using a relay that are on the internet.

    I'd use a LM339 Quad comparator just because I have some and they work from 5 to 36 volts. It is rather hard to find a single comparator here, so I'd just waste the other 3.

    I need to do more research about the Hystersis calibration for the Comparator, but the device would work like this.

    Solar Panel > Battery voltage = Charge on
    Battery Voltage + 0.4v> Solar Panel = Charge off

    OR

    Solar Panel > Battery voltage + 0.4 = Charge on
    Battery Voltage > Solar Panel = Charge off

    Are these the same or significantly different?

    Since the NiMH prefer a per cell voltage of 1.4 to 1.6 volts to charge; at 8 cells the charge range would be 11.2 to 12.8 Volts. I presume the solar panel doesn't output 12.8v and that the NiMH will pretty much survive getting power at less than 11.2 volts. In fact, in that mode, the solar panel may be directly providing power to the devices.

    The idea of tapping the SX at 3 cells would use the battery itself in lieu of a voltage regulator. I don't think a 4 cell tap is wise 3 x 1.6 volts = 4.8 volts; 3 x 1.2 volts = 3. 6 volts. Both well about the 2.2 volt brown out trigger.

    So it would seem that just the one current regulator would do nicely and no voltage regulators.

    What remains to consider is a good relay control or solid-state solution.
  • Peter KG6LSEPeter KG6LSE Posts: 1,383
    edited 2012-07-27 04:21
    A Op amp Used as a comparator ...
  • Peter KG6LSEPeter KG6LSE Posts: 1,383
    edited 2012-07-27 04:21
    A Op amp Used as a comparator ...
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-07-27 04:50
    I just don't understand why one would use an op amp as a comparator when a comparator is the right device in the first place.

    In any event, I am pondering two solutions.

    1. A 5volt relay with a resistor that would turn on when the solar panel has a high enough voltage, and shut off when the battery level exceeds the solar panel by a certain amount.

    The 0.4v is arbitrary and in actual use a much wider range may be idea.

    2. An all solid-state device using a comparator with a power MOSfet and NO voltage regulation.

    I am running into problems as the info on the web presumes the comparator will have a regulated supply. But I don't see why it has to do so.

    The LM339 is an open collector output that requires a pull-up for operation and requires attention to the fact that the output is HIGH when off and LOW when on.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-07-27 09:44
    Take a look at the attached file. If you add one more 6 volt 1.5 watt solar panel in series, everything might be easier to do.

    The 6 volt rating is open circuit, but under load these panels deliver something like 5.1volts. So three would realistically provide 15.3 volts output at the same rated milliamps of output.

    This circuit shows a 12 volt panel (10.2 volts actual output) and intended to charge a 6 volt battery (at 6.8 or so volts). I think we could adjust the values to get the 11.2 to 12.8 volts that the NiMH prefer for charging AND have an automatic shut off of overcharging.

    Also, blocking diodes would cause some voltage drops.

    And, you actually may find that you really don't want or need 270ma of charge, so a current limit to a lesser value (adjustable via a pot) might be a good addition and that has some diode voltage drops too.

    In other words, I don't think you have a high enough solar panel set up to get a really good charging system that will take good care of the batteries over time.
  • RDL2004RDL2004 Posts: 2,554
    edited 2012-07-27 11:32
    I had never used an LM317 as a current regulator before, so this morning I hooked up a circuit to do some experimenting and see how it worked.
    Here is the circuit diagram. Notice in this circuit there is no "load". The only thing in the current path are the LM317 and R1.

    attachment.php?attachmentid=94536&d=1343413079


    Now, in a previous post in this thread I said that an LM317 shouldn't get hot with 250 mA going through it.

    This is true as long as it isn't doing anything.

    If you connect in and out on an LM317 to a variable voltage power supply with current limiting, you can turn the current up pretty much as high as the power supply can handle through a dead short. The power supply will put out practically no voltage and the LM317 won't get hot, it just acts like a piece of wire. However, when used as a regulator, it can get very hot.

    So, how does the LM317 regulate current? It uses Ohm's Law, I=V/R
    The LM317 does "whatever it has to do" to maintain 1.25 volts between it's Out and Adjust pins (across R1).
    That is what an LM317 is designed to do.
    Since 1.25 volts is a fixed value due to the LM317's internal voltage reference, the only variables left are the current (I) and resistance (R).
    In this setup a 4 ohm 25 watt resistor was used for R1. Solving for I gives:

    I = 1.25/4

    or 0.3125 amps

    The 1.25 volts the LM317 wants to maintain across R1 is negative at the Adjust pin (pin 1) and positive at Vout (pin 2), this means that as long as the LM317 is working, Vout should never rise above 1.25 volts. The LM317 is not really regulating current, it's regulating voltage. You change the current by changing the resistance between Adjust and Vout.

    Here are the results I got:
    V in     V out     I out     Temp     Power Dissipation
    ____     _____     _____     _____    _________________
    
    20       1.25      0.30      125 F    5.6 watts
    15       1.25      0.30      105 F    4.1 watts
    12       1.25      0.30       95 F    3.2 watts
     6       1.25      0.30       80 F    1.4 watts 
     3       0.938     0.22       75 F    0.4 watts
    

    V in is the indicated voltage on the power supply I used (BK Precision 1651)
    V out was measured between pin 2 and pin 1 (ground) on the LM317
    I out was measured between R1 and the power supply's negative terminal
    Temperature was measured with an infrared thermometer at the LM317 heatsink tab (rounded to nearest 5 degrees)
    (see the third attachment for metering details)

    As you can see, the LM317 maintains V out at 1.25 volts, and therefore the current through R1 at 0.3 amps, no matter what the input voltage is, as long as V in is high enough for regulation. (see the second attachment for photos of measurements)

    In order to regulate, the LM317 like all linear regulators, acts like a variable resistor. The voltage difference between Vin and Vout is turned into heat.

    Power Dissipation = (Vin - Vout) * I

    This is why the LM317 gets hot. You can see I have it attached to a fairly chunky heatsink. Before I did this I was easily able to drive it into thermal shutdown, with the heatsink attached it runs fairly cool.

    The way this test was set up, the Adjust pin is essentially at circuit "Ground", the negative terminal on the power supply.
    If there was some kind of load down stream from this point, that would raise the Adjust pin above 0 volts and Vout would go up accordingly.
    600 x 600 - 70K
    1024 x 680 - 234K
  • davejamesdavejames Posts: 4,047
    edited 2012-07-27 12:33
    David B wrote: »
    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.

    This appears to have been lost in the thread.

    David is making a very good suggestion here, and it would provide a baseline as to how long the batteries would provide the required load current.

    Imperical and takes some time - but you'll get the data you need without any question.
  • kwinnkwinn Posts: 8,697
    edited 2012-07-27 12:41
    When you connect the microcontroller across 4 of the 8 batteries in series and have all 8 batteries power a load the 4 batteries powering the micro will be discharged to a greater degree than the 4 that are powering the load. Charging them in series will result in one of two conditions. Either there will be 4 fully charged batteries and 4 partially charged ones, or there will be 4 over charged batteries and 4 fully charged ones.

    I would suggest using the solar cells to charge the batteries as shown in the attached diagram. This circuit presumes that you know how much current the controller and load circuit draw when active and inactive as well as the typical charging current provided by the solar cells. It also requires two of the microcontroIler I/O pins. The microcontroller is used to calculate the required charge time and connects the solar cells to the batteries for that length of time.

    You could also add circuitry to measure the currents drawn by the two circuits, the charging currents produced by the solar cells, and then have the microcontroller calculate the time required to fully recharge the batteries.
    578 x 543 - 15K
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-07-27 17:15
    After 3 overnight tests with my circuit, I have concluded I need to either go 12 Volt or completely shut down the circuit until ready to use. The problem with shutting down the circuit is starting it back up automatically when the switch is Off. The reason I say Off is because this is how the device works.... When the AC condenser fan kicks on, the wind lifts up a flap that makes contact at the base. When the fan turns off, the flap goes down and breaks that contact. When contact is made or when the contact is disconnected, the H-Bridge is activated for 1 second according to the which state the water should be in for the contact position. I am using the SX to control the H-Bridge since I don't know of anything else to use that I can do exactly what I need.

    With the current set up, the batteries are around 3.9V when I wake up in the morning after starting the circuit right before I go to bed. I usually get about 6 hours of sleep. So from say 12pm to 6am, my batteries lose almost 2/3's their power. Removing the 7805 would probably help, but spending $1 for an LDO and then an additional $5 to $10 for shipping is insane :p

    Going to a 12 volt setup would probably be better since I already have one of those 12 volt batteries that go in battery backups. I don't remember what the mAh is on those though. The only issue is I would have to purchase yet another solar panel which would be another $15 to $20. This is supposed to be a cheap, simple project :p None of them turn out this way for me.... especially by the time they get done.
  • ZootZoot Posts: 2,227
    edited 2012-07-27 17:26
    Plenty of suppliers these days, including Digi-Key, will send first class USPS. If you are buying a few small parts, this means shipping will be very low (i.e. shipping might be 50 cents or $1). You won't have tracking or delivery confirmation, but for something that cheap, it's fine.

    If the flap is your "switch", then I would use the low-power standby circuit. The flap will "turn on" the entire SX circuit (the transistor switched load that goes to the Stamp Vin on the schematic would go to the regulator Vin pin). The flap switch would be hooked up to BOTH the standby power circuit and an input pin. Your main program's very first line would be HIGH on the output pin to keep the power on. The input pin could be read to see when the flap switch changes again, and then can issue a LOW to the standby circuit, effectively shutting the whole thing down. This would use very very very little power except when the whole circuit/SX was in use, plus you could run the SX at a faster clock if that is better for your PWM.

    Loopy is not entirely correct about wakeup on interrupt using Port B pins -- this is why your ISR should accomodate checking for changes of state on port B interrupt pins, so that the pending register can be cleared. Generally you set up your ISR so that it checks for a change in state of the interrupt pin mask, and ONLY runs the code (say, setting a flag for the mainline program) if there's been a change (otherwise it may be that the interrupt is running for another reason). When the pin changes state, an interrupt is generated, the ISR is run, then program control goes back to the mainline. A flag that was set in the ISR based on the interrupt pins can then be used for the mainline to more useful stuff "knowing" that it has just resumed running with a port b change (even if sleeping).
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-07-27 17:49
    I have the sleep / wake up working correctly since I only put the chip to "sleep" when the water valve is off. My bench testing is 1 cycle though the program (Water On, then Water Off) to ensure the chip goes to "sleep". Then I let it sit for the rest of the night in sleep mode.

    Is there an alternative to BC548 transistors? This is in the schematic above in the PDF which I have seen on a few other sites. I don't have any of these transistors on hand, but I do have plenty MPSA06 NPN transistors laying around since I use them quite often. I am by far no electronic genius, but I know enough to be dangerous :p Also, the zener diode is another problem since I can't fine tune the voltage I am needing to stop at. Using a 12V battery on the SX that can power it for a few days without a charge is what I need. I could then use the SX as a controller to kick the charger on and off by detecting the voltage where the zener diode is placed. I am sure having a program running this testing circuit would make the current drain more, but with a big enough solar panel / array, I could keep the charge up enough to have a reliable circuit. Since I am trying to charge via solar, I need to count in for cloudy / rainy days.

    Here is a data sheet on both transistors above :
    https://www.jameco.com/webapp/wcs/stores/servlet/ProductDisplay?langId=-1&storeId=10001&productId=254781&catalogId=10001&krypto=9x3mj8umRTpXWFRGqyE397k2aQsGnhy94BUAopEgBogx80dX5zdprQ%3D%3D&ddkey=https:StoreCatalogDrillDownView

    https://www.jameco.com/webapp/wcs/stores/servlet/Product_10001_10001_26462_-1
  • RDL2004RDL2004 Posts: 2,554
    edited 2012-07-27 18:12
    The BC548 is just a basic npn transistor. It looks to me like the the MPSA06 is a little more capable overall.

    http://en.wikipedia.org/wiki/BC548
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-07-27 18:48
    So would replacing the zener diode with the SX voltage checking circuit (ANALOGIN) be a better option for what I am trying to do? What is the minimum frequency I can use analogin accurately?
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-07-28 01:44
    We seem to be getting way off into the weeds with this project. Here is a discussion of how to adapt to a better solution using 3 6volt 1.5watt solar cells. I suspect current regulation has never been your problem.

    Please refer to the previously provided attachment schematic.

    Solar charge circuit with cutoff

    Since you choose to use 8 AA NiMH batteries, these may not adequately charge via two 6 volt 1.5 watt solar cells.

    Why so? NiMH do nominally output 1.2 volts in use, but they require a higher voltage for charging. Wikipedia recomends 1.4 to 1.6 volts. Also, solar cells are often rated at the voltage they output with no load. And to make the matter worse, a 6 volt solar cell at no load may actually provide only 5.1 volts under load.

    So if you want an 8 cell bank to FULLY charge, the batteries require 11.2 to 12.8 volts. But a pair of these solar cells in series will only be able to provide about 10.2 volts. Yes this more than 9.8 Volts, but much less than the optimal range of 11.2 to 12.8 volts.

    There has also been another distraction. You have built a 270 ma current limiter to protect the 8 AA from overcharging. This device implements a voltage drop of 1.2 volts. So the 10.2 volts is dropped to actually 9 volts when used. The device is of no use without adding another 6 volt solar cell in series, and even then it remains quite useless. Why so? Not only is the voltage output too low, but these 6 volt 1.5 watt solar panels output a maximum of 250ma. Having a 270 ma regulator in place means that it is never going to bother with regulating anything.

    Also, the current regulator will allow current to flow backwards and discharge the battery into the solar cell when there is darkness. There is a need for at least one blocking diode and these insert yet another voltage drop of 0.6 to 0.7 volts.


    The only way out of this is to completely revise your approach.


    First of all, you don't need the current regulator that you have, but you do need a blocking diode. (Don't worry, we can still use the LM317.)

    With two 6 volt 1.5 watt (250ma) solar cells directly connected you get 10.2 volts for charging. With the same two 6 volt 1.5watt (250ma) solar cells and one blocking diode, you get 9.5 volts at 250ma for charging. That is still not good enough.

    I just don't see you you can get the 8 AA NiMH to take a full charge without adding one more 6 volt 1.5 watt (250ma) solar cell in series. This may seem too high, but please read further.

    With three 6 volt 1.5 watt solar cells in series, the actual voltage under load is about 15.3 volts and the supply is still providing 250ma when in full sun. This configuration is in the ball park for fully charging the NiMH cells you have. You still need at least one blocking diode at 0.6 - 0.7 (unless you use Shottky diodes that drop at 0.3 volts).

    Lets assume you use regular diodes for blocking. The 15.3 volt less the 0.7 blocking diode at the panel results in 14.6 volts of actual output. This is useful at it is above the 11.2 to 12.8 volt charging range. For simplicity, lets target the center of the charging range or 12 volts as our full charge voltage cutoff.

    14.6 volts available for regulation, less 12 volts gives use 2.6 volts of difference for the LM317 to operate as an adjustable voltage regulator.

    How do we install the LM317 voltage regulation? The LM317 usually requires 1.25 volts difference from input to output to function, but the PDF does say 1.30 volts maximum. And we need another blocking diode to protect the regulator from reverse flow through it. So we require at least 2.0 volts minimum difference for proper regulator operation.

    14.6 volts available, minus 2 volts gives use 12.6volts as the highest possible output. That is good as we only need 12 volts.

    We can adapt the previous design to provide an adjustment between 12.6 and 12.0 volts by changing the 1K pot to 5K. Lets split the differences and set the regulated output to 12.3 volts (AT 2.3 volts difference, this gives the LM317 about 1.6 volts from Vin-Vout and then that 0.7 output blocking diode brings the total to 2.3 volts).

    12.3 volts is a good number as the 8 AA NiMH require somewhere between 11.2 and 12.8 volts to charge. Since with only have 250 ma available from the solar panel, that is our current limiter device. We are within safe zones for C/10 rate of charge and peak voltage. So the circuit may not require an additional current limiting resistor unless you to want to further reduce current.

    What remains is to add a peak voltage cut off feature. Even though the regulator tries to provide 12.3 volts at 250ma, the discharged battery has low internal resistance that pulls this figure down until it nears a full charge. The plus terminal of the battery is going to actually keep the voltage well below 12.3 volts and 12.0 volts until it nears a full charge.

    When we approach full charge, setting up a zener diode and a PNP switching transistor to drop the LM317 to its lowest out put of 1.2 volts effectively locks out the solar panel as the 1.2 volts is fighting againts a 12 volt battery. I see the schematic uses a 6.8 volt zener for a 6.8 maximum cutoff. If we follow this and use a 12.0 zener, we should get the battery to cut off at 12.0 volts as a full charge.

    So now the 3 solar cells provide a fully charged 8 AA NiMH with protection from overcharge

    Is that everything?

    Well, I am not exactly sure. You see, the transistor (lets say a 2n2222) has its own internal BE voltage drop of 0.7 volts. So I suspect that with 12.0 zener, you get a cut off at 12.0 plus 0.7 or 12.7volts. Since that is higher than our set 12.3 volts regulated output, it would never arrive at cutoff.

    You may actually need a 11.3volt zener with the 0.7 drop in the 2n2222 to get the whole unit working right. The regulated voltage from the solar cell must be higher than the overcharge cutoff for proper operation.

    Once you have built the device, you need to test it with discharged batteries to observer that they are indeed charging and that they charge is discontinued at the right voltage. Zener diodes come with a variation of .2 volts or more, so you have to buy 10 or so and test for the closest to a good fit.

    So, you can adapt the posted schematic with the following components.

    D1 and D2, no change 1n4007
    VR change to 5K ohm
    R1 change to 240 ohms
    R2 no change at 1K ohms
    R3 remove -- O ohms
    T1 change to 2n2222 or keep existing.
    ZD change to something between 11.3 volts and 12. volts according to observation 1watt.

    Capacitors? Generally the LM317 recommends one capacitor in the input and output to smooth regulation. These may not be required with the solar cell providing power. Try the device first without them, and only add if problems arise. I suspect that the
    capacitor on the output side may be more useful as it smooths regulation by adding delay to the regulation cycle. The input side capacitor is intended to reject noise in the supply which may be non-existent. Be sure to NOT substantially change suggested size as discharge of larger capacitors may cause backflows that can damage the LM317.

    Goals --- Solar charging at C/10 charge rate and the regulator attempting to provide 12.3 volts
    Cutoff of solar charge when the battery presents 12 volts of charge (each cell at 1.5 volts)


    NOTE --- It is quite common for fully charged batteries to exceed their ''nominal" rated output volt. Forgetting this can damage ICs. IN this case 1.5 volts instead of 1.2 volts. If one wants to tap the 8 cell pack for SAFE operation of a 5 volt micro-controller, DO NOT tap at 4 cells (6 volts peak), but at 3 cells (4.5 volts peak).

    It still might be easier to provide a low-quiescent current regulator to specifically provide 5 volts to the SX and forget about tapping the battery pack.

    Admittedly, there are other ways of doing a solar charge, but everything here so far has ignored the fact that the actual two 6 volt 1.5 watt solar panels are not enough.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-07-28 02:32
    Wakeup ON Interrupt is a misnomer. The original SX documents show Wakeup/Interrupt, but writers have overlooked the slash.
    Zoot wrote: »
    Loopy is not entirely correct about wakeup on interrupt using Port B pins -- this is why your ISR should accomodate checking for changes of state on port B interrupt pins, so that the pending register can be cleared. Generally you set up your ISR so that it checks for a change in state of the interrupt pin mask, and ONLY runs the code (say, setting a flag for the mainline program) if there's been a change (otherwise it may be that the interrupt is running for another reason). When the pin changes state, an interrupt is generated, the ISR is run, then program control goes back to the mainline. A flag that was set in the ISR based on the interrupt pins can then be used for the mainline to more useful stuff "knowing" that it has just resumed running with a port b change (even if sleeping).

    Could you please clarify. I mentioned that you have EITHER a Wake up to Reset or to Interupt via the Port B pins and suggest that the Reset approach was cleaner. Is an ISR really necessary? And when you do a RETI, where does it go? I fear you will just return to your last SLEEP instruction.

    Frankly, it seems that all the problems with power consumption are independent of what the SX is doing at this point. But I may be confused as we keep getting something new introduced into the project -- like this AC compressor fan and some sort of flap that may be acting as a switch.

    At the core of all this is the simple fact that a comprehensive solar design requires knowing how much power is required, what is a necessary minimum operating voltage, and having adequate solar panels balanced to appropriate batteries.

    As it is, the solar panels just don't seem to be providing a full charge for the 8 NiMH and I don't know that they will do any better with a higher voltage battery and a higher AH rating. Have nightly test been with verified fully charged NiMH batteries or have these been charged with the existing solar scheme (which is flawed)?

    A fully charged NiMH 8 cell should initially show between 11.2 to 12.8 volts, not 9.8 volts. I am trying to find a way to resolve this economically, but parts were bought without completely understanding the engineering. Ignoring the engineering will not make the problem go away.

    Still, I'd love to learn to properly use SLEEP and Wakeup, preferable without evoking an ISR.

    And regardless of whether PORT B is used to reset or interrupt, I do admit that it has to be managed each time a wakeup is evoked.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-07-28 05:22
    There are many alternatives to the BC548. The one you mention will likely work as will the 2n2222 or the 2n3904. This is in a switching context and at a rather slow speed, generalized NPN transistors are pretty much the over-qualified for the role.

    Also, I have been thinking about the cutoff zener. IF 11.3 is difficult to get, going lower will charge the battery and be less likely to cause it to wear out rather than going higher. The range is about 10.5 to 11.3 if I am right about the transistor diode drop. If I am wrong, the ranage is 11.2 to 12.0 volts. The main thing is that it is better to adjust to the low side of the full charge voltage range.

    I continue to re-read about SLEEP and Port B wakeup. I am trying to sort out if an ISR is absolutely necessary and may even run a test bench tonight.
  • LawsonLawson Posts: 870
    edited 2012-07-28 06:41
    There are many alternatives to the BC548. The one you mention will likely work as will the 2n2222 or the 2n3904. This is in a switching context and at a rather slow speed, generalized NPN transistors are pretty much the over-qualified for the role.

    Also, I have been thinking about the cutoff zener. IF 11.3 is difficult to get, going lower will charge the battery and be less likely to cause it to wear out rather than going higher. The range is about 10.5 to 11.3 if I am right about the transistor diode drop. If I am wrong, the ranage is 11.2 to 12.0 volts. The main thing is that it is better to adjust to the low side of the full charge voltage range.

    Loopy, using a regulator AND a high voltage cut off is redundant. Just putting a 12V linear regulator between the solar panels' blocking diode and the batteries will limit the maximum battery voltage. (with the solar cells limiting the max current) You do need to be careful with the choice of regulator though. A "standard" regulator like the LM317 should be a good choice as the ground pin current should be relatively constant, low drop out regulators can be bad for solar charging because they can draw a lot more current when dropped out.

    If you want an even simpler system, a 5 watt zener diode could be placed in parallel with the solar cells to "bleed off" any excess current. this or this one should work well. This has the added bonus of only using power when the battery is fully charged, any other time the zener should only be drawing <1mA. (note: the zener WILL get hot once the battery is charged)

    Lawson

    Personally, I'd
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-07-28 07:12
    @Lawson
    I was beginning to wonder about that. What you say makes a lot of sense to me. And the regulator output could be adjusted to whatever performs best for battery life - say 11.2 volts instead of 12 volts.

    I still wonder if there is a good reason to drop the regulator output to 1.2 volts - such as making the regulator run with less heat. I started with what I copied from the internet. There were two circuits with a cutoff - one was the solar panel scheme and the other was for charging from AC mains at a much higher rate of 5 amps. Since both employed the same wiring, I thought it best to stay with their approach.

    If 12 volts is the ideal cut off, I suppose one could just use the two blocking diodes and a 7812 regulator with the 8x NiMH - so simple.

    I suppose the zener diode and cut off transistor may be required if an R3 resistor is introduced for current limiting as the zener connects at the downstream end of the resistor.

    I have been rereading the SX20 document and a Wakeup reset can occur that vectors to the highest register address, but it also seems the condition of the WKPEN_B register will determine whether the Wakeup is a simple reset or enters the ISR location at $000.

    Wherever the program restarts, all three of the wakeup registers for Port B need to be reinstated for the next run or wakeup will be not functioning. Having a sucessful one cycle test is dubious. You have to get the wakeup to got through at least two full cycles to confirm that you have programmed it right. That means you have to trigger the Port B pin at least twice and get good results. Of course, doing it 5 or 6 times will be even more assuring.

    Unlike the SX28, the PIC devices may actually allow a Wakeup trigger to continue the program after the SLEEP instruction. So don't rely on PIC documents as I first suggested. The situation is NOT the same. SXes will NOT continue the program after a SLEEP wake up. The text explicitly mentions vectoring to $FFF on reset and to $000 on interrupt.
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-07-28 09:10
    I will purchase 1 more solar panel today or tomorrow depending on what time I get out of work today. I now understand that I don't have enough solar power to charge the batteries correctly. I will also look to see if radioshack has the zener diodes since those seem to be the best for my application.

    As for the Sleep command.... I have the Sleep command right after the water valve is shut off making the SX only go to full power when the AC condenser is running. If the wake up restarts the chip or the program, it does not hurt anything since all the SX is doing is turning the valve on or off for 1 second. When it wakes, the RB.0 pin is checked then it responds accordingly.

    Here is the code as of right now :
    DEVICE          SX28, OSC32KHZ, BOR22, 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
    temp2		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:
        water_running = 0
        TRIS_C_pins = %00000011
        TRIS_B_pins = %00000001
        TRIS_A_pins	= %0000
        WKPND_B = %00000000    'Clear pending register
        WKED_B =     %00000000    'Interrupt on rising edge
        WKEN_B =  %11111110    'Enable interrupts on bit 0 only
        if water_running <> 0 then
    	Set_State Water_Off
    	water_running = 0
        endif
    
    Main:
        DO
    	if Switch <> 0 then
    	    if water_running <> 1 then
    		Set_State Water_On
    	    endif
    	else
    	    if water_running <> 0 then
    		for temp2 = 1 to 100
    		    if Switch <> 0 then
    			GOTO Main
    		    endif
    		    pause 10
    		next
    		if Switch <> 1 then
    		    Set_State Water_Off
    		    SLEEP
    		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
        endif
        RETURN
    

    I added a debounce to the switch to help prevent a dirty contact from causing the chip to cycle between Sleep and Wake up.

    Now one thing that I don't know I can get a hold of quickly is an LDO regulator since radioshack no longer carries a good selection of electronics. I may have to order one to get the power consumption even lower. In my case, I need to charge the batteries as fast as possible and drain them as slow as possible....especially if there are a few cloudy / rainy days.

    Tapping into the batteries for a straight power supply with no regulator just worries me especially if something goes wrong with the charging circuit. For bench testing the charging circuit, I have used my 12V battery in place of the solar cells. Output of the battery with no load is 12.3V which should be more than enough to charge the NIMH's. In my area, there is a max of 8 hours useable sunlight so I need to have the batteries fully charged within 8 hours.

    In one of the posts above, it was said that the zener will get hot when the batteries are fully charged. Is this because of the output of the solar panels being dumped to ground? Is this safe to have this happen every sunny day when the batteries are full?
  • kwinnkwinn Posts: 8,697
    edited 2012-07-28 10:54
    Using a single battery to power everything allows the circuitry to be greatly simplified.

    Charging current regulator:

    Not required. A 6V 1.5W will put out a theoretical maximum current of 300mA in full sunshine. In actual use it will be less than that, somewhere in the 200 – 240mA area.

    Charging voltage regulator:

    Required. By setting the output voltage of this regulator to the same voltage as the fully charged battery reaches with no load on it the charging current will drop to 0 when the battery is charged.

    Blocking diode:

    Required. Almost all voltage regulators would allow current to flow from the battery back through the solar cell.

    Low voltage regulator:

    Required. Provides the logic level voltage for the microcontroller and associated circuitry. You could use the 317 here if you go with a linear regulator, however a switching regulator would draw much less current (about half) from the batteries.

    Summary starting from the solar cell + output:

    Blocking diode, battery charging regulator (LDO preferred), logic voltage regulator (switcher preferred).
  • eagletalontimeagletalontim Posts: 1,399
    edited 2012-07-28 11:16
    So dropping the 7805 completely out of the circuit is ok even though the SX chip will be pulling power from only 3 batteries which could cause an uneven charge across all 8 batteries?

    I went to RadioShack and bought another 6V 1.5W solar panel along with a 12V zener diode and a few other resistors to complete the attached circuit in a previous post. I will attempt to build it and set the voltage to 11.5V if I can figure it out :p

    EDIT : RadioShack also had a 7812 regulator which I suppose I could use in place of the LM317. I would basically just have to put the zener in place to ground the output of the solar panels once the batteries are full. Question is, the voltage on the zener once 12V is hit would be 12V - the voltage drop correct? With a 1K resistor after the zener, wouldn't that make the voltage at the base of the transistor around 10 volts which is way too high for the base?
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-07-28 11:39
    Happy to hear you added another 6 volt solar panel. The discussion has been rather fast paced and creative, so I am a bit concerned about your construction plans. Mostly, if you use the zener diode, whose plan will you be following? A 12 volt zener may be too high for what I gave you. And I am wondering if you actually got a 1/2 watt, a 1 watt, or a 5 watt zener - this matters.

    Are you getting ahead of yourself? Have you actually determined that the 8 cell NiMH was not fully charged in your runs where there seemed to be too little power in the morning? There may have been a discharge due to the lack of using a blocking diode and keeping the solar cell connected.

    As you can see, I have lots of concerns about keeping on track to find a good solution. Kwinn likes LDO regulators, but they have seriously odd behavior in the Low Dropout region that I and others have recommended you stay away from them for regulation of the solar panel output. The additional power draw could waste quite a bit of battery power unnecessarily or make solar charging unpredictible.

    I know from my own experience in Taiwan that the Low-Quiescent Current regulators for the micro-controller may be hard to get, but that is the ideal solution for the 5 volt to the SX. I figure that if your H-Bridge will tolerate operation at a lower HIGH, say 3.0 volts - then unregulated operation of the SX will work out. If you do have problems with the H-Bridge turning on, you can temporarily use a 78L05 to verify that the voltage is too low. But long-term use of the 78L05 will suck a steady 6ma out of the battery even when the SX is in SLEEP. The low-quiescent current regulator should only such 50 micro-amps!

    The BasicStamp2 uses a low-quiescent current regulator and you can read about it by locating a PDF. It is an LM2936-5V. (it happens to be an LDO as well, but in this situation you may never reach the LDO region if it is powered at 9.6 volts.)

    If you have the LM317 set to output 11.3 volts after the last blocking diode, the 12 zener and the related shut down circuit is rather useless. The shut down would be about the output limit of the LM317 and never be triggered. In any event, you would still be charging the batteries and having the solar panel shut down when a full 11.3 volt charge is in the batteries.

    Lawson's idea of putting a 12 volt, 5 watt zener parallel with the solar panel is confusing to me. After all, we now have solar panels that we want to get about 15.3 volts out of. I guess he meant to use just the 12 volt, 5 watt zener and NO LM317. With ONE and only one blocking diode, the batteries would get 11.3 volts. In a worst case analysis - 18 volts at 300 ma would produce 5.4 watts and destroy the zener as it is rated only for 5.0 watts. Of course we can hope that 15.3v at 250 ma or 18v at 250ma or 15.3v at 300ma is realistic and just squeek by - but I am not very comfortable with that.

    BTW, 5watts is hot. Just think of putting your hand on a 5 watt light bulb. Of course, 100 watt light bulb is much worse. But the point is that the power is being dumped as real heat.
Sign In or Register to comment.