Go to the source code of this file.
◆ DACPORT
◆ DACCSPIN
◆ ADCPORT
◆ ADCCSPIN
◆ SPIInit()
Initializes the SPI Interface.
◆ DACSetRaw()
| void DACSetRaw |
( |
uint16_t |
value | ) |
|
Sets the raw Value of the DAC.
- Parameters
-
◆ DACSetAmps()
| void DACSetAmps |
( |
double |
i | ) |
|
Sets the DAC to a certain Current.
This function also switches the current range to high or low if the desired value is higher than rangeHighLimit or lower than rangeLowLimit.
- Parameters
-
◆ DACSetAmpsByStr()
| void DACSetAmpsByStr |
( |
char * |
str | ) |
|
Sets the sink to the value of a string.
- Parameters
-
| str | A Pointer to the string containing the value in amperes |
◆ SpiGetADC()
◆ SpiGetADC2()
◆ ADCGetIavg()
| double ADCGetIavg |
( |
void |
| ) |
|
Returns the averaged Value for Load Current.
This function honors the range setting and returns the value measured by the active sense resistor.
- Returns
- The averaged Load Current in A
◆ ADCGetIByVal()
| double ADCGetIByVal |
( |
uint16_t |
iRaw, |
|
|
bool |
isHigh |
|
) |
| |
Returns the Current for a given Value.
- Parameters
-
| iRaw | The raw value from the ADC, normalized to 16 bits |
| isHigh | True if the value represents a high current mode value |
- Returns
- The Load Current in A
◆ ADCGetAs()
Gets the Ampere Seconds consumed.
- Returns
- The As
◆ ADCGetVavg()
| double ADCGetVavg |
( |
void |
| ) |
|
Returns the averaged Value for the Sink Voltage.
- Note
- The voltage over the sink may be reduced by cable and/or additional resistance and may not reflect the exact value of the source voltage.
- Returns
- The Voltage over the Sink in V
◆ SpiSendAndReceiveByte()
| uint8_t SpiSendAndReceiveByte |
( |
uint8_t |
b | ) |
|
Sends and receives a Byte over the SPI Bus.
SPI implies the reception of a byte whenever one is sent. It depends on the hardware if it contains useful data.
- Note
- This function blocks for the time of the transfer.
- Parameters
-
- Returns
- The received Byte
◆ CalcIMaxLookupTable()
| void CalcIMaxLookupTable |
( |
void |
| ) |
|
Calculates the Lookup Table for IMax.
◆ SPIADCBusy()
| static bool SPIADCBusy |
( |
void |
| ) |
|
|
inlinestatic |
Returns True if SPI is occupied by ADC.
Since the ADC is handled in the interrupt, no DAC-transfer must be made while this function returns true.
- Returns
- True during ADC-Operations
◆ SpiSelectDAC()
| static void SpiSelectDAC |
( |
void |
| ) |
|
|
inlinestatic |
◆ SPIDeselectDAC()
| static void SPIDeselectDAC |
( |
void |
| ) |
|
|
inlinestatic |
◆ SpiSelectADC()
| static void SpiSelectADC |
( |
void |
| ) |
|
|
inlinestatic |
◆ SPIDeselectADC()
| static void SPIDeselectADC |
( |
void |
| ) |
|
|
inlinestatic |
◆ IsHighCurrentMode()
| static bool IsHighCurrentMode |
( |
void |
| ) |
|
|
inlinestatic |
Returns True if High Current Mode is active.
- Note
- We use PORTD instead of PIND since the gate capacitance of the FET prevents PIND from changing 'instantaneously'.
- Returns
- True if High Current Mode is active, False if in Low Current Mode
◆ SPISetLEDs()
| void SPISetLEDs |
( |
uint8_t |
mask | ) |
|
Sets the State of the 8 LEDs on the SPI-Shift-Register.
- Parameters
-
| mask | A Bitmask of the LEDs |
- Note
- The LEDs are not set immediately but on the next SPI interrupt covering the LED shift register. This may introduce a small delay.
◆ SetLowCurrentMode()
| void SetLowCurrentMode |
( |
void |
| ) |
|
◆ SetHighCurrentMode()
| void SetHighCurrentMode |
( |
void |
| ) |
|
◆ ADCGetIhighLifeRaw()
| uint16_t ADCGetIhighLifeRaw |
( |
| ) |
|
Returns the Life Value for the Current.
The current is measured over the lower of the two shunts representing the high current range. The value is normalized to 16 bit unsigned int.
- Returns
- The current in the range of 0000 to ffff
◆ ADCGetIlowLifeRaw()
| uint16_t ADCGetIlowLifeRaw |
( |
| ) |
|
Returns the Life Value for the Current.
The current is measured over the higher of the two shunts representing the low current range. Note that this value is garbage if the resistor is shorted by the MOSFET. The value is normalized to 16 bit unsigned int.
- Returns
- The current in the range of 0000 to ffff
◆ ADCGetVLifeRaw()
| uint16_t ADCGetVLifeRaw |
( |
| ) |
|
Returns the Life Value for the Sink Voltage.
The value is normalized to 16 bit unsigned int.
- Returns
- The Voltage over the Sink in the range of 0000 to ffff
◆ ADCGetIHighAvgRaw()
| uint16_t ADCGetIHighAvgRaw |
( |
| ) |
|
Returns the averaged Value for the Current.
The current is measured over the lower of the two shunts representing the high current range. The value is normalized to 16 bit unsigned int.
- Returns
- The current in the range of 0000 to ffff
◆ ADCGetILowAvgRaw()
| uint16_t ADCGetILowAvgRaw |
( |
| ) |
|
Returns the averaged Value for the Current.
The current is measured over the higher of the two shunts representing the low current range. Note that this value is garbage if the resistor is shorted by the MOSFET. The value is normalized to 16 bit unsigned int.
- Returns
- The current in the range of 0000 to ffff
◆ ADCGetVAvgRaw()
| uint16_t ADCGetVAvgRaw |
( |
| ) |
|
Returns the averaged Value for the Sink Voltage.
The value is normalized to 16 bit unsigned int.
- Returns
- The Voltage over the Sink in the range of 0000 to ffff
◆ CalcRChannel()
| void CalcRChannel |
( |
void |
| ) |
|
◆ ahRaw
The sum of current values.
◆ ahCnt
Number of average values added to ahRaw;.
◆ ahTickCnt
The number of 100Hz interrupts since ahRaw is counting.
◆ derating
Temperature Derating factor *65535. Maximum Power has to be derated by multiplication with derating.
◆ soaIMaxLUT
Lookup Table for maximum DAC-Value versus ADC-Voltage.
This table contains the maximum DAC-Values for the high byte of a given ADC voltage result. So the ADC interrupt can easily decide to reduce the current with each measurement if the SOA is violated.
This table has to be calculated by CalcIMaxLookupTable() on system startup!
- Note
- For now, we keep this as uint16_t but 256 values with two bytes each make a quarter of the controllers RAM. We could reduce this to only the upper byte of the DAC at the cost of usable SOA area. Further reduction is possible by using less bits of the ADC value.
Note also that the values still have to be degraded according to the case (heatsink) temperature!
◆ ADC_RcvStruct
◆ SPIADCAvg
Averaged Values over 16 measurements. These values may get up to 14 bits of precision.