0% found this document useful (0 votes)
74 views11 pages

T Main BRI Main

This document contains program code for controlling a remote welding cell. It defines constants, variables, procedures and tasks for initializing the cell, starting and stopping production, synchronizing robot tasks, and acknowledging completion signals from the PLC. The code handles events like power on, start, and stop, and initializes all signals, flags and tasks. Procedures are included to start tasks, acknowledge their completion, and reset flags accordingly.

Uploaded by

brali_23
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
74 views11 pages

T Main BRI Main

This document contains program code for controlling a remote welding cell. It defines constants, variables, procedures and tasks for initializing the cell, starting and stopping production, synchronizing robot tasks, and acknowledging completion signals from the PLC. The code handles events like power on, start, and stop, and initializes all signals, flags and tasks. Procedures are included to start tasks, acknowledge their completion, and reset flags accordingly.

Uploaded by

brali_23
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 11

46-66071: T_Main/BRI_Main %%% VERSION: 1 LANGUAGE: ENGLISH %%% MODULE BRI_Main !****************************************************************** !****************************************************************** !* * !* R e m o t e - S c h w e i z e l l e * !* ----------------------------------------* !* * !

!* Customer : brose Fahrzeugteile GmbH & Co.KG * !* Roboter Nr. : IRB 66-54172 / 76-51379 * !* Software : RobotWare OS 5.07.01.02 / M2004 * !* Autor : A. GRAN * !* Company : brose Fahrzeugteile GmbH & Co.KG * !* Department : ZFT-BT * !* Telephone : +49 (9561) 21 2859 * !* * !* Version : 1.0 * !* Created : 13.11.2006 * !* Modified : 13.11.2006 by: A. Gran * !* * !****************************************************************** !****************************************************************** ! !********************************************************** !* Lokale Konstanten * !********************************************************** LOCAL CONST num CHECK_TCP:=1; LOCAL CONST num MAN_REINIGEN:=2; LOCAL CONST num START_PRODUKTION:=3; LOCAL CONST num INDEX_REINIGEN:=9; ! !********************************************************** !* numerische Variablen und Speichernde * !********************************************************** ! !*********************************************************** !* Interrupt * !*********************************************************** !Interrupt fr Halt nach Takt VAR intnum irHaltTakt; ! !********************************************************** !* Lokale Variablen * !********************************************************** LOCAL VAR bool bStartProd:=FALSE; LOCAL VAR bool bStartOK:=FALSE; LOCAL VAR string stMachine:="Remoteschweianlage X7"; LOCAL VAR string stAddData_1:=""; LOCAL VAR string stAddData_2:=""; LOCAL VAR string stAddData_3:=""; LOCAL VAR string stAuthor:="ZFT-BT / A. GRAN"; LOCAL VAR string stVersion:="19.02.2007"; LOCAL VAR bool bShowInfo:=TRUE; LOCAL VAR string stDebugMSG{6}; ! !********************************************************** !* boolsche Variablen * !********************************************************** PERS bool bProgEnde:=FALSE; PERS bool BlockWeldingInt{4}:=[TRUE,TRUE,FALSE,FALSE]; PERS bool bSyncMode:=FALSE; PERS bool bVC:=FALSE; ! !********************************************************** ! numerische Variablen und Speichernde fr Taktzeit * !********************************************************** VAR clock clStation_1; VAR clock clStation_2; VAR clock clStation_3; VAR clock clStation_4; VAR clock clStation_5; ! !********************************************************** ! GpProcSH * !********************************************************** CONST num MM_NoAction:=0; CONST num MM_ReadCode:=100;!1; CONST num MM_STN_Change:=2; CONST num MM_ActivateSTN:=3; CONST num MM_DeactivateSTN:=4; CONST num MM_Init:=5; CONST num MM_HomePos:=10; CONST num MM_SafePos:=11; CONST num MM_ServicePos:=12; CONST num MM_CheckTCP:=13; CONST num MM_Cleaning:=14; CONST num MM_ChangeClean:=15; CONST num MM_Lasertest:=16; CONST num MM_Focustest:=17; CONST num MM_Weldtest:=18; Page 1 of 11

