aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules/Thread
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2018-10-17 16:38:13 +0300
committerAvi Levkovich <avi@twine-s.com>2018-10-17 16:38:13 +0300
commit78a2d97b5a33b81c51cd8069056e3e3179aeb549 (patch)
tree241ea08041cfa6642a661b8dadf1e863eb183c5e /Software/Embedded_SW/Embedded/Modules/Thread
parentda9f683c50c5c8ec4ad6b1e654f0cc487e1bcc0f (diff)
parentc3424087c9a2aff7f509f9c866d151945633a382 (diff)
downloadTango-78a2d97b5a33b81c51cd8069056e3e3179aeb549.tar.gz
Tango-78a2d97b5a33b81c51cd8069056e3e3179aeb549.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Thread')
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c2
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h1
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c72
3 files changed, 38 insertions, 37 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
index ccc9623a3..c7dd4f7ae 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
@@ -107,7 +107,7 @@ uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue)
uint32_t status=OK;
uint32_t numOfSteps = InternalWinderCfg.startoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep;
- MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].maxfrequency);
+ MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,InternalWinderCfg.segmentoffsetpulses);
//REPORT_MSG(numOfSteps, "Winder_PrepareStage2");
REPORT_MSG(MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].maxfrequency, "Winder_PrepareStage2");
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h
index 2961bd105..c5e3edc85 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h
@@ -27,6 +27,7 @@ uint32_t InternalWindingConfigMessage(JobSpool* request);
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 ThreadSegmentState(void *JobDetails, int SegmentId);
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
index 023e0dfc8..54309a187 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
@@ -14,7 +14,6 @@
#include "PMR/Hardware/HardwareDancerType.pb-c.h"
#include "PMR/Printing/JobSegment.pb-c.h"
#include "PMR/Printing/JobTicket.pb-c.h"
-#include "PMR/common/ErrorCode.pb-c.h"
#include <PMR/Diagnostics/EventType.pb-c.h>
#include <utils/ustdlib.h>
@@ -71,10 +70,12 @@ double TotalProcessedLength = 0.0;
double LengthCalculationMultiplier;
uint32_t PoolerPreviousPosition = 0, PoolerCurrentPosition = 0;
-double PoolerCurrentProcessedLength = 0.0;
double PoolerTotalProcessedLength = 0.0;
double PoolerLengthCalculationMultiplier;
+double TempPoolerTotalProcessedLength = 0.0;
+double TempTotalProcessedLength = 0.0;
+
bool PrepareState = false;
int CurrentSegmentId = 0;
typedef void (* ProcessedLengthFunc)(void);
@@ -133,17 +134,16 @@ void ThreadUpdateProcessLength (double length, void *Funcptr)
{
CurrentRequestedLength = length*100;//Centimetres
CurrentProcessedLength = 0;
- PoolerCurrentProcessedLength = 0;
ProcessedLengthFuncPtr = (ProcessedLengthFunc)Funcptr;
initialpos = 0xFFFF;
Poolerinitialpos = 0xFFFF;
}
-
+char Lenstr[150];
uint32_t ThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue)
{
uint32_t positionDiff = 0;
double length = 0.0;
- char str[150];
+
int index = MAX_THREAD_MOTORS_NUM;
// if (ThreadControlActive == false)
// return OK;
@@ -185,14 +185,15 @@ uint32_t ThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue)
static int pooler_counter = 0;
pooler_counter++;
TotalProcessedLength+= (length/100);
+ TempTotalProcessedLength = TotalProcessedLength;
if (pooler_counter%10 == 0)
{
if (PrepareState == true)
{
//later - add temperatures
- TemperatureListString(str);
+ TemperatureListString(Lenstr);
- SendJobProgress(0.0,0,false, str);
+ SendJobProgress(0.0,0,false, Lenstr);
}
else
{
@@ -202,9 +203,9 @@ uint32_t ThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue)
}
if (CurrentProcessedLength>=CurrentRequestedLength )
{
- usnprintf(str, 100, "Total processed length: Feeder: %d Pooler %d",(int)TotalProcessedLength,(int)PoolerTotalProcessedLength);
- SendJobProgress(0.0,0,false, str);
- Report(str,__FILE__,__LINE__,(int)TotalProcessedLength,RpWarning,(int)PoolerTotalProcessedLength,0);
+ usnprintf(Lenstr, 100, "Total processed length: Feeder: %d Pooler %d",(int)TotalProcessedLength,(int)PoolerTotalProcessedLength);
+ SendJobProgress(0.0,0,false, Lenstr);
+ Report(Lenstr,__FILE__,__LINE__,(int)TotalProcessedLength,RpWarning,(int)PoolerTotalProcessedLength,0);
// segment/intersegment/distance to spool finished
if (ProcessedLengthFuncPtr)
ProcessedLengthFuncPtr();
@@ -248,7 +249,8 @@ uint32_t PoolerThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue)
PoolerPreviousPosition = PoolerCurrentPosition;
length = (double)(positionDiff)*PoolerLengthCalculationMultiplier;
- PoolerCurrentProcessedLength+=length;
+ PoolerTotalProcessedLength+= (length/100);
+ TempPoolerTotalProcessedLength = PoolerTotalProcessedLength;
return OK;
}
@@ -311,14 +313,14 @@ uint32_t ThreadControlSpeedReadFunction(uint32_t IfIndex, uint32_t ReadValue)
}
return OK;
}
-double calculatedError[1000];
//double eNormalizedError[100];
+//int TranslatedreadValue[100];
+/*double calculatedError[1000];
int MotorId[1000];
int readValue[1000];
-//int TranslatedreadValue[100];
int AveragereadValue[1000];
int calculatedspeed[1000];
-int timestamp[1000];
+int timestamp[1000];*/
int controlIndex = 0;
bool keepdata = true;
/*int32_t KeepReadValue = 0;
@@ -440,7 +442,7 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue)
usnprintf(Message, 60, "Dancer %d limit %d value %d Zero %d",DancerId,DancerStopActivityLimit[index],avreageSampleValue,DancersCfg[DancerId].zeropoint);
//JobAbortedByUser = true;
ThreadControlActive = false;
- JobEndReason = JOB_WINDER_DANCER_FAIL+index;
+ JobEndReason = JOB_WINDER_DANCER_FAIL+DancerId;
SendJobProgress(0.0,0,false, Message);
//EndState(CurrentJob,Message );
SegmentReady(Module_Thread,ModuleFail);
@@ -462,36 +464,19 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue)
//KeepNormalizedError = NormalizedError;
}
calculated_speed = (1-MotorControlConfig[index].m_calculatedError)*OriginalMotorSpd_2PPS[index];
- /*if (index == FEEDER_MOTOR)
- {
- if (KeepReadValue != TranslatedReadValue)
- {
- eNormalizedError[controlIndex] = NormalizedError;
- calculatedError[controlIndex] = MotorControlConfig[index].m_calculatedError;
- readValue[controlIndex] = ReadValue;
- TranslatedreadValue[controlIndex] = TranslatedReadValue;
- AveragereadValue[controlIndex] = avreageSampleValue;
- calculatedspeed[controlIndex] = calculated_speed;
- controlIndex++;
- if (controlIndex >= 99) controlIndex = 0;
- KeepReadValue = TranslatedReadValue;
- }
- }*/
if (abs(calculated_speed-CurrentControlledSpeed[index])>2)
{
- if (keepdata == true)
+ /*if (keepdata == true)
{
calculatedError[controlIndex] = MotorControlConfig[index].m_calculatedError;
- //double eNormalizedError[100];
MotorId[controlIndex] = index;
readValue[controlIndex] = ReadValue;
- //int TranslatedreadValue[100];
AveragereadValue[controlIndex] = avreageSampleValue;
calculatedspeed[controlIndex] = calculated_speed;
timestamp[controlIndex] = HibernateRTCSSGet();
if (controlIndex++>=999)
controlIndex = 0;
- }
+ }*/
CurrentControlledSpeed[index] = calculated_speed;
MotorSetSpeed(ThreadMotorIdToMotorId[index], calculated_speed);
}
@@ -508,6 +493,21 @@ uint32_t ThreadGetMotorSpeed(threadMotorsEnum MotorId)
{
return CurrentControlledSpeed[MotorId];
}
+//********************************************************************************************************************
+double ThreadGetMotorCalculatedError(int DancerId)
+{
+ switch (DancerId)
+ {
+ case FEEDER_DANCER:
+ return (double)MotorControlConfig[FEEDER_MOTOR].m_calculatedError;
+ case POOLER_DANCER:
+ return (double)MotorControlConfig[POOLER_MOTOR].m_calculatedError;
+ case WINDER_DANCER:
+ return (double)MotorControlConfig[WINDER_MOTOR].m_calculatedError;
+
+ }
+ return 0;
+}
//********************************************************************************************************************
uint32_t ThreadInitialTestStub(HardwareMotor * request)
@@ -579,7 +579,7 @@ uint32_t ThreadEmptyCBFunction(uint32_t IfIndex, uint32_t ReadValue)
PoolerSpeedControlId = 0xFF;
}
//SetMotHome(ThreadMotorIdToMotorId[Motor_i]);
- LengthCalculationMultiplier = (MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].pulleyradius*2*PI)/(MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].pulseperround*MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].microstep);
+ PoolerLengthCalculationMultiplier = (MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].pulleyradius*2*PI)/(MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].pulseperround*MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].microstep);
PoolerSpeedControlId = AddControlCallback(PoolerThreadLengthCBFunction, eHundredMillisecond,MotorGetPositionFromFPGA,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToMotorId[Motor_i],Motor_i);
}
if (Motor_i == FEEDER_MOTOR) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will not be controlled
@@ -737,7 +737,7 @@ char Endstr[150];
int Motor_i;
ThreadControlActive = false;
- usnprintf(Endstr, 100, "Total processed length: Feeder: %d Pooler %d",(int)TotalProcessedLength,(int)PoolerTotalProcessedLength);
+ usnprintf(Endstr, 100, "Total _processed length: Feeder: %d Pooler %d",(int)TotalProcessedLength,(int)PoolerTotalProcessedLength);
SendJobProgress(0.0,0,false, Endstr);
Report(Endstr,__FILE__,__LINE__,(int)TotalProcessedLength,RpWarning,(int)PoolerTotalProcessedLength,0);