|
3-phase PV router
|
Which 1-Wire transaction of the temperature sensors runs on which mains cycle. More...
#include <stdint.h>

Go to the source code of this file.
Classes | |
| struct | TempSchedule::Action |
| The transaction to run, and the sensor it reads (ADDRESS, READ, CLOSE). More... | |
| class | TempSchedule::Scheduler< N, CONVERSION_CYCLES > |
| The round of the sensors, one transaction per mains cycle. More... | |
Namespaces | |
| namespace | TempSchedule |
Enumerations | |
| enum class | TempSchedule::Step : uint8_t { TempSchedule::NONE , TempSchedule::CONVERT , TempSchedule::ADDRESS , TempSchedule::READ , TempSchedule::CLOSE } |
| The 1-Wire transaction of a mains cycle. More... | |
Functions | |
| constexpr uint16_t | TempSchedule::conversionCycles (const uint8_t supplyFrequency) |
| The mains cycles from the conversion to the first read. | |
| constexpr bool | TempSchedule::fitsInPeriod (const uint8_t noOfSensors, const uint8_t supplyFrequency, const uint16_t periodCycles) |
| Whether a round ends within its datalog period. | |
| constexpr uint16_t | TempSchedule::roundCycles (const uint8_t noOfSensors, const uint8_t supplyFrequency) |
| The mains cycles of a round on time: from the conversion to the last CLOSE. | |
Variables | |
| constexpr uint16_t | TempSchedule::CONVERSION_MS { 750 } |
| constexpr uint8_t | TempSchedule::STEPS_PER_SENSOR { 3 } |
Which 1-Wire transaction of the temperature sensors runs on which mains cycle.
A reset of the 1-Wire bus, and each 0 written, keep interrupts off for 65 to 70 µs (the OneWire library): the ADC interrupt then starts up to ~1100 cycles late, and must still write ADMUX within the 1664 cycles of its conversion. The heaviest ADC interrupts are those of the mains cycle's work, run once per cycle shortly after L1's positive crossing (processing.cpp, processStartNewCycle()): a slot that delays one of them can make it miss that deadline. The calls at the other crossings (each phase's half cycles) are lighter.
The main loop therefore runs the bus I/O as short transactions, one per mains cycle at most, each started as soon as the loop sees the new cycle (Shared::b_newMainsCycle, set once processStartNewCycle() is done): its long slots end before the negative crossing, among the ordinary ADC interrupts. A round:
A transaction runs only on a cycle seen on time, the loop idle when it began: after a long pass (the per-second work, the display, an RF frame), the flag may be several milliseconds old, and the transaction waits for the next cycle.
One round per datalog period: started when the loop handles the end of the period (before the datalog output, whose UART interrupts would add to the delay of the ADC interrupt), or at the next cycle, it ends long before the period does (fitsInPeriod()), and the datalog sends its values. With sensors built in, the loop handles the datalog event, raised at L1's crossing, on the pass that sees the new cycle: 1248 us after the event, and the datalog output of a temperature build is that much later.
Definition in file temp_schedule.h.