aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2019-09-15 09:00:11 +0300
committerShlomo Hecht <shlomo@twine-s.com>2019-09-15 09:00:11 +0300
commit47a1a32bb5aaab88092615656a77eb8015653ce0 (patch)
tree8f66c5b80e93ab2778ff8b6b5189aaf885139d23 /Software/Embedded_SW
parente1aa8527550e5f9559e84031c702eb59995c53d3 (diff)
parent239bfe1cb2b194555197f713017e41ce98359869 (diff)
downloadTango-47a1a32bb5aaab88092615656a77eb8015653ce0.tar.gz
Tango-47a1a32bb5aaab88092615656a77eb8015653ce0.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Embedded_SW')
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c67
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.h2
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.c57
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.h1
-rw-r--r--Software/Embedded_SW/Embedded/Modules/General/buttons.c35
-rw-r--r--Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c12
-rw-r--r--Software/Embedded_SW/Embedded/Modules/IFS/ifs.h2
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Waste/Waste_init.c3
8 files changed, 159 insertions, 20 deletions
diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c
index 18550caa6..a7713a253 100644
--- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c
+++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c
@@ -13,6 +13,8 @@
#include "PMR/Hardware/HardwareMotor.pb-c.h"
#include "PMR/Hardware/HardwareDancerType.pb-c.h"
#include <ti/sysbios/knl/Task.h>
+#include <PMR/Diagnostics/EventType.pb-c.h>
+#include "Modules/AlarmHandling/AlarmHandling.h"
extern TempSensorResponseStruct TempSensorResponse[MAX_TEMPERATURE_SENSOR_ID];
#include <drivers/FPGA/FPGA_SSI_Comm.h>
@@ -654,6 +656,11 @@ uint32_t FPGA_MotorConfig_callback(TimerMotors_t _motorId, uint32_t ReadValue)
break;
}
+ else
+ {
+ LOG_ERROR (_motorId,"kvalhold / tvalhold is Zero");
+ AlarmHandlingSetAlarm (EVENT_TYPE__MACHINE_STATE_HW_CONFIG_FAILED,ON);
+ }
case MOTOR_CONFIG_KVAL_TVAL_RUN:
ConfigStages[_motorId]++;
@@ -672,6 +679,7 @@ uint32_t FPGA_MotorConfig_callback(TimerMotors_t _motorId, uint32_t ReadValue)
}
+
if((MotorDriverResponse[_motorId].DriverMode == Current) && (MotorDriverResponse[_motorId].DriverType == CombinrdMotDriver))
{
//in order use the same value as it is in L6472 (current limited to 4A instead of 10A in PowrStep01)
@@ -687,6 +695,11 @@ uint32_t FPGA_MotorConfig_callback(TimerMotors_t _motorId, uint32_t ReadValue)
break;
}
+ else
+ {
+ LOG_ERROR (_motorId,"kvalrun / tvalrun is Zero");
+ AlarmHandlingSetAlarm (EVENT_TYPE__MACHINE_STATE_HW_CONFIG_FAILED,ON);
+ }
case MOTOR_CONFIG_KVAL_TVAL_ACC:
ConfigStages[_motorId]++;
@@ -720,6 +733,11 @@ uint32_t FPGA_MotorConfig_callback(TimerMotors_t _motorId, uint32_t ReadValue)
break;
}
+ else
+ {
+ LOG_ERROR (_motorId,"kvalacc / tvalacc is Zero");
+ AlarmHandlingSetAlarm (EVENT_TYPE__MACHINE_STATE_HW_CONFIG_FAILED,ON);
+ }
case MOTOR_CONFIG_KVAL_TVAL_DEC:
ConfigStages[_motorId]++;
@@ -756,6 +774,12 @@ uint32_t FPGA_MotorConfig_callback(TimerMotors_t _motorId, uint32_t ReadValue)
break;
}
+ else
+ {
+ LOG_ERROR (_motorId,"kvaldec / tvaldec is Zero");
+ AlarmHandlingSetAlarm (EVENT_TYPE__MACHINE_STATE_HW_CONFIG_FAILED,ON);
+ }
+
case MOTOR_CONFIG_ST_SLP_T_FAST:
ConfigStages[_motorId]++;
input_value = 0;
@@ -781,6 +805,12 @@ uint32_t FPGA_MotorConfig_callback(TimerMotors_t _motorId, uint32_t ReadValue)
break;
}
+ else
+ {
+ LOG_ERROR (_motorId,"stslp / tfast is Zero");
+ AlarmHandlingSetAlarm (EVENT_TYPE__MACHINE_STATE_HW_CONFIG_FAILED,ON);
+ }
+
case MOTOR_CONFIG_INT_SPD:
ConfigStages[_motorId]++;
if(MotorsCfg[_motorId].intspd!=0)
@@ -816,6 +846,11 @@ uint32_t FPGA_MotorConfig_callback(TimerMotors_t _motorId, uint32_t ReadValue)
break;
}
+ else
+ {
+ LOG_ERROR (_motorId,"fnslpacc / tonmin is Zero");
+ AlarmHandlingSetAlarm (EVENT_TYPE__MACHINE_STATE_HW_CONFIG_FAILED,ON);
+ }
case MOTOR_CONFIG_FN_SLP_DEC_TOFF_MIN:
ConfigStages[_motorId]++;
@@ -842,14 +877,24 @@ uint32_t FPGA_MotorConfig_callback(TimerMotors_t _motorId, uint32_t ReadValue)
break;
}
+ else
+ {
+ LOG_ERROR (_motorId,"fnslpdec / toffmin is Zero");
+ AlarmHandlingSetAlarm (EVENT_TYPE__MACHINE_STATE_HW_CONFIG_FAILED,ON);
+ }
case MOTOR_CONFIG_OCD_TH:
ConfigStages[_motorId]++;
if(MotorsCfg[_motorId].overcurrentthreshold!=0)
{
temp = x_SET_PARAM | x_OCD_TH;
- temp = temp << 24;
- temp |= MotorsCfg[_motorId].overcurrentthreshold<<16;
+ temp = temp << 24;
+ if(MotorsCfg[_motorId].overcurrentthreshold == 0)
+ {
+ LOG_ERROR (_motorId,"OCD_TH is Zero");
+ AlarmHandlingSetAlarm (EVENT_TYPE__MACHINE_STATE_HW_CONFIG_FAILED,ON);
+ }
+ temp |= MotorsCfg[_motorId].overcurrentthreshold<<16;
if( MillisecWriteToMotor(_motorId, temp, 4, FPGA_MotorConfig_callback) < 0 ) return ERROR;
break;
}
@@ -860,6 +905,11 @@ uint32_t FPGA_MotorConfig_callback(TimerMotors_t _motorId, uint32_t ReadValue)
temp = x_SET_PARAM | x_STALL_TH;
temp = temp << 24;
temp |= MotorsCfg[_motorId].stallthreshold<<16;
+ if(MotorsCfg[_motorId].stallthreshold == 0)
+ {
+ LOG_ERROR (_motorId,"STALL_TH is Zero");
+ AlarmHandlingSetAlarm (EVENT_TYPE__MACHINE_STATE_HW_CONFIG_FAILED,ON);
+ }
if( MillisecWriteToMotor(_motorId, temp, 4, FPGA_MotorConfig_callback) < 0 ) return ERROR;
break;
}
@@ -1964,6 +2014,8 @@ uint32_t Power_Step_01_Mode(TimerMotors_t _motorId, MOTDRIVER_MODE New_Mode)
{
status = ERROR;
}
+
+ ReportWithPackageFilter(ControlFilter,"Change PowerStep01 mode", __FILE__,__LINE__,_motorId,RpMessage,New_Mode,0);
}
@@ -1971,3 +2023,14 @@ uint32_t Power_Step_01_Mode(TimerMotors_t _motorId, MOTDRIVER_MODE New_Mode)
}
+uint32_t Power_Step_01_Dispenser_Mode(uint8_t Dispenser_ID, MOTDRIVER_MODE New_Mode)
+{
+ uint32_t status = OK;
+
+ status = Power_Step_01_Mode(Dispenser_ID + HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_1, New_Mode);
+
+ return status;
+}
+
+
+
diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.h b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.h
index 5520cd4f0..42acd3e9e 100644
--- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.h
+++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.h
@@ -47,7 +47,7 @@ uint32_t Power_Step_01_Mode(TimerMotors_t _motorId, MOTDRIVER_MODE New_Mode);
void FPGA_SetMotPowerStep01GateCfg(TimerMotors_t _motorId);
void FPGA_SetGoToDirPosition(TimerMotors_t _motorId);//GoTo_DIR command
-uint32_t Power_Step_01_Mode(TimerMotors_t _motorId, MOTDRIVER_MODE New_Mode);
+uint32_t Power_Step_01_Dispenser_Mode(uint8_t Dispenser_ID, MOTDRIVER_MODE New_Mode);
extern bool Extended_Motor_Param;
diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.c
index 9839b1324..590cec568 100644
--- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.c
+++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.c
@@ -25,6 +25,7 @@
#include "drivers/ADC_Sampling/adc.h"
#include "ADC_MUX.h"
+#include "Modules/AlarmHandling/AlarmHandling.h"
bool MidTank_Pressure_Read_Enable[NUM_OF_MIDTANKS] = {true,true,true,true,true,true,true,true};
double MidTank_Pressure[NUM_OF_MIDTANKS] = {1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0};
@@ -243,6 +244,60 @@ double Calculate_MidTank_Liquid(uint32_t VsampleInBits, double Factor )//MidTan
return LiquidLitter;
}
+//Initial_Offset_A 2.5-3 [V] +-10%
+double Deafault_Initial_Offset_A = 2.5;//TBD
+double Max_Initial_Offset_A = 3.3;//TBD
+double Min_Initial_Offset_A = 2.25;//TBD
+//Slope_B 0.5 [Litter/Volts] +-10%
+double Deafault_Slope_B = 0.5;//TBD
+double Max_Slope_B = 0.6;//TBD
+double Min_Slope_B = 0.4;//TBD
+
+
+double Calc_Calibration_MidTank_Liquid(uint32_t VsampleInBits, MidTank_t MidTank_ID )
+{
+ double temp, VADC = 0.0 ,VSensor,LiquidLitter;
+ double Factor = 0.93;//Only for dispenser 8 (due to the material density)
+
+ //---- VBits -> VADC ----
+
+ //ADC 12 bit -> 4096 -> 2.5V
+
+ temp = VsampleInBits*2.5;
+ VADC = temp / 4096;
+
+ //---- VADC -> VSensor ---
+
+ //VADC = 1.96 - 10k( VSensor - 1.96) / 46.4k (from the electrical scheme)
+ // VSensor = 0 V -> VADC = 2.3824 V
+ // VSensor = 10 V -> VADC = 0.2272 V
+
+ VSensor = (1.96- VADC) * 4.64 + 1.96;
+
+ if( ( Initial_Offset_A[MidTank_ID] > Max_Initial_Offset_A) || ( Initial_Offset_A[MidTank_ID] < Min_Initial_Offset_A) ||
+ ( Slope_B[MidTank_ID] > Max_Initial_Offset_A) || ( Slope_B[MidTank_ID] < Min_Slope_B) )
+ {
+ temp = VSensor - Deafault_Initial_Offset_A;
+ LiquidLitter = temp * Deafault_Slope_B;
+ LOG_ERROR (MidTank_ID,"Wrong MidTank Calibration parameters");
+ }
+ else
+ {
+ temp = VSensor - Initial_Offset_A[MidTank_ID]; //Volt
+ LiquidLitter = temp * Slope_B[MidTank_ID]; //Litter
+ }
+
+ if(MidTank_ID == MIDTANK_8)
+ temp *= Factor;//Only for dispenser 8 (due to the material density)
+
+ if(LiquidLitter < 0)
+ LiquidLitter = 0;
+
+ return LiquidLitter;
+}
+
+
+
void Enable_MidTank_Pressure_Reading(MidTank_t MidTank_ID) //0-7
{
assert (MidTank_ID<NUM_OF_MIDTANKS);
@@ -322,6 +377,8 @@ double Read_MidTank_Pressure_Sensor(MidTank_t MidTank_ID) //0-7
MidTank_Pressure[MidTank_ID] = Calculate_MidTank_Liquid(VsampleInBits , Factor);//According to Gal (email 28-Aug-19)
+ //Calc_Calibration_MidTank_Liquid(VsampleInBits, MidTank_ID );
+
return MidTank_Pressure[MidTank_ID];
}
double Get_MidTank_Pressure_Sensor(MidTank_t MidTank_ID) //0-7
diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.h b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.h
index 9a1569098..e0aa9396f 100644
--- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.h
+++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.h
@@ -60,4 +60,5 @@ bool Get_Heaters_Current_Integer(HEATERS_CURRENT Heater_ID,int32_t* value );
uint32_t Read_Heaters_Current(HEATERS_CURRENT Heater_ID);
void ADC_MUX_Init();
+double Calc_Calibration_MidTank_Liquid(uint32_t VsampleInBits, MidTank_t MidTank_ID );
#endif /* DRIVERS_I2C_COMMUNICATION_ADC_MUX_ADC_MUX_H_ */
diff --git a/Software/Embedded_SW/Embedded/Modules/General/buttons.c b/Software/Embedded_SW/Embedded/Modules/General/buttons.c
index 3ffb63508..b44cba8b4 100644
--- a/Software/Embedded_SW/Embedded/Modules/General/buttons.c
+++ b/Software/Embedded_SW/Embedded/Modules/General/buttons.c
@@ -54,7 +54,7 @@ uint32_t joggingMachine( button *pBtn); //uint8_t OnOffPB,
uint32_t ButtonLoadCallBackFunction(uint32_t IfIndex, uint32_t ReadValue);
uint32_t ButtonLoadCBFunction(uint32_t IfIndex, uint32_t ReadValue);
uint32_t LoadStatMachine( button *pBtn);
-
+uint32_t LoadLongPress( button *pBtn);
/*
void Power_Reset();
@@ -63,6 +63,7 @@ uint8_t Buzzer(OPERATION_MODE Buzzer_Mode);
bool Read_PWR_Button();//TODO move to GPIO folder
*/
+#define LOADLONGPRESS 3
int PowerDown()
{
@@ -197,7 +198,7 @@ uint32_t ButtonJogCBFunction(uint32_t IfIndex, uint32_t ReadValue)
//setJoggingEnableCondition(&jog);
joggingMachine(&jog);
}
- return 0;
+ return OK;
}
@@ -208,13 +209,23 @@ uint32_t ButtonLoadCBFunction(uint32_t IfIndex, uint32_t ReadValue)
if ((load.bttn_status == release) && (ReadValue == press))
{
REPORT_MSG(parameter," ------------ Start thread loading empty function ----------------- ");
- load.bttn_status = press;
+ //load.bttn_status = press;
LoadStatMachine(&load);
-
+ load.count=1;
+ }
+ else if ((load.bttn_status == press) && (ReadValue == press) )
+ {
+ if (load.count == LOADLONGPRESS) // todo
+ {
+ load.count = 0;
+ LoadLongPress( &load );
+ }
+ else load.count++;
}
- else load.bttn_status = ReadValue;
- return 0;
+
+ load.bttn_status = ReadValue;
+ return OK;
}
/*---------------------------------------------------------------------------------*/
@@ -301,7 +312,7 @@ uint32_t ShortLongOffPB(uint8_t OnOffPB, button *pBtn)
default:
break;
}
- return 0;
+ return OK;
}
@@ -388,7 +399,7 @@ uint32_t StateMachine( button *pBtn) //short press(=0)/long press(=1)
default:
break;
}
-return 0;
+return OK;
}
@@ -520,7 +531,7 @@ uint32_t joggingMachine( button *pBtn) //uint8_t OnOffPB,
//
// }
// }
-return 0;
+return OK;
}
@@ -657,3 +668,9 @@ void test_avi()
}
+uint32_t LoadLongPress( button *pBtn)
+{
+
+ return OK;
+}
+
diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c
index 11ac84ea8..1baf9ceb9 100644
--- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c
+++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c
@@ -150,7 +150,7 @@ uint32_t IDS_HomeDispenserBackMoveCallback(uint32_t motorId, uint32_t ReadValue)
MotorStop(motorId,Hard_Hiz);
CurrentDispenserSpeed[DispenserId] = 0;
if (Extended_Motor_Param == true)
- Combined_dispenser_Driver_Mode(DispenserId,Voltage);
+ Power_Step_01_Dispenser_Mode(DispenserId,Voltage);
MotorSetMicroStep(motorId, KeepMicrostep[DispenserId]);
HomingActive[DispenserId]= false;
PrimingActive[DispenserId]= false;
@@ -226,7 +226,7 @@ uint32_t IDS_HomeDispenser (uint32_t DispenserId, uint32_t speed , callback_fptr
Control3WayValvesWithCallback ((Valves_t)DispenserId, MidTank_Dispenser, NULL); //direction: MidTank_Dispenser or Dispenser_Mixer
KeepMicrostep[DispenserId] = MotorsCfg[MotorId].microstep;
if (Extended_Motor_Param == true)
- Combined_dispenser_Driver_Mode(DispenserId,Current);
+ Power_Step_01_Dispenser_Mode(DispenserId,Current);
MotorSetMicroStep(MotorId, 1);
SysCtlDelay(180000);
//open dry air valve in the dispenser
@@ -253,7 +253,7 @@ uint32_t IDS_Dispenser_Alarm_On (uint8_t DispenserId)
Valve_Set(IDS_Id_to_AirValve[DispenserId], Atm_MidTank_OFF);
Enable_MidTank_Pressure_Reading(DispenserId);
if (Extended_Motor_Param == true)
- Combined_dispenser_Driver_Mode(DispenserId,Voltage);
+ Power_Step_01_Dispenser_Mode(DispenserId,Voltage);
status |= MotorSetMicroStep(MotorId, KeepMicrostep[DispenserId]);
status |= MotorStop(DispenserId, Hard_Hiz);
CurrentDispenserSpeed[DispenserId] = 0;
@@ -298,7 +298,7 @@ uint32_t IDS_StopHomeDispenser (uint32_t DispenserId)
}
PrimingActive[DispenserId] = false;
if (Extended_Motor_Param == true)
- Combined_dispenser_Driver_Mode(DispenserId,Voltage);
+ Power_Step_01_Dispenser_Mode(DispenserId,Voltage);
MotorSetMicroStep(MotorId, KeepMicrostep[DispenserId]);
CurrentDispenserSpeed[DispenserId] = 0;
CurrentDispenserSpeed[DispenserId] = 0;
@@ -373,7 +373,7 @@ uint32_t IDS_EmptyDispenserCallback(uint32_t motorId, uint32_t ReadValue)
MotorStop(motorId,Hard_Hiz);
CurrentDispenserSpeed[DispenserId] = 0;
if (Extended_Motor_Param == true)
- Combined_dispenser_Driver_Mode(DispenserId,Voltage);
+ Power_Step_01_Dispenser_Mode(DispenserId,Voltage);
MotorSetMicroStep(motorId, KeepMicrostep[DispenserId]);
PrimingActive[DispenserId]= false;
if (DispenserId == LUBRICANT_DISPENSER)
@@ -408,7 +408,7 @@ uint32_t IDS_EmptyDispenser (uint32_t DispenserId, uint32_t speed , callback_fpt
//open dispenser valve dispenser to midtank direction
Control3WayValvesWithCallback ((Valves_t)DispenserId, Dispenser_Mixer, NULL); //direction: MidTank_Dispenser or Dispenser_Mixer
if (Extended_Motor_Param == true)
- Combined_dispenser_Driver_Mode(DispenserId,Current);
+ Power_Step_01_Dispenser_Mode(DispenserId,Current);
//Valve_Set((Valves_t) request->index, Dispenser_Mixer);
KeepMicrostep[DispenserId] = MotorsCfg[MotorId].microstep;
MotorSetMicroStep(MotorId, 1);
diff --git a/Software/Embedded_SW/Embedded/Modules/IFS/ifs.h b/Software/Embedded_SW/Embedded/Modules/IFS/ifs.h
index ad66520ab..f00ba7849 100644
--- a/Software/Embedded_SW/Embedded/Modules/IFS/ifs.h
+++ b/Software/Embedded_SW/Embedded/Modules/IFS/ifs.h
@@ -22,7 +22,7 @@
#define CARTRIDGE_INK_TIMEOUTx2 (SECONDS_600 / SECONDS_5) /**< TimeOut (5 minutes) for second try finishing transfer the Ink from Ink cartridge to MidTank */
#define CartridgeInkTimeOutCallBackTime (eOneSecond * SECONDS_5)
#define CartridgeInkCallBackTime eOneSecond
-#define MidTank_Pressure_EMPTY 200 //todo get from Moti the correct number
+#define MidTank_Pressure_EMPTY 0.4 //todo get from Moti the correct number
#define CARTRIDGE_CAPATICY 1500 //todo get from Moti the correct number
#define FULL 1000 //todo get from Moti the correct number
diff --git a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_init.c b/Software/Embedded_SW/Embedded/Modules/Waste/Waste_init.c
index 3265fb56b..7796f09cf 100644
--- a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_init.c
+++ b/Software/Embedded_SW/Embedded/Modules/Waste/Waste_init.c
@@ -897,7 +897,8 @@ bool WasteTankCBFunction()
cart1.color = BLINK;
break;
}
- REPORT_MSG(WHS_full," ------------ close cartridge cover ----------------- ");
+#warning The messege removed (close cartridge cover)
+ //REPORT_MSG(WHS_full," ------------ close cartridge cover ----------------- ");
IFS_info.INK_isOK_flag = true; // 1
break;