Vous êtes sur la page 1sur 43

Menu

ARDUINO MPPT SOLAR CHARGE CONTROLLER
ack to project overview
An Arduino ased Solar MPPT charge controller.

Deasish Dutta

Description Files 0 Components 49 Logs 14 Instructions 1 Discussion 101

« ack to project details


SORT BY:

Newest

Battery Temperature and Charging Voltage Compensation
09/16/2015 at 09:45 • 0 comments

All chemical reactions are affected  temperature. atter charging is also an electrochemical reaction, so it too is affected 
temperature. As the atter gets warmer, the gassing increases. As the atter gets colder,it ecomes more resistant to charging. So
atter charging voltages should e corrected ased on atter temperature. This adjustment is referred to as temperature
compensation, a charging feature that helps ensure that a atter is neither undercharged nor overcharged regardless of atter
temperature.
Using normal target voltages to charge a atter that is colder than approximatel 25ºC (77ºF) will result in an undercharged atter,
which will deliver lower performance, reduced life and a higher life ccle cost. Appling normal target voltages to a atter that is hotter
than 25ºC ma result in an overcharged atter. This condition could lead to the dring out of VRLA atter cells. With flooded cells,
the result will e excessive outgassing, increased atter maintenance in the form of more frequent watering and reduced atter life
due to thermal stress. In fact, some atter manufacturers and charger manufacturers recommend not charging a atter that is 50ºC
(122ºF) or hotter.

Temperature Sensor :

To monitor the atter temperature a DS1820 1-Wire digital temperature sensor from Maxim IC will e used. It can measures
temperatures from -55°C to +125°C. Fahrenheit equivalent is -67°F to +257°F with ±0.5°C accurac.

We choose a waterproofed version of the DS1820 Temperature sensor. It is quite hand to measure something far awa, or in wet
conditions.

You can see it here

You can see the Data Sheet

Temperature Compensation Formula:

minus 0.018 volts per degree Celsius

xample :

1. Let the atter temperature is 0 degC and float voltage is 13.8V ( STC : at 25degC )

Compensation Required = ( 0 - 25) * ( - 0.018 ) = + 0.45V

Compensated Float Voltage = 13.8 + 0.45 = 14.25 V

2. Let the atter temperature is 35 degC and float voltage is 13.8V ( STC : at 25degC )

Compensation Required = ( 35 - 25) * ( - 0.018 ) = - 0.18V

Compensated Float Voltage = 13.8 - 0.18= 13.62 V


So cold atteries ( example-1) require a higher charge voltage in order to push current into the atter plates and electrolte, and
warmer atteries( example-2 ) require a lower charge voltage to eliminate potential damage to valve regulated lead acid (VRLA) cells
and reduce unnecessar gassing if flooded cells are used.

Reference : http://solarprofessional.com

Software requirements for MPPT controller V3.1
08/30/2015 at 15:06 • 1 comment

Software requirements for MPPT controller V3.1

Draft  Keith Hungerford, updated 12th Septemer 2015

Charging states

The charger operates in one of several charging states, depending on the sunlight level.

Charger OFF state

At nil or low sunlight levels, as indicated  solar voltage elow atter voltage + 0.5 Volts, the charger state is OFF.

Transition from the OFF state occurs when

a) if atter voltage is greater than 11.5 volts and solar voltage rises aove atter voltage + 0.5 Volts

) if atter voltage is less than 11.5 volts and solar voltage rises aove 12.5 volts.

When either of these voltage conditions is met the charger goes into one of the following states:

i) Float state if the atter voltage is greater than the Float voltage;

ii) oost state if the atter voltage is less than the Float voltage and the oost time since the last night time is less than [1 hour];
iii) ulk state if the atter voltage is less than the Float voltage and the oost time since the last night time is greater than [1 hour]

In all 3 cases initiall the controller will use the DCM charging algorithm.

oost DCM and ulk DCM states

When in the oost DCM or ulk DCM state, the charger can go to OFF state if the solar voltage falls elow (atter voltage + 0.5 Volts).

The charger can go to oost CCM or ulk CCM state if the Solar Power rises aove 10% of the rated power.

The charger can go to the Float state if atter voltage rises aove Float.

The charger can go from oost DCM to ulk DCM if the oost time since the last night is greater than oost duration.

oost CCM and ulk CCM states

When in the oost CCM or ulk CCM state the charger can go to oost DCM or ulk DCM if the Solar Power falls elow 10% of rated
power.

The charger can go from oost CCM to ulk CCM if the oost time since the last night is greater than oost duration

Float state

The float state is functionall the same as ulk state when the atter voltage reaches Float.

When in Float state the charger keeps just sufficient current flowing to the atter to maintain the atter voltage at Float.

Charging algorithms

CCM algorithm

Continuous Current Mode (CCM) applies when the availale solar power is more than 10% of the rated power (strictl, when the current
in the inductor alwas flows towards the atter, ut this is difficult to measure directl in the software so we use the power level as a
prox estimate).
In this mode, the PWM period is set at 12 microseconds. The PWM dut ccle is set either at a value that achieves maximum power, or
to meet the charging voltage required  the atter (see atter management conditions elow). When it is required to reduce the
charging rate so as to limit the atter voltage, the PWM dut is reduced, there increasing the panel voltage aove the maximum
power point and reducing the current accordingl.

The Fast PWM mode of the Arduino is used to generate this PWM. The PWM period of 12 microseconds is 192 clock ccles at 16 MHz.
The PWM period is divided into a Panel Connect phase followed  an arth Connect phase. The length of the Panel Connect phase is
controlled  PWM Dut.

When maximising power, the power level is measured approximatel ever 0.5 milliseconds and is compared to the previous power
level measurement. The PWM dut ccle is changed up or down  1 CPU clock ccle after ever measurement. After the first
measurement, the PWM dut ccle is increased. On susequent measurements, if the power level is increased or is the same as the
previous measurement, the PWM dut ccle is changed in the same direction as in the previous ccle. If the power level is decreased
from the previous ccle, the PWM dut ccle is changed to go in the opposite direction to that in the previous ccle.

When tracking the allowale atter voltage, the atter voltage is measured approximatel ever 0.5 milliseconds and is compared to
the target value. If the new value is within +0.1 volts of the target value, the PWM dut is left unchanged. If the new value is higher than
the target value  more than 0.1 volts, the PWM dut is increased  one step. If the new value is lower than the target value  more
than 0.1 volts, the PWM dut is decreased  one step.

Whether maximising power or tracking atter voltate, the atter charging current must not e allowed to exceed 105% of the rated
current. If the atter charging current voltage reaches 105% of the rated current, the charging rate is reduced to keep within that limit.

DCM algorithm

Discontinuous Current Mode (DCM) applies when the availale solar power is less than 10% of the rated power.

In this mode, the PWM period is set at 100 microseconds which is 1600 clock ccles at 16 MHz. The PWM period is divided into three
phases: a Panel Connect phase, followed  an arth Connect phase, followed  a Null phase. The length of the Panel Connect phase
is controlled  PWM Dut through setting a “1” on oth IN and SD pins of driver IC No. 2 (which drives Q2 and Q3). The length of the
arth Connect phase is controlled  setting a “0” on IN and a “1” on SD pins of driver IC No. 2. The Null phase is the remainder of the
PWM period, during which time the SD pin of driver No. 2 are oth “0”, so that oth transistors are OFF.

In this mode the length of the arth Connect phase is set to e Panel Connect phase multiplied  the ratio of (Panel voltage - atter
voltage) to Panel voltage. Thus if the atter voltage is 13 and the panel voltage is 19.5 volts, the arth Connect phase is (19.5-13)/19.5 =
1/3 of the Panel Connect phase. So if the Panel connect phase lasts 9 microseconds, the arth connect phase will last 3 microseconds.
In this case the Null phase will e (100 – 9 – 3) = 88 microseconds.

When maximising power, the power level is measured approximatel ever 0.5 milliseconds and is compared to the previous power
level measurement. The Panel Connect time is changed up or down  1 CPU clock ccle after ever measurement. The arth Connect
time is changed to follow the Panel Connect time. After the first measurement, the Panel connect time is increased. On susequent
measurements, if the power level is increased or is the same as the previous measurement, the Panel connect time is changed in the
same direction as in the previous ccle. If the power level is decreased from the previous ccle, the Panel connect time is changed to
go in the opposite direction to that in the previous ccle. Once the new Panel connect time is known, the corresponding arth connect
time is calculated.