46-66071: T_Main/BRI_Main CONST num MM_ToolChange:=20; CONST num MM_Tool_InOut:=21; CONST num MM_Production:=30; CONST num MM_ProdWithQuitt:=1;!31; CONST num MM_SyncEndCommand:=32; CONST num ML_PRC_EXITMENU:=40; CONST num ML_PRC_EXITPROD:=41; ! !********************************************************** ! GpSyncSH * !********************************************************** PERS tasks syncTask{10}:=[["T_MAIN"],["T_ROB1"],["T_ROB2"],[""],[""],[""],[""],[""],[""],[""]]; PERS tasks sync_all_tasks{10}:=[["T_MAIN"],["T_ROB1"],["T_ROB2"],[""],[""],[""],[""],[""],[""],[""]]; PERS tasks sync_rob_tasks{10}:=[["T_ROB1"],["T_ROB2"],[""],[""],[""],[""],[""],[""],[""],[""]]; PERS tasks sync_mec_tasks{10}:=[["T_ROB1"],["T_ROB2"],[""],[""],[""],[""],[""],[""],[""],[""]]; PERS tasks sync_main_rob1{10}:=[["T_MAIN"],["T_ROB1"],[""],[""],[""],[""],[""],[""],[""],[""]]; PERS tasks sync_main_rob2{10}:=[["T_MAIN"],["T_ROB2"],[""],[""],[""],[""],[""],[""],[""],[""]]; PERS tasks sync_main_rob3{10}:=[["T_MAIN"],["T_ROB1"],[""],[""],[""],[""],[""],[""],[""],[""]]; PERS tasks sync_main_rob4{10}:=[["T_MAIN"],["T_ROB1"],[""],[""],[""],[""],[""],[""],[""],[""]]; PERS tasks sync_main_rob5{10}:=[["T_MAIN"],["T_ROB1"],[""],[""],[""],[""],[""],[""],[""],[""]]; PERS tasks sync_main_pos1{10}:=[["T_MAIN"],["T_ROB1"],[""],[""],[""],[""],[""],[""],[""],[""]]; !PERS tasks sync_ROB1_POS1{10}:=[["T_ROB1"],["T_POS1"],[""],[""],[""],[""],[""],[""],[""],[""]]; !PERS tasks sync_ROB1_ROB2{10}:=[["T_ROB1"],["T_ROB2"],[""],[""],[""],[""],[""],[""],[""],[""]]; !PERS tasks sync_ROB1_ROB3{10}:=[["T_ROB1"],["T_ROB3"],[""],[""],[""],[""],[""],[""],[""],[""]]; VAR syncident syncCommandStart; VAR syncident syncCommandActiv; VAR syncident syncCommandEnd; VAR syncident sync_point3; VAR syncident sync_point4; VAR syncident sync_point5; VAR syncident sync_point6; VAR syncident sync_point7; VAR syncident sync_point8; VAR syncident sync_point9; VAR syncident sync_point10; VAR syncident sync_point11; VAR syncident sync_point12; VAR syncident sync_point13; VAR syncident sync_point14; VAR syncident sync_point15; VAR syncident sync_point16; VAR syncident sync_point17; VAR syncident sync_point18; VAR syncident sync_point19; VAR syncident sync_point20; VAR bool bTask1_active; VAR bool bTask2_active; VAR bool bTask3_active; VAR bool bTask4_active; VAR bool bTask5_active; !********************************************************** !Copy EPS Files to HOME directory * !********************************************************** CONST string stEPSCalInternal:="INTERNAL:/OPTIONS/PSC/psc_calib_"; CONST string stEPSCalHome:="HOME:/SafetyBCK/psc_calib_"; CONST string stEPSInternal:="INTERNAL:/OPTIONS/PSC/psc_user_"; CONST string stEPSHome:="HOME:/SafetyBCK/psc_user_"; ! Filezie of an empty EPS user_config CONST num nEPSFilesize:=230; !********************************************************** !* Prozedur PowerOn * !* * !* Description: * !* * !* Neustart der IRC 5 an SPS melden und Rckmeldung * !* abwarten wird in haupt und als Ereigniss Netzein * !* gestartet * !* * !* Date: Version: Programmer: Reason: * !* 28.06.2005 1.0 A. Gran created * !********************************************************** PROC evPowerOn() ! ! Programm luft im "Virtual Controller" bVC:=StrMap(GetSysInfo(\CtrlId),STR_LOWER, STR_UPPER)="VC"; ! ! Steuerung wurde neu gestartet Set doRestartDone; ! !Warten auf Rckmeldung SPS Neustart erkannt IF bVC=FALSE WaitDI diRestartAck,high; ! ! Neustart rcksetzen Reset doRestartDone; CopyEPS_Config; ENDPROC !********************************************************** !* Prozedur evStart * !* * !* Das Event "Start" lst diese Routine aus * !* * Page 2 of 11

