re-program Nanjg to simple voltage monitor switch, possible?

Hey Everyone,

I have designed an outdoor wifi router with a nature camera attached. The entire system is solar powered and works with a standard 26650 or a couple 18650's in parallel. I am using the sparkfun sunny buddy as a charge controller, and a simple usb step up converter.

I would like to re-program a Nanjg driver (of any flavor) to help me control the load. I would like the load to be cut off when the battery voltage gets down to about 3v, and the stay off until the battery voltage increases to about 3.8v.

I think this should work if my understanding of the board is correct, and I can figure out the software... I only require about 500ma, which should be within spec of most Nanjg boards...

Anyone have any thoughts or advice? I have always wanted to try programming one of these boards, and so this could be an interesting beginner project if I am on the right track here...


Thanks!

Should be easily do-able. Think the MCU uses ~5 mA or so with no extra power saving done. We use the Watch Dog timer at about 16 msecs. Dunno bout how you go about cutting the load though - another I/O pin for output?

Is the load supposed to be current controlled? (i.e. led)

If yes, then disable PWM register bit and set ATtiny13A PWM output (AMC7135 Vdd) to digital output 0/gnd.

If no, then use digital output 1(disable) or 0(enable) to a logic level pFET (i.e. high side switch) instead of the AMC7135(s) for the load output.

My first thoughts… the driver programed for single mode (high, or 0% pwm), with low voltage protection would get me close. I could modify the voltage protection as necessary to get low voltage cutoff at 3.0v and ‘cuton’ again at 3.8v.

I was hoping to just run the driver inline between the battery and the load, just like the load were an LED.

The load needs to be NOT current controlled. I need to draw at most 500ma, so if I use the 1.4a or even the 1.05 amp driver, I will have plenty of headroom before the current control from the 7135 chips kick in.

I am more familiar with software and coding, so the hardware details are going to be my challenge…

I like this idea, I have been thinking about something similar with a driver . I do not see why it would not work. Without a switch, the driver would always be in the on state, if the supplied voltage were enough to over come the voltage divider feeding the input ADC on the MCU. You would really only need a 3 7135 driver to supply a stable 500ma load.

This could also be done with a FET driver, with the FET running in direct drive. This might actually run cooler, not sure what kind of case you are putting it in. Again, very simple to build and should be very simple to program for 1 mode only.

Can you flash chips? You could use a very basic firmware like Star and strip it to one mode and give it a shot! If you can’t flash chips, let me know… I have done a few here for other folks trying other experiments.

I am glad to hear this should work! I have not flashed chips before, but I have the programmer, clip, and a few drivers on the way. Hope to have them by next week…

Using the AMC7135’s is unnecessary when not trying to provide a constant current sink to led’s. The AMC7135’s are purpose built for that. I am not altogether sure just what will happen exactly to the load when supplied with the constant current. The load just needs to be hooked up to the battery with a software controlled switch in between.

One solution would just be a piece of strip board or small development board, ATtinyXX, resistor divider, logic level pFET, and wire it up. You wouldn’t have to buy a SOIC clip for the Nanjing 105 and deal with iffy programming connections. I’ll post a link if I see a cheap development board that would work. Wouldn’t be surprised that a ATtiny board is shared on the OSHPark pcb site.

I am obviously a slow typer of comments, so didn’t see netprince response till after the fact.

Not what I had hoped for, would have been nice if there was a little thru hole prototype area, but cheap! Still need a bit of board to land on for pfet etc. http://www.banggood.com/ATTINY85-Mini-Usb-MCU-Development-Board-For-Arduino-p-971122.html

nickelflipper that board is interesting, thanks, will keep that in mind.

So I’m looking at the code and trying to plan things out… I’m curious if it will be possible to put an LED between one of the stars and the ground ring, and light up that LED when the voltage protection has triggered? I’m not sure if the stars can be used in that way…

Hoping to try some stuff this weekend…