Since the Panel connect time and arth connect time are defined in integer numers of clock ccles, it will often not e possile to
make the arth connect time the exact multiple of the Panel connect time required for the ratio of (Panel voltage - atter voltage) /
Panel voltage. In this case the arth connect time should e made the next lowest integer of clock ccles, elow the exact value.

When tracking the allowale atter voltage, the atter voltage is measured approximatel ever 0.5 milliseconds and is compared to
the target value. If the new value is within +0.1 volts of the target value, the Panel connect time is left unchanged. If the new value is
higher than the target value  more than 0.1 volts, the Panel connect time is increased  one step. If the new value is lower than the
target value  more than 0.1 volts, the Panel connect time is decreased  one step. Then the corresponding arth connect time is
determined as defined for CCM.

Float algorithm

The algorithm for tracking the float voltage is the same as defined for DCM.

Off algorithm

All MOSFTs (Q1, Q2 and Q3) are turned OFF in this state.

atter management

Float charging :

When atter voltage exceeds the Float value, the charger goes into a Float Charging state which provides just enough current to
keep the atter within 0.1 volts of the Float value.
ulk charging :

When sufficient solar power is availale, the charger goes into a ulk Charging state using the appropriate algorithms (DCM or CCM). In
this state the atter voltage will e allowed to go up to Float voltage and the atter charging current must not e allowed to exceed
105% of the rated current. If the atter voltage reaches Float voltage – 0.1 volts, or the current reaches the rated current, the charging
rate is reduced to sta elow those limits.

oost charging :

For a maximum of oost Duration in each dail charging ccle, the atter voltage will e allowed to go up to oost Voltage, provided
the atter voltage has fallen elow the oost Reconnect voltage since the previous oost charging period. During this state, the
atter charging current must not e allowed to exceed 105% of the rated current. If the atter voltage reaches oost Voltage, or the
charging current reaches the rated current, the charging rate is reduced to sta elow those limits.

atter management parameters

The controller will use the following parameters to manage the atter charge and discharge:

Float voltage 13.8 volts

oost voltage 14.2 volts

oost reconnect voltage 13.2 volts

Low Voltage Disconnect 11.1 volts

Low Voltage Reconnect 12.6 volts

oost duration 1 hour

The values given aove are the default for 25 degrees Celsius. If a temperature sensor is installed, these voltages should all e
adjusted  minus 0.018 volts per degree Celsius. For example, at 0 degrees C the Float voltage would ecome 13.8 + 25*0.018 = 14.25
volts.

Load control states

This function controls the load MOSFT(Q4).


Via the serial monitor, the user can select either After Dark Lighting mode or Continuous mode.

Load control algorithms

1. atter discharge protection

If the atter voltage falls elow Low Voltage Disconnect voltage the load is disconnected.

Once the atter voltage rises to the Low Voltage Reconnect voltage the load is reconnected.

2. After dark Lighting

ON: Turn on loads at night (when the solar panel is producing less than 5% power) and the atter voltage is not disconnected due to
the Low Voltage Disconnect logic.

OFF: Turn off loads in da time as well as due to the Low Voltage Disconnect logic.

3. Continuous

Turn on the load at all times suject to the Low Voltage Disconnect logic.

LD displa

This function displa the current state of charge of the atter via LD as follows:

1. YLLOW means overvoltage (over Float voltage)

1. RD means undervoltage (disconnected due to atter voltage falling elow Low Voltage Disconnect, and still elow Low
Voltage Reconnect voltage)
2. GRN is Normal, ie aove LVD / LVR and at or elow Float voltage.

LCD displa

This function is used to displa the status of solar panel, atter and load of the controller on a 20X4 character I2C LCD displa.
WiFi data logging

This function sends parameters (sol voltage, current, power & atter voltage, charging current etc) to the www.thingspeak.com via a
SP8266 wifi module.

First the wifi module will connect to the wifi router automaticall (User has to set the SSID, Router Password and Thingspeak API ke).

