3-phase PV router
Loading...
Searching...
No Matches
Functions
Time critical functions

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.
 

Detailed Description

Functions used by the ISR

Function Documentation

◆ confirmPolarity()

void confirmPolarity ( const uint8_t  phase)
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.

Parameters
phasethe phase number [0..NO_OF_PHASES[

Definition at line 330 of file processing.cpp.

Here is the caller graph for this function:

◆ ISR()

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):

  • Keep it short
  • Don't use delay()
  • Don't do serial prints
  • Make variables shared with the main code volatile
  • Variables shared with main code may need to be protected by "critical sections"
  • Don't try to turn interrupts off or on

Definition at line 77 of file main.cpp.

Here is the call graph for this function:

◆ nextLogicalLoadToBeAdded()

uint8_t nextLogicalLoadToBeAdded ( )
inline

Retrieve the next load that could be added (be aware of the order)

Returns
The load number if successful, NO_OF_DUMPLOADS in case of failure

Definition at line 584 of file processing.cpp.

Here is the caller graph for this function:

◆ nextLogicalLoadToBeRemoved()

uint8_t nextLogicalLoadToBeRemoved ( )
inline

Retrieve the next load that could be removed (be aware of the reverse-order)

Returns
The load number if successful, NO_OF_DUMPLOADS in case of failure

Definition at line 607 of file processing.cpp.

Here is the caller graph for this function:

◆ proceedHighEnergyLevel()

void proceedHighEnergyLevel ( )
inline

Process the case of high energy level, some action may be required.

Definition at line 408 of file processing.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ proceedLowEnergyLevel()

void proceedLowEnergyLevel ( )
inline

Process the case of low energy level, some action may be required.

Definition at line 449 of file processing.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ processCurrentRawSample()

void processCurrentRawSample ( const uint8_t  phase,
const int16_t  rawSample 
)

Process the calculation for the actual current raw sample for the specific phase.

Parameters
phasethe phase number [0..NO_OF_PHASES[
rawSamplethe current sample for the specified phase

Definition at line 299 of file processing.cpp.

Here is the caller graph for this function:

◆ processDataLogging()

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.

Here is the caller graph for this function:

◆ processLatestContribution()

void processLatestContribution ( const uint8_t  phase)
inline

Process the latest contribution after each phase specific new cycle additional processing is performed after each main cycle based on phase 0.

Parameters
phasethe phase number [0..NO_OF_PHASES[

Definition at line 629 of file processing.cpp.

Here is the caller graph for this function:

◆ processMinusHalfCycle()

void processMinusHalfCycle ( const uint8_t  phase)
inline

Process the start of a new -ve half cycle, for this phase, just after the zero-crossing point.

Parameters
phasethe phase number [0..NO_OF_PHASES[

Definition at line 550 of file processing.cpp.

Here is the caller graph for this function:

◆ processPlusHalfCycle()

void processPlusHalfCycle ( const uint8_t  phase)
inline

Process the start of a new +ve half cycle, for this phase, just after the zero-crossing point.

Parameters
phasethe phase number [0..NO_OF_PHASES[

Definition at line 704 of file processing.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ processPolarity()

void processPolarity ( const uint8_t  phase,
const int16_t  rawSample 
)
inline

Process with the polarity for the actual voltage sample for the specific phase.

Parameters
phasethe phase number [0..NO_OF_PHASES[
rawSamplethe current sample for the specified phase

Definition at line 283 of file processing.cpp.

Here is the caller graph for this function:

◆ processRawSamples()

void processRawSamples ( const uint8_t  phase)

This routine is called by the ISR when a pair of V & I sample becomes available.

Parameters
phasethe phase number [0..NO_OF_PHASES[

Definition at line 732 of file processing.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ processStartNewCycle()

void processStartNewCycle ( )
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:

  • change the LOGICAL load states as necessary to maintain the energy level
  • update the PHYSICAL load states according to the logical -> physical mapping
  • update the driver lines for each of the loads.

Definition at line 495 of file processing.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ processStartUp()

void processStartUp ( const uint8_t  phase)
inline

Process the startup period for the router.

Parameters
phasethe phase number [0..NO_OF_PHASES[

Definition at line 384 of file processing.cpp.

Here is the caller graph for this function:

◆ processVoltage()

void processVoltage ( const uint8_t  phase)
inline

Process the calculation for the current voltage sample for the specific phase.

Parameters
phasethe phase number [0..NO_OF_PHASES[

Definition at line 354 of file processing.cpp.

Here is the caller graph for this function:

◆ processVoltageRawSample()

void processVoltageRawSample ( const uint8_t  phase,
const int16_t  rawSample 
)

Process the current voltage raw sample for the specific phase.

Parameters
phasethe phase number [0..NO_OF_PHASES[
rawSamplethe current sample for the specified phase

Definition at line 780 of file processing.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updatePhysicalLoadStates()

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.

Here is the caller graph for this function: