From a0d320fb1ebe92afde03ed9c02a1a1a9f44e42b2 Mon Sep 17 00:00:00 2001 From: Avi Levkovich Date: Mon, 15 Jun 2020 17:08:55 +0300 Subject: Add stub to read all the parameters in powerstep01 --- .../Motor_GMotor_Get_Param_Powerstep01_rev2.cs | 292 +++++++++++++++++++++ .../stubs/Scripts/Assemblies/newWHS/Blower.cs | 14 +- 2 files changed, 296 insertions(+), 10 deletions(-) create mode 100644 Software/Stubs Collection/stubs/Motor_GMotor_Get_Param_Powerstep01_rev2.cs (limited to 'Software/Stubs Collection') diff --git a/Software/Stubs Collection/stubs/Motor_GMotor_Get_Param_Powerstep01_rev2.cs b/Software/Stubs Collection/stubs/Motor_GMotor_Get_Param_Powerstep01_rev2.cs new file mode 100644 index 000000000..505444080 --- /dev/null +++ b/Software/Stubs Collection/stubs/Motor_GMotor_Get_Param_Powerstep01_rev2.cs @@ -0,0 +1,292 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +//unmark Auto logging ! + +//General Configuration +const Int32 x_ABS_POS = 0x01; +const Int32 x_EL_POS = 0x02; +const Int32 x_MARK = 0x03; +const Int32 x_SPEED = 0x04; +const Int32 x_ACC = 0x05; +const Int32 x_DEC = 0x06; +const Int32 x_MAX_SPEED = 0x07; +const Int32 x_MIN_SPEED = 0x08; +const Int32 x_ADC_OUT = 0x12; +const Int32 x_OCD_TH = 0x13; +const Int32 x_FS_SPD = 0x15; +const Int32 x_STEP_MODE = 0x16; +const Int32 x_ALARM_EN = 0x17; +const Int32 x_POWERSTEP01_GATECFG1 = 0x18; +const Int32 x_POWERSTEP01_GATECFG2 = 0x19; +const Int32 x_POWERSTEP01_CONFIG = 0x1A; +const Int32 x_POWERSTEP01_STATUS = 0x1B; +//VOLTAGE / CURRENT +const Int32 x_KTVAL_HOLD = 0x09; +const Int32 x_KTVAL_RUN = 0x0A; +const Int32 x_KTVAL_ACC = 0x0B; +const Int32 x_KTVAL_DEC = 0x0C; +const Int32 x_ST_SLP_T_FAST = 0x0E; +const Int32 x_FN_SLP_ACC_TON_MIN = 0x0F; +const Int32 x_FN_SLP_DEC_TOFF_MIN = 0x10; + +const Int32 x_INT_SPD = 0x0D;//voltage +const Int32 x_K_THERM = 0x11;//VOLTAGE +const Int32 x_STALL_TH = 0x14;//VOLTAGE + +//------------------------------- +const Int32 x_GET_PARAM = 0x20; +//------------------------------- +Int32 Start_index = 0; // start from motor + +const Int32 Max_Motor_ID = 25; + +string[] Motor_ID = new string[30]; + + +Motor_ID[0] ="DH_CLEANHEAD "; +Motor_ID[1] ="DH_CLEANMECH "; +Motor_ID[2] ="DH_LID "; +Motor_ID[3] ="DRYER_DRIVING"; +Motor_ID[4] ="DRYER_LID "; +Motor_ID[5] ="DRYER_LOADARM"; +Motor_ID[6] ="DISPENCER_1 "; +Motor_ID[7] ="DISPENCER_2 "; +Motor_ID[8] ="DISPENCER_3 "; +Motor_ID[9] ="DISPENCER_4 "; +Motor_ID[10]="DISPENCER_5 "; +Motor_ID[11]="DISPENCER_6 "; +Motor_ID[12]="DISPENCER_7 "; +Motor_ID[13]="DISPENCER_8 "; +Motor_ID[14]="SCREW "; +Motor_ID[15]="WINDER "; +Motor_ID[16]="LDANCER1 "; +Motor_ID[17]="LDANCER2 "; +Motor_ID[18]="LDRIVING "; +Motor_ID[19]="LLODING "; +Motor_ID[20]="LPIVOT "; +Motor_ID[21]="RDANCER "; +Motor_ID[22]="RDRIVING "; +Motor_ID[23]="RLOADARM "; +Motor_ID[24]="RLODING "; +Motor_ID[25]="SPARE1_1 "; +Motor_ID[26]="SPARE1_2 "; +Motor_ID[27]="SPARE2_1 "; +Motor_ID[28]="SPARE2_2 "; +Motor_ID[29]="SPARE3 "; + + + + +public void OnExecute(StubManager stubManager) +{ + Int32 i = 0; + + Int32 motname = 0; +//stubManager.Run("StubFpgaWriteRegRequest" ,0x60000380 , 0x06b9); //7ff mati +//stubManager.Run("StubFpgaWriteRegRequest" ,0x60000390 , 0x003f); +//stubManager.Run("StubFpgaWriteRegRequest" ,0x60000550 , 0x0003); //ff mati +//stubManager.Run("StubFpgaWriteRegRequest" ,0x60000b80 , 0x001f); + + for (i = Start_index; i < Max_Motor_ID; i++) + { + + if((i%8 ==0) ) + { + stubManager.Write("\n\n"); + stubManager.Write("MoTor\t\t\tMIN_SPEED\tMAX_SPEED\tSTEP_MODE\tACC\t\tDEC\t\tKTVAL_HOLD\tKTVAL_RUN\tTKVAL_ACC\tTKVAL_DEC\tOCD_TH\t\tSTALL_TH\tFS_SPD\n"); + stubManager.Write("------\t\t\t--------\t--------\t----------\t---\t\t---\t\t----------\t---------\t---------\t---------\t------\t\t--------\t------\n"); + } + //stubManager.Write(i); + + stubManager.Write(Motor_ID[i]); + stubManager.Write("\t\t"); + + var response = stubManager.Run("StubMotorRequest" ,i, (x_GET_PARAM | x_MIN_SPEED)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run("StubMotorRequest" ,i, (x_GET_PARAM | x_MAX_SPEED)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run("StubMotorRequest" ,i, (x_GET_PARAM | x_STEP_MODE)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run("StubMotorRequest" ,i, (x_GET_PARAM | x_ACC)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run("StubMotorRequest" ,i, (x_GET_PARAM | x_DEC)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run("StubMotorRequest" ,i, (x_GET_PARAM | x_KTVAL_HOLD)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run("StubMotorRequest" ,i, (x_GET_PARAM | x_KTVAL_RUN)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run("StubMotorRequest" ,i, (x_GET_PARAM | x_KTVAL_ACC)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run("StubMotorRequest" ,i, (x_GET_PARAM | x_KTVAL_DEC)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run("StubMotorRequest" ,i, (x_GET_PARAM | x_OCD_TH)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run("StubMotorRequest" ,i, (x_GET_PARAM | x_STALL_TH)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run("StubMotorRequest" ,i, (x_GET_PARAM | x_FS_SPD)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + stubManager.Write("\n\n"); + + } + + + + for (i = Start_index; i < Max_Motor_ID; i++) + { + + if((i%8 ==0) ) + { + stubManager.Write("\n\n"); + + stubManager.Write("MoTor\t\t\tINT_SPD\tST_SLP\t\tSLP_ACC_TON_MIN\tSLP_DEC_TOFF_MIN\n"); + stubManager.Write("-----\t\t\t-------\t------\t\t---------------\t----------------\n"); + } + + stubManager.Write(Motor_ID[i]); + +// stubManager.Write(i); + stubManager.Write("\t\t"); + + var response = stubManager.Run("StubMotorRequest" ,i, (x_GET_PARAM | x_INT_SPD)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run("StubMotorRequest" ,i, (x_GET_PARAM | x_ST_SLP_T_FAST)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run("StubMotorRequest" ,i, (x_GET_PARAM | x_FN_SLP_ACC_TON_MIN)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t\t"); + + response = stubManager.Run("StubMotorRequest" ,i, (x_GET_PARAM | x_FN_SLP_DEC_TOFF_MIN)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + stubManager.Write("\n\n"); + + } + + + for (i = Start_index; i < Max_Motor_ID; i++) + { + + if((i%8 ==0) ) + { + stubManager.Write("\n\n"); + + stubManager.Write("MoTor\t\t\tPS01_CONFIG\t\tPS01_STATUS\t\tPS01_GATECFG1\t\tPS01_GATECFG2\n"); + stubManager.Write("-----\t\t\t------------\t\t-----------\t\t-------------\t\t------------\n"); + } + + stubManager.Write(Motor_ID[i]); + stubManager.Write("\t\t"); + + var response = stubManager.Run("StubMotorRequest" ,i, (x_GET_PARAM | x_POWERSTEP01_CONFIG)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t\t"); + + response = stubManager.Run("StubMotorRequest" ,i, (x_GET_PARAM | x_POWERSTEP01_STATUS)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t\t"); + + response = stubManager.Run("StubMotorRequest" ,i, (x_GET_PARAM | x_POWERSTEP01_GATECFG1)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t\t"); + + response = stubManager.Run("StubMotorRequest" ,i, (x_GET_PARAM | x_POWERSTEP01_GATECFG2)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\n\n"); + + + } + + for (i = Start_index; i < Max_Motor_ID; i++) + { + + if((i%8 ==0) ) + { + stubManager.Write("\n\n"); + + stubManager.Write("MoTor\t\t\tABS_POS\tEL_POS\t\tMARK\t\tSPEED\t\tALARM_EN\tK_THERM\tADC_OUT\tDriver_Type\n"); + stubManager.Write("-----\t\t\t-------\t------\t\t----\t\t-----\t\t--------\t--------\t------\t\t---------\n"); + } + + stubManager.Write(Motor_ID[i]); + + stubManager.Write("\t\t"); + + var response = stubManager.Run("StubMotorRequest" ,i, (x_GET_PARAM | x_ABS_POS)<<24, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run("StubMotorRequest" ,i, (x_GET_PARAM | x_EL_POS)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run("StubMotorRequest" ,i, (x_GET_PARAM | x_MARK)<<24, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run("StubMotorRequest" ,i, (x_GET_PARAM | x_SPEED)<<24, 0, 0); + stubManager.WriteHex((response.RecivedData * 1000.0 / 67108.0),4); + stubManager.Write("\t\t"); + + response = stubManager.Run("StubMotorRequest" ,i, (x_GET_PARAM | x_ALARM_EN)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run("StubMotorRequest" ,i, (x_GET_PARAM | x_K_THERM)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run("StubMotorRequest" ,i, (x_GET_PARAM | x_ADC_OUT)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + if( response.RecivedData > 0x15 && response.RecivedData < 0x1c ) + stubManager.Write("\t\tDual_Driver"); + else if ( response.RecivedData > 0x0b && response.RecivedData < 0x12 ) + stubManager.Write("\t\tVolage_Driver"); + else if ( response.RecivedData > 8 && response.RecivedData < 0x0a) + stubManager.Write("\t\tCurrent_Driver"); + else + stubManager.Write("\t\tNo_Driver"); + + stubManager.Write("\n\n"); + + } + +} \ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/newWHS/Blower.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/newWHS/Blower.cs index f9807f6f3..d5c98e2cd 100644 --- a/Software/Stubs Collection/stubs/Scripts/Assemblies/newWHS/Blower.cs +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/newWHS/Blower.cs @@ -12,16 +12,10 @@ using Tango.Stubs; public void OnExecute(StubManager stubManager) { -// Request ---- -// Int32 : Amount -// Int32 : Delay -// Response ---- -// Double : Progress - - -//Blower speed -var response1 = stubManager.Run("ProgressRequest" ,0x3E8, /* speed =*/0xc00); //Blower speed -//Thread.Sleep(5000); //Sleep for 10 milli. + //Blower speed + var response1 = stubManager.Run("ProgressRequest" ,0x3E8, /*disable control loop*/0x0000 + /* speed =*/0xFFF); //Blower speed + // to enable control loop send 0x1000 + // speed max voltage value is 0xFFF } \ No newline at end of file -- cgit v1.3.1