pseudocode 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. on start:
  2. check config options:
  3. battery type - lithium, lead acid
  4. Series cells
  5. Parallel cells
  6. start PCM for transistors
  7. if type is lithium
  8. Vcell = 3.7
  9. else if type is lead
  10. Vcell = 12
  11. set Vnom = Vcell * Series
  12. loop:
  13. measure: battery voltage and current
  14. measure: panel voltage and current
  15. measure: temperature
  16. if MPPT mode
  17. calculate incremental conductance
  18. calculate battery conductance
  19. adjust duty cycle accordingly
  20. else
  21. maintain charge
  22. check time
  23. find sunset time
  24. if time is after sunset
  25. set interrupt to sunrise
  26. sleep
  27. calculate coulomb change with numerical integration
  28. calculate voltage/temp coefficient
  29. adjust state of charge (SoC) accordingly
  30. if SoC > 95%
  31. PWM mode
  32. else if SoC < 5%
  33. disconnect load relay
  34. turn of load LED
  35. else if in PWM mode
  36. MPPT mode
  37. if load is disconnected, reconnect
  38. if screen is on
  39. display latest time, temperature, SoC, capacity, voltages, currents, load power
  40. else if screen has just turned off
  41. clear screen
  42. record every 5 mins: time, mAh, SoC, average load, average panel voltage