Yes….But putting the led between the star and ground ring will most certainly blow the led, this is because leds are current controlled devices. Say you wanted 10ma (20ma max) to flow thru a red led; the formula is Vdd- Vf = IR. For a lithium ion battery at nominal voltage of 3.7V would be R = (3.7-2.2)/0.010 = 150 ohms. So, use a 150 ohm resistor along with a red indicator led.

At some point you just want to put the ATTiny to sleep, with no load whatsoever, as most Li-ion batteries have a 2.5V minimum discharge voltage. Over discharge of Li-ion battery is not a good thing.

I am wondering why nobody has linked to this: BLF X6 X5/Astrolux S2 S3 SS SC Taschenlampe Treiber Sale - Banggood Deutschland-arrival notice-arrival notice

You just need to watch the ADC with a simple if lower than desired cutoff voltage then switch off fet….

Or you can just use a protected 18650s, that is what I usually do in such applications…I also always wonder why there are so many things sold without low voltage protection. Also you should pay attention about charging in freezing conditions, if you plan to use it in winter because that is also a point a lot of people don’t pay attention to…

+1

Doh, for fet driver … and double Doh for the protected battery suggestion. At least someone has their thinking cap on straight.

Thanks for the links and advice everyone…

I am trying a protected cell right now, it doesn’t work out for my needs. We haven’t had a lot of sun in my area lately so its been hard to test…

I think what is happening is that the sunny buddy wont apply full charge current when the cell’s voltage is low enough to trip the protection circuit. It wants to apply a low current until the voltage recovers to around 3v, then it starts charging will full current. This doesn’t work because the load tries to use all the charge current, and the cell never charges.

End result… battery runs the load at night until the protection circuit trips… sun comes up… charger starts charging with recovery current… and the system is stuck… which is why I need this project to allow the battery to recover some before the load is switched on…

nickelflipper: thanks, so if I understand you correctly an LED between a star and the ground ring will receive 3.7v, but there is no current limit… like being directly connected to the battery? I figured it would be more like a signal output like the pwm pin output?

I may just avoid a status led altogether, just thought it would handy for debugging…

netprince: You are right, the pin current is limited to 40ma for the ATTiny.

I just tested a PIC microcontroller output pin with (no resistor) green led (with Vf = 3.2? and Vdd = 3.9V), and it survived a measured 24ma. PIC pins are clamped at 25ma. The PIC data sheet mentions the possibility of damaging the device if maximum ratings are applied.

How big is the solar panel? Wifi chips are power hogs, so some time limitations would have to be imposed to save the energy budget.

nickelflipper: thanks… and you are reading my mind. I was thinking about time limitations. The wifi radio is in client mode, its only there to upload the pictures from the nature camera. I’ve been monitoring the current requirements, and I can easily see two big jumps in current required… one as the wifi radio comes online, and another as the camera comes online. Tops out at about 400ma at 5v. (little bit higher at the battery before the boost circuit)

The panel is a 10w outdoor panel, but its limited to about 5w by the sunny buddy. (though the larger panel will still have benefits in overcast conditions)

This has been a learning exercise for me, thats for sure. Its a bonus that I will be able to flash drivers in the future…

Ok, after several hours setting up my programming clips, and then several more hours figuring out the code, I have something that works on my bench. Its too late here to do anything more than test… but I wanted to post the code here and see if anyone sees any big problems…

https://oneitguy.com/voltC.c

I will hopefully install it tomorrow and see how it works. Thanks again for all the pointers everyone…

I installed the driver with custom software on Sunday, along with the battery fully recharged. The router/camera ran until about 3am, at which point the driver cut off the load. This morning it has been quite cloudy, but the battery reached the turn-on voltage at 1pm and turned on the load. This is the first time the system came back to life on its own. I am quite pleased… Thanks everyone for the pointers.

Glad that it worked:)

Have you measured the standby current from the driver and looked into the sleep commands already…? In my memory a few lines code made a huge differents in standby current over the whole day without any negative effect.