diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2018-07-08 18:58:19 +0300 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2018-07-08 18:58:19 +0300 |
| commit | 01313ef571f4ca7376c8579db38d83a892360e0a (patch) | |
| tree | 15d6365e9ae738268fffe3cd69797c4798393a36 /Software/Embedded_SW/Embedded/Modules/Thread | |
| parent | a2cf6c8d62083a63ee193a1cd206ab345368b242 (diff) | |
| download | Tango-01313ef571f4ca7376c8579db38d83a892360e0a.tar.gz Tango-01313ef571f4ca7376c8579db38d83a892360e0a.zip | |
some debug info
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Thread')
| -rw-r--r-- | Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index cfff7773b..f91c2a733 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -122,8 +122,8 @@ void ThreadUpdateProcessLength (double length, void *Funcptr) ProcessedLengthFuncPtr = (ProcessedLengthFunc)Funcptr; initialpos = 0xFFFF; } -double MotorSentData[1000] = {0}; -uint32_t PosDif[1000] = {0}; +double MotorSentData[100] = {0}; +uint32_t PosDif[100] = {0}; int MotorDataIndex = 0; @@ -175,7 +175,7 @@ uint32_t ThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue) //PosDif[MotorDataIndex] = positionDiff; MotorSentData[MotorDataIndex] = length; MotorDataIndex+=1; - if (MotorDataIndex == 999) MotorDataIndex = 0; + if (MotorDataIndex == 99) MotorDataIndex = 0; static int pooler_counter = 0; pooler_counter++; if (pooler_counter%10 == 0) @@ -248,6 +248,12 @@ uint32_t ThreadControlSpeedReadFunction(uint32_t IfIndex, uint32_t ReadValue) } return OK; } +double calculatedError[1000]; +int readValue[1000]; +int calculatedspeed[1000]; +int controlIndex = 0; +int32_t KeepReadValue = 0; + uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) { //#define MAX_CONTROL_SAMPLES 6 @@ -259,6 +265,7 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) int DancerId; static int pooler_counter = 0; int32_t TranslatedReadValue, avreageSampleValue = 0; + double tempcalcspeed = 0; uint32_t calculated_speed; double NormalizedError; char Message[60]; @@ -324,10 +331,26 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) MotorControlConfig[index].m_calculatedError = PIDAlgorithmCalculation((float)MotorControlConfig[index].m_SetParam , (float)MotorControlConfig[index].m_mesuredParam, &MotorControlConfig[index].m_params, &MotorControlConfig[index].m_preError, &MotorControlConfig[index].m_integral); if (index != FEEDER_MOTOR) //feeder unit handles errors opposite to left unit + { MotorControlConfig[index].m_calculatedError = (-1*MotorControlConfig[index].m_calculatedError); + } else - KeepNormalizedError = NormalizedError; + { + //KeepNormalizedError = NormalizedError; + } calculated_speed = (1-MotorControlConfig[index].m_calculatedError)*OriginalMotorSpd_2PPS[index]; + if (index == POOLER_MOTOR) + { + if (KeepReadValue != TranslatedReadValue) + { + calculatedError[controlIndex] = MotorControlConfig[index].m_calculatedError; + readValue[controlIndex] = TranslatedReadValue; + calculatedspeed[controlIndex] = calculated_speed; + controlIndex++; + if (controlIndex >= 999) controlIndex = 0; + KeepReadValue = TranslatedReadValue; + } + } if (abs(calculated_speed-CurrentControlledSpeed[index])>5) { CurrentControlledSpeed[index] = calculated_speed; @@ -489,7 +512,13 @@ uint32_t ThreadPreSegmentState(void *JobDetails) float process_speed; if (JobTicket->processparameters) - process_speed= JobTicket->processparameters->dyeingspeed; + if (JobTicket->processparameters->dyeingspeed) + process_speed= JobTicket->processparameters->dyeingspeed; + else + { + LOG_ERROR (-1," unknown job speed"); + return ERROR; + } SetOriginMotorSpeed(process_speed); //ControlStart(); |
