...
To support this, here’s a breakdown of the project. Note that there are 2 solar boards, one of which has 5 MPPTs and one of which has 6, so firmware must support both.
Hardware schematic: https://githubuniversity-of-waterloo-solar-car-team.365.altium.com/uw-midsun/hardware/blob/mh_29_solar_sense_rev_1/MSXIV_SolarSense/MSXIV_SolarSense/Project Outputs for MSXIV_SolarSense/MSXIV_SolarSense_1.0.PDF/designs/8FAC72B9-AC08-48C2-83C3-E6D6555B3F5A#design
Modules
Generating data:
sense is a generic module that encapsulates the pattern of “periodically, read X and store the data, then tell the data store that we’re done.”
The
sense_register()
function takes a callback. All of the callbacks passed into this function will be periodically called (at a configurable interval), followed by a call todata_store_done()
.The callback passed to
sense_register()
should read voltage/current/temperature (and maybe PWM) data from hardware, then store it in the data store.
sense_current, sense_voltage, sense_temperature, and sense_mppt provide the callbacks passed to
sense_register()
. Each callssense_register()
in theirinit
function.sense_current reads the current output of the solar array through an MCP3427 ADC over I2C (via ACS722 current sense, though that shouldn’t be relevant for firmware).
sense_voltage reads the voltage from each of the MPPTs via 5-6 MCP3427s over I2C.
sense_temperature reads temperature data from GPIO pins PA0-4 (5 MPPTs) or PA0-5 (6 MPPTs) from thermistors.
sense_mppt communicates with the (presumably) SPV1020 MPPTs over SPI and reads their current and input voltage (and possibly PWM). It also reads the status register and raises fault events if an MPPT has an overcurrent/overvoltage/overtemperature bit set.
...