![]() |
PS_Fgen_FW
4da88f4073c1cc65ea45c3a652a2751e495e50db
Firmware for an Power Supply and Function Generator build from an ATX power supply
|
Power supply channel Class. More...
#include <PS_Channel.h>
Public Member Functions | |
PS_Channel (float minVolt, float maxVolt, uint8_t minOvpLevel, uint8_t maxOvpLevel, float minOvpDelay, float maxOvpDelay, float minOcpLevel, float maxOcpLevel, float minOcpDelay, float maxOcpDelay, float minOppLevel, float maxOppLevel, float minOppDelay, float maxOppDelay) | |
Constructor of the PS_Channel. | |
void | SwitchOffOutput () |
Set the voltage at the output of this channel to zero. | |
void | UpdateOutput () |
Set the voltage at the output of this channel to the value calculated by the PID regulator if the output is enabled and in CV state. | |
void | DoRegulationISR () |
This method is called periodically based on the device timer ISR (multiples of the device timer period) and runs in the ISR context. | |
void | CheckProtections () |
Check if one of the protections for the power supply channel is tripped and update the PsState accordingly. | |
void | ClearProtections () |
Clear the protections for the power supply channel and return to the CV state. | |
bool | IsProtectionActive () |
Check if at least one protection is active (OVP, OCP, OPP) | |
PsStates_t | GetPsState () |
Return the current state of this channel. | |
bool | SetRegulationMode (PsRegulationModes_t regulationMode) |
Set the RegulationMode property of the PS channel. | |
PsRegulationModes_t | GetRegulationMode () |
Get the RegulationMode property of the PS channel. | |
bool | SetEnabled (bool enabled) |
Set the Enabled property of the PS channel. | |
bool | GetEnabled () |
Get the Enabled property of the PS channel. | |
bool | SetVoltage (float voltage) |
Set the Voltage property of the PS channel. | |
float | GetVoltage () |
Get the Voltage property of the PS channel. | |
bool | SetOvpLevel (uint8_t ovpLevel) |
Set the OvpLevel property of the PS channel. | |
uint8_t | GetOvpLevel () |
Get the OvpLevel property of the PS channel. | |
bool | SetOvpState (bool ovpState) |
Set the OvpState property of the PS channel. | |
bool | GetOvpState () |
Get the OvpState property of the PS channel. | |
bool | SetOvpDelay (float ovpDelay) |
Set the OvpDelay property of the PS channel. | |
float | GetOvpDelay () |
Get the OvpDelay property of the PS channel. | |
bool | SetOcpLevel (float ocpLevel) |
Set the OcpLevel property of the PS channel. | |
float | GetOcpLevel () |
Get the OcpLevel property of the PS channel. | |
bool | SetOcpState (bool ocpState) |
Set the OcpState property of the PS channel. | |
bool | GetOcpState () |
Get the OcpState property of the PS channel. | |
bool | SetOcpDelay (float ocpDelay) |
Set the OcpDelay property of the PS channel. | |
float | GetOcpDelay () |
Get the OcpDelay property of the PS channel. | |
bool | SetOppLevel (float oppLevel) |
Set the OppLevel property of the PS channel. | |
float | GetOppLevel () |
Get the OppLevel property of the PS channel. | |
bool | SetOppState (bool oppState) |
Set the OppState property of the PS channel. | |
bool | GetOppState () |
Get the OppState property of the PS channel. | |
bool | SetOppDelay (float oppDelay) |
Set the OppDelay property of the PS channel. | |
float | GetOppDelay () |
Get the OppDelay property of the PS channel. | |
![]() | |
Channel (ChannelTypes_t channelType) | |
Constructor of the Channel class. | |
ChannelTypes_t | GetChannelType () |
Function that can be used to return the _channelType property. | |
Static Public Member Functions | |
static void | PSRegulationModeChanged (void *channel) |
Callback function that can be used for user interface controls modifying the RegulationMode property. | |
static void | PSEnabledChanged (void *channel) |
Callback function that can be used for user interface controls modifying the Enabled property. | |
static void | PSVoltageChanged (void *channel) |
Callback function that can be used for user interface controls modifying the Voltage property. | |
static void | PSOvpLevelChanged (void *channel) |
Callback function that can be used for user interface controls modifying the OvpLevel property. | |
static void | PSOvpStateChanged (void *channel) |
Callback function that can be used for user interface controls modifying the OvpState property. | |
static void | PSOvpDelayChanged (void *channel) |
Callback function that can be used for user interface controls modifying the OvpDelay property. | |
static void | PSOcpLevelChanged (void *channel) |
Callback function that can be used for user interface controls modifying the OcpLevel property. | |
static void | PSOcpStateChanged (void *channel) |
Callback function that can be used for user interface controls modifying the OcpState property. | |
static void | PSOcpDelayChanged (void *channel) |
Callback function that can be used for user interface controls modifying the OcpDelay property. | |
static void | PSOppLevelChanged (void *channel) |
Callback function that can be used for user interface controls modifying the OppLevel property. | |
static void | PSOppStateChanged (void *channel) |
Callback function that can be used for user interface controls modifying the OppState property. | |
static void | PSOppDelayChanged (void *channel) |
Callback function that can be used for user interface controls modifying the OppDelay property. | |
Public Attributes | |
volatile PsStates_t | PsState |
Current state of the power supply channel. | |
volatile PsRegulationModes_t | RegulationMode |
Current regulation mode of the power supply channel. | |
Parameter< bool > | Enabled |
Is the channel enabled or not. | |
Parameter< float > | Voltage |
Voltage of the power supply channel. | |
Parameter< bool > | OvpState |
Is the over voltage protection for the channel enabled or not. | |
Parameter< uint8_t > | OvpLevel |
OVP trip level in percentage of the Voltage. | |
Parameter< float > | OvpDelay |
Time after which the over voltage protection kicks in. | |
Parameter< bool > | OcpState |
Is the over current protection for the channel enabled or not. | |
Parameter< float > | OcpLevel |
OCP trip level in Ampere. | |
Parameter< float > | OcpDelay |
Time after which the over current protection kicks in. | |
Parameter< bool > | OppState |
Is the over power protection for the channel enabled or not. | |
Parameter< float > | OppLevel |
OPP trip level in Watt. | |
Parameter< float > | OppDelay |
Time after which the over power protection kicks in. | |
volatile float | MeasuredVoltage |
Measured Voltage for this channel. | |
volatile float | MeasuredCurrent |
Measured Current for this channel. | |
volatile float | MeasuredPower |
Measured Power for this channel. | |
volatile uint16_t | TimeCounter_OvpDelay_ms |
Time counter used to measure how long the channel has an over voltage. | |
volatile uint16_t | TimeCounter_OcpDelay_ms |
Time counter used to measure how long the channel has an over current. | |
volatile uint16_t | TimeCounter_OppDelay_ms |
Time counter used to measure how long the channel has an over power. | |
Private Attributes | |
float | _PIDVoltErrorSum |
PID voltage regulator error sum. | |
float | _PIDVoltErrorLast |
PID voltage regulator last error. | |
float | _setVoltage |
Voltage to which the output should be set. | |
Additional Inherited Members | |
![]() | |
ChannelTypes_t | _channelType |
Type of the channel. | |
Power supply channel Class.
This is a channel holding all parameters of a power supply implementation.
The voltage is regulated by a PID regulator.
An anti-windup provision is implemented on the PID integrator to prevent deep saturation (aka integrator windup) when the output is saturated:
PS_Channel::PS_Channel | ( | float | minVolt, |
float | maxVolt, | ||
uint8_t | minOvpLevel, | ||
uint8_t | maxOvpLevel, | ||
float | minOvpDelay, | ||
float | maxOvpDelay, | ||
float | minOcpLevel, | ||
float | maxOcpLevel, | ||
float | minOcpDelay, | ||
float | maxOcpDelay, | ||
float | minOppLevel, | ||
float | maxOppLevel, | ||
float | minOppDelay, | ||
float | maxOppDelay ) |
Constructor of the PS_Channel.
minVolt | Minimum allowed voltage for the PS channel |
maxVolt | Maximum allowed voltage for the PS channel |
minOvpLevel | Minimum allowed Ovp level for the PS channel |
maxOvpLevel | Maximum allowed Ovp level for the PS channel |
minOvpDelay | Minimum allowed Ovp delay for the PS channel |
maxOvpDelay | Maximum allowed Ovp delay for the PS channel |
minOcpLevel | Minimum allowed Ocp level for the PS channel |
maxOcpLevel | Maximum allowed Ocp level for the PS channel |
minOcpDelay | Minimum allowed Ocp delay for the PS channel |
maxOcpDelay | Maximum allowed Ocp delay for the PS channel |
minOppLevel | Minimum allowed Opp level for the PS channel |
maxOppLevel | Maximum allowed Opp level for the PS channel |
minOppDelay | Minimum allowed Opp delay for the PS channel |
maxOppDelay | Maximum allowed Opp delay for the PS channel |
void PS_Channel::DoRegulationISR | ( | ) |
This method is called periodically based on the device timer ISR (multiples of the device timer period) and runs in the ISR context.
It is used to increment the protection timers if neccessary, to change the channel state if an protection kicks in and to calculate a new PID value.
Voltage PID regulator see: https://rn-wissen.de/wiki/index.php/Regelungstechnik
PID Integrator anti-windup see: https://www.embeddedrelated.com/showcode/346.php
|
inline |
Get the Enabled property of the PS channel.
|
inline |
Get the OcpDelay property of the PS channel.
|
inline |
Get the OcpLevel property of the PS channel.
|
inline |
Get the OcpState property of the PS channel.
|
inline |
Get the OppDelay property of the PS channel.
|
inline |
Get the OppLevel property of the PS channel.
|
inline |
Get the OppState property of the PS channel.
|
inline |
Get the OvpDelay property of the PS channel.
|
inline |
Get the OvpLevel property of the PS channel.
|
inline |
Get the OvpState property of the PS channel.
|
inline |
Return the current state of this channel.
|
inline |
Get the RegulationMode property of the PS channel.
|
inline |
Get the Voltage property of the PS channel.
|
inline |
Check if at least one protection is active (OVP, OCP, OPP)
|
static |
Callback function that can be used for user interface controls modifying the Enabled property.
channel | Pointer to a PS_Channel |
|
static |
Callback function that can be used for user interface controls modifying the OcpDelay property.
channel | Pointer to a PS_Channel |
|
static |
Callback function that can be used for user interface controls modifying the OcpLevel property.
channel | Pointer to a PS_Channel |
|
static |
Callback function that can be used for user interface controls modifying the OcpState property.
channel | Pointer to a PS_Channel |
|
static |
Callback function that can be used for user interface controls modifying the OppDelay property.
channel | Pointer to a PS_Channel |
|
static |
Callback function that can be used for user interface controls modifying the OppLevel property.
channel | Pointer to a PS_Channel |
|
static |
Callback function that can be used for user interface controls modifying the OppState property.
channel | Pointer to a PS_Channel |
|
static |
Callback function that can be used for user interface controls modifying the OvpDelay property.
channel | Pointer to a PS_Channel |
|
static |
Callback function that can be used for user interface controls modifying the OvpLevel property.
channel | Pointer to a PS_Channel |
|
static |
Callback function that can be used for user interface controls modifying the OvpState property.
channel | Pointer to a PS_Channel |
|
static |
Callback function that can be used for user interface controls modifying the RegulationMode property.
channel | Pointer to a PS_Channel |
|
static |
Callback function that can be used for user interface controls modifying the Voltage property.
channel | Pointer to a PS_Channel |
bool PS_Channel::SetEnabled | ( | bool | enabled | ) |
Set the Enabled property of the PS channel.
enabled | New value for the Enabled property |
bool PS_Channel::SetOcpDelay | ( | float | ocpDelay | ) |
Set the OcpDelay property of the PS channel.
ocpDelay | New value for the OcpDelay property |
bool PS_Channel::SetOcpLevel | ( | float | ocpLevel | ) |
Set the OcpLevel property of the PS channel.
ocpLevel | New value for the OcpLevel property |
bool PS_Channel::SetOcpState | ( | bool | ocpState | ) |
Set the OcpState property of the PS channel.
ocpState | New value for the OcpState property |
bool PS_Channel::SetOppDelay | ( | float | oppDelay | ) |
Set the OppDelay property of the PS channel.
oppDelay | New value for the OppDelay property |
bool PS_Channel::SetOppLevel | ( | float | oppLevel | ) |
Set the OppLevel property of the PS channel.
oppLevel | New value for the OppLevel property |
bool PS_Channel::SetOppState | ( | bool | oppState | ) |
Set the OppState property of the PS channel.
oppState | New value for the OppState property |
bool PS_Channel::SetOvpDelay | ( | float | ovpDelay | ) |
Set the OvpDelay property of the PS channel.
ovpDelay | New value for the OvpDelay property |
bool PS_Channel::SetOvpLevel | ( | uint8_t | ovpLevel | ) |
Set the OvpLevel property of the PS channel.
ovpLevel | New value for the OvpLevel property |
bool PS_Channel::SetOvpState | ( | bool | ovpState | ) |
Set the OvpState property of the PS channel.
ovpState | New value for the OvpState property |
bool PS_Channel::SetRegulationMode | ( | PsRegulationModes_t | regulationMode | ) |
Set the RegulationMode property of the PS channel.
regulationMode | New value for the RegulationMode property |
bool PS_Channel::SetVoltage | ( | float | voltage | ) |
Set the Voltage property of the PS channel.
voltage | New value for the Voltage property |
void PS_Channel::UpdateOutput | ( | ) |
Set the voltage at the output of this channel to the value calculated by the PID regulator if the output is enabled and in CV state.
Otherwise switch off the output.
|
private |
Voltage to which the output should be set.
This value is calculated by the PID voltage regulator.
Parameter<bool> PS_Channel::Enabled |
Is the channel enabled or not.
If enabled, the voltage is available at the output.
volatile float PS_Channel::MeasuredCurrent |
Measured Current for this channel.
This value is used for PID regulation of the output current in CC state.
volatile float PS_Channel::MeasuredPower |
Measured Power for this channel.
This value is calculated from the MeasuredVoltage and MeasuredCurrent.
volatile float PS_Channel::MeasuredVoltage |
Measured Voltage for this channel.
This value is used for PID regulation of the output voltage in CV state.
Parameter<bool> PS_Channel::OcpState |
Is the over current protection for the channel enabled or not.
If disabled, the OcpLevel and OcpDelay parameters have not effect.
Parameter<bool> PS_Channel::OppState |
Is the over power protection for the channel enabled or not.
If disabled, the OppLevel and OppDelay parameters have not effect.
Parameter<bool> PS_Channel::OvpState |
Is the over voltage protection for the channel enabled or not.
If disabled, the OvpLevel and OvpDelay parameters have not effect.
volatile PsRegulationModes_t PS_Channel::RegulationMode |
Current regulation mode of the power supply channel.
For more details about the options see the enumeration values.
volatile uint16_t PS_Channel::TimeCounter_OcpDelay_ms |
Time counter used to measure how long the channel has an over current.
If this value exceeds the OcpDelay, the over current protection kicks in.
volatile uint16_t PS_Channel::TimeCounter_OppDelay_ms |
Time counter used to measure how long the channel has an over power.
If this value exceeds the OppDelay, the over power protection kicks in.
volatile uint16_t PS_Channel::TimeCounter_OvpDelay_ms |
Time counter used to measure how long the channel has an over voltage.
If this value exceeds the OvpDelay, the over voltage protection kicks in.
Parameter<float> PS_Channel::Voltage |
Voltage of the power supply channel.
This is the voltage that the PID regulator tries to produce on the output in CV state.