If the Wifi module connects successfull, it will transmit data to wifi @ 15sec intervals (this ma e greatl reduced after development is
complete, to mae once ever 15 minutes or even once per hour).

Current Status : Working ut wifi module has to e first connected to the router  using a separate program and using AT command
from serial monitor.

Serial monitor

This function prints software parameters on a computer connected via the Arduino US port useful for deugging.

It also provides a command line interface for changing settale parameters in the controller. Settale parameters are:

Load control mode (After Dark or Continuous);

atter management values (see atter management section).

In asic operation the default mode is to output data to the serial monitor. The user can put in a command such as "stop" which will stop
the stream of serial data and print a single line with a prompt such as "tpe LIST for a list of commands, tpe START to restart data
logging".

If the user tpes "LIST” or list" the serial monitor puts out a list of parameters and their current values. The user can then put in a
command to change an value.

Hardware interfaces

The following pins will e used for interfacing to the various hardware devices.
// A0 - Voltage divider (solar) 150K / 20 K scale factor 0.04150390625

// A1 - ACS 712 Solar current scale factors for 5A unit: current 0.026393581 Offset 13.5135135

// A2 - Voltage divider (atter) 100K / 20 K scale factor 0.029296875

// A3 - ACS 712 atter current scale factors for 5A unit: current 0.026393581 Offset 13.5135135

// A4 - LCD SDA

// A5 - LCD SCL

// A6 - ACS 712 atter current scale factors for 5A unit: current 0.026393581 Offset 13.5135135

// A7 - not used

// D0, D1 - reserved, US port

// D2 - SP8266 Tx

// D3 - SP8266 Rx through the voltage divider

// D4 - temperature from DS1820 proe

// D5 - LCD ack light control utton

// D6 - Load Control

// D7 - not used

// D8 - not used

// D9 – IR2104 MOSFT driver IN

// D10 – IR2104 MOSFT driver SD

// D11- Green LD


// D12- Yellow LD

// D13- Red LD

Overview of Version­3.1
08/30/2015 at 14:50 • 6 comments

After lot testing we oserved that MOSFT ( Q3 ) in ver-3.0 design is urning repeatedl.We tried to modif the existing software ut
not find an satisfactor result.

The other prolem was that MOSFT Q1 ( in V-3.0) conduct even when there is no solar input.

To solve the aove prolems and enhance the power handling capailit we are modifing oth the hardware and software.This is
named as Version-3.1 Charge Controller.This version have 3 options.

1. 5 Amp version :

T94-26 toroid, 48 turns of AWG20 wire to give 135 uH (it takes almost 1.5m of wire)

Q1, Q2 and Q3 all pairs of IRFZ44N MOSFTs (6 in all).

C1 will e 3 * 220 uF low SR capacitors in parallel,

C2 will e a single 220 uF low SR capacitor

Single ACS712 on the panel side as per version 3.0

2. 8 Amp version :

T106-26 toroid wound with 23 turns of a compound wire made from 3 strands of AWG20 wire twisted together to give 47 uH (this takes
aout 3.1 m of wire).

Q2 will e a pair of FDP150N10A MOSFTs in parallel.


C1 will e 5 * 220 uF low SR capacitors in parallel,
C2 will e a single 220 uF low SR capacitor

Two ACS712, one on the panel side as per version 3.0 and one in series with the atter.

3 10 Amp version :

T130-26 toroid wound with 23 turns of a compound wire made from 4 strands of AWG18 wire twisted together to give 41 uH (this takes
aout 4.5 m of wire).

Q2 will e a pair of FDP150N10A MOSFTs in parallel.


C1 will e 6 * 220 uF low SR capacitors in parallel,
C2 will e 2 * 220 uF low SR capacitors in parallel.

Three ACS712, one on the panel side as per version 3.0, one in series with the atter and one in series with the load.

Here is a rough sketch for V-3.1


You can download the complete schematic from here

We are working on new PC for V-3.1 Here is the sample of one
The drive circuitr (common to all 3 versions) will use 3 separate IR2104 driver chips, one for each of Q1, Q2 and Q3. We drive the Q1
and Q2 drivers from pin D9 and HO1 and HO2, and drive Q3 from pin D10 and LO3.

In driver chips 1 and 2, pins IN and SD are driven in parallel  Arduino output pin D9. In the case of driver 1 (for Q1) there is a low pass
RC filter in series, with a time constant of aout 1 ms. Driver 2 is driven directl (as in the current circuit, ut proal with a slightl
higher series resistor to allow more current for the Q1 driver and its RC filter).

In driver chip 3, IN is driven  D9 and SD is driven  D10.

The purpose of using separate drivers for Q2 and Q3 is to enale us to switch Q3 OFF to operate in Asnchronous mode at low
current levels when the controller will e in DCM (Discontinuous Current Mode). There ma e a etter wa to do this ut in the short
time we have availale this is a simple option and eas and reliale to implement.

All 3 versions should have LCD displas, WiFi, LD indicators (mae with a more fanc coding scheme to separatel indicate DCM and
CCM).

All 3 versions should e ale to cope with either 18 V or 30 V panels, and use algorithms that stop them urning out if the panel can
produce more current than the rating allows. This can all e done auto-detect.

All the components exposed to panel voltage need to e rated for at least 40 V (in particular C1 and our uck converter to generate
12V for the drivers and to power the control electronics.

Overview of MPPT algorithm modelling
08/26/2015 at 07:29 • 0 comments
Panel model consists of a simple step-wise linear model of a solar panel.See the aove figure.

1. Constant Current : up to 18 volts


2. Constant Power : etween 18 and 19 volts

3. Power decline linearl to zero : etween 19 and 21 volts

4. Zero Current and Power : aove 21 volts

In the spread sheet attached elow there are 5 MPPT models.Here is some rief description on each.

1. MPPT model 1 implements the logic flow chart as shown in aove figure

2. MPPT model 2 implements the same logic flow chart with a declining panel power.

3. MPPT model 3 implements the algorithm used in the Arduino software. It is eas to adjust it for fixed or variale panel power and for
various starting conditions.

4. MPPT model 4 is the same as Model 3 except that it used “<=” rather than “<” for the power test.

5. MPPT model 5 is the functionall the same as Model 4. It uses three ranches on the power comparison to the previous iteration,
which has the same result as the comparison in Model 4. The main difference is it uses the equivalent of the integer arithmetic used in
the Arduino for calculation of PWM dut ccles.

Models 1 to 3 all exhiit similar characteristics, as follows:

The all converge satisfactoril when given a high PWM starting point (aove the MPP) or a lower one with a derived voltage less than
the maximum cut-off voltage of the panel (in the model, 21 V).

None of them work at all when given a low PWM starting point with a derived voltage aove the maximum cut-off voltage.

The MPPT model 4 corrects this last prolem  constantl increasing the PWM (ie decreasing the derived voltage) in the case of equal
(ie zero) power. It will alwas find the MPP of the panel model no matter what starting point is used. It ma take more steps than
provided in the examples, ut it alwas converges.

MPPT model 4 also sweeps the total maximum power area.

To clarif this: Models 1 to 3 when converged all oscillate at the top or ottom edge of the MPP area, depending on whether the
approached it from aove or elow.
It seems desirale for the tracking to sweep the whole MPP area, irrespective of which direction the approach came. This would etter
deal with cases where the power curve had local flat spots for some reason. Model 4 does this.

MPPT Model 5 provides a tool for exploring the effect of integer arithmetic on the PWM calculations and the resultant voltages and
currents.

Integer arithmetic in PWM calculations :

At the hardware level, the current software uses Timer1 to produce the PWM signal at a 20 microsecond period.20 microseconds is
320 clock ccles of the Arduino clock (which is 16 MHz, ie with a period of 62.5 ns).ecause the Timer1 lirar uses the “Phase and
Frequenc correct” PWM mode of Timer1, which counts oth up and down, the setting of the TOP level (which defines the 20
microsecond period) is 160. The PWM dut can e changed in units of 2 clock ccles, or 125 ns.The integer calculation of PWM runs like
this (using the current software):The MPPT code uses a 16 it integer variale “pwm” to manage the dut ccle. It runs from 0 to 100 to
represent 0 to 100% dut ccle, and can e stepped up or down  1 unit (ie 1%) in each pass through the MPPT algorithm. The Timer1
lirar accepts PWM dut parameter in the form of a 16 it integer variale which runs etween 0 and 1023 to represent dut ccle as a
fraction of 1024.

I will use an example to illustrate how the calculations run.

As an example we start with a desired PWM dut ccle of 70%, that is the integer “pwm” has a value of 70. To convert this to an integer
etween 0 and 1023 to pass to the Timer1 lirar, the software multiplies pwm (70)  1023 (giving 71610.The MPPT code then divides
this numer  100 giving 716, which it passes to the Timer1 lirar. Note that 716 / 1024 = 0.6992188..., which is a small amount less
than the 70% we started out with.

Note that even if we had multiplied the original 70  1024, it would still have produced 716 as the interface parameter value.When the
Timer1 lirar receives the pwm dut ccle parameter, it multiplies it  the counter setting of the TOP register, corresponding in our
case to 160 which is the value for a 20 microsecond period. This gives 716*160 = 114,560.Timer1 then divides that product  1024, in
our case giving 111. This is the value that is put into the register that triggers the transitions from 0 to 1 and then 1 ack to 0 for the PWM
signal. It will give 111/160 = 69.375% or 13.875 microseconds of 1, and the remainder of 0 in the PWM signal.

Thus, from a specified value of 70 (70%) we end up with an actual PWM dut ccle of 69.375%.This is a sstematic change. As we step
the pwm integer up or down, the difference changes.Thus 70% ecomes 69.375%, 71% ecomes 70%, 72% ecomes 71.25%, and so
on. The step size on the input side is alwas 1%, ut the step size on the output side is sometimes 0.625% (which is 1/160), and
sometimes 1.25% (which is 2/160).

It can happen that the ideal pwm dut ccle falls in a spot (like 70.625%) that cannot e accessed ecause of the nature of the integer
arithmetic.

Download the Spreadsheet analsis from here

Quarter Final Video
08/15/2015 at 19:43 • 0 comments

Keith Presentation
08/13/2015 at 12:30 • 0 comments

keith.hungerford ( team memer ) from Australia, who is one of the major contriutor to this project.He has experimented a lot on this
project.After m request he made this nice video explaining the efficienc,losses at various load,how DCM will take care at low load
condition, aout the MPPT v4 controller and writing of a new Arduino TimerOne lirar to handle our requirement.

These are the loss analsis curves at different load condition.

At 100 Watt :
At 80 Watt :
At 1 watt :
In the 100% ( 100W ) graph, the optimum PWM period is 14 microseconds, at which period the decrease in the core loss is alanced 
the increase in the switching and capacitive drive loss. When Keith checked, he found that the capacitive drive losses are so nearl
equal to the switching losses that the curves full overlap and ou cannot see the capacitive loss curve. It is more clear at 80% ( 80W )
load where oth curves are visile.

As the load decreases, the resistive losses decrease and the relative influence of these period-dependent losses increases, ut the
pattern remains the same. In the MOSFTS, the importance of the switching losses decreases with decreasing load, since there is less
current flowing and therefore a reduced amount of charge to e asored, even though the voltage excursion is unchanged. The
capacitive losses come to dominate. ecause the switching losses are less, the optimum PWM period decreases with decreasing load.
At 10% load it is down to 11 microseconds.

However the difference etween the total loss at 11 microseconds and 14 microseconds is onl 5% of the loss, so a single PWM period
of around 14 microseconds is quite efficient SO LONG AS TH CONTROLLR IS IN CCM.

Somewhere elow the 10 % load point, ut aove the 5% load point, the controller goes into DCM. That is, there is not enough current
flowing out of the panel to make the current in the inductor alwas flow in the same direction.
His design assumption in this spreadsheet is that the controller algorithms explicitl support DCM. That is, the switch off Q3 at the time
that the current would start flowing "ackwards". So now, in DCM, the controller has 3 phases within the PWM period. There is the
phase when current flows from the panel via Q2 through the inductor, and increases. there is the phase when current flows from arth
via Q3 through the inductor, and decrease. Then there is the Null phase when no current flows through the inductor.

This Null phase is a good one as far as losses in the inductor and MOSFTs are concerned - there is no current and so no loss.
However C1 is receiving all of the current from the panels, and C2 is delivering all of the current to the atter or load. This creates
extra voltage ripple at the panels, and at the atter/load.

So long as the voltage ripple at the panels and atter/load is within reasonale limits, in DCM it is etter to have a much longer PWM
period. Hence the appearance of ver long PWM periods at ver low load levels. The length of the PWM period is mainl limited  the
voltage ripple tolerale at the atter, and the reduction in efficienc of the panel caused  the ripple there.

Finished the Soldering
08/12/2015 at 03:22 • 3 comments
Purchased all the missing components and started to solder it on PC.After few hours of work, everthing is soldered.I have tested
auxiliar power circuitr,everthing works fine.The next task is to test the charging circuit.I will update it soon.

Soldering the Components on PCB
08/12/2015 at 03:09 • 0 comments
Toda I soldered most of the components on the new PC.ut few components are not availale in m stock.So I can't solder them.I
will solder the remaining components after uing it from m local shop.

The following components are missing

1.Fuse Holder

2.TVS Diodes

3.5.1V Zener Diode

4.US Port

Improvement in LCD Display Function
08/11/2015 at 15:57 • 1 comment
The LCD displa functionalit is improved.The aove video shows the simulation to test the modified software.

These are the improvements

1. Dnamic atter status in atter icon.arlier it was alwas showing aout half full .Now it changes according to the atter SOC, just
like in cell phone.

2. Removing the long if else statement for displaing the atter SOC. Now used a math function to do the jo.

3. Adding a spinner icon to show the charger is running.It stops when program stuck up.

Code efore Modification :

void lcd_display() 

  back_light_pin_State = digitalRead(BACK_LIGHT_PIN); 
  if (back_light_pin_State == HIGH) 
  { 
    time = millis();                        // If any of the buttons are pressed, save the time in millis to "time" 
  } 
  
 lcd.setCursor(0, 0); 
 lcd.print("SOL"); 
 lcd.setCursor(4, 0); 
 lcd.write(1); 
 lcd.setCursor(0, 1); 
 lcd.print(sol_volts); 
 lcd.print("V");  
 lcd.setCursor(0, 2); 
 lcd.print(sol_amps); 
 lcd.print("A");   
 lcd.setCursor(0, 3); 
 lcd.print(sol_watts); 
 lcd.print("W ");  
 lcd.setCursor(8, 0); 
 lcd.print("BAT"); 
 lcd.setCursor(12, 0); 
 lcd.write(2); 
 lcd.setCursor(8, 1); 
 lcd.print(bat_volts); 
 lcd.setCursor(8,2); 
  
 if (charger_state == on)  
 lcd.print("on"); 
 else if (charger_state == off)
 lcd.print("off"); 
 else if (charger_state == bulk) 
 lcd.print("bulk"); 
 else if (charger_state == bat_float) 
 lcd.print("float"); 
 
  
 //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ 
 //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐Battery State Of Charge ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ 
 //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ 
 lcd.setCursor(8,3); 
 if ( bat_volts >= 12.7) 
 lcd.print( "100%"); 
 else if (bat_volts >= 12.5 && bat_volts < 12.7) 
 lcd.print( "90%"); 
 else if (bat_volts >= 12.42 && bat_volts < 12.5) 
 lcd.print( "80%"); 
 else if (bat_volts >= 12.32 && bat_volts < 12.42) 
 lcd.print( "70%"); 
 else if (bat_volts >= 12.2 && bat_volts < 12.32) 
 lcd.print( "60%"); 
 else if (bat_volts >= 12.06 && bat_volts < 12.2) 
 lcd.print( "50%"); 
 else if (bat_volts >= 11.90 && bat_volts < 12.06) 
 lcd.print( "40%"); 
 else if (bat_volts >= 11.75 && bat_volts < 11.90) 
 lcd.print( "30%"); 
 else if (bat_volts >= 11.58 && bat_volts < 11.75) 
 lcd.print( "20%"); 
 else if (bat_volts >= 11.31 && bat_volts < 11.58) 
 lcd.print( "10%"); 
 else if (bat_volts < 11.3) 
 lcd.print( "0%"); 
  
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐Duty Cycle‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ 
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ 
 lcd.setCursor(15,0); 
 lcd.print("PWM"); 
 lcd.setCursor(19,0); 
 lcd.write(3); 
 lcd.setCursor(15,1); 
 lcd.print(pwm);  
 lcd.print("%"); 
 //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ 
 //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐Load Status‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ 
 //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ 
 lcd.setCursor(15,2); 
 lcd.print("Load"); 
 lcd.setCursor(15,3); 
 if (load_status == 1) 
 { 
    lcd.print("On"); 
 } 
 else 
 { 
   lcd.print("Off"); 
 } 
 backLight_timer();                      // call the backlight timer function in every loop  

 
void backLight_timer(){ 
  if((millis() ‐ time) <= 15000) // if it's been less than the 15 secs, turn the backlight on 
      lcd.backlight();           // finish with backlight on   
  else  
      lcd.noBacklight();         // if it's been more than 15 secs, turn the backlight off 
}

Code After Modification :

void lcd_display() 

  static bool current_backlight_state = ‐1; 
  back_light_pin_State = digitalRead(BACK_LIGHT_PIN); 
  if (current_backlight_state != back_light_pin_State) { 
    current_backlight_state = back_light_pin_State; 
    if (back_light_pin_State == HIGH) 
      lcd.backlight();// finish with backlight on 
    else 
      lcd.noBacklight();
  } 
 
  if (back_light_pin_State == HIGH) 
  { 
    time = millis();                        // If any of the buttons are pressed, save the time in millis to "time" 
  } 
  
 lcd.setCursor(0, 1); 
 lcd.print(sol_volts); 
 lcd.print("V "); 
 lcd.setCursor(0, 2); 
 lcd.print(sol_amps); 
 lcd.print("A");   
 lcd.setCursor(0, 3); 
 lcd.print(sol_watts); 
 lcd.print("W ");  
 lcd.setCursor(8, 1); 
 lcd.print(bat_volts); 
 lcd.setCursor(8,2); 
 
 if (charger_state == on)  
 lcd.print("on   "); 
 else if (charger_state == off)
 lcd.print("off  "); 
 else if (charger_state == bulk) 
 lcd.print("bulk "); 
 else if (charger_state == bat_float) 
 { 
 lcd.print("     "); 
 lcd.setCursor(8,2); 
 lcd.print("float"); 
 } 
  
 //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ 
 //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐Battery State Of Charge ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ 
 //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ 
 int pct = 100.0*(bat_volts ‐ 11.3)/(12.7 ‐ 11.3); 
 if (pct < 0) 
     pct = 0; 
 else if (pct > 100) 
     pct = 100; 
 
 lcd.setCursor(12,0); 
 lcd.print((char)(pct*5/100)); 
 
 lcd.setCursor(8,3); 
 pct = pct ‐ (pct%10); 
 lcd.print(pct); 
 lcd.print("%  "); 
  
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐Duty Cycle‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ 
//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ 
 lcd.setCursor(15,0); 
 lcd.print("PWM"); 
 lcd.setCursor(19,0); 
 lcd.write(PWM_ICON); 
 lcd.setCursor(15,1); 
 lcd.print("   "); 
 lcd.setCursor(15,1); 
 if( charger_state == off) 
 lcd.print(0); 
 else 
 lcd.print(pwm);  
 lcd.print("% "); 
 //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ 
 //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐Load Status‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ 
 //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ 
 lcd.setCursor(15,2); 
 lcd.print("Load"); 
 lcd.setCursor(15,3); 
 if (load_status) 
 { 
    lcd.print("On  "); 
 } 
 else 
 { 
   lcd.print("Off "); 
 }  
 spinner(); 
 backLight_timer();                      // call the backlight timer function in every loop  

 
void backLight_timer(){ 
  if((millis() ‐ time) <= 15000)         // if it's been less than the 15 secs, turn the backlight on 
      lcd.backlight();                   // finish with backlight on   
  else  
      lcd.noBacklight();                 // if it's been more than 15 secs, turn the backlight off 

void spinner(void) { 
  static int cspinner; 
  static char spinner_chars[] = { '*','*', '*', ' ', ' '}; 
  cspinner++; 
  lcd.print(spinner_chars[cspinner%sizeof(spinner_chars)]); 

PCB Arrived
08/11/2015 at 15:27 • 0 comments

Vous aimerez peut-être aussi