aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2018-12-20 15:07:17 +0200
committerShlomo Hecht <shlomo@twine-s.com>2018-12-20 15:07:17 +0200
commit4554080793bd46fcb8f55578d2f67917584dc332 (patch)
tree080d2f35589a41703dbc79518568b5aaa7a500fd /Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
parent0b638c292d3d8e95fdad56eed1b5b38523c6dc33 (diff)
downloadTango-4554080793bd46fcb8f55578d2f67917584dc332.tar.gz
Tango-4554080793bd46fcb8f55578d2f67917584dc332.zip
Version 1.3.0.5: break sensor debounce (10 msec default). temperature spikes ignored in heating control. thread winding improved.
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c')
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c80
1 files changed, 44 insertions, 36 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
index 0e0a9f987..72391e3a9 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
@@ -355,6 +355,8 @@ void testDancersControl()
bool dancerinvalid = false;
int MotorFailedSample[MAX_THREAD_MOTORS_NUM] = {0,0,0,0,0};
char Message[60];
+uint16_t BreakSensorCounter = 0;
+uint16_t BreakSensorLatchCounter = 0;
uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue)
{
//#define MAX_CONTROL_SAMPLES 6
@@ -425,16 +427,29 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue)
{
if (ReadBreakSensor()==ERROR)
{
- //consider applying the debouce parameters later
- //BreakSensordebouncetimemilli
- JobEndReason = JOB_THREAD_BREAK;
- ThreadControlActive = false;
- SendJobProgress(0.0,0,false, "ReadBreakSensor Error");
- SegmentReady(Module_Thread,ModuleFail);
- AlarmHandlingSetAlarm(EVENT_TYPE__ThreadBreak,true);
- //EndState(CurrentJob,"ReadBreakSensor Error" );
- LOG_ERROR(index, "ReadBreakSensor Error");
- return OK;
+ BreakSensorCounter++;
+ BreakSensorLatchCounter++;
+ if (BreakSensorCounter>=BreakSensordebouncetimemilli)
+ {
+ //consider applying the debouce parameters later
+ //BreakSensordebouncetimemilli
+ JobEndReason = JOB_THREAD_BREAK;
+ ThreadControlActive = false;
+ SendJobProgress(0.0,0,false, "ReadBreakSensor Error");
+ SegmentReady(Module_Thread,ModuleFail);
+ AlarmHandlingSetAlarm(EVENT_TYPE__ThreadBreak,true);
+ //EndState(CurrentJob,"ReadBreakSensor Error" );
+ LOG_ERROR(index, "ReadBreakSensor Error");
+ return OK;
+ } //passed limit
+ }//ReadBreakSensor()==ERROR
+ else //reset counter - we are looking for consequent calls
+ {
+ if (BreakSensorCounter)
+ {
+ LOG_ERROR(BreakSensorCounter, "ReadBreakSensor Spike");
+ }
+ BreakSensorCounter = 0;
}
}
}
@@ -525,7 +540,7 @@ uint32_t ThreadInitialTestStub(HardwareMotor * request)
//MotorsConfigMessage(request);
ThreadPrepareState(request);
- ThreadPreSegmentState(request);
+ ThreadPreSegmentState(request,0);
return OK;
}
bool InitialProcess = false;
@@ -659,7 +674,7 @@ void SetOriginMotorSpeed(float process_speed)
}
//********************************************************************************************************************
-uint32_t ThreadPreSegmentState(void *JobDetails)
+uint32_t ThreadPreSegmentState(void *JobDetails, uint32_t SegmentId)
{
//set the speed only before the first segment, speed is constant across all job segments and intersegments
JobTicket* JobTicket = JobDetails;
@@ -671,32 +686,25 @@ uint32_t ThreadPreSegmentState(void *JobDetails)
return ERROR;
}
REPORT_MSG (dyeingspeed," ThreadPreSegmentState");
-
- SetOriginMotorSpeed(process_speed);
- ThreadControlActive = true;
- PrepareState = false;
- // set the new speed in the dryer motor to the speed of the new segment
- MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING, OriginalMotorSpd_2PPS[DRYER_MOTOR]);
- //only for testing - when control works, these motors will take their speed from the dryer
- //MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_LDRIVING, OriginalMotorSpd_2PPS[POOLER_MOTOR]);
- //only for testing - when control works, these motors will take their speed from the dryer
- //MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_RDRIVING, OriginalMotorSpd_2PPS[FEEDER_MOTOR]);
-
-//#warning rocker disabled
- if (MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].maxfrequency > 0)
+ if (SegmentId == 0) // do all this only in the beginning of the job. do not touch after that (assuming spool does not change mid job)
{
- MotorSetDirection((TimerMotors_t)HARDWARE_MOTOR_TYPE__MOTO_RLOADING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].directionthreadwize);
- MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, 1);
- }
- if (MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].maxfrequency > 0)
- {
- MotorSetDirection((TimerMotors_t)HARDWARE_MOTOR_TYPE__MOTO_LLOADING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].directionthreadwize);
- MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, 1);
- }
-// #warning rocker disabled
-
-// MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RDRIVING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDRIVING].directionthreadwize, 0, GPI_LS_RLOADMOTOR_UP, EndState); //TODO
+ SetOriginMotorSpeed(process_speed);
+ ThreadControlActive = true;
+ PrepareState = false;
+ // set the new speed in the dryer motor to the speed of the new segment
+ MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING, OriginalMotorSpd_2PPS[DRYER_MOTOR]);
+ if (MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].maxfrequency > 0)
+ {
+ MotorSetDirection((TimerMotors_t)HARDWARE_MOTOR_TYPE__MOTO_RLOADING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].directionthreadwize);
+ MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, 1);
+ }
+ if (MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].maxfrequency > 0)
+ {
+ MotorSetDirection((TimerMotors_t)HARDWARE_MOTOR_TYPE__MOTO_LLOADING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].directionthreadwize);
+ MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, 1);
+ }
+ }
// activate control fr all motors
//set speed for both rocker motors
//wait for all motors to get to the required speed (set the target speed for the control to check)