46-66071: T_Main/BRI_Main !* Date: Version: Programmer: Reason: * !* 23.05.2007 1.0 A. Gran created * !********************************************************** PROC evStart() ENDPROC !********************************************************** !* Prozedur evStop * !* * !* Das Event "Stop" lst diese Routine aus * !* * !* Date: Version: Programmer: Reason: * !* 23.05.2007 1.0 A. Gran created * !********************************************************** PROC evStop() ENDPROC !********************************************************** !* Prozedur InitCell * !* * !* Description: * !* * !* Definiertes setzen aller Signale und Merker * !* * !* Date: Version: Programmer: Reason: * !* 13.11.2006 1.0 A. Gran created * !********************************************************** PROC InitCell() ! ! Setzen der Variablen evPowerOn; bBlockTask:=FALSE; bProgEnde:=FALSE; bSyncMode:=FALSE; bStartOK:=FALSE; bTask1_active:=FALSE; bTask2_active:=FALSE; bTask3_active:=FALSE; bTask4_active:=FALSE; bTask5_active:=FALSE; ! ! Definiertes Setzen der Ausgnge QuittStart; SetGO sgoCommand,0; SetGO sgoSTN,0; SetGO sgoProg_1,0; SetGO sgoProg_2,0; SetGO sgoProg_3,0; SetGO sgoProg_4,0; SetGO sgoProg_5,0; SetGO sgoSyncEndComand,0; SetDO soStartCommand,0; ! ! Initialisiere alle Tasks StartCommand MM_Init; ENDPROC !********************************************************** !* Prozedur QuittStart * !* * !* Description: * !* * !* Diese Routine besttigt den zyklus Start an die SPS * !* * !* Date: Version: Programmer: Reason: * !* 26.11.2004 1.0 R. Kunkel created * !* 03.11.2006 2.0 A. Gran Brose * !********************************************************** PROC QuittStart( \num inIndex) VAR num nIndex; ! IF NOT Present(inIndex) THEN nIndex:=0; ELSE nIndex:=inIndex; ENDIF TEST nIndex ! Programmstart 1 fertig? CASE 1: Set doProgEnd_1; WaitMsgDI diProgStart_1,low,"muiStartLow"; Reset doProgEnd_1; bTask1_active:=FALSE; ! Programmstart 2 fertig? CASE 2: Set doProgEnd_2; WaitMsgDI diProgStart_2,low,"muiStartLow"; Reset doProgEnd_2; bTask2_active:=FALSE; ! Programmstart 3 fertig? CASE 3: Set doProgEnd_3; WaitMsgDI diProgStart_3,low,"muiStartLow"; Reset doProgEnd_3; bTask3_active:=FALSE; ! Programmstart 4 fertig? CASE 4: Page 3 of 11

46-66071: T_Main/BRI_Main Set doProgEnd_4; WaitMsgDI diProgStart_4,low,"muiStartLow"; Reset doProgEnd_4; bTask4_active:=FALSE; ! Programmstart 5 fertig? CASE 5: Set doProgEnd_5; WaitMsgDI diProgStart_5,low,"muiStartLow"; Reset doProgEnd_5; bTask5_active:=FALSE; ! Unterprogrammstart 1 fertig? CASE 11: Set doSubEnd_1; WaitMsgDI diSubStart_1,low,"muiStartLow"; Reset doSubEnd_1; ! Unterprogrammstart 2 fertig? CASE 12: Set doSubEnd_2; WaitMsgDI diSubStart_2,low,"muiStartSubLow"; Reset doSubEnd_2; ! Unterprogrammstart 3 fertig? CASE 13: Set doSubEnd_3; WaitMsgDI diSubStart_3,low,"muiStartSubLow"; Reset doSubEnd_3; ! Unterprogrammstart 4 fertig? CASE 14: Set doSubEnd_4; WaitMsgDI diSubStart_4,low,"muiStartSubLow"; Reset doSubEnd_4; ! Unterprogrammstart 5 fertig? CASE 15: Set doSubEnd_5; WaitMsgDI diSubStart_5,low,"muiStartSubLow"; Reset doSubEnd_5; ! Unterprogrammstart 6 fertig? CASE 16: Set doSubEnd_6; WaitMsgDI diSubStart_6,low,"muiStartSubLow"; Reset doSubEnd_6; ! Unterprogrammstart 7 fertig? CASE 17: Set doSubEnd_7; WaitMsgDI diSubStart_7,low,"muiStartSubLow"; Reset doSubEnd_7; ! Unterprogrammstart 8 fertig? CASE 18: Set doSubEnd_8; WaitMsgDI diSubStart_8,low,"muiStartSubLow"; Reset doSubEnd_8; ! Unterprogrammstart 9 fertig? CASE 19: Set doSubEnd_9; WaitMsgDI diSubStart_9,low,"muiStartSubLow"; Reset doSubEnd_9; ! Unterprogrammstart 10 fertig? CASE 20: Set doSubEnd_10; WaitMsgDI diSubStart_10,low,"muiStartSubLow"; Reset doSubEnd_10; ! Unterprogrammstart 11 fertig? CASE 21: Set doSubEnd_11; WaitMsgDI diSubStart_11,low,"muiStartSubLow"; Reset doSubEnd_11; DEFAULT: Set doProgEnd_1; Set doProgEnd_2; Set doProgEnd_3; Set doProgEnd_4; Set doProgEnd_5; Set doSubEnd_1; Set doSubEnd_2; Set doSubEnd_3; Set doSubEnd_4; Set doSubEnd_5; Set doSubEnd_6; Set doSubEnd_7; Set doSubEnd_8; Set doSubEnd_9; Set doSubEnd_10; Set doSubEnd_11; ! !Warten auf Besttigung von SPS WaitMsgGI giProgStart,0,"muiStartLow"; WaitMsgGI giSubStart,0,"muiStartSubLow"; Reset doProgEnd_1; Reset doProgEnd_2; Reset doProgEnd_3; Reset doProgEnd_4; Reset doProgEnd_5; Reset doSubEnd_1; Reset doSubEnd_2; Reset doSubEnd_3; Reset doSubEnd_4; Reset doSubEnd_5; Reset doSubEnd_6; Reset doSubEnd_7; Reset doSubEnd_8; Reset doSubEnd_9; Reset doSubEnd_10; Reset doSubEnd_11; ENDTEST ENDPROC !********************************************************** Page 4 of 11

