Fixed multiple bugs and errors.

- Added WARNING handler
- put voltage calculations to dedicated module

fixed last errors. Updated menu repair screen without ERROR from PID 

This is version 0.9.0.3, which is used for the first duration test
Will also be tagged

git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@272 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
mmi
2017-11-15 15:40:39 +00:00
parent 17207a3a4b
commit 711f8e72be
46 changed files with 2572 additions and 454 deletions

View File

@@ -36,6 +36,7 @@
#include "DAConverters.h"
#include "Display.h"
#include "Error.h"
#include "Warning.h"
#include "platform.h"
#include "CoverSolenoid.h"
@@ -43,6 +44,7 @@
#include "Logger.h"
#include "PCBA.h"
#include "Power6V5Supply.h"
#include "TeslaGunSafety.h"
#include "Version.h"
// -----------------------------------------------------------------------------
@@ -60,7 +62,7 @@
// File-scope variables
// -----------------------------------------------------------------------------
static bool _hsb_safetyIsEnabled = false;
// -----------------------------------------------------------------------------
// Function declarations
@@ -104,7 +106,7 @@ ErrorStatus hsb_generateStartScreen(struct Display* Display)
}
ErrorStatus hsb_enableSafety(void)
ErrorStatus hsb_enableSafetyWithError(void)
{
ErrorStatus returnValue = SUCCESS;
@@ -117,8 +119,7 @@ ErrorStatus hsb_enableSafety(void)
if (returnValue == SUCCESS)
{
// Check for INTERLOCK CLOSE
// if (Interlock_isClosed(interlock))
if (1)
if (Interlock_isClosed(interlock))
{
// Enable Interrupt for interlock switch
Interlock_setEXTI(interlock, ENABLE);
@@ -130,11 +131,82 @@ ErrorStatus hsb_enableSafety(void)
}
}
if (returnValue == SUCCESS)
{
// In case of a TESLA repair, release the teslaGunSafety
if (PCBA_getInstance()->pcba == PCBA_Tesla)
{
TeslaGunSafety_release();
}
}
// if Interlock(s) closed, continue procedure
if (returnValue == SUCCESS)
{
// Power the circuit
Power6V5Supply_on();
returnValue = Power6V5Supply_on();
}
if (returnValue == SUCCESS)
{
_hsb_safetyIsEnabled = true;
}
else
{
_hsb_safetyIsEnabled = false;
}
return returnValue;
}
ErrorStatus hsb_enableSafetyWithWarning(void)
{
ErrorStatus returnValue = SUCCESS;
// First, Lock the cover
if (returnValue == SUCCESS)
{
CoverSolenoid_lock();
}
if (returnValue == SUCCESS)
{
// Check for INTERLOCK CLOSE
if (Interlock_isClosed(interlock))
{
// Enable Interrupt for interlock switch
Interlock_setEXTI(interlock, ENABLE);
}
else
{
Warning_postWarning(WARNING_INTERLOCK_COMMON_FAIL);
returnValue = ERROR;
}
}
if (returnValue == SUCCESS)
{
// In case of a TESLA repair, release the teslaGunSafety
if (PCBA_getInstance()->pcba == PCBA_Tesla)
{
TeslaGunSafety_release();
}
}
// if Interlock(s) closed, continue procedure
if (returnValue == SUCCESS)
{
// Power the circuit
returnValue = Power6V5Supply_on();
}
if (returnValue == SUCCESS)
{
_hsb_safetyIsEnabled = true;
}
else
{
_hsb_safetyIsEnabled = false;
}
return returnValue;
}
@@ -148,16 +220,19 @@ ErrorStatus hsb_disableSafety(void)
int adcR2Value = HSB_SECURITY_VOLTAGE_THRESHOLD;
int adcR3Value = HSB_SECURITY_VOLTAGE_THRESHOLD;
Display_clearScreen(mainDisplay);
if (PCBA_getInstance()->pcba == PCBA_Tesla)
{
TeslaGunSafety_block();
}
// Display_clearScreen(mainDisplay);
char buffer[mainDisplay->displayDevice->parameters.numberOfColumns];
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "WAITING FOR");
Display_write(mainDisplay, buffer, 2, 5);
Display_write(mainDisplay, buffer, 3, 5);
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "POWER");
Display_write(mainDisplay, buffer, 3, 7);
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "POWER DOWN");
Display_write(mainDisplay, buffer, 4, 6);
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "DOWN");
Display_write(mainDisplay, buffer, 4, 8);
// Power-down the DAC outputs
DAConverter_setOutputVoltage(dacRow1, 0);
@@ -167,18 +242,40 @@ ErrorStatus hsb_disableSafety(void)
// Un-Power the circuit
Power6V5Supply_off();
// Verify that all High Voltage Supplies are shut off and voltages are below security value
while ((abs(adcR1Value) >= HSB_SECURITY_VOLTAGE_THRESHOLD) || (abs(adcR2Value) >= HSB_SECURITY_VOLTAGE_THRESHOLD) || (abs(adcR3Value) >= HSB_SECURITY_VOLTAGE_THRESHOLD))
if (PCBA_getInstance()->pcba != PCBA_Tesla)
{
adcR1Value = ADConverter_getInputVoltage(adcRow1);
adcR2Value = ADConverter_getInputVoltage(adcRow2);
adcR3Value = ADConverter_getInputVoltage(adcRow3);
vTaskDelay(100);
// Verify that all High Voltage Supplies are shut off and voltages are below security value
while ((abs(adcR1Value) >= HSB_SECURITY_VOLTAGE_THRESHOLD) || (abs(adcR2Value) >= HSB_SECURITY_VOLTAGE_THRESHOLD) || (abs(adcR3Value) >= HSB_SECURITY_VOLTAGE_THRESHOLD))
{
adcR1Value = ADConverter_getInputVoltage(adcRow1);
adcR2Value = ADConverter_getInputVoltage(adcRow2);
adcR3Value = ADConverter_getInputVoltage(adcRow3);
vTaskDelay(100);
}
}
else
{
// Verify that all High Voltage Supplies are shut off and voltages are below security value
while (abs(adcR2Value) >= HSB_SECURITY_VOLTAGE_THRESHOLD)
{
adcR2Value = ADConverter_getInputVoltage(adcRow2);
vTaskDelay(100);
}
}
Display_clearLine(mainDisplay, 3);
Display_clearLine(mainDisplay, 4);
Interlock_setEXTI(interlock, DISABLE);
_hsb_safetyIsEnabled = false;
return returnValue;
}
bool hsb_safetyIsEnabled(void)
{
return _hsb_safetyIsEnabled;
}