aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2019-05-02 14:40:11 +0300
committerShlomo Hecht <shlomo@twine-s.com>2019-05-02 14:40:11 +0300
commit25011c65a3081d256a6ae4672f737d51bc3c7464 (patch)
tree0c03b50e022af29553c4f001b6ada7710b79c5a5 /Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
parent35bc11b0c67ed1fdd8fd1ddc0a6a94f5258de141 (diff)
downloadTango-25011c65a3081d256a6ae4672f737d51bc3c7464.tar.gz
Tango-25011c65a3081d256a6ae4672f737d51bc3c7464.zip
fix job length bug. read screw encoder. better logging in IDS
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c')
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
index d65156066..937ae63b7 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
@@ -54,6 +54,9 @@ uint32_t ScrewControlId = 0xFF;
InternalWinderConfigStruc InternalWinderCfg = {0};
+uint32_t ScrewLocationLimitSwitch = 0,ScrewLocationStart = 0;
+uint32_t ScrewLocationRun[3];
+
uint32_t Winder_Init(void)
{
ScrewTimerInterruptInit();
@@ -109,6 +112,10 @@ uint32_t Winder_Prepare(void)
AlarmHandlingSetAlarm(EVENT_TYPE__WINDER_CONE_DOES_NOT_EXIST,true);
return ERROR;
}*/
+
+ ScrewLocationRun[0] = 0;
+ ScrewLocationRun[1] = 0;
+
if (FPGA_Read_limit_Switches(GPI_LS_SCREW_RIGHT)==LIMIT)
{
//REPORT_MSG(LIMIT, "Winder_Prepare at limit");
@@ -136,6 +143,11 @@ uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue)
//MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,InternalWinderCfg.segmentoffsetpulses);
//REPORT_MSG(numOfSteps, "Winder_PrepareStage2");
+ Read_Screw_Encoder();
+ ScrewLocationLimitSwitch = Screw_RotEnc.Position;
+ REPORT_MSG(ScrewLocationLimitSwitch, "Winder_PrepareStage2 Encoder Location");
+
+
REPORT_MSG(millisecondCounter/*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].maxfrequency*/, "Winder_PrepareStage2");
if (ReadValue != LIMIT)
{
@@ -157,7 +169,13 @@ uint32_t Winder_ScrewAtOffsetCallback(uint32_t deviceID, uint32_t BusyFlag)
//SetMotHome(HARDWARE_MOTOR_TYPE__MOTO_SCREW); //set this point as the spool home
//MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,temp_MaxFrequency);
+ Read_Screw_Encoder();
+ ScrewLocationStart = Screw_RotEnc.Position;
+
+ REPORT_MSG(ScrewLocationStart, "Winder_ScrewAtOffsetCallback Encoder Location");
+
ScrewCurrentDirection = false;
+ ScrewLocationRun[ScrewCurrentDirection] = Screw_RotEnc.Position;
ScrewSpeed = 0;
ScrewControlId = 0xFF;
ScrewNumberOfSteps = 0;
@@ -230,6 +248,10 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag)
ScrewCurrentDirection = 1-ScrewCurrentDirection;
CalculationDirectionChangeCounter++;
+ //REPORT_MSG(ScrewLocationRun[1] - ScrewLocationRun[0], "Screw Run NumberOfSteps");
+ usnprintf(ScrewStr, 100, "Winder Encoder: 0 0x%x 1 0x%x diff %d ",ScrewLocationRun[0],ScrewLocationRun[1],abs(ScrewLocationRun[1] - ScrewLocationRun[0]));
+ //usnprintf(ScrewStr, 100, "Winder Encoder: 0 %d 1 %d diff %d ",ScrewLocationRun[0],ScrewLocationRun[1],ScrewLocationRun[1] - ScrewLocationRun[0]);
+ Report(ScrewStr,__FILE__,__LINE__,ScrewLocationLimitSwitch,RpWarning,ScrewLocationStart, 0);
if (ScrewCurrentDirection == 1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize) //next time going out
{
@@ -288,7 +310,7 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag)
//Report(TempScrewStr,__FILE__,__LINE__,0,RpWarning,0, 0);
//Report(ScrewStr,__FILE__,__LINE__,ScrewCurrentDirection,RpWarning,CalculationDirectionChangeCounter, 0);
//REPORT_MSG(temp , "new winder speed");
- Report("new winder speed",__FILE__,ScrewNumberOfSteps,temp,RpWarning,ScrewSpeed,0);
+ //Report("new winder speed",__FILE__,ScrewNumberOfSteps,temp,RpWarning,ScrewSpeed,0);
}
/********************************************************************************/
@@ -440,6 +462,9 @@ void ScrewTimerInterrupt(int ARG0)
ROM_TimerIntClear(Screw_timerBase, TIMER_TIMA_TIMEOUT); // Clear the timer interrupt
ROM_IntMasterDisable();
+ Read_Screw_Encoder();
+ ScrewLocationRun[ScrewCurrentDirection] = Screw_RotEnc.Position;
+
if (SCREW_TimerActivated == true)
{
ROM_TimerLoadSet(Screw_timerBase, TIMER_A,(int)ScrewRunningTime);
@@ -455,13 +480,7 @@ void ScrewTimerInterrupt(int ARG0)
}
ROM_IntMasterEnable();
Rotations+=0.03;
- /*random++;
- if (random >= 2)
- random = -1;*/
- //Report("ScrewTimerInterrupt dir, duration, speed", __FILE__,ScrewCurrentDirection,ScrewRunningTime, RpMessage, ScrewSpeed, 0);
- //
- // Enable all interrupts.
- //
+
return ;
}