Updated HW test items for SWo
git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@248 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
@@ -232,7 +232,7 @@ static void initTask(void* parameters)
|
||||
MAX5715Channel_construct(&dac->dac[1], dac, 1);
|
||||
MAX5715Channel_construct(&dac->dac[2], dac, 2);
|
||||
|
||||
xTaskCreate(printSystemInfoTask, (const char* const)"SysInfoTask", 512, NULL, 0, &sysTaskHandle);
|
||||
// xTaskCreate(printSystemInfoTask, (const char* const)"SysInfoTask", 512, NULL, 0, &sysTaskHandle);
|
||||
|
||||
// Let start screen stay for 5 seconds
|
||||
vTaskDelay(INIT_START_SCREEN_DELAY);
|
||||
@@ -244,6 +244,8 @@ static void initTask(void* parameters)
|
||||
hwTestItems.power6v5Enable = power6v5Enable;
|
||||
hwTestItems.interlock1 = interlock1;
|
||||
hwTestItems.interlock2 = interlock2;
|
||||
hwTestItems.tesla1 = tesla1;
|
||||
hwTestItems.tesla1 = tesla2;
|
||||
hwTestItems.solenoid = solenoid;
|
||||
hwTestItems.mcp0Relay = mcp0Relay;
|
||||
hwTestItems.mcp1Relay = mcp1Relay;
|
||||
@@ -252,7 +254,8 @@ static void initTask(void* parameters)
|
||||
hwTestItems.cat1Relay = cat1Relay;
|
||||
hwTestItems.cat2Relay = cat2Relay;
|
||||
hwTestItems.teslaLock = teslaLock;
|
||||
hwTestItems.pcba = pcba;
|
||||
hwTestItems.pcba = pcba;
|
||||
hwTestItems.keypad = keypad;
|
||||
// EEPROM TO BE DONE
|
||||
HwValidationMenu_construct(hwValidation, &uart1->device, &hwTestItems, 1, 512);
|
||||
|
||||
|
||||
@@ -144,18 +144,6 @@ static void repairMenu_task(void* parameters)
|
||||
|
||||
Display_clearLine(self->display, 3);
|
||||
|
||||
char key;
|
||||
Keypad_KeyState keyState;
|
||||
if (Storm700_readKey(storm700, &key, &keyState) == SUCCESS)
|
||||
{
|
||||
LOGGER_DEBUG(mainLog, "Got key %c %d", key, keyState);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER_ERROR(mainLog, "Getting key failed");
|
||||
}
|
||||
|
||||
|
||||
struct RepairProcessParameters rpParameters;
|
||||
rpParameters.adcRow1 = &adc1->channel[0];
|
||||
rpParameters.adcRow2 = &adc1->channel[1];
|
||||
@@ -164,8 +152,11 @@ static void repairMenu_task(void* parameters)
|
||||
rpParameters.dacRow2 = &dac->dac[1];
|
||||
rpParameters.dacRow3 = &dac->dac[2];
|
||||
|
||||
struct RepairPresetParameters presetStage1 = {.voltage = 0xA00, .duration = 300, .softstartDuration = 120};
|
||||
struct RepairPresetParameters presetStage2 = {.voltage = 0xE00, .duration = 120, .softstartDuration = 30};
|
||||
// struct RepairPresetParameters presetStage1 = {.voltage = 0xE00, .duration = 300, .softstartDuration = 120};
|
||||
// struct RepairPresetParameters presetStage2 = {.voltage = 0x600, .duration = 120, .softstartDuration = 30};
|
||||
|
||||
struct RepairPresetParameters presetStage1 = {.voltage = 0xE00, .duration = 300, .softstartDuration = 120};
|
||||
struct RepairPresetParameters presetStage2 = {.voltage = 0x600, .duration = 120, .softstartDuration = 30};
|
||||
|
||||
struct RepairPreset repairPreset;
|
||||
repairPreset.numberOfStages = 2;
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "repairProcess.h"
|
||||
#include "repairPreset.h"
|
||||
|
||||
#include "internalADC.h"
|
||||
#include "Logger.h"
|
||||
#include "MAX5715.h"
|
||||
|
||||
@@ -54,16 +55,13 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static void repairProcess_task(void* parameters);
|
||||
|
||||
static void SignalProfileGenerator();
|
||||
|
||||
|
||||
static int SignalProfileGenerator(uint32_t startTime, uint32_t currentTime, struct RepairPreset* repairPreset, int presetIndex);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function definitions
|
||||
@@ -100,6 +98,15 @@ ErrorStatus repairProcess_construct(struct RepairProcess* self, struct RepairPro
|
||||
self->dacRow2 = parameters->dacRow2;
|
||||
self->dacRow3 = parameters->dacRow3;
|
||||
|
||||
self->pidRow1.initialized = false;
|
||||
self->pidRow2.initialized = false;
|
||||
self->pidRow3.initialized = false;
|
||||
|
||||
|
||||
PID_construct(&self->pidRow1, 10, 10, 10, 0, 10000000);
|
||||
PID_construct(&self->pidRow2, 100, 0, 0, 0, 10000000);
|
||||
PID_construct(&self->pidRow3, 10, 10, 10, 0, 10000000);
|
||||
|
||||
LOGGER_INFO(mainLog, "Repair Process task started");
|
||||
}
|
||||
else
|
||||
@@ -159,14 +166,25 @@ static void repairProcess_task(void* parameters)
|
||||
struct RepairProcess* self = (struct RepairProcess*)parameters;
|
||||
|
||||
uint8_t presetIndex = 0;
|
||||
uint32_t startTime = 0;
|
||||
uint32_t softStartTimer = 0;
|
||||
uint32_t voltageHoldTimer = 0;
|
||||
|
||||
uint16_t voltageTarget = 0;
|
||||
uint32_t pidError;
|
||||
|
||||
uint16_t voltageRow1 = 0;
|
||||
uint16_t voltageRow2 = 0;
|
||||
uint16_t voltageRow3 = 0;
|
||||
|
||||
uint16_t adcVoltageRow1 = 0;
|
||||
uint16_t adcVoltageRow2 = 0;
|
||||
uint16_t adcVoltageRow3 = 0;
|
||||
|
||||
uint16_t voltageTarget = 0;
|
||||
uint16_t dacVoltageRow1 = 0;
|
||||
uint16_t dacVoltageRow2 = 0;
|
||||
uint16_t dacVoltageRow3 = 0;
|
||||
|
||||
|
||||
// Reset the seconds counter to 0
|
||||
self->secondsCounter = 0;
|
||||
@@ -183,6 +201,7 @@ static void repairProcess_task(void* parameters)
|
||||
LOGGER_DEBUG(mainLog, "Repair Process: Preparing new stage of repair process");
|
||||
// Prepare a new repair process
|
||||
//Load the timers
|
||||
startTime = self->secondsCounter;
|
||||
softStartTimer = self->secondsCounter + self->repairPreset->preset[presetIndex].softstartDuration;
|
||||
LOGGER_DEBUG(mainLog, "Softstart timer is %d (%d + %d)", softStartTimer, self->secondsCounter, self->repairPreset->preset[presetIndex].softstartDuration);
|
||||
voltageHoldTimer = self->secondsCounter + self->repairPreset->preset[presetIndex].duration;
|
||||
@@ -211,24 +230,29 @@ static void repairProcess_task(void* parameters)
|
||||
{
|
||||
// Perform softstart / ramp-up
|
||||
|
||||
// if (PCBA_getInstance()->pcba == Tesla)
|
||||
// {
|
||||
// // Tesla repair only runs ADC row2 and DAC row2
|
||||
// calculateSoftStartStep(self->secondsCounter, softStartTimer, voltageTarget, &voltageRow2);
|
||||
// LOGGER_DEBUG(mainLog, "Softstart running -> new target is %x", voltageRow2);
|
||||
// MAX5715Channel_setValue(self->dacRow2, voltageRow2);
|
||||
// }
|
||||
// else if ((PCBA_getInstance()->pcba == Anode) || (PCBA_getInstance()->pcba == CathodeMCP))
|
||||
// {
|
||||
// calculateSoftStartStep(self->secondsCounter, softStartTimer, voltageTarget, &voltageRow1);
|
||||
// calculateSoftStartStep(self->secondsCounter, softStartTimer, voltageTarget, &voltageRow2);
|
||||
// calculateSoftStartStep(self->secondsCounter, softStartTimer, voltageTarget, &voltageRow3);
|
||||
// LOGGER_DEBUG(mainLog, "Softstart running -> new target is %x %x %x", voltageRow1, voltageRow2, voltageRow3);
|
||||
//
|
||||
// MAX5715Channel_setValue(self->dacRow1, voltageRow1);
|
||||
// MAX5715Channel_setValue(self->dacRow2, voltageRow2);
|
||||
// MAX5715Channel_setValue(self->dacRow3, voltageRow3);
|
||||
// }
|
||||
LOGGER_DEBUG(mainLog, "------------------------------");
|
||||
|
||||
if (PCBA_getInstance()->pcba == Tesla)
|
||||
{
|
||||
// Tesla repair only runs ADC row2 and DAC row2
|
||||
voltageRow2 = SignalProfileGenerator(startTime, self->secondsCounter, self->repairPreset, presetIndex);
|
||||
LOGGER_DEBUG(mainLog, "Softstart running -> new target is %x", voltageRow2);
|
||||
ADCChannel_read(self->adcRow3, &adcVoltageRow2);
|
||||
LOGGER_DEBUG(mainLog, "Softstart running ->ADC reads %x", adcVoltageRow2);
|
||||
pidError = voltageRow2 - adcVoltageRow2;
|
||||
LOGGER_DEBUG(mainLog, "Softstart running ->PID Error %x", pidError);
|
||||
int pidCalc = PID_calculate(&self->pidRow2, voltageRow2, pidError);
|
||||
LOGGER_DEBUG(mainLog, "Softstart running ->PID calculates %x", pidCalc);
|
||||
|
||||
if (pidCalc >= 0)
|
||||
{
|
||||
MAX5715Channel_setValue(self->dacRow2, pidCalc);
|
||||
}
|
||||
}
|
||||
else if ((PCBA_getInstance()->pcba == Anode) || (PCBA_getInstance()->pcba == CathodeMCP))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Check for end of softstart
|
||||
if (softStartTimer < self->secondsCounter)
|
||||
@@ -242,19 +266,29 @@ static void repairProcess_task(void* parameters)
|
||||
case VOLTAGE_HOLD:
|
||||
{
|
||||
// Actual repair state - hold target voltage until duration has passed
|
||||
LOGGER_DEBUG(mainLog, "Voltage Hold running -> target is %x", voltageTarget);
|
||||
|
||||
LOGGER_DEBUG(mainLog, "------------------------------");
|
||||
|
||||
if (PCBA_getInstance()->pcba == Tesla)
|
||||
{
|
||||
// Tesla repair only runs ADC row2 and DAC row2
|
||||
MAX5715Channel_setValue(self->dacRow2, voltageTarget);
|
||||
|
||||
voltageRow2 = SignalProfileGenerator(startTime, self->secondsCounter, self->repairPreset, presetIndex);
|
||||
LOGGER_DEBUG(mainLog, "Voltage Hold running -> new target is %x", voltageRow2);
|
||||
ADCChannel_read(self->adcRow3, &adcVoltageRow2);
|
||||
LOGGER_DEBUG(mainLog, "Voltage Hold running ->ADC reads %x", adcVoltageRow2);
|
||||
pidError = voltageRow2 - adcVoltageRow2;
|
||||
LOGGER_DEBUG(mainLog, "Voltage Hold running ->PID Error %x", pidError);
|
||||
int pidCalc = PID_calculate(&self->pidRow2, voltageRow2, pidError);
|
||||
LOGGER_DEBUG(mainLog, "Voltage Hold running ->PID calculates %x", pidCalc);
|
||||
|
||||
if (pidCalc >= 0)
|
||||
{
|
||||
MAX5715Channel_setValue(self->dacRow2, pidCalc);
|
||||
}
|
||||
}
|
||||
else if ((PCBA_getInstance()->pcba == Anode) || (PCBA_getInstance()->pcba == CathodeMCP))
|
||||
{
|
||||
MAX5715Channel_setValue(self->dacRow1, voltageTarget);
|
||||
MAX5715Channel_setValue(self->dacRow2, voltageTarget);
|
||||
MAX5715Channel_setValue(self->dacRow3, voltageTarget);
|
||||
|
||||
}
|
||||
|
||||
// Check for end of softstart
|
||||
@@ -304,7 +338,7 @@ static void repairProcess_task(void* parameters)
|
||||
MAX5715Channel_setValue(self->dacRow2, voltageRow2);
|
||||
MAX5715Channel_setValue(self->dacRow3, voltageRow3);
|
||||
|
||||
LOGGER_DEBUG(mainLog, "Repair process finished");
|
||||
// LOGGER_DEBUG(mainLog, "Repair process finished");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -321,4 +355,34 @@ static void repairProcess_task(void* parameters)
|
||||
}
|
||||
|
||||
|
||||
static int SignalProfileGenerator(uint32_t startTime, uint32_t currentTime, struct RepairPreset* repairPreset, int presetIndex)
|
||||
{
|
||||
int returnValue = 0;
|
||||
|
||||
// Differ between softstart period and voltage hold
|
||||
if (currentTime - startTime < repairPreset->preset[presetIndex].softstartDuration)
|
||||
{
|
||||
// Still in Softstart
|
||||
int startVoltage = 0;
|
||||
|
||||
// If first preset, start voltage is 0
|
||||
if (presetIndex == 0)
|
||||
{
|
||||
startVoltage = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Softstart for another stage - start voltage is hold voltage of previous preset
|
||||
startVoltage = repairPreset->preset[presetIndex - 1].voltage;
|
||||
}
|
||||
returnValue = ((repairPreset->preset[presetIndex].voltage - startVoltage) / repairPreset->preset[presetIndex].softstartDuration) * (currentTime - startTime) + startVoltage;
|
||||
}
|
||||
else
|
||||
{
|
||||
// In voltage hold
|
||||
returnValue = repairPreset->preset[presetIndex].voltage;
|
||||
}
|
||||
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user