1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- on start:
- check config options:
- battery type - lithium, lead acid
- Series cells
- Parallel cells
- start PCM for transistors
- if type is lithium
- Vcell = 3.7
- else if type is lead
- Vcell = 12
- set Vnom = Vcell * Series
- loop:
- measure: battery voltage and current
- measure: panel voltage and current
- measure: temperature
- if MPPT mode
- calculate incremental conductance
- calculate battery conductance
- adjust duty cycle accordingly
- else
- maintain charge
- check time
- find sunset time
- if time is after sunset
- set interrupt to sunrise
- sleep
- calculate coulomb change with numerical integration
- calculate voltage/temp coefficient
- adjust state of charge (SoC) accordingly
- if SoC > 95%
- PWM mode
- else if SoC < 5%
- disconnect load relay
- turn of load LED
- else if in PWM mode
- MPPT mode
- if load is disconnected, reconnect
- if screen is on
- display latest time, temperature, SoC, capacity, voltages, currents, load power
- else if screen has just turned off
- clear screen
- record every 5 mins: time, mAh, SoC, average load, average panel voltage
|