46-66071: T_Main/BRI_Main !* Prozedur StartCommand * !* * !* Description: * !* * !* Diese Routine startet sendet den Auftrag an alle * !* TASKS * !* * !* Date: Version: Programmer: Reason: * !* 18.10.2004 1.0 R. Kunkel created * !* 03.11.2006 2.0 A. Gran Brose * !********************************************************** PROC StartCommand( num inAction \num inTask \num inSTN, \num inProg_1, \num inProg_2, \num inProg_3, \num inProg_4, \num inProg_5) VAR num nTask; VAR num nSTN; VAR num nProg_1; VAR num nProg_2; VAR num nProg_3; VAR num nProg_4; VAR num nProg_5; IF NOT Present(inTask) THEN nTask:=99; ELSE nTask:=inTask; ENDIF IF NOT Present(inProg_1) THEN nProg_1:=0; ELSE nProg_1:=inProg_1; ENDIF IF NOT Present(inProg_2) THEN nProg_2:=0; ELSE nProg_2:=inProg_2; ENDIF IF NOT Present(inProg_3) THEN nProg_3:=0; ELSE nProg_3:=inProg_3; ENDIF IF NOT Present(inProg_4) THEN nProg_4:=0; ELSE nProg_4:=inProg_4; ENDIF IF NOT Present(inProg_5) THEN nProg_5:=0; ELSE nProg_5:=inProg_5; ENDIF IF NOT Present(inSTN) THEN nSTN:=0; ELSE nSTN:=inSTN; ENDIF TEST nTask CASE 1: syncTask:=sync_main_rob1; CASE 2: syncTask:=sync_main_rob2; CASE 3: syncTask:=sync_main_rob3; CASE 4: syncTask:=sync_main_rob4; CASE 5: syncTask:=sync_main_pos1; DEFAULT: syncTask:=sync_all_tasks; ENDTEST ! ! Tasks starten IF (inAction<>MM_SyncEndCommand) and (inAction<>MM_noAction) THEN SetGO sgoCommand,inAction; SetGO sgoTask,nTask; SetGO sgoSTN,nSTN; SetGO sgoProg_1,nProg_1; SetGO sgoProg_2,nProg_2; SetGO sgoProg_3,nProg_3; SetGO sgoProg_4,nProg_4; SetGO sgoProg_5,nProg_5; SetDO soStartCommand,1; WaitSyncTask syncCommandStart, syncTask; !Juergen ENDIF ! ! Warten auf Beendigung SetDO soStartCommand,0; SetGO sgoCommand,0; SetGO sgoTask,0; SetGO sgoSTN,0; SetGO sgoProg_1,0; SetGO sgoProg_2,0; SetGO sgoProg_3,0; Page 5 of 11

46-66071: T_Main/BRI_Main SetGO sgoProg_4,0; SetGO sgoProg_5,0; bShowInfo:=TRUE; if inAction<>MM_ProdWithQuitt then WaitSyncTask syncCommandEnd,syncTask; SetGO sgoSyncEndComand,0; endif IF inAction=MM_noAction WaitTime 0.02; ENDPROC

!Juergen

!********************************************************** !* Prozedur Main * !* * !* Description: * !* * !* * !* * !* Date: Version: Programmer: Reason: * !* 03.11.2006 1.0 A. Gran Brose * !********************************************************** PROC Main() VAR num nAction; VAR num nTask; VAR num nSTN; VAR num nProg_1; VAR num nProg_2; VAR num nProg_3; VAR num nProg_4; VAR num nProg_5; ! ! Aktuelle Sprache setzen InitLanguage "DE"; ! ! Version des Roboterprogramms stVersion:="24.10.2008"; ! ! Startwerte setzen InitCell; ! ! SPS start? bShowInfo:=True; WHILE TRUE DO WHILE not PLC_Command(nAction,nTask,nSTN,nProg_1,nProg_2,nProg_3,nProg_4,nProg_5) DO ProgInfo bShowInfo,stMachine,stAddData_1,stAddData_2,stAddData_3,stAuthor,stVersion; ENDWHILE ! ! Aktion ausfhren TEST nAction ! Keine Aktion CASE MM_NoAction: Waittime 0.01; ! Stationswechsel CASE MM_STN_Change: StartCommand MM_NoAction; ! Aktiviere Stationstisch CASE MM_ActivateSTN: StartCommand MM_NoAction; ! Deaktiviere Stationstisch CASE MM_DeactivateSTN: StartCommand MM_NoAction; ! Fahre nach HomePos CASE MM_HomePos: StartCommand MM_HomePos; ! Fahre nach SafePos CASE MM_SafePos: StartCommand MM_NoAction; ! Fahre nach ServicePos CASE MM_ServicePos: StartCommand MM_ServicePos\inTask:=nTask; ! Warten auf fertig QuittStart\inIndex:=nProg_1; ! Laser Leistungstest CASE MM_Lasertest: StartCommand MM_Lasertest\inTask:=nTask; ! Warten auf fertig QuittStart\inIndex:=nProg_1; ! Fokus Laser berprfen CASE MM_Focustest: StartCommand MM_Focustest\inTask:=nTask; ! Warten auf fertig QuittStart\inIndex:=nProg_1; ! Schweiversuch durchfhren CASE MM_Weldtest: StartCommand MM_Weldtest\inTask:=nTask; ! Warten auf fertig QuittStart\inIndex:=nProg_1; ! TCP im BullsEye prfen CASE MM_CheckTCP: StartCommand MM_NoAction; ! Brennerreinigen CASE MM_Cleaning: StartCommand MM_NoAction; ! Stationswechsel und dabei Brenner reinigen CASE MM_ChangeClean: StartCommand MM_NoAction; ! Umrsten CASE MM_ToolChange: StartCommand MM_ToolChange\inTask:=nTask; ! Warten auf fertig QuittStart\inIndex:=nProg_1; ! Werkzeug auf Wagen ablegen oder holen CASE MM_Tool_InOut: StartCommand MM_Tool_InOut\inTask:=nTask; ! Warten auf fertig QuittStart\inIndex:=nProg_1; ! Produktion (Zelle hat einen Ablauf) CASE MM_Production: StartCommand MM_NoAction; ! Produktion mit SPS Quittierung fr jeden Roboter CASE MM_ProdWithQuitt: CycletimeStart(nTask); Page 6 of 11

46-66071: T_Main/BRI_Main ! Task starten StartCommand MM_ProdWithQuitt\inTask:=nTask\inProg_1:=nProg_1\inProg_2:=nProg_2; ! End-Syncronisierung fr Action "MM_ProdWithQuitt" CASE MM_SyncEndCommand: StartCommand MM_SyncEndCommand\inTask:=nTask; ! Warten auf fertig QuittStart\inIndex:=nTask; !Rcksetzten aller Signale ResetCycle; ! Stoppe Zeit fr "Taktzeitanzeige" CycletimeEnd(nTask); DEFAULT: nMsgAnswere := MessageDlg("!!! Error !!!", "muiMultiMove"); Stop; ENDTEST WaitTime 0.01; ENDWHILE ! ERROR IF ERRNO=ERR_REFUNKPRC THEN EXIT; ENDIF nMsgAnswere := MessageDlg("!!! Error !!!", "muiProgram"); Stop; ENDPROC !********************************************************** !* Prozedur CycletimeStart n * !* * !* Description: * !* * !* Start zum Messen der Zykluszeit auf ... * !* * !* Date: Version: Programmer: Reason: * !* 19.02.2004 1.0 R. Kunkel created * !* 03.11.2006 2.0 A. Gran Brose * !********************************************************** PROC CycletimeStart(num inTask) IF inTask<1 OR inTask>5 RETURN; TEST inTask CASE 1: ClkReset clStation_1; ClkStart clStation_1; CASE 2: ClkReset clStation_2; ClkStart clStation_2; CASE 3: ClkReset clStation_3; ClkStart clStation_3; CASE 4: ClkReset clStation_4; ClkStart clStation_4; CASE 5: ClkReset clStation_5; ClkStart clStation_5; ENDTEST ENDPROC !********************************************************** !* Prozedur CycletimeEnd n * !* * !* Description: * !* * !* Ende der Zykluszeit erfassen * !* * !* Date: Version: Programmer: Reason: * !* 19.02.2004 1.0 R. Kunkel created * !* 16.07.2007 2.0 A. Gran Brose * !********************************************************** PROC CycletimeEnd(num inTask) VAR num nCycletime; VAR num nMinutes; VAR num nSeconds; IF inTask<1 OR inTask>5 RETURN; TEST inTask CASE 1: ClkStop clStation_1; nCycletime:=ClkRead(clStation_1); nCycletime:=Round(nCycletime\Dec:=0); nMinutes:=Round(nCycletime/60*100\Dec:=0); nMinutes:=Trunc(nMinutes/100\Dec:=0); IF nMinutes>0 THEN nSeconds:=nCycletime-nMinutes*60; stAddData_2:=GetMUI_Text("muiAddData_2")+ValToStr(nMinutes)+" min "+ValToStr(nSeconds)+" sec"; ELSE nCycletime:=ClkRead(clStation_1); nCycletime:=Round(nCycletime\Dec:=2); stAddData_2:=GetMUI_Text("muiAddData_2")+ValToStr(nCycletime)+" sec"; ENDIF CASE 2: ClkStop clStation_2; nCycletime:=ClkRead(clStation_2); nCycletime:=Round(nCycletime\Dec:=0); Page 7 of 11

46-66071: T_Main/BRI_Main nMinutes:=Round(nCycletime/60*100\Dec:=0); nMinutes:=Trunc(nMinutes/100\Dec:=0); IF nMinutes>0 THEN nSeconds:=nCycletime-nMinutes*60; stAddData_3:=GetMUI_Text("muiAddData_3")+ValToStr(nMinutes)+" min "+ValToStr(nSeconds)+" sec"; ELSE nCycletime:=ClkRead(clStation_2); nCycletime:=Round(nCycletime\Dec:=2); stAddData_3:=GetMUI_Text("muiAddData_3")+ValToStr(nCycletime)+" sec"; ENDIF CASE 3: ClkStop clStation_3; nCycletime:=ClkRead(clStation_3); nCycletime:=Round(nCycletime\Dec:=0); nMinutes:=Round(nCycletime/60*100\Dec:=0); nMinutes:=Trunc(nMinutes/100\Dec:=0); IF nMinutes>0 THEN nSeconds:=nCycletime-nMinutes*60; !stAddData_3:=GetMUI_Text("muiAddData_3")+ValToStr(nMinutes)+" min "+ValToStr(nSeconds)+" sec"; ELSE nCycletime:=ClkRead(clStation_3); nCycletime:=Round(nCycletime\Dec:=2); !stAddData_3:=GetMUI_Text("muiAddData_3")+ValToStr(nCycletime)+" sec"; ENDIF CASE 4: ClkStop clStation_4; nCycletime:=ClkRead(clStation_4); nCycletime:=Round(nCycletime\Dec:=0); nMinutes:=Round(nCycletime/60*100\Dec:=0); nMinutes:=Trunc(nMinutes/100\Dec:=0); IF nMinutes>0 THEN nSeconds:=nCycletime-nMinutes*60; !stAddData_3:=GetMUI_Text("muiAddData_3")+ValToStr(nMinutes)+" min "+ValToStr(nSeconds)+" sec"; ELSE nCycletime:=ClkRead(clStation_4); nCycletime:=Round(nCycletime\Dec:=2); !stAddData_3:=GetMUI_Text("muiAddData_3")+ValToStr(nCycletime)+" sec"; ENDIF CASE 5: ClkStop clStation_5; nCycletime:=ClkRead(clStation_5); nCycletime:=Round(nCycletime\Dec:=0); nMinutes:=Round(nCycletime/60*100\Dec:=0); nMinutes:=Trunc(nMinutes/100\Dec:=0); IF nMinutes>0 THEN nSeconds:=nCycletime-nMinutes*60; !stAddData_3:=GetMUI_Text("muiAddData_3")+ValToStr(nMinutes)+" min "+ValToStr(nSeconds)+" sec"; ELSE nCycletime:=ClkRead(clStation_5); nCycletime:=Round(nCycletime\Dec:=2); !stAddData_3:=GetMUI_Text("muiAddData_3")+ValToStr(nCycletime)+" sec"; ENDIF ENDTEST ENDPROC !********************************************************** !* Prozedur ResetCycle * !* * !* Description: * !* * !* Diese Routine initialisiert alle Signale im laufenden * !* Zyklus * !* * !* Date: Version: Programmer: Reason: * !* 30.11.2004 1.0 R. Kunkel created * !* 03.11.2006 2.0 A. Gran Brose * !********************************************************** PROC ResetCycle() bStartProd:=FALSE; bSyncMode:=FALSE; bShowInfo:=TRUE; ERROR RAISE; ENDPROC !********************************************************** !* Funktion PLC_Command * !* * !* Description: * !* * !* Diese Funktion liest den Auftrag von der SPS * !* * !* Date: Version: Programmer: Reason: * !* 18.10.2004 1.0 R. Kunkel created * !* 03.11.2006 2.0 A. Gran Brose * !********************************************************** FUNC bool PLC_Command( VAR num inAction, VAR num inTask, VAR num inSTN, VAR num inProg_1, VAR num inProg_2, VAR num inProg_3, VAR num inProg_4, Page 8 of 11

46-66071: T_Main/BRI_Main VAR num inProg_5) VAR num nSTN; VAR bool bReturn; ! !Einlesen der Tischseite vor Roboter nSTN:=ActualSTN(); bReturn:=FALSE; ! ! SPS-Starts auswerten IF GOutput(sgoSyncEndComand) <> 0 THEN ! Task mchte End-Syncronisierung inTask:=GOutput(sgoSyncEndComand); inAction:=MM_SyncEndCommand; bSyncMode:=FALSE; bReturn:=TRUE; ! Programmstart ELSEIF diProgStart_1=high AND (bTask1_active=FALSE) THEN inTask:=1; inAction:=MM_ProdWithQuitt; inProg_1:=giProgNo_1; inProg_2:=giProgNo_2; bSyncMode:=FALSE; bReturn:=TRUE; SetDO soIRB1_Started, 1; ! Programmstart ELSEIF diProgStart_2=high AND (bTask2_active=FALSE) THEN inTask:=2; inAction:=MM_ProdWithQuitt; inProg_1:=giProgNo_3; inProg_2:=giProgNo_4; bSyncMode:=FALSE; bReturn:=TRUE; SetDO soIRB2_Started, 1; ! Programmstart ELSEIF diProgStart_3=high AND (bTask3_active=FALSE) THEN inTask:=0; inAction:=MM_noAction; inProg_1:=giProgNo_3; inProg_2:=giProgNo_3 + 1; bSyncMode:=FALSE; bReturn:=TRUE; ! Programmstart ELSEIF diProgStart_4=high AND (bTask4_active=FALSE) THEN inTask:=0; inAction:=MM_noAction; inProg_1:=giProgNo_4; inProg_2:=giProgNo_4 + 1; bSyncMode:=FALSE; bReturn:=TRUE; ! Programmstart ELSEIF diProgStart_5=high AND (bTask5_active=FALSE) THEN inTask:=0; inAction:=MM_noAction; inProg_1:=giProgNo_5; inProg_2:=giProgNo_5 + 1; bSyncMode:=FALSE; bReturn:=TRUE; ! Unterprogrammstart 1: ELSEIF diSubStart_1=high THEN inTask:=1; inAction:=MM_noAction; bSyncMode:=FALSE; inProg_1:=11; bReturn:=TRUE; ! Unterprogrammstart 2: ELSEIF diSubStart_2=high THEN inTask:=2; inAction:=MM_noAction; bSyncMode:=FALSE; inProg_1:=12; bReturn:=TRUE; ! Unterprogrammstart 3: ELSEIF diSubStart_3=high THEN inTask:=1; inAction:=MM_noAction; bSyncMode:=FALSE; inProg_1:=13; bReturn:=TRUE; ! Unterprogrammstart 4: ELSEIF diSubStart_4=high THEN inTask:=1; inAction:=MM_noAction; bSyncMode:=FALSE; inProg_1:=14; bReturn:=TRUE; ! Unterprogrammstart 5: ELSEIF diSubStart_5=high THEN inTask:=1; inAction:=MM_noAction; bSyncMode:=FALSE; inProg_1:=15; bReturn:=TRUE; ! Unterprogrammstart 6: ELSEIF diSubStart_6=high THEN inTask:=1; inAction:=MM_noAction; bSyncMode:=FALSE; inProg_1:=16; bReturn:=TRUE; ! Unterprogrammstart 7: ELSEIF diSubStart_7=high THEN inTask:=2; inAction:=MM_noAction; bSyncMode:=FALSE; inProg_1:=17; bReturn:=TRUE; ! Unterprogrammstart 8: ELSEIF diSubStart_8=high THEN Page 9 of 11

46-66071: T_Main/BRI_Main inTask:=1; inAction:=MM_noAction; bSyncMode:=FALSE; inProg_1:=18; bReturn:=TRUE; ! Unterprogrammstart 9: ELSEIF diSubStart_9=high THEN inTask:=2; inAction:=MM_noAction; bSyncMode:=FALSE; inProg_1:=19; bReturn:=TRUE; ! Unterprogrammstart 10 ELSEIF diSubStart_10=high THEN inTask:=0; inAction:=MM_noAction; bSyncMode:=FALSE; inProg_1:=20; bReturn:=TRUE; ! Unterprogrammstart 11 ELSEIF diSubStart_11=high THEN inTask:=0; inAction:=MM_noAction; bSyncMode:=FALSE; inProg_1:=21; bReturn:=TRUE; ELSE inTask:=0; inSTN:=0; inAction:=MM_NoAction; bReturn:=FALSE; WaitTime 0.01; ENDIF ! ! Welche Task wurde aktiviert IF (inAction=MM_ProdWithQuitt) THEN TEST inTask CASE 1: bTask1_active:=True; CASE 2: bTask2_active:=True; CASE 3: bTask3_active:=True; CASE 4: bTask4_active:=True; CASE 5: bTask5_active:=True; ENDTEST ENDIF RETURN bReturn; ENDFUNC !********************************************************** !* Funktion ActualSTN * !* * !* Description: * !* * !* Diese Funktion liefert die Seite zurck die aktuell * !* vor den Roboteren steht * !* * !* Date: Version: Programmer: Reason: * !* 18.10.2004 1.0 R. Kunkel created * !* 03.11.2006 2.0 A. Gran Brose * !********************************************************** FUNC num ActualSTN() !IF diLS_1_INPOS=high AND diLS_2_INPOS=low RETURN 1; !IF diLS_2_INPOS=high AND diLS_1_INPOS=low RETURN 2; RETURN 0; ENDFUNC !********************************************************** !* Funktion Deplete * !* * !* Diese Funktion berprft ob die Produktion auf einer * !* Tischseite abgewhlt ist * !* * !* Date: Version: Programmer: Reason: * !* 15.01.2004 1.0 R. Kunkel created * !********************************************************** FUNC bool Deplete() !IF diLS_1_INPOS=high AND diLS_2_INPOS=low AND diLeerfahrtS1=low RETURN FALSE; !IF diLS_1_INPOS=low AND diLS_2_INPOS=high AND diLeerfahrtS2=low RETURN FALSE; RETURN TRUE; ENDFUNC !********************************************************** !* CopyEPS_Config * !* * !* This routine copies the EPS files into !* the home directory. You can add this to an !* Event routine for PowerOn event * !* * !* Date: Version: Programmer: Reason: * !* 2008-07-04 1.0 K.Behnisch created * !********************************************************** PROC CopyEPS_Config() VAR VAR VAR VAR string string string string stEPSCalFileInt; stEPSFileInt; stEPSCalFileHome; stEPSFileHome;

* *

Page 10 of 11

46-66071: T_Main/BRI_Main ! create folder MakeDir "HOME:/SafetyBCK"; FOR i FROM 1 TO 4 DO ! Check all files stEPSCalFileHome:= stEPSCalHome+ ValToStr(i)+ ".xml"; stEPSCalFileInt:= stEPSCalInternal+ ValToStr(i)+ ".xml"; stEPSFileHome:= stEPSHome+ ValToStr(i)+ ".sxml"; stEPSFileInt:= stEPSInternal+ ValToStr(i)+ ".sxml"; ! If file has a config then safe to Home IF FileSize(stEPSFileInt) > nEPSFilesize THEN IF IsFile(stEPSFileHome) THEN ! delete existing file RemoveFile stEPSFileHome; ENDIF IF IsFile(stEPSCalFileHome) then ! delete existing file RemoveFile stEPSCalFileHome; ENDIF ! Copy actual config CopyFile stEPSFileInt, stEPSFileHome; CopyFile stEPSCalFileInt, stEPSCalFileHome; ENDIF ENDFOR ERROR IF ERRNO = ERR_FILEEXIST THEN !Do Nothing ELSEIF ERRNO = ERR_FILEACC then TRYNEXT; ENDIF ENDPROC ENDMODULE

Page 11 of 11

You might also like