diff options
Diffstat (limited to 'Software/Stubs Collection/stubs/Scripts/Jig_Tester/Dryer_Jig1.cs')
| -rw-r--r-- | Software/Stubs Collection/stubs/Scripts/Jig_Tester/Dryer_Jig1.cs | 455 |
1 files changed, 0 insertions, 455 deletions
diff --git a/Software/Stubs Collection/stubs/Scripts/Jig_Tester/Dryer_Jig1.cs b/Software/Stubs Collection/stubs/Scripts/Jig_Tester/Dryer_Jig1.cs deleted file mode 100644 index d1f0efa94..000000000 --- a/Software/Stubs Collection/stubs/Scripts/Jig_Tester/Dryer_Jig1.cs +++ /dev/null @@ -1,455 +0,0 @@ -using System; -using System.Text; -using System.IO; -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; - - - -const int Dryer_UNDER_TEST=12; -//-------------------------------------------------------------------------------- -//--------------------------- -Int32 last_14bit_position; -Int32 position_32bit=0; -float [] DryerTemp = new float[20] ; - - -string [,] Units_status_Dryer = new string[Dryer_UNDER_TEST,2] { - {"Lid_Motor","Not Test"}, //0 - {"LS_Lid_Open","Not Test"}, //1 - {"LS_Lid_Close","Not Test"}, //2 - {"DRIVING_Motor","Not Test"}, //3 - {"SSI_Encoder","Not Test"}, //4 - {"LoadArm_Motor","Not Test"}, //5 - {"Blower_test","Not Test"}, //6 - {"Air_PT100_test","Not Test"}, //7 - {"Main_PT100_test","Not Test"}, //8 - {"Sec.PT100","Not Test"}, //9 - {"SSR1_heater","Not Test"}, //10 - {"SSR2_heater","Not Test"}, //11 - }; - - - -//-------------------------------------------------------------------------------- - - -public Task<decimal> Dryer_test( Action<string> settext, CancellationToken cancellationToken, string SN, string Location ) -{ - Task<decimal> task = null; - // Start a task and return it - task = Task.Run(() => - { - stubManager.Write("S/N:" +SN+ "\n"); - stubManager.Write("Location:" +Location+ "\n"); - - copy_table (Dryer_UNDER_TEST,Units_status_Dryer); - - settext("Test Dryer LId"); - Test_LId(); - - settext("Test Dryer motor Driving"); - Test_motor_driving(); - - settext("Test Dryer Load Arm"); - Test_Load_Arm (); - - settext("Test Dryer Blower heaters pt100"); - Test_Blower_heaters_pt100(); - - Status=write_to_file(SN,Location,Dryer_UNDER_TEST,"Dryer"); - - settext("End Test"); - - decimal result = 0; - - return result; - }); - return task; -} -//------------------------------------------ -int Test_Blower_heaters_pt100() -{ - - float ftemp=0; - float ftemp1=0; - - SetBit(F1_gpo_01,5,1); //turn off Blower - delay(500); - - var RetVal=Fpga_Read_Reg(F1_Tacho_reg8); - - DialogResult result = MessageBox.Show("Close Dryer Door", "Warning"); - - SetBit(F1_gpo_01,4,1); //Dir - SetBit(F1_gpo_01,3,1); //Torqer High - SetBit(F1_gpo_01,5,0); //turn on Blower - - const int LOW = 70;//0 - 100% - stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,F2_Prescaler1_reg11, 0xFF);//Freq 8 bit - stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,F2_BLOWER_PWM_LOW, LOW+1);//Low 8 bit - stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,F2_BLOWER_PWM_HIGH, 101 - LOW);//High 8 bit - - delay(1000); - RetVal=Fpga_Read_Reg(F1_Tacho_reg8); - stubManager.Write("blower Speed- " + RetVal.Value + "\n"); - if ((RetVal.Value<150)||(RetVal.Value>250) ) - { - Units_status[6,1]="Fail"; - stubManager.Write("Error,Fan rotate\n"); - return 0; - } - Units_status[6,1]="Pass"; - - stubManager.Write("Temp Befor heating \n"); - if (test_pt100_dryer()!=0) - return 0; - -float temp=0; -float temp1=4096*95*5; - - //Write GPO_DRYER_SSR1_CTRL SSR/SSR no. 1 - SetBit (F2_CTRL, 10, 1); //turn SSR1 on - stubManager.Write("\tTesting SSR no. 1\t"); - delay(1000); -var response1 = stubManager.Run<StubIntADCReadResponse>("StubIntADCReadRequest" ,16); - temp=Convert.ToUInt32 (response1.SamplingInBits); - temp=temp*800*3*100; - temp=temp/(4096*95*50); - stubManager.Write("Current = "+ temp + "A\n"); - if ((temp>6) || (temp<3)) - Units_status[10,1]="Fail"; - else - Units_status[10,1]="Pass"; - - //Write GPO_DRYER_SSR2_CTRL SSR/SSR no. 2 - SetBit (F2_CTRL, 9, 1); - stubManager.Write("\tTesting SSR no. 2\t"); - delay(1000); - response1 = stubManager.Run<StubIntADCReadResponse>("StubIntADCReadRequest" ,17); - temp=Convert.ToUInt32 (response1.SamplingInBits); - temp=temp*800*3*100; - temp=temp/(4096*95*100); - stubManager.Write("Current = "+ temp + "A\n"); - if ((temp>3) || (temp<1)) - Units_status[11,1]="Fail"; - else - Units_status[11,1]="Pass"; - - delay(50000); - -//check air temp - ftemp=Read_pt100(6); - stubManager.Write("After heating air temp is " + ftemp + "\n"); - ftemp = ftemp - DryerTemp[6]; - if ((ftemp<5)||(ftemp>40)) - Units_status[7,1]="Fail"; - else - Units_status[7,1]="Pass"; - - - -//check Main temp - ftemp=Read_pt100(7); - stubManager.Write("After heating Main temp is " + ftemp + "\n"); - ftemp = ftemp - DryerTemp[7]; - if ((ftemp<5)||(ftemp>60)) - Units_status[8,1]="Fail"; - else - Units_status[8,1]="Pass"; - -//check Sec. temp - ftemp=Read_pt100(8); - stubManager.Write("After heating Sec. temp is " + ftemp + "\n"); - ftemp = ftemp - DryerTemp[8]; - if ((ftemp<5)||(ftemp>60)) - Units_status[9,1]="Fail"; - else - Units_status[9,1]="Pass"; - - SetBit (F2_CTRL, 10, 0); //turn SSR1 off - SetBit (F2_CTRL, 9, 0); //turn SSR2 off - - SetBit(F1_gpo_01,5,1); //turn off Blower - return 1; - -} - - int test_pt100_dryer() - { - float ftemp=0; - int temp=0; - int j=0; - for (int i = 6; i < 9; i++) - { - DryerTemp[i]=Read_pt100(i); - - ftemp=DryerTemp[i]; - if ((ftemp>140)|| (ftemp<10)) - { - Units_status[i+1,1]="Fail"; - } - else - { - Units_status[i+1,1]="Pass"; - } - stubManager.Write(Units_status[i+1,0] +"\t"+ ftemp.ToString("F2")); - stubManager.Write("°C \t" + Units_status[i+1,1] + " \n"); - - } - return 0; - } -//------------------------------------------ -int Test_motor_driving () - -{ - MessageBox.Show("Open Dryer Door and add CHEATER to Door. ", "Warning"); - stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,DryerMain_Motor, true, 500); //rotate Dryer Motor. - stubManager.Write("Dryer Motor rotate \n "); - DialogResult result = MessageBox.Show("Are Dryer Motor rotate?", "Warning",MessageBoxButtons.YesNo); - if(result == DialogResult.No) - { - Units_status[3,1]="Fail"; - stubManager.Write("Dryer Motor not rotate\n"); - } - else - { - Units_status[3,1]="Pass"; - stubManager.Write("Dryer Motor rotate\n"); - } - stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,DryerMain_Motor,3); //stop motor - - return 0; -} -//---------------------------------- -int Test_Load_Arm() -{ - - Int32 temp3=0; - Int32 j=0; - Int32 i=0; - - if (!Encoder_Dryer_Exist()) - { - Units_status[4,1]="Fail"; - stubManager.Write("Encoder of Dryer Fail \n"); - return 0; - - } -// position_32bit=0; -//last_14bit_position - ReadEncoder_Dryer(); - position_32bit=0; - ReadEncoder_Dryer(); - Int32 temp=position_32bit; - stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,DrierLoadingArm_Motor, false, 100);//40 - delay(50); -// temp=ReadEncoder_Dryer(); - while ((temp3>1)&& (i<12000) ) //wait until Limit Switch or timeout 12000*50msec=10min - { - i++; - delay(50); - ReadEncoder_Dryer(); -// stubManager.Write("position_32bit " + position_32bit +"\t"); - - if (Math.Abs(position_32bit)> (50*0x4000)) - temp3=3; - if ((position_32bit-temp)>20) - temp3++; -// stubManager.Write("Temp " + temp +"\n"); - temp=position_32bit; -// stubManager.Write("Temp3 " + temp3 +"\n"); - } - stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,DrierLoadingArm_Motor, 3); - - DialogResult result1 = MessageBox.Show("Arm Motor rotate ?", "Warning",MessageBoxButtons.YesNo); - if(result1 == DialogResult.No) - { - Units_status[5,1]="Fail"; - stubManager.Write("Arm Motor Not rotate\n"); - return 0; - } - Units_status[5,1]="Pass"; - - DialogResult result2 = MessageBox.Show("Did Arm Motor arrive to mecahnicl stopper ?", "Warning",MessageBoxButtons.YesNo); - if(result2 == DialogResult.No) - { - Units_status[4,1]="Fail"; - stubManager.Write("Arm Motor Not arrive to mecahnicl stopper \n"); - return 0; - } - - position_32bit=0; - stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,DrierLoadingArm_Motor, true, 100); - delay(50); - i=0; - temp3=0; - - - while ((temp3>1)&& (i<12000) ) //wait until Limit Switch or timeout 12000*50msec=10min - { - - -// while ((Math.Abs(ReadEncoder_Dryer())< (30*0x4000))&& (i<12000)) -// -// { - delay(50); - i++; -// stubManager.Write("position_32bit " + position_32bit +"\t" + i + "\n" ); - ReadEncoder_Dryer(); -// stubManager.Write("position_32bit " + position_32bit +"\t"); - - if (Math.Abs(position_32bit)> (50*0x4000)) - temp3=3; - if ((temp-position_32bit)>20) - temp3++; -// stubManager.Write("Temp " + temp +"\n"); - temp=position_32bit; - - - } - stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,DrierLoadingArm_Motor, 3); - - DialogResult result3 = MessageBox.Show("Did Arm Motor make 30 rounds?", "Warning",MessageBoxButtons.YesNo); - if(result3 == DialogResult.No) - { - Units_status[4,1]="Fail"; - stubManager.Write("Arm Motor not make 30 rounds\n"); - return 0; - } - Units_status[4,1]="Pass"; - return 1; -} -bool Encoder_Dryer_Exist() -{ - Int32 temp; - stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x6000019e, 0x0000); //triggers a TX transmission - - var response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,0x60000190); - var response1 = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,0x60000192); - - temp = Convert.ToInt32 (response.Value & 0x0300); - if (temp==0) - return true; - else - return false; -} - - - -void ReadEncoder_Dryer() -{ - Int32 temp; - Int32 temp1; - stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x6000019e, 0x0000); //triggers a TX transmission - - var response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,0x60000190); - var response1 = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,0x60000192); - - temp = Convert.ToInt32 (((((response1.Value <<16) + response.Value)>>10 ) & 0x3fff)); - if (temp>last_14bit_position) - { - temp1=temp-last_14bit_position; - position_32bit=position_32bit+temp1; - if (temp1>0x2000) - position_32bit=position_32bit-0x4000; - } - else if (temp<last_14bit_position) - - { - temp1=last_14bit_position-temp; - position_32bit=position_32bit-temp1; - if (temp1>0x2000) - position_32bit=position_32bit+0x4000; - } - - last_14bit_position=temp; - - return ; -} -//----------------------------------- -int Test_LId () -{ - Int32 Bit = 1; - int i = 0; - - UInt32 PowerStep_driver=0; - - if (Get_Driver_Type(4)>0x14) - PowerStep_driver=1; - - - - - stubManager.Run<StubMotorMovResponse>("StubMotorMovRequest" ,DryerLid_Motor, false, 0x800000+2*(1-PowerStep_driver)); //mov Dryer Lid motor down - delay(2000); - stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,DryerLid_Motor, 2); //Hard stop hiZ motor - delay(1000); - - stubManager.Run<StubMotorMovResponse>("StubMotorMovRequest" ,DryerLid_Motor, false, 0x800000+2*PowerStep_driver); //mov Dryer Lid motor up - - while ((Bit != 0x0) && (i<200)) //wait until Limit Switch or timeout 200*50msec=10sec - { - Bit = GetBit(F1_LS_01_Direct,4); - delay(50); - i++; - } - stubManager.Write("\n--------1-Lid Open--------"); - - stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,DryerLid_Motor, 2); //Hard stop hiZ motor - DialogResult result1 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.YesNo); - if(result1 == DialogResult.No) - { - Units_status[1,1]="Fail"; - stubManager.Write("LS_Lid_Open Not calibrate\n"); - return 0; - } - Units_status[1,1]="Pass"; - - stubManager.Run<StubMotorMovResponse>("StubMotorMovRequest" ,DryerLid_Motor, false, 0x800000+2*(1-PowerStep_driver)); //mov Dryer Lid motor down - - Bit = 1; - i=0; - while ((Bit != 0x0) && (i<200)) //wait until Limit Switch or timeout 200*50msec=10sec - { - Bit = GetBit(F1_LS_01_Direct,5); - delay(50); - i++; - } - stubManager.Write("\n--------2-Lid Close--------"); - - stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,DryerLid_Motor, 2); //Hard stop hiZ motor - DialogResult result2 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.YesNo); - if(result2 == DialogResult.No) - { - Units_status[2,1]="Fail"; - stubManager.Write("LS_Lid_Close Not calibrate\n"); - return 0; - } - Units_status[2,1]="Pass"; - Units_status[0,1]="Pass"; - return 1; - -} - -UInt32 Get_Driver_Type(UInt32 i) -{ - Int32 x_GET_PARAM = 0x20; - Int32 x_ADC_OUT = 0x12; - UInt32 ADC_out ; - - - var response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_ADC_OUT)<<8, 0, 0); - - ADC_out= (response.RecivedData) & 0x001F; - stubManager.WriteHex(ADC_out,2) ; - return ADC_out ; -} - |
