3-phase PV router
|
Functions | |
void | confirmPolarity (const uint8_t phase) |
This routine prevents a zero-crossing point from being declared until a certain number of consecutive samples in the 'other' half of the waveform have been encountered. | |
ISR (ADC_vect) | |
Interrupt Service Routine - Interrupt-Driven Analog Conversion. | |
uint8_t | nextLogicalLoadToBeAdded () |
Retrieve the next load that could be added (be aware of the order) | |
uint8_t | nextLogicalLoadToBeRemoved () |
Retrieve the next load that could be removed (be aware of the reverse-order) | |
void | proceedHighEnergyLevel () |
Process the case of high energy level, some action may be required. | |
void | proceedLowEnergyLevel () |
Process the case of low energy level, some action may be required. | |
void | processCurrentRawSample (const uint8_t phase, const int16_t rawSample) |
Process the calculation for the actual current raw sample for the specific phase. | |
void | processDataLogging () |
Process with data logging. | |
void | processLatestContribution (const uint8_t phase) |
Process the latest contribution after each phase specific new cycle additional processing is performed after each main cycle based on phase 0. | |
void | processMinusHalfCycle (const uint8_t phase) |
Process the start of a new -ve half cycle, for this phase, just after the zero-crossing point. | |
void | processPlusHalfCycle (const uint8_t phase) |
Process the start of a new +ve half cycle, for this phase, just after the zero-crossing point. | |
void | processPolarity (const uint8_t phase, const int16_t rawSample) |
Process with the polarity for the actual voltage sample for the specific phase. | |
void | processRawSamples (const uint8_t phase) |
This routine is called by the ISR when a pair of V & I sample becomes available. | |
void | processStartNewCycle () |
This code is executed once per 20mS, shortly after the start of each new mains cycle on phase 0. | |
void | processStartUp (const uint8_t phase) |
Process the startup period for the router. | |
void | processVoltage (const uint8_t phase) |
Process the calculation for the current voltage sample for the specific phase. | |
void | processVoltageRawSample (const uint8_t phase, const int16_t rawSample) |
Process the current voltage raw sample for the specific phase. | |
void | updatePhysicalLoadStates () |
This function provides the link between the logical and physical loads. | |
Functions used by the ISR
|
inline |
This routine prevents a zero-crossing point from being declared until a certain number of consecutive samples in the 'other' half of the waveform have been encountered.
phase | the phase number [0..NO_OF_PHASES[ |
Definition at line 330 of file processing.cpp.
ISR | ( | ADC_vect | ) |
Interrupt Service Routine - Interrupt-Driven Analog Conversion.
An Interrupt Service Routine is now defined which instructs the ADC to perform a conversion for each of the voltage and current sensors in turn.
This Interrupt Service Routine is for use when the ADC is in the free-running mode. It is executed whenever an ADC conversion has finished, approx every 104 µs. In free-running mode, the ADC has already started its next conversion by the time that the ISR is executed. The ISR therefore needs to "look ahead".
At the end of conversion Type N, conversion Type N+1 will start automatically. The ISR which runs at this point therefore needs to capture the results of conversion Type N, and set up the conditions for conversion Type N+2, and so on.
By means of various helper functions, all of the time-critical activities are processed within the ISR.
The main code is notified by means of a flag when fresh copies of loggable data are available.
Keep in mind, when writing an Interrupt Service Routine (ISR):
Definition at line 77 of file main.cpp.
|
inline |
Retrieve the next load that could be added (be aware of the order)
Definition at line 584 of file processing.cpp.
|
inline |
Retrieve the next load that could be removed (be aware of the reverse-order)
Definition at line 607 of file processing.cpp.
|
inline |
Process the case of high energy level, some action may be required.
Definition at line 408 of file processing.cpp.
|
inline |
Process the case of low energy level, some action may be required.
Definition at line 449 of file processing.cpp.
void processCurrentRawSample | ( | const uint8_t | phase, |
const int16_t | rawSample | ||
) |
Process the calculation for the actual current raw sample for the specific phase.
phase | the phase number [0..NO_OF_PHASES[ |
rawSample | the current sample for the specified phase |
Definition at line 299 of file processing.cpp.
void processDataLogging | ( | ) |
Process with data logging.
At the end of each datalogging period, copies are made of the relevant variables for use by the main code. These variable are then reset for use during the next datalogging period.
Definition at line 657 of file processing.cpp.
|
inline |
Process the latest contribution after each phase specific new cycle additional processing is performed after each main cycle based on phase 0.
phase | the phase number [0..NO_OF_PHASES[ |
Definition at line 629 of file processing.cpp.
|
inline |
Process the start of a new -ve half cycle, for this phase, just after the zero-crossing point.
phase | the phase number [0..NO_OF_PHASES[ |
Definition at line 550 of file processing.cpp.
|
inline |
Process the start of a new +ve half cycle, for this phase, just after the zero-crossing point.
phase | the phase number [0..NO_OF_PHASES[ |
Definition at line 704 of file processing.cpp.
|
inline |
Process with the polarity for the actual voltage sample for the specific phase.
phase | the phase number [0..NO_OF_PHASES[ |
rawSample | the current sample for the specified phase |
Definition at line 283 of file processing.cpp.
void processRawSamples | ( | const uint8_t | phase | ) |
This routine is called by the ISR when a pair of V & I sample becomes available.
phase | the phase number [0..NO_OF_PHASES[ |
Definition at line 732 of file processing.cpp.
|
inline |
This code is executed once per 20mS, shortly after the start of each new mains cycle on phase 0.
Changing the state of the loads is a 3-part process:
Definition at line 495 of file processing.cpp.
|
inline |
Process the startup period for the router.
phase | the phase number [0..NO_OF_PHASES[ |
Definition at line 384 of file processing.cpp.
|
inline |
Process the calculation for the current voltage sample for the specific phase.
phase | the phase number [0..NO_OF_PHASES[ |
Definition at line 354 of file processing.cpp.
void processVoltageRawSample | ( | const uint8_t | phase, |
const int16_t | rawSample | ||
) |
Process the current voltage raw sample for the specific phase.
phase | the phase number [0..NO_OF_PHASES[ |
rawSample | the current sample for the specified phase |
Definition at line 780 of file processing.cpp.
void updatePhysicalLoadStates | ( | ) |
This function provides the link between the logical and physical loads.
The array, logicalLoadState[], contains the on/off state of all logical loads, with element 0 being for the one with the highest priority. The array, physicalLoadState[], contains the on/off state of all physical loads.
The lowest 7 bits of element is the load number as defined in 'physicalLoadState'. The highest bit of each 'loadPrioritiesAndState' determines if the load is ON or OFF. The order of each element in 'loadPrioritiesAndState' determines the load priority. 'loadPrioritiesAndState[i] & loadStateMask' will extract the load number at position 'i' 'loadPrioritiesAndState[i] & loadStateOnBit' will extract the load state at position 'i'
Any other mapping relationships could be configured here.
Definition at line 234 of file processing.cpp.