Go Down

Topic: Arduino nano v3 Solar pwm controller (Read 1 time) previous topic - next topic


Then add a 10k in series with it's collector as well.

20uA seems very small even with the gain of T2 if you want to switch a big MOSFET reasonably quickly - 3-5nF gate capacitance or more ?

suppose the gain of T2 is 100 - optimistic. Then the turn on current is only 2mA.

this means that with 5nF  I =  C dV/dT -> 0.4 V/uS, and to traverse 10 volts will take 25uS.

Pretty slow.

At 1kHz PWM this means  50uS spent in transitions per 1ms cycle or  5% of the time - a significant loss.



Jul 10, 2018, 11:56 am Last Edit: Jul 10, 2018, 01:09 pm by Wawa
D9 is ~500Hz PWM, so one transistion per 1ms.
And from non-conducting to almost fully conducting is not the full 10volt
But there is indeed some loss there.
If that's a problem or not depends on the output power of the panel.

Gate current(s) could be increased by lowering the value of R5 and R3 to say 100k.
And maybe removing (short) R2. (Parts numbers of OP's diagram).
Needed or not depends on the gate charge of the actual mosfet used.


Jul 10, 2018, 08:05 pm Last Edit: Jul 10, 2018, 08:07 pm by FredScuttle
I believe the analogWrite function takes care of pinModeing the target pin, but, does the pin return to input after the analogWrite is finished?
This works on a Pro Mini:
Code: [Select]
void setup() {

void loop() {
  for(byte i = 0; i <= 240;i+= 10){


Changing a PINMODE is handled by the Analogwrite() function... but once set... it leaves it that way.  It will not change back to default  INPUT mode when the function call is completed.


Jul 11, 2018, 04:22 pm Last Edit: Jul 11, 2018, 04:24 pm by TomGeorge
Yes D9 remains @ 0 volts or very close to that. I even removed the transistor completely to measure this.
So I wonder could it be a software problem, knowing nothing about programming it would be impossible for me to spot the error if any.
regards and sorry about late reply

I did remove the 220k from T1 emitter and connected it directly to ground.
When you did this, was a base resistor fitted to the transistor?
If you did not have a base resistor fitted, then you could have damaged the pin9 output because the 0.6V Vbe of T1 would have clamped the output pin when it was trying to output 5V.

Modify your code to control another unused PWM pin on the Nano and try it with T1 removed.
Have you made a PCB for this project?
Can you post an image of the CAD for the PCB?

Thanks.. Tom.. :)
Everything runs on smoke, let the smoke out, it stops running....


Hi Tom and thanks for your interest in helping me.
No there is no resistor between D9 and T1, but I don't think it has been damaged.
Yes I did build this circuit as a etched pcb that's why it's so difficult to make changes.
I'll try running the blink led sketch on pin 9 just to make sure it still ok.
I'll be right back with this info.


Jul 11, 2018, 11:49 pm Last Edit: Jul 11, 2018, 11:50 pm by TomGeorge
Can you post an image of the PCB pattern please?
Eagle should have the provision for you to save/export a jpg of the pattern so you can post it into this thread.

Thanks.. Tom.. :)
Everything runs on smoke, let the smoke out, it stops running....


Ok I can confirm the arduino board is fine, I run the blink sketch on pin D9 and wit works fine 0-5 volts reading on my meter. I'll upload the image you're asking in a few minutes i'm not on my main pc now.

So the question remains why there is no activity on D9 when running the actual pwm sketch.


I think I already explained that in post#9.
The question was not answered.

The whole circuit is a closed loop.
The circuit measures battery voltage, and adjusts the PWM value to that.
If battery is higher than "setpoint", then charging stops.


Jul 12, 2018, 12:43 am Last Edit: Jul 12, 2018, 12:46 am by bigote
Thanks Leo but it is my understanding that charging should stop @ 13.6 not @ 12.8.

Here is a fixed typos on my schematic. and pcb that Tom ask for.

I have put back the 220k to the emeter of T1 to gnd.


Jul 12, 2018, 02:07 am Last Edit: Jul 12, 2018, 02:12 am by allanhurst
There is inherent inaccuracy of the measurement of the battery voltage.

1/ The resistors used in the divider chain. What tolerance are they?

2/ The  voltage reference itself.

Suggest you measure with an accurate voltmeter the actual voltage, and use eg serialWrite to see what adc reading you get.

Adjust constants in sw to get the correct value.


ps With a few extra components and different sw you could make this into a MPPT controller for better efficiency - but get the basic system working first.


Thanks for the images.

You need C3 and C4 mounted as close as possible to the 7812 pins, also a 0.1uF capacitor in parallel with them, again a close as possible to the 7812 pins.

Increase your track widths, the less copper you have to remove the better, you bought that copper with the blank PCB, why etch most of it away.

I would be adding some tell-tail LEDs to vital control wires so you don't have to DMM probe all the time.
When its up and running, you just don't solder the LEDs into the PCB.

Tom... :)
Everything runs on smoke, let the smoke out, it stops running....


Thanks Leo but it is my understanding that charging should stop @ 13.6 not @ 12.8.
Charging stops when the returned A/D value of the analogue pin is higher than setpoint (542).
And that depends on more than one thing.
Battery voltage, how accurate is the voltage divider, and how accurate is VCC of the Nano.

Post#12: Add some print statements, so you can see what is written to D9.


Jul 12, 2018, 10:03 pm Last Edit: Jul 12, 2018, 10:05 pm by bigote
Hey guys thanks for sticking with me.

Both R6-R7 sensing resistors are 1% and the actual voltage @ A1 pin is 2.683
Battery voltage now is @ 12.7 obviously not fully charged.
I don't think there are any p/s issues as the arduino's integrated regulator is doing a good job providing 5.0 volts.
If anyone has a better design, I'm ready to scrap this one and move on.
I choose this one only because it seemed like a proven tried and true design which apparently many people had already build.
So I'm all ears, I'm not interested in those complicated designs with lcd display etc.
All I want is something simple that can fit on a small pcb like the one shown above.

Thanks again


Go Up