diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2018-10-25 11:15:14 +0300 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2018-10-25 11:15:14 +0300 |
| commit | 3aa08870dc50c19cfaa619d26f7c37610d950457 (patch) | |
| tree | 8179304c8f91a367613ab814c5e9c653e0ab8464 /Software/Embedded_SW/Embedded | |
| parent | 2eb5e880d44c358ef6a97232e90e77ea0ec582ae (diff) | |
| download | Tango-3aa08870dc50c19cfaa619d26f7c37610d950457.tar.gz Tango-3aa08870dc50c19cfaa619d26f7c37610d950457.zip | |
small corrections
Diffstat (limited to 'Software/Embedded_SW/Embedded')
7 files changed, 48 insertions, 110 deletions
diff --git a/Software/Embedded_SW/Embedded/Common/report/reportInit.c b/Software/Embedded_SW/Embedded/Common/report/reportInit.c index 5d010bc1e..dc6f11ccb 100644 --- a/Software/Embedded_SW/Embedded/Common/report/reportInit.c +++ b/Software/Embedded_SW/Embedded/Common/report/reportInit.c @@ -114,7 +114,7 @@ int ReportResponseFunc(char *message, /* The formatted message size_t container_size = message_container__pack(&responseContainer, container_buffer); if (SendChars(container_buffer, container_size) == false) //comm tx mailbox full { - CommunicationMailboxFlush(); + //CommunicationMailboxFlush(); //protobufToken[0] = 0; } } diff --git a/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c b/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c index b63c74fee..cc2feb8d8 100644 --- a/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c +++ b/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c @@ -12,7 +12,7 @@ static void (*callback)(char* buffer, size_t length); Mailbox_Handle CommunicationRxMsgQ = NULL; Mailbox_Handle CommunicationTxMsgQ = NULL; -#define COMMUNICATION_NUM_MSGS 20 +#define COMMUNICATION_NUM_MSGS 60 typedef struct CommRxMessage{ //uint16_t messageId; uint16_t msgSize; diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c index 4ff47b56c..9eb9d9822 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c @@ -68,21 +68,6 @@ typedef struct MillisecMessage{ uint32_t tick; uint8_t messageData[20]; }MillisecMessageStruc; -typedef enum -{ - ScrewMessage, - //ScrewCalculateTemperature, -}ScrewMessages; - -typedef struct ScrewMessage{ - uint16_t messageId; - uint16_t msglen; - uint32_t tick; - // uint32_t SensorId; - // uint32_t Data; -}ScrewMessageStruc; -Task_Handle Screw_Task_Handle; -Mailbox_Handle ScrewMsgQ = NULL; //uint32_t ADC_Data[MAX_ADC_DEVICES] = {0}; //uint32_t TemperatureSensor_Data[MAX_TEMPERATURE_SENSOR_ID] = {0}; @@ -115,9 +100,10 @@ uint32_t Control_Delta_Position_Pass(uint32_t Current_Read,uint32_t Previous_Rea //********************************************************************** /******************** CODE ********************************************/ //********************************************************************** -uint32_t MSBacklog[200]={0}; -uint8_t Motor_Id[200]={0}; -uint32_t MSTick[200]={0}; +#define LOG_SIZE 200 +uint32_t MSBacklog[LOG_SIZE+1]={0}; +uint8_t Motor_Id[LOG_SIZE+1]={0}; +uint32_t MSTick[LOG_SIZE+1]={0}; uint16_t MsecLogindex = 0; void MillisecInit(void) @@ -127,9 +113,7 @@ void MillisecInit(void) Error_init(&eb); - MillisecMsgQ = Mailbox_create(sizeof(MillisecMessageStruc), 5, NULL,&eb); - ScrewMsgQ = Mailbox_create(sizeof(ScrewMessageStruc), 5, NULL,&eb); - + MillisecMsgQ = Mailbox_create(sizeof(MillisecMessageStruc), 2, NULL,&eb); for (i=0;i<NUM_OF_MOTORS;i++) { MotorsMsgQ[i] = Mailbox_create(sizeof(MillisecMotorDataStruc), 5, NULL,&eb); @@ -170,16 +154,6 @@ void MillisecStart(void) ROM_TimerIntEnable(Millisec_timerBase, TIMER_TIMA_TIMEOUT); ADCAcquireStart(0,1); } -void ScrewFreeInterrupt(void) -{ - MillisecMessageStruc Message; - Message.messageId = ScrewMessage; - if (ScrewMsgQ != NULL) - Mailbox_post(ScrewMsgQ , &Message, BIOS_NO_WAIT); - - ROM_IntMasterEnable(); - return ; -} void OneMilliSecondMillisecInterrupt(UArg arg0) { @@ -225,13 +199,12 @@ uint32_t MotorActivity = 0; int32_t MillisecMoveScrew(unsigned long Data, int Length, MSecFptr Callback) { //========================== - MSBacklog[MsecLogindex]=Data; + /*MSBacklog[MsecLogindex]=Data; Motor_Id[MsecLogindex]=HARDWARE_MOTOR_TYPE__MOTO_SCREW; MSTick[MsecLogindex]=msec_millisecondCounter; MsecLogindex++; - if (MsecLogindex>=199) - MsecLogindex = 0; - LOG_ERROR(Data, "MillisecMoveScrew"); + if (MsecLogindex>=LOG_SIZE) + MsecLogindex = 0;*/ //========================== @@ -251,14 +224,12 @@ int32_t MillisecMoveScrew(unsigned long Data, int Length, MSecFptr Callback) int32_t MillisecSetScrewSpeed(unsigned long Data, int Length, MSecFptr Callback) { //========================== - MSBacklog[MsecLogindex]=Data; +/* MSBacklog[MsecLogindex]=Data; Motor_Id[MsecLogindex]=HARDWARE_MOTOR_TYPE__MOTO_SCREW; - MSTick[MsecLogindex]=msec_millisecondCounter; MsecLogindex++; - if (MsecLogindex>=199) + if (MsecLogindex>=LOG_SIZE) MsecLogindex = 0; - //========================== - LOG_ERROR(Data, "MillisecSetScrewSpeed"); + */ //========================== ScrewSetMaxSpeedPending.Callback = Callback; ScrewSetMaxSpeedPending.Data = Data; @@ -276,12 +247,18 @@ int32_t MillisecSetMotorSpeed(TimerMotors_t MotorId, unsigned long Data, int Len { if (MotorId >= NUM_OF_MOTORS) return -1; //========================== + if ((MotorId == HARDWARE_MOTOR_TYPE__MOTO_WINDER)|| + (MotorId == HARDWARE_MOTOR_TYPE__MOTO_RDRIVING)|| + (MotorId == HARDWARE_MOTOR_TYPE__MOTO_LDRIVING)|| + (MotorId == HARDWARE_MOTOR_TYPE__MOTO_SCREW)) + { MSBacklog[MsecLogindex]=Data; MSTick[MsecLogindex]=msec_millisecondCounter; Motor_Id[MsecLogindex]=MotorId; MsecLogindex++; - if (MsecLogindex>=199) + if (MsecLogindex>=LOG_SIZE) MsecLogindex = 0; + } //========================== SpeedSetPending[MotorId].Callback = Callback; @@ -312,12 +289,18 @@ int32_t MillisecWriteToMotor(TimerMotors_t MotorId, unsigned long Data, int Leng { MillisecMotorDataStruc MotorData = {0}; //========================== + if ((MotorId == HARDWARE_MOTOR_TYPE__MOTO_WINDER)|| + (MotorId == HARDWARE_MOTOR_TYPE__MOTO_RDRIVING)|| + (MotorId == HARDWARE_MOTOR_TYPE__MOTO_LDRIVING)|| + (MotorId == HARDWARE_MOTOR_TYPE__MOTO_SCREW)) + { MSBacklog[MsecLogindex]=Data; MSTick[MsecLogindex]=msec_millisecondCounter; Motor_Id[MsecLogindex]=MotorId; MsecLogindex++; - if (MsecLogindex>=199) + if (MsecLogindex>=LOG_SIZE) MsecLogindex = 0; + } //========================== if (MotorId >= NUM_OF_MOTORS) return -1; MotorActivity++; @@ -334,12 +317,18 @@ int32_t MillisecReadFromMotor(TimerMotors_t MotorId, unsigned long Data, int Len MillisecMotorDataStruc MotorData = {0}; if (MotorId >= NUM_OF_MOTORS) return -1; //========================== + if ((MotorId == HARDWARE_MOTOR_TYPE__MOTO_WINDER)|| + (MotorId == HARDWARE_MOTOR_TYPE__MOTO_RDRIVING)|| + (MotorId == HARDWARE_MOTOR_TYPE__MOTO_LDRIVING)|| + (MotorId == HARDWARE_MOTOR_TYPE__MOTO_SCREW)) + { MSBacklog[MsecLogindex]=Data; Motor_Id[MsecLogindex]=MotorId; MSTick[MsecLogindex]=msec_millisecondCounter; MsecLogindex++; - if (MsecLogindex>=199) + if (MsecLogindex>=LOG_SIZE) MsecLogindex = 0; + } //========================== MotorActivity++; MotorActivity++; @@ -398,7 +387,6 @@ uint32_t MillisecLoop(uint32_t tick) } MotorActivity--; } - if (Motor_i == HARDWARE_MOTOR_TYPE__MOTO_SCREW) { if (ScrewSetMaxSpeedPending.Active == true) @@ -414,8 +402,6 @@ uint32_t MillisecLoop(uint32_t tick) { MotorSendFPGARequest(HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewMovePending.Data,ScrewMovePending.Length); MotorActivity--; - /*if (Screwindex>=50) - Screwindex = 0;*/ ScrewMovePending.Active = false; if (ScrewMovePending.Callback) ScrewMovePending.Callback(Motor_i,0); @@ -449,12 +435,16 @@ uint32_t MillisecLoop(uint32_t tick) } } //FPGA_GetTempSensorBusy(); + //int PT100Busy[MAX_TEMPERATURE_SENSOR_ID] = {0,0,0,0,0,0,0,0,0,0}; if (PT100Activity) { for (Sensor_i = 0;Sensor_i < MAX_TEMPERATURE_SENSOR_ID;Sensor_i++) { - //if (TempDriverDriverResponse[Sensor_i].Busy == true) - // continue; + /*if (TempSensorResponse[Sensor_i].Busy == true) + { + PT100Busy[Sensor_i]++; + continue; + }*/ if (PT100Data[Sensor_i].Active == true) { TemperatureSendSensorDummyClk(Sensor_i); @@ -535,27 +525,6 @@ uint32_t MillisecLoop(uint32_t tick) return OK; } -int SendNextScrewMessage() -{ - volatile uint32_t temp; // read the busy value - - if (Mailbox_pend(MotorsMsgQ[HARDWARE_MOTOR_TYPE__MOTO_SCREW] , &MotorData[HARDWARE_MOTOR_TYPE__MOTO_SCREW], BIOS_NO_WAIT)==true) - { - if (MotorSendFPGARequest((HardwareMotorType)HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorData[HARDWARE_MOTOR_TYPE__MOTO_SCREW].Data,MotorData[HARDWARE_MOTOR_TYPE__MOTO_SCREW].Length) != OK) //sent the data to the FPGA - { - LOG_ERROR(MotorData[HARDWARE_MOTOR_TYPE__MOTO_SCREW].Data,"SCREW Send message failed"); - } - else - { - LOG_ERROR(MotorData[HARDWARE_MOTOR_TYPE__MOTO_SCREW].Data,"SCREW Send message OK"); - MotorActivity--; - } - } - ROM_SysCtlDelay(SYS_CLK_FREQ / 50000); - - temp = F1_Moto_Driver_NBUSY2_L; // read the latch in order to clear the latch value (read it after moving to prevent interrupt before movement) - -} /****************************************************************************** * ======== messageTsk ======== * Task for this function is created statically. See the project's .cfg file. @@ -616,30 +585,3 @@ uint32_t getDrawerFansStatus(void) { return DrawerFansStatus; } - -/****************************************************************************** - * ======== messageTsk ======== - * Task for this function is created statically. See the project's .cfg file. - * this message task is created statically in system initialization, - ******************************************************************************/ -void ScrewTask(UArg arg0, UArg arg1) -{ - ScrewMessageStruc Message; - //char str[60]; - //uint16_t length; - //Clock_setTimeout(HostKAClock, 1000); - //Clock_start(HostKAClock); - Screw_Task_Handle = Task_self(); - while(1) - { - Mailbox_pend(ScrewMsgQ , &Message, BIOS_WAIT_FOREVER); - switch (Message.messageId) - { - case ScrewMessage: - SendNextScrewMessage(); - break; - default: - break; - } - } -} diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h index 6e11471cc..517716c08 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h @@ -35,7 +35,6 @@ uint32_t getDrawerFansStatus(void); void MillisecInit(void); void MillisecStop(void); void MillisecStart(void); -void ScrewFreeInterrupt(void); extern bool watchdogCriticalAlarm; diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c index 857b90d9e..960581da7 100644 --- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c +++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c @@ -159,11 +159,11 @@ uint32_t MotorHomingRequestFunc(MessageContainer* requestContainer) { if ((JobIsActive() == false)&&(isMotorConfigured(MotorId) == true)) { - if (request->direction == MOTOR_DIRECTION__Backward) //opening the loading system + if (request->direction == MOTOR_DIRECTION__Forward) //opening the loading system { if ( Motor_Id_to_LS_IdUp[MotorId] != MAX_GPI) { - MotorMovetoLimitSwitch (MotorId,1-MotorsCfg[MotorId].directionthreadwize, speed, Motor_Id_to_LS_IdUp[MotorId], MotorHomingRequestCallback); + MotorMovetoLimitSwitch (MotorId,MotorsCfg[MotorId].directionthreadwize, speed, Motor_Id_to_LS_IdUp[MotorId], MotorHomingRequestCallback); ustrncpy (HomingToken[MotorId], requestContainer->token,36); return OK; } @@ -172,7 +172,7 @@ uint32_t MotorHomingRequestFunc(MessageContainer* requestContainer) { if ( Motor_Id_to_LS_IdDown[MotorId] != MAX_GPI) { - MotorMovetoLimitSwitch (MotorId,MotorsCfg[MotorId].directionthreadwize, speed, Motor_Id_to_LS_IdDown[MotorId], MotorHomingRequestCallback); + MotorMovetoLimitSwitch (MotorId,1-MotorsCfg[MotorId].directionthreadwize, speed, Motor_Id_to_LS_IdDown[MotorId], MotorHomingRequestCallback); ustrncpy (HomingToken[MotorId], requestContainer->token,36); return OK; } @@ -264,7 +264,7 @@ uint32_t DispenserHomingRequestFunc(MessageContainer* requestContainer) { if ((JobIsActive() == false)&&(isMotorConfigured(MotorId) == true)) { - if (request->direction == MOTOR_DIRECTION__Forward) //dispenser homing + if (request->direction == MOTOR_DIRECTION__Backward) //dispenser homing IDS_HomeDispenser(request->index,speed,DispenserHomingRequestCallback); else //empty dispenser - support TBD IDS_EmptyDispenser(request->index,speed,DispenserHomingRequestCallback);//return ERROR; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c index 9e3bdb052..b00e2fca4 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -186,7 +186,6 @@ uint32_t CalculateNumberOfSteps (uint32_t Counter, bool direction) NumberOfSteps -= (Counter/InternalWinderCfg.spoolbackingrate); REPORT_MSG(ScrewNumberOfSteps, "Head Backing"); ScrewNumberOfSteps--; - /* screw speed adjustment is suspended screw_horizontal_speed = InternalWinderCfg.segmentoffsetpulses / InternalWinderCfg.NumberOfRotationPerPassage; // calculation input#2: number of rotations per second - (basically: speed/winder perimeter. later - according to winder actual speed - calculate according to winder position accumulation in the last second. RotationsPerSecond = dyeingspeed / (InternalWinderCfg.diameter * PI); @@ -197,7 +196,6 @@ uint32_t CalculateNumberOfSteps (uint32_t Counter, bool direction) MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed); REPORT_MSG(ScrewSpeed, "CalculateNumberOfSteps"); CurrentControlledSpeed[SCREW_MOTOR] = ScrewSpeed; - */ } if ((Counter%InternalWinderCfg.SpoolBottomBackingRate == 0)||(Counter%InternalWinderCfg.SpoolBottomBackingRate == 1)) @@ -337,7 +335,6 @@ uint32_t Winder_End(void) RemoveControlCallback(ScrewControlId,ScrewDirectionChange); CurrentControlledSpeed[SCREW_MOTOR] = 0; pend = MillisecFlushMsgQ(HARDWARE_MOTOR_TYPE__MOTO_SCREW); - //Screw_Interrupt(false,NULL); return MotorStop (HARDWARE_MOTOR_TYPE__MOTO_SCREW,Hard_Hiz); } void Winder_ScrewHomeLimitSwitchInterrupt(void) diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index f579ff6bc..6c58e1645 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -467,17 +467,17 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) calculated_speed = (1-MotorControlConfig[index].m_calculatedError)*OriginalMotorSpd_2PPS[index]; if (abs(calculated_speed-CurrentControlledSpeed[index])>2) { - /*if (keepdata == true) + if (keepdata == true) { - calculatedError[controlIndex] = MotorControlConfig[index].m_calculatedError; + /* calculatedError[controlIndex] = MotorControlConfig[index].m_calculatedError; MotorId[controlIndex] = index; readValue[controlIndex] = ReadValue; AveragereadValue[controlIndex] = avreageSampleValue; calculatedspeed[controlIndex] = calculated_speed; timestamp[controlIndex] = HibernateRTCSSGet(); if (controlIndex++>=999) - controlIndex = 0; - }*/ + controlIndex = 0;*/ + } CurrentControlledSpeed[index] = calculated_speed; MotorSetSpeed(ThreadMotorIdToMotorId[index], calculated_speed); } |
