aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-03-26 14:22:12 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-03-26 14:22:12 +0300
commit2f1579f22a700dc64533532d533dfacb3a3531d0 (patch)
treef88cf8c1ae220e2d632965a9290ee788f3dcd3cc /Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
parent1061758f95b7ba633e6bcc2c3556b42f033b1a79 (diff)
parentbca898b563219f5d02fb7d611a49f2a20306f214 (diff)
downloadTango-2f1579f22a700dc64533532d533dfacb3a3531d0.tar.gz
Tango-2f1579f22a700dc64533532d533dfacb3a3531d0.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c')
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c188
1 files changed, 12 insertions, 176 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
index 6e4624723..5f14a17a7 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
@@ -10,8 +10,9 @@
#include "../control/pidalgo.h"
#include "PMR/Hardware/HardwareMotor.pb-c.h"
#include "PMR/Hardware/HardwareMotorType.pb-c.h"
+
#include "drivers/Motors/Motor.h"
-#include "Drivers/Danser_SSI/ssi_comm.h"
+#include "drivers/Danser_SSI/ssi_comm.h"
#include "drivers/Heater/TemperatureSensor.h"
#include "drivers/Heater/Heater.h"
////////////////////////////////State machine operation////////////////////////////////////
@@ -31,70 +32,6 @@ typedef enum
uint32_t ThreadMotorIdToMotorId[MAX_THREAD_MOTORS_NUM] = {MOTOR_RDRIVING,MOTOR_DRYER_DRIVING,MOTOR_LDRIVING,MOTOR_WINDER,MOTOR_SCREW};
uint32_t ThreadMotorIdToDancerId[MAX_THREAD_MOTORS_NUM] = {FEEDER_DANCER,NUM_OF_DANCERS,POOLER_DANCER,WINDER_DANCER,NUM_OF_DANCERS};
-/********************************************************************************************
-* functions describes motor operation flow and movement state during profile execution
-* used to operate in runtime correct profileflow execution
-*********************************************************************************************/
-static ReturnCode EntryState(void *JobDetails);
-static ReturnCode PrepareState(void *JobDetails);
-static ReturnCode PreSegmentState(void *JobDetails);
-static ReturnCode SegmentState(void *JobDetails);
-static ReturnCode EndState(void *JobDetails);
-static ReturnCode ExitState(void *JobDetails);
-;
-
-/**********************************************************************
-* the array and enum of PrintingState_t below must be in sync order
-***********************************************************************/
-static ReturnCode (* state[])(void *JobDetails) = { EntryState, PrepareState, PreSegmentState, SegmentState, EndState, ExitState};
-
-typedef enum
-{
- Entry= 0,
- Prepare,
- PreSegment,
- Segment,
- End,
- Exit
-} PrintingState_t;
-
-typedef struct
-{
- PrintingState_t m_sourceState;
- ReturnCode m_returnCode;
- PrintingState_t m_destinationState;
-} Transition_t;
-
-//*************************************************************
-/* transitions from end state aren't needed */
-//*************************************************************
-#define NUM_OF_TRANSITION 17
-#define EXIT_STATE Exit
-#define ENTRY_STATE Entry
-/*************************************************************
- * table which describes fast motors transitions states
- * during p_profile / segments execution
- *************************************************************/
-static Transition_t stateTransitionTable[NUM_OF_TRANSITION] =
-{};
-/* {Entry, NextState, HomingStart},
- {Entry, Repeat, Entry}, //for homing of dispensers
- {HomingStart, NextState, Start},
- {HomingStart, Repeat, HomingStart},
- {Start, NextState, Segment},
- {Start, Repeat, Start},
- {Segment, Inter, Intersegment},
- {Segment, Repeat, Segment},
- {Segment, Home, HomingEnd},
- {Intersegment, NextState, Segment},
- {Intersegment, Repeat, Intersegment},
- {Intersegment, Home, HomingEnd},
- {HomingEnd, NextState, End},
- {HomingEnd, Repeat, HomingEnd},
- {End, NextState, Entry},
- {End, Repeat, Entry},
- {Exit, Stop, Exit} //for stoping the machine iteration in case of error
-};*/
typedef struct
{
bool m_isEnabled;
@@ -106,28 +43,11 @@ typedef struct
bool m_isReady;
PID_Config_Params m_params;
}MotorControlConfig_t;
-/*typedef struct
-{
- float epsilon;
- float dt;
- float MAX;
- float MIN;
- float Kp;
- float Kd;
- float Ki;
-}PID_Config_Params;
-#define epsilon 0.01
-#define dt 0.01 //100ms loop time
-#define MAX 4 //For Current Saturation
-#define MIN -4
-#define Kp 0.1
-#define Kd 0.01
-#define Ki 0.005
-*/
+
MotorControlConfig_t MotorControlConfig[MAX_THREAD_MOTORS_NUM];
uint32_t DeviceId2Motor[MAX_THREAD_MOTORS_NUM];
////////////////////////Slow Motor State////////////////////////////////////
-static PrintingState_t gPrintingState;
+
////////////////////////////////////////////////////////////////////////////
uint32_t ThreadSpeedControlCBFunction(uint32_t deviceID, uint32_t ReadValue)
@@ -200,14 +120,6 @@ uint32_t ThreadControlCBFunction(uint32_t deviceID, uint32_t ReadValue)
}
//********************************************************************************************************************
-/********************************************************************************************************************
-*function describes entry point of motor in profile execution - accelerate from stop position
-*function described above used to operate motor operation flow and movement state during profile execution
-*********************************************************************************************************************/
-static ReturnCode EntryState(void *JobDetails)
-{
- return NextState;
-}
//********************************************************************************************************************
#ifdef DEBUG_TEST_FUNCTIONS
@@ -217,7 +129,7 @@ uint32_t Debug_Get_Dancer_Read(uint32_t DancerId, uint32_t Parameter1, uint32_t
}
#endif
//********************************************************************************************************************
-static ReturnCode PrepareState(void *JobDetails)
+ ReturnCode PrepareState(void *JobDetails)
{
int Motor_i;
//start thread control for all motors
@@ -251,11 +163,11 @@ static ReturnCode PrepareState(void *JobDetails)
}
//set 3 dancers to the profile positions
- return NextState;
+ return OK;
}
//********************************************************************************************************************
-static ReturnCode PreSegmentState(void *JobDetails)
+ReturnCode PreSegmentState(void *JobDetails)
{
TimerMotors_t Motor_i;
@@ -268,102 +180,27 @@ static ReturnCode PreSegmentState(void *JobDetails)
//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)
//call the job state machine when the thread system is ready
- return NextState;
+ return OK;
}
//********************************************************************************************************************
-static ReturnCode SegmentState(void *JobDetails)
+ ReturnCode SegmentState(void *JobDetails)
{
- return Repeat;
+ return OK;
}
//********************************************************************************************************************
-static ReturnCode EndState(void *JobDetails)
+ ReturnCode EndState(void *JobDetails)
{
- return NextState;
-}
-//********************************************************************************************************************
-static ReturnCode ExitState(void *JobDetails)
-{
- return Stop;
+ return OK;
}
-//***********************************************************************************************************************
-//this function is responsible for operating and transitioning between the diffrent motor state executions of the profile
-//the lower managment level
-//***********************************************************************************************************************
-static PrintingState_t LookupTransitions(PrintingState_t state,ReturnCode returnCode)
-{
- char str[80];
- uint8_t len = 0;
- uint8_t indexInTransitionTable;
- for (indexInTransitionTable = 0; indexInTransitionTable < NUM_OF_TRANSITION; ++indexInTransitionTable)
- {
- if ((stateTransitionTable[indexInTransitionTable].m_sourceState == state) && (stateTransitionTable[indexInTransitionTable].m_returnCode == returnCode))
- {
- //len = usnprintf(str, 60, "\r\n tick %d state %d return code %d",tick,state, returnCode );
- //cb_push_back (str, len);
-
- //in normal execution flow function should not arrive here
- //in case it did the meaning is that the entery point was wrong and a bug should be corrected
- return stateTransitionTable[indexInTransitionTable].m_destinationState;
- }
- }
- //int tick = UsersysTickGet();
- //len = usnprintf(str, 60, "\r\n tick %d state %d return code %d",tick,state, returnCode );
- //cb_push_back (str, len);
-
- //in normal execution flow function should not arrive here
- //in case it did the meaning is that the entery point was wrong and a bug should be corrected
- len = usnprintf(str, 80, "Internal: invalid slow motor transition state %d return code %d",state, returnCode );
-
- return EXIT_STATE;
-}
-//********************************************************************************
-//this function is used to manage and operate the motor managmant state mashine
-//the highest managment level
-//********************************************************************************
-bool ThreadPrintingIterate(void *JobDetails)
-{
- uint32_t tick = 0;
- char str[60];
- uint8_t len = 0;
- PrintingState_t keepstate = gPrintingState;
- //
- // Disable all interrupts.
- //
- ROM_IntMasterDisable();
-
- ReturnCode (* state_fun)(void *JobDetails) = state[gPrintingState];
- //if (_motorId == SCREW_MOTOR)
- // screw_movement[gPrintingState[_motorId]]++;
- ReturnCode returnCode = state_fun(JobDetails);
-
- gPrintingState = LookupTransitions(gPrintingState, returnCode);
-// if (keepstate != gPrintingState){
-// }
-
- //
- // Enable all interrupts.
- //
- ROM_IntMasterEnable();
- return (gPrintingState != EXIT_STATE);
-}
-
-
-//********************************************************************************************************************
-
-void ThreadPrintingsInit(void)
-{
-// gPrintingState = Start;
-}
//********************************************************************************************************************
void ThreadStartPrinting(void)
{
- gPrintingState = ENTRY_STATE;
//PrintingIterate();
}
@@ -372,6 +209,5 @@ void ThreadStartPrinting(void)
void ThreadStopPrinting(void)
{
- gPrintingState = EXIT_STATE;
//PrintingIterate();
}