aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2018-06-13 09:45:52 +0300
committerAvi Levkovich <avi@twine-s.com>2018-06-13 09:45:52 +0300
commit0d5c2e03b1f0e06cd307eaa2d5b7eaab894126d5 (patch)
tree19119cd31ed779383beafbd12c32424baf5c1f3b /Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
parent2d900a86cae2027dc43d73e92da889d6e1aa3f7b (diff)
downloadTango-0d5c2e03b1f0e06cd307eaa2d5b7eaab894126d5.tar.gz
Tango-0d5c2e03b1f0e06cd307eaa2d5b7eaab894126d5.zip
update I2C
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c')
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c39
1 files changed, 10 insertions, 29 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
index 56e1bf844..92bfa9c92 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
@@ -22,7 +22,6 @@
#include "drivers/Heater/TemperatureSensor.h"
#include "drivers/Heater/Heater.h"
#include "drivers/Motors/Motor.h"
-#include "drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h"
#include "modules/heaters/heaters.h"
////////////////////////////////State machine operation////////////////////////////////////
@@ -38,7 +37,7 @@ uint32_t ControlIdtoMotorId [MAX_THREAD_MOTORS_NUM] = {0xFF};
uint32_t SpeedControlId=0xFF;
int OriginalMotorSpd_2PPS[MAX_THREAD_MOTORS_NUM] = {0};
-uint32_t JobCounter = 0;
+
typedef struct
{
bool m_isEnabled;
@@ -67,8 +66,6 @@ ProcessedLengthFunc ProcessedLengthFuncPtr = NULL;
void ThreadSegmentEnded(void);
void ThreadInterSegmentEnded(void);
void ThreadDistanceToSpoolEnded(void);
-
-double KeepNormalizedError = 0;
////////////////////////Slow Motor State////////////////////////////////////
//uint32_t ThreadPreSegmentState(void *JobDetails);
@@ -168,7 +165,7 @@ uint32_t ThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue)
#warning control disabled
CurrentProcessedLength+=length;
-
+#warning control disabled
PosDif[MotorDataIndex] = CurrentPosition;
//PosDif[MotorDataIndex] = positionDiff;
MotorSentData[MotorDataIndex] = length;
@@ -179,9 +176,7 @@ uint32_t ThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue)
pooler_counter++;
if (pooler_counter%10 == 0)
{
- //SendJobProgress(CurrentProcessedLength/CurrentRequestedLength,CurrentSegmentId,false);
- SendJobProgress(/*KeepNormalizedError*/MotorControlConfig[index].m_calculatedError,CurrentSegmentId,false);
-
+ SendJobProgress(CurrentProcessedLength/CurrentRequestedLength,CurrentSegmentId,false);
}
if (pooler_counter>=100)
{
@@ -192,6 +187,8 @@ uint32_t ThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue)
}
if (CurrentProcessedLength>=CurrentRequestedLength )
{
+ SendJobProgress(100,0,true);
+ #warning handle job wit several segments!!!
// segment/intersegment/distance to spool finished
if (ProcessedLengthFuncPtr)
ProcessedLengthFuncPtr();
@@ -283,14 +280,10 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue)
{
DancerId = ThreadMotorIdToDancerId[index];
if (ReadValue < 10)
- return OK;
+ return;
TranslatedReadValue = ReadValue - DancersCfg[DancerId].zeropoint;
- if (index == POOLER_MOTOR)
- {
- //pooler dancer is right sided: data is opposite
+ if (index == POOLER_MOTOR) //pooler dancer is right sided: data is opposite
TranslatedReadValue = (-1*TranslatedReadValue);
- JobCounter++;
- }
//TranslatedReadValue = 0;//test
MotorSamples[index][MotorSamplePointer[index]] = TranslatedReadValue;//(-1 * TranslatedReadValue);
MotorSamplePointer[index]++;
@@ -298,20 +291,12 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue)
for (i=0;i<MotorsControl[index].pvinputfilterfactormode;i++)
avreageSampleValue += MotorSamples[index][i];
avreageSampleValue = avreageSampleValue / MotorsControl[index].pvinputfilterfactormode;
- //Stop Execution if the dancer moves too much
-#warning need to disable this in the first second of the job execution
- if ((abs(avreageSampleValue)> DancerStopActivityLimit[index])&&(JobCounter > eOneSecond))
- {
- EndState(CurrentJob);
- }
NormalizedError = avreageSampleValue*NormalizedErrorCoEfficient[index];
MotorControlConfig[index].m_mesuredParam = NormalizedError;
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
+ if (index == FEEDER_MOTOR) //feeder unit handles errors opposite to left unit
MotorControlConfig[index].m_calculatedError = (-1*MotorControlConfig[index].m_calculatedError);
- else
- KeepNormalizedError = NormalizedError;
calculated_speed = (1-MotorControlConfig[index].m_calculatedError)*OriginalMotorSpd_2PPS[index];
if (abs(calculated_speed-CurrentControlledSpeed[index])>5)
{
@@ -324,7 +309,7 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue)
pooler_counter++;
if (pooler_counter>=1000)
{
- //float error_integered = MotorControlConfig[index].m_calculatedError*1000;
+ float error_integered = MotorControlConfig[index].m_calculatedError*1000;
/*{
"HeaterGroupId": 0,
"Zone1Temp": 80,
@@ -339,7 +324,7 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue)
}*/
//HeatingTestSendResonse(0, false,true,true, MotorDriverRequest[22].Speed,MotorDriverRequest[18].Speed,MotorDriverRequest[15].Speed,MotorDriverRequest[3].Speed, "MotorSpeed");
- HeatingTestSendResonse(0, false,true,true, /*OriginalMotorSpd_2PPS[index]*/_speed,OriginalMotorSpd_2PPS[index]/*(int)error_integered*/,MotorControlConfig[index].m_calculatedError,ReadValue, "FeederSpeed");
+ HeatingTestSendResonse(0, false,true,true, /*OriginalMotorSpd_2PPS[index]*/_speed,OriginalMotorSpd_2PPS[index]/*(int)error_integered*/,calculated_speed,ReadValue, "FeederSpeed");
pooler_counter = 0;
}
}
@@ -365,8 +350,6 @@ bool InitialProcess = false;
{
int Motor_i, HW_Motor_Id, Pid_Id;
CurrentSegmentId = 0;
-
- JobCounter = 0;
//start thread control for all motors
for (Motor_i = 0;Motor_i < MAX_THREAD_MOTORS_NUM;Motor_i++)
{
@@ -492,7 +475,6 @@ uint32_t ThreadPreSegmentState(void *JobDetails)
MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, 10);
//#warning rocker disabled
-// MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RDRIVING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDRIVING].directionthreadwize, 0, GPI_LS_RLOADMOTOR_UP, EndState); //TODO
// activate control fr all motors
//set speed for both rocker motors
@@ -504,7 +486,6 @@ uint32_t ThreadPreSegmentState(void *JobDetails)
}
else
{
- ThreadUpdateProcessLength (0,(void *)NULL);
PreSegmentReady(Module_Thread,ModuleDone);
InitialProcess = false;
}