aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules/Thread
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
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')
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c9
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h2
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c9
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c80
4 files changed, 58 insertions, 42 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
index 2b6d3aaea..6915cc657 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
@@ -180,7 +180,7 @@ double WinderReferenceSpeed=0;
int32_t TotalWinderSpeed=0;
uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag)
{
- uint32_t Steps,i;
+ uint32_t Steps;
double temp;
double screw_horizontal_speed = 0;
double RotationsPerSecond;
@@ -232,6 +232,7 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag)
}
screw_horizontal_speed = ScrewNumberOfSteps / InternalWinderCfg.NumberOfRotationPerPassage;
RotationsPerSecond = WinderReferenceSpeed / (double)MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].pulseperround;
+ ROM_IntMasterDisable();
ScrewSpeed = screw_horizontal_speed*RotationsPerSecond;
CurrentControlledSpeed[SCREW_MOTOR] = ScrewSpeed;
temp = SYS_CLK_FREQ;
@@ -239,6 +240,8 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag)
temp /= ScrewSpeed;
if (ScrewRunningTime != temp)
{
+ ScrewRunningTime = temp;//(SYS_CLK_FREQ*Steps)/ScrewSpeed;
+ ROM_IntMasterEnable();
//usnprintf(TempScrewStr, 100, "Winder: Horizon,Rotation, PPR, RPP{ %d, %d ,%d, %d} ",(int)screw_horizontal_speed,(int)RotationsPerSecond,(int)InternalWinderCfg.NumberOfRotationPerPassage,(int)MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].pulseperround);
usnprintf(ScrewStr, 100, "Winder: Steps,Speed, Time, WinderSpeed{ %d, %d ,%d, %d} ",(int)ScrewNumberOfSteps,(int)ScrewSpeed,(int)temp,(int)WinderReferenceSpeed);
// Report(logmsg[index],__FILE__,__LINE__,index,RpWarning,index, Counter[index]);
@@ -248,9 +251,9 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag)
//REPORT_MSG(temp , "new winder speed");
//Report("new winder speed",__FILE__,__LINE__,temp,RpWarning,ScrewSpeed,0);
}
- ScrewRunningTime = temp;//(SYS_CLK_FREQ*Steps)/ScrewSpeed;
/********************************************************************************/
+ ROM_IntMasterEnable();
return OK;
}
@@ -409,7 +412,7 @@ void ScrewTimerInterrupt(int ARG0)
{
TimerDisable(Screw_timerBase, TIMER_A);
}
- //Report("ScrewTimerInterrupt dir, duration, speed", __FILE__,ScrewCurrentDirection,ScrewRunningTime, RpMessage, ScrewSpeed, 0);
+ Report("ScrewTimerInterrupt dir, duration, speed", __FILE__,ScrewCurrentDirection,ScrewRunningTime, RpMessage, ScrewSpeed, 0);
//
// Enable all interrupts.
//
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h
index c5e3edc85..34be77177 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h
@@ -29,7 +29,7 @@ uint32_t ThreadConfigBreakSensor(void *request);
uint32_t ThreadGetMotorSpeed(threadMotorsEnum MotorId);
double ThreadGetMotorCalculatedError(int DancerId);
uint32_t ThreadPrepareState(void *JobDetails);
-uint32_t ThreadPreSegmentState(void *JobDetails);
+uint32_t ThreadPreSegmentState(void *JobDetails, uint32_t SegmentId);
uint32_t ThreadSegmentState(void *JobDetails, int SegmentId);
uint32_t ThreadDistanceToSpoolState(void);
uint32_t ThreadEndState(void *JobDetails);
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c
index 41daa4002..f641737ee 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c
@@ -21,8 +21,10 @@ double NormalizedErrorCoEfficient[MAX_THREAD_MOTORS_NUM] = {0};
int DancerStopActivityLimit[MAX_THREAD_MOTORS_NUM] = {0};
HardwareDancer DancersCfg[MAX_SYSTEM_DANCERS] = {0};
+#define BREAK_SENSOR_LIMIT 10
+
bool BreakSensorenabled;
-int32_t BreakSensordebouncetimemilli;
+int32_t BreakSensordebouncetimemilli = BREAK_SENSOR_LIMIT;
HardwarePidControlType ThreadMotorIdToControlId[MAX_THREAD_MOTORS_NUM] = {HARDWARE_PID_CONTROL_TYPE__MotorFeeder,HARDWARE_PID_CONTROL_TYPE__MotorDryer,HARDWARE_PID_CONTROL_TYPE__MotorPooler,HARDWARE_PID_CONTROL_TYPE__MotorWinder,0};
@@ -116,7 +118,10 @@ uint32_t ThreadConfigBreakSensor(void *request)
if (SensorCfg)
{
BreakSensorenabled = SensorCfg->enabled;
- BreakSensordebouncetimemilli = SensorCfg->debouncetimemilli;
+ if (SensorCfg->debouncetimemilli)
+ {
+ BreakSensordebouncetimemilli = SensorCfg->debouncetimemilli;
+ }
return OK;
}
return ERROR;
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)