Created a version that regulates negatively. Buggy, though. Enough for pre-compliance but must be fixed afterwards
git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@264 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
@@ -218,6 +218,10 @@ ErrorStatus MAX5715Channel_setValue(const struct MAX5715_DAC* self, uint16_t val
|
|||||||
|
|
||||||
static ErrorStatus channelWrite(const struct DACDevice* self, uint32_t voltage)
|
static ErrorStatus channelWrite(const struct DACDevice* self, uint32_t voltage)
|
||||||
{
|
{
|
||||||
|
if (voltage > ((1 << MAX5715_RESOLUTION_IN_BITS) - 1))
|
||||||
|
{
|
||||||
|
voltage = ((1 << MAX5715_RESOLUTION_IN_BITS) - 1);
|
||||||
|
}
|
||||||
// MASK the uint32_t DAC value (voltage) with the resolution of the MAX5715 DAC
|
// MASK the uint32_t DAC value (voltage) with the resolution of the MAX5715 DAC
|
||||||
return MAX5715Channel_setValue((struct MAX5715_DAC*)self, (((1 << MAX5715_RESOLUTION_IN_BITS) - 1) & voltage));
|
return MAX5715Channel_setValue((struct MAX5715_DAC*)self, (((1 << MAX5715_RESOLUTION_IN_BITS) - 1) & voltage));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Define release version for firmware here
|
# Define release version for firmware here
|
||||||
RELEASE_PRODUCT = \""S0\""
|
RELEASE_PRODUCT = \""S0\""
|
||||||
RELEASE_MAJOR = 0
|
RELEASE_MAJOR = 0
|
||||||
RELEASE_MINOR = 1
|
RELEASE_MINOR = 2
|
||||||
RELEASE_BRANCH = 0
|
RELEASE_BRANCH = 0
|
||||||
RELEASE_PATCH = 0
|
RELEASE_PATCH = 0
|
||||||
|
|
||||||
|
|||||||
@@ -137,6 +137,17 @@ ErrorStatus Keypad_construct(struct Keypad* self, size_t numberOfRows, size_t nu
|
|||||||
// rxQueueItem.keyEvent = RELEASED;
|
// rxQueueItem.keyEvent = RELEASED;
|
||||||
// // Put event in queue
|
// // Put event in queue
|
||||||
// xQueueSend(self->rxQueue, &rxQueueItem, 0);
|
// xQueueSend(self->rxQueue, &rxQueueItem, 0);
|
||||||
|
////
|
||||||
|
// rxQueueItem.rowCoordinate = 0;
|
||||||
|
// rxQueueItem.columnCoordinate = 0;
|
||||||
|
// rxQueueItem.keyEvent = PRESSED;
|
||||||
|
// // Put event in queue
|
||||||
|
// xQueueSend(self->rxQueue, &rxQueueItem, 0);
|
||||||
|
// rxQueueItem.rowCoordinate = 0;
|
||||||
|
// rxQueueItem.columnCoordinate = 0;
|
||||||
|
// rxQueueItem.keyEvent = RELEASED;
|
||||||
|
// // Put event in queue
|
||||||
|
// xQueueSend(self->rxQueue, &rxQueueItem, 0);
|
||||||
//
|
//
|
||||||
// rxQueueItem.rowCoordinate = 0;
|
// rxQueueItem.rowCoordinate = 0;
|
||||||
// rxQueueItem.columnCoordinate = 0;
|
// rxQueueItem.columnCoordinate = 0;
|
||||||
@@ -149,6 +160,17 @@ ErrorStatus Keypad_construct(struct Keypad* self, size_t numberOfRows, size_t nu
|
|||||||
// // Put event in queue
|
// // Put event in queue
|
||||||
// xQueueSend(self->rxQueue, &rxQueueItem, 0);
|
// xQueueSend(self->rxQueue, &rxQueueItem, 0);
|
||||||
//
|
//
|
||||||
|
// rxQueueItem.rowCoordinate = 1;
|
||||||
|
// rxQueueItem.columnCoordinate = 2;
|
||||||
|
// rxQueueItem.keyEvent = PRESSED;
|
||||||
|
// // Put event in queue
|
||||||
|
// xQueueSend(self->rxQueue, &rxQueueItem, 0);
|
||||||
|
// rxQueueItem.rowCoordinate = 1;
|
||||||
|
// rxQueueItem.columnCoordinate = 2;
|
||||||
|
// rxQueueItem.keyEvent = RELEASED;
|
||||||
|
// // Put event in queue
|
||||||
|
// xQueueSend(self->rxQueue, &rxQueueItem, 0);
|
||||||
|
//
|
||||||
// rxQueueItem.rowCoordinate = 0;
|
// rxQueueItem.rowCoordinate = 0;
|
||||||
// rxQueueItem.columnCoordinate = 1;
|
// rxQueueItem.columnCoordinate = 1;
|
||||||
// rxQueueItem.keyEvent = PRESSED;
|
// rxQueueItem.keyEvent = PRESSED;
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
#define HSB_MAINREPR_TASK_PRIORITY (2)
|
#define HSB_MAINREPR_TASK_PRIORITY (2)
|
||||||
#define HSB_MAINREPR_TASK_STACKSIZE (1024)
|
#define HSB_MAINREPR_TASK_STACKSIZE (1024)
|
||||||
#define HSB_MAINREPR_OOL_DURATION (20)
|
#define HSB_MAINREPR_OOL_DURATION (20)
|
||||||
#define HSB_MAINREPR_OOL_VALUE (200)
|
#define HSB_MAINREPR_OOL_VALUE (300)
|
||||||
|
|
||||||
#define HSB_ADC_ANODE_MIN_VOLTAGE (0)
|
#define HSB_ADC_ANODE_MIN_VOLTAGE (0)
|
||||||
#define HSB_ADC_ANODE_MAX_VOLTAGE (10042)
|
#define HSB_ADC_ANODE_MAX_VOLTAGE (10042)
|
||||||
|
|||||||
@@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
#include "ADConverter.h"
|
#include "ADConverter.h"
|
||||||
|
|
||||||
|
#include "Logger.h"
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Constant and macro definitions
|
// Constant and macro definitions
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@@ -100,20 +102,21 @@ static int calculateVoltage(const struct ADConverter* self, uint32_t adcValue)
|
|||||||
int returnValue = 0;
|
int returnValue = 0;
|
||||||
if (self->initialized)
|
if (self->initialized)
|
||||||
{
|
{
|
||||||
uint32_t maxAdcValue = ((1 << self->adcDevice->resolutionInBits) - 1);
|
int maxAdcValue = ((1 << self->adcDevice->resolutionInBits) - 1);
|
||||||
|
|
||||||
returnValue = adcValue * (self->maxVoltage - self->minVoltage);
|
returnValue = (int)adcValue * (self->maxVoltage - self->minVoltage);
|
||||||
returnValue = returnValue / maxAdcValue;
|
returnValue = returnValue / maxAdcValue;
|
||||||
returnValue = returnValue + self->minVoltage;
|
returnValue = returnValue + self->minVoltage;
|
||||||
|
|
||||||
if (returnValue < self->minVoltage)
|
LOGGER_DEBUG(mainLog, "%X, %d, %d, %d", adcValue, self->maxVoltage, self->minVoltage, returnValue);
|
||||||
{
|
// if (returnValue < self->minVoltage)
|
||||||
returnValue = self->minVoltage;
|
// {
|
||||||
}
|
// returnValue = self->minVoltage;
|
||||||
else if (returnValue > self->maxVoltage)
|
// }
|
||||||
{
|
// else if (returnValue > self->maxVoltage)
|
||||||
returnValue = self->maxVoltage;
|
// {
|
||||||
}
|
// returnValue = self->maxVoltage;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
#include "DAConverter.h"
|
#include "DAConverter.h"
|
||||||
|
|
||||||
|
#include "Logger.h"
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Constant and macro definitions
|
// Constant and macro definitions
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@@ -89,6 +91,7 @@ extern ErrorStatus DAConverter_setOutputVoltage(const struct DAConverter* self,
|
|||||||
uint32_t dacValue;
|
uint32_t dacValue;
|
||||||
dacValue = calculateDACValue(self, voltage);
|
dacValue = calculateDACValue(self, voltage);
|
||||||
DACDevice_write(self->dacDevice, dacValue);
|
DACDevice_write(self->dacDevice, dacValue);
|
||||||
|
LOGGER_DEBUG(mainLog, "Voltage %d --- value %X", voltage, dacValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -105,8 +108,8 @@ static uint32_t calculateDACValue(const struct DAConverter* self, int voltage)
|
|||||||
if (self->initialized)
|
if (self->initialized)
|
||||||
{
|
{
|
||||||
uint32_t maxDacValue = ((1 << self->dacDevice->resolutionInBits) - 1);
|
uint32_t maxDacValue = ((1 << self->dacDevice->resolutionInBits) - 1);
|
||||||
dacValue = (voltage - self->minVoltage) * maxDacValue;
|
dacValue = (abs(voltage) - abs(self->minVoltage)) * maxDacValue;
|
||||||
dacValue/= (self->maxVoltage - self->minVoltage);
|
dacValue/= (abs(self->maxVoltage) - abs(self->minVoltage));
|
||||||
if (dacValue > maxDacValue)
|
if (dacValue > maxDacValue)
|
||||||
{
|
{
|
||||||
dacValue = maxDacValue;
|
dacValue = maxDacValue;
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ void SignalProfileGenerator_calculate(struct SignalProfileGenerator* self)
|
|||||||
{
|
{
|
||||||
self->isProcessRunning = true;
|
self->isProcessRunning = true;
|
||||||
|
|
||||||
self->signal = ((self->repairPreset->preset[self->currentPresetIndex].voltage * SPG_FIXPOINT_FACTOR - self->startVoltage * SPG_FIXPOINT_FACTOR) / self->repairPreset->preset[self->currentPresetIndex].softstartDuration) * (self->secondsCounter - self->startTime) + self->startVoltage * SPG_FIXPOINT_FACTOR;
|
self->signal = ((self->repairPreset->preset[self->currentPresetIndex].voltage * SPG_FIXPOINT_FACTOR - (self->startVoltage * SPG_FIXPOINT_FACTOR)) / self->repairPreset->preset[self->currentPresetIndex].softstartDuration) * (self->secondsCounter - self->startTime) + (self->startVoltage * SPG_FIXPOINT_FACTOR);
|
||||||
self->signal = self->signal / SPG_FIXPOINT_FACTOR;
|
self->signal = self->signal / SPG_FIXPOINT_FACTOR;
|
||||||
|
|
||||||
incrementSecondsCounter(self);
|
incrementSecondsCounter(self);
|
||||||
|
|||||||
@@ -240,6 +240,16 @@ static void initTask(void* parameters)
|
|||||||
// Construct the repair menu
|
// Construct the repair menu
|
||||||
repairMenus_construct();
|
repairMenus_construct();
|
||||||
|
|
||||||
|
// DAConverter_setOutputVoltage(dacRow1, -500);
|
||||||
|
// DAConverter_setOutputVoltage(dacRow2, -400);
|
||||||
|
// DAConverter_setOutputVoltage(dacRow3, -300);
|
||||||
|
//
|
||||||
|
// while (1)
|
||||||
|
// {
|
||||||
|
// LOGGER_DEBUG(mainLog, "%i %i %i", ADConverter_getInputVoltage(adcRow1), ADConverter_getInputVoltage(adcRow2), ADConverter_getInputVoltage(adcRow3));
|
||||||
|
// vTaskDelay(1000);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
// xTaskCreate(printSystemInfoTask, (const char* const)"SysInfoTask", 512, NULL, 0, &sysTaskHandle);
|
// xTaskCreate(printSystemInfoTask, (const char* const)"SysInfoTask", 512, NULL, 0, &sysTaskHandle);
|
||||||
|
|
||||||
|
|||||||
@@ -71,16 +71,36 @@ static const char cursorValue[2] = {0x7E, '\0'};
|
|||||||
|
|
||||||
|
|
||||||
// TEMPORARY PRESET STORAGE
|
// TEMPORARY PRESET STORAGE
|
||||||
static const struct RepairPreset preset1 = {.numberOfStages = 1, .preset[0].softstartDuration = 200, .preset[0].duration = 60, .preset[0].voltage = 1000};
|
static const struct RepairPreset preset1t = {.numberOfStages = 1, .preset[0].softstartDuration = 100, .preset[0].duration = 200, .preset[0].voltage = 1000};
|
||||||
static const struct RepairPreset preset2 = {.numberOfStages = 1, .preset[0].softstartDuration = 200, .preset[0].duration = 400, .preset[0].voltage = 3000};
|
static const struct RepairPreset preset2t = {.numberOfStages = 1, .preset[0].softstartDuration = 200, .preset[0].duration = 400, .preset[0].voltage = 3000};
|
||||||
static const struct RepairPreset preset3 = {.numberOfStages = 1, .preset[0].softstartDuration = 300, .preset[0].duration = 600, .preset[0].voltage = 300};
|
static const struct RepairPreset preset3t = {.numberOfStages = 1, .preset[0].softstartDuration = 300, .preset[0].duration = 600, .preset[0].voltage = 300};
|
||||||
static const struct RepairPreset preset4 = {.numberOfStages = 1, .preset[0].softstartDuration = 400, .preset[0].duration = 800, .preset[0].voltage = 400};
|
static const struct RepairPreset preset4t = {.numberOfStages = 1, .preset[0].softstartDuration = 400, .preset[0].duration = 800, .preset[0].voltage = 400};
|
||||||
static const struct RepairPreset preset5 = {.numberOfStages = 1, .preset[0].softstartDuration = 500, .preset[0].duration = 1000, .preset[0].voltage = 500};
|
static const struct RepairPreset preset5t = {.numberOfStages = 1, .preset[0].softstartDuration = 500, .preset[0].duration = 1000, .preset[0].voltage = 500};
|
||||||
static const struct RepairPreset preset6 = {.numberOfStages = 1, .preset[0].softstartDuration = 600, .preset[0].duration = 1200, .preset[0].voltage = 600};
|
static const struct RepairPreset preset6t = {.numberOfStages = 1, .preset[0].softstartDuration = 120, .preset[0].duration = 240, .preset[0].voltage = 800};
|
||||||
static const struct RepairPreset preset7 = {.numberOfStages = 1, .preset[0].softstartDuration = 700, .preset[0].duration = 1400, .preset[0].voltage = 700};
|
static const struct RepairPreset preset7t = {.numberOfStages = 1, .preset[0].softstartDuration = 700, .preset[0].duration = 1400, .preset[0].voltage = 700};
|
||||||
static const struct RepairPreset preset8 = {.numberOfStages = 1, .preset[0].softstartDuration = 800, .preset[0].duration = 1600, .preset[0].voltage = 800};
|
static const struct RepairPreset preset8t = {.numberOfStages = 1, .preset[0].softstartDuration = 120, .preset[0].duration = 300, .preset[0].voltage = 4000};
|
||||||
static const struct RepairPreset preset9 = {.numberOfStages = 2, .preset[0].softstartDuration = 900, .preset[0].duration = 1800, .preset[0].voltage = 6000, .preset[1].softstartDuration = 100, .preset[1].duration = 1800, .preset[1].voltage = 8000};
|
static const struct RepairPreset preset9t = {.numberOfStages = 2, .preset[0].softstartDuration = 900, .preset[0].duration = 1800, .preset[0].voltage = 4000, .preset[1].softstartDuration = 100, .preset[1].duration = 1800, .preset[1].voltage = 5000};
|
||||||
static const struct RepairPreset* presetArray[9] = {&preset1, &preset2, &preset3, &preset4, &preset5, &preset6, &preset7, &preset8, &preset9};
|
|
||||||
|
static const struct RepairPreset preset1a = {.numberOfStages = 1, .preset[0].softstartDuration = 000, .preset[0].duration = 200, .preset[0].voltage = 1000};
|
||||||
|
static const struct RepairPreset preset2a = {.numberOfStages = 1, .preset[0].softstartDuration = 200, .preset[0].duration = 400, .preset[0].voltage = 3000};
|
||||||
|
static const struct RepairPreset preset3a = {.numberOfStages = 1, .preset[0].softstartDuration = 300, .preset[0].duration = 600, .preset[0].voltage = 300};
|
||||||
|
static const struct RepairPreset preset4a = {.numberOfStages = 1, .preset[0].softstartDuration = 400, .preset[0].duration = 800, .preset[0].voltage = 400};
|
||||||
|
static const struct RepairPreset preset5a = {.numberOfStages = 1, .preset[0].softstartDuration = 500, .preset[0].duration = 1000, .preset[0].voltage = 500};
|
||||||
|
static const struct RepairPreset preset6a = {.numberOfStages = 1, .preset[0].softstartDuration = 600, .preset[0].duration = 1200, .preset[0].voltage = 800};
|
||||||
|
static const struct RepairPreset preset7a = {.numberOfStages = 1, .preset[0].softstartDuration = 700, .preset[0].duration = 1400, .preset[0].voltage = 700};
|
||||||
|
static const struct RepairPreset preset8a = {.numberOfStages = 1, .preset[0].softstartDuration = 120, .preset[0].duration = 300, .preset[0].voltage = 6000};
|
||||||
|
static const struct RepairPreset preset9a = {.numberOfStages = 2, .preset[0].softstartDuration = 900, .preset[0].duration = 1800, .preset[0].voltage = 6000, .preset[1].softstartDuration = 100, .preset[1].duration = 1800, .preset[1].voltage = 8000};
|
||||||
|
|
||||||
|
static const struct RepairPreset preset1n = {.numberOfStages = 1, .preset[0].softstartDuration = 100, .preset[0].duration = 200, .preset[0].voltage = -1000};
|
||||||
|
static const struct RepairPreset preset2n = {.numberOfStages = 1, .preset[0].softstartDuration = 200, .preset[0].duration = 400, .preset[0].voltage = -1800};
|
||||||
|
static const struct RepairPreset preset3n = {.numberOfStages = 1, .preset[0].softstartDuration = 300, .preset[0].duration = 600, .preset[0].voltage = -300};
|
||||||
|
static const struct RepairPreset preset4n = {.numberOfStages = 1, .preset[0].softstartDuration = 400, .preset[0].duration = 800, .preset[0].voltage = -400};
|
||||||
|
static const struct RepairPreset preset5n = {.numberOfStages = 1, .preset[0].softstartDuration = 500, .preset[0].duration = 1000, .preset[0].voltage = -500};
|
||||||
|
static const struct RepairPreset preset6n = {.numberOfStages = 1, .preset[0].softstartDuration = 600, .preset[0].duration = 1200, .preset[0].voltage = -600};
|
||||||
|
static const struct RepairPreset preset7n = {.numberOfStages = 1, .preset[0].softstartDuration = 700, .preset[0].duration = 1400, .preset[0].voltage = -700};
|
||||||
|
static const struct RepairPreset preset8n = {.numberOfStages = 1, .preset[0].softstartDuration = 120, .preset[0].duration = 300, .preset[0].voltage = -1800};
|
||||||
|
static const struct RepairPreset preset9n = {.numberOfStages = 2, .preset[0].softstartDuration = 900, .preset[0].duration = 1800, .preset[0].voltage = -1200, .preset[1].softstartDuration = 100, .preset[1].duration = 1800, .preset[1].voltage = -1600};
|
||||||
|
static const struct RepairPreset* presetArray[9];
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Function declarations
|
// Function declarations
|
||||||
@@ -161,6 +181,43 @@ ErrorStatus repairMenu_construct(struct RepairMenu* self, struct Display* displa
|
|||||||
|
|
||||||
if (returnValue == SUCCESS)
|
if (returnValue == SUCCESS)
|
||||||
{
|
{
|
||||||
|
if (PCBA_getInstance()->pcba == PCBA_CathodeMCP)
|
||||||
|
{
|
||||||
|
presetArray[0] = &preset1n;
|
||||||
|
presetArray[1] = &preset2n;
|
||||||
|
presetArray[2] = &preset3n;
|
||||||
|
presetArray[3] = &preset4n;
|
||||||
|
presetArray[4] = &preset5n;
|
||||||
|
presetArray[5] = &preset6n;
|
||||||
|
presetArray[6] = &preset7n;
|
||||||
|
presetArray[7] = &preset8n;
|
||||||
|
presetArray[8] = &preset9n;
|
||||||
|
}
|
||||||
|
else if (PCBA_getInstance()->pcba == PCBA_Anode)
|
||||||
|
{
|
||||||
|
presetArray[0] = &preset1a;
|
||||||
|
presetArray[1] = &preset2a;
|
||||||
|
presetArray[2] = &preset3a;
|
||||||
|
presetArray[3] = &preset4a;
|
||||||
|
presetArray[4] = &preset5a;
|
||||||
|
presetArray[5] = &preset6a;
|
||||||
|
presetArray[6] = &preset7a;
|
||||||
|
presetArray[7] = &preset8a;
|
||||||
|
presetArray[8] = &preset9a;
|
||||||
|
}
|
||||||
|
else if (PCBA_getInstance()->pcba == PCBA_Tesla)
|
||||||
|
{
|
||||||
|
presetArray[0] = &preset1t;
|
||||||
|
presetArray[1] = &preset2t;
|
||||||
|
presetArray[2] = &preset3t;
|
||||||
|
presetArray[3] = &preset4t;
|
||||||
|
presetArray[4] = &preset5t;
|
||||||
|
presetArray[5] = &preset6t;
|
||||||
|
presetArray[6] = &preset7t;
|
||||||
|
presetArray[7] = &preset8t;
|
||||||
|
presetArray[8] = &preset9t;
|
||||||
|
}
|
||||||
|
|
||||||
// Construct the menu based on PCBA information
|
// Construct the menu based on PCBA information
|
||||||
returnValue = repairMenu_createMenu(self);
|
returnValue = repairMenu_createMenu(self);
|
||||||
|
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ static void repairProcess_task(void* parameters)
|
|||||||
LOGGER_DEBUG(mainLog, "Signal: %d, TimeToRemain %d", self->signalProfileGenerator.signal, SignalProfileGenerator_getRemainingTime(&self->signalProfileGenerator));
|
LOGGER_DEBUG(mainLog, "Signal: %d, TimeToRemain %d", self->signalProfileGenerator.signal, SignalProfileGenerator_getRemainingTime(&self->signalProfileGenerator));
|
||||||
|
|
||||||
// Check for correct signal
|
// Check for correct signal
|
||||||
if (self->signalProfileGenerator.signal >= 0)
|
// if (self->signalProfileGenerator.signal >= 0)
|
||||||
{
|
{
|
||||||
// Regulation is unique for each row
|
// Regulation is unique for each row
|
||||||
// For TESLA repair only row 1 (out of 0,1,2) is used
|
// For TESLA repair only row 1 (out of 0,1,2) is used
|
||||||
@@ -246,22 +246,8 @@ static void repairProcess_task(void* parameters)
|
|||||||
// Calculate the error
|
// Calculate the error
|
||||||
self->row[loopCounter].pidError = self->signalProfileGenerator.signal - (int)self->row[loopCounter].lastADCValue;
|
self->row[loopCounter].pidError = self->signalProfileGenerator.signal - (int)self->row[loopCounter].lastADCValue;
|
||||||
// Calculate the PID
|
// Calculate the PID
|
||||||
int pidCalculate = PID_calculate(&self->row[loopCounter].pid, self->row[loopCounter].pidError);
|
self->row[loopCounter].lastDACValue = PID_calculate(&self->row[loopCounter].pid, self->row[loopCounter].pidError);
|
||||||
|
|
||||||
///TODO MUST BE MOVED TO DACDevice
|
|
||||||
// Verify that pid value does not overflow the DAC
|
|
||||||
if (pidCalculate > 0xFFF)
|
|
||||||
{
|
|
||||||
self->row[loopCounter].lastDACValue = 0xFFF;
|
|
||||||
}
|
|
||||||
else if (pidCalculate < 0)
|
|
||||||
{
|
|
||||||
self->row[loopCounter].lastDACValue = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
self->row[loopCounter].lastDACValue = pidCalculate;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the error condition exceeds the tolerated duration
|
// Check if the error condition exceeds the tolerated duration
|
||||||
if (self->row[loopCounter].errorData.outOfLimitsCounter >= self->row[loopCounter].errorData.outOfLimitsDuration)
|
if (self->row[loopCounter].errorData.outOfLimitsCounter >= self->row[loopCounter].errorData.outOfLimitsDuration)
|
||||||
|
|||||||
@@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
#include "repairProcessRow.h"
|
#include "repairProcessRow.h"
|
||||||
|
|
||||||
|
#include "PCBA.h"
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Constant and macro definitions
|
// Constant and macro definitions
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@@ -58,6 +60,9 @@ ErrorStatus repairProcessRow_construct(struct RepairProcessRow* self, const stru
|
|||||||
{
|
{
|
||||||
ErrorStatus returnValue = SUCCESS;
|
ErrorStatus returnValue = SUCCESS;
|
||||||
|
|
||||||
|
int iMin = 0;
|
||||||
|
int iMax = 0;
|
||||||
|
|
||||||
if (!self->initialized)
|
if (!self->initialized)
|
||||||
{
|
{
|
||||||
if (returnValue == SUCCESS)
|
if (returnValue == SUCCESS)
|
||||||
@@ -75,7 +80,22 @@ ErrorStatus repairProcessRow_construct(struct RepairProcessRow* self, const stru
|
|||||||
|
|
||||||
if (returnValue == SUCCESS)
|
if (returnValue == SUCCESS)
|
||||||
{
|
{
|
||||||
returnValue = PID_construct(&self->pid, 3000, 2000, 0, 0, 100000000);
|
if (PCBA_getInstance()->pcba == PCBA_Anode)
|
||||||
|
{
|
||||||
|
iMin = 0;
|
||||||
|
iMax = 100000000;
|
||||||
|
}
|
||||||
|
else if (PCBA_getInstance()->pcba == PCBA_CathodeMCP)
|
||||||
|
{
|
||||||
|
iMin = -100000000;
|
||||||
|
iMax = 0;
|
||||||
|
}
|
||||||
|
else if (PCBA_getInstance()->pcba == PCBA_Tesla)
|
||||||
|
{
|
||||||
|
iMin = 0;
|
||||||
|
iMax = 100000000;
|
||||||
|
}
|
||||||
|
returnValue = PID_construct(&self->pid, 3000, 2000, 0, iMin, iMax);
|
||||||
}
|
}
|
||||||
if (returnValue == SUCCESS)
|
if (returnValue == SUCCESS)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user