SEW伺服电机IPOS典型控制程序

更新时间:2024-05-14 10:40:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

/****************************************************************************

--------------------------------

10.18.01 D.Broerman Copied from Version 5 of Rack Stacker Software

08.01.02 D.Broerman Added Position_6a to control the Vaccum Cup extend position 10.08.02 D.Broerman V04 Added sequence to Load from Rack 31.01.03 St. Reuter V05 Communication via Device Net 17.04.03 IBB China CSG Pos.13 Necessary Parameters: --------------------------

Operating Mode = VFC-n-Reg. & IPOS Parameter P700

Parameter P100 Sollwertquelle = Feldbus Parameter P101 Steuerquelle = Feldbus

Binary Inputs Base Unit DI00 Enable

P600 DI01 Release/Rapid Stop P601 DI02 High Speed Input 1 P602 DI03 High Speed Input 2 P603 DI04 Spare P604 DI05 Spare aaa

Binary Option Card 1

P610 DI10 IPOS Input (Vacuum Cup Extended Prox) P611 DI11 IPOS Input (Vacuum Cup Retracted Prox) P612 DI12 IPOS Input (Vacuum Switch) P613 DI13 IPOS Input (Spare) P614 DI14 IPOS Input (Spare) P615 DI15 IPOS Input (Spare) P616 DI16 IPOS Input (Spare) P617 DI17 IPOS Input (Spare)

Binary Inputs IPOS Inputs PA 1 (Device Net)

DI20 IPOS Input (Start Cycle Signal Stacking) DI21 IPOS Input (Stop Cycle Signal)

DI22 IPOS Input (MotorRight/ Halt, Arm Up Hand) DI23 IPOS Input (MotorLeft/ Halt, Arm Down Hand) DI24 IPOS Input (Vacuum Man Mode) DI25 IPOS Input (Release Man Mode)

DI26 IPOS Input (Vacuum Cup In/Out Man Mode) DI27 IPOS Input (Stacker Mode)

(Automatic = 1) (ManualMode = 0) DI30 IPOS Input (Loading Cycle Start) DI31 IPOS Input (Start Rack Reference) DI32 Spare DI33 Spare DI34 Spare DI35 Spare DI36 Spare DI37 Spare

Binary Outputs Base Unit

DB00 Configured with Brake P620 DO01 Drive Ready P621 DO02 Drive Fault

Binary Output Option Card 1

P630 DO10 IPOS Output (Arm Down)

P631 DO11 IPOS Output (Conv Release In Transport) P632 DO12 IPOS Output (Stacker Fault) P633 DO13 IPOS Output (Basic Position)

P634 DO14 IPOS Output (Conv Release Out Transport) P635 DO15 IPOS Output (Vacuum Cup Extended) P636 DO16 IPOS Output (Rack Reference Position) P637 DO17 IPOS Output (Vacuum Fault)

Output Option Card 2

DO20 IPOS Output (Vacuum Cup Extend Sol) DO21 IPOS Output (Vacuum Cup Retract Sol) DO22 IPOS Output (Vacuum On Sol) D023 IPOS Output (Vacuum Off Sol) DO24 IPOS Output (Blow Off On) DO25 IPOS Output (Spare) DO26 IPOS Output (Spare) DO27 IPOS Output (Spare)

P941 IPOS Geberquelle = Motor Encoder on Terminal X15

Anwenderprogramm mit folgenden Funktionen : -------------------------------------------

1)Allgemeiner ManualMode eines positioniergeregelten Antriebs.

- 黚er zwei Eingangsklemmen kann der Antrieb mit einer festen Geschwindigkeit in beide Richtungen gefahren werden. - Die Lageregelung ist dabei aktiv.

- Eine vorherige Referenzfahrt ist nicht notwendig.

2)Betriebsart Automatic

****************************************************************************/

#include #include

//================= Fahr Variables =========================================== #pragma globals 200 250

long V_MotorRight, V_MotorLeft;

//================= Ziel Position - Variables ============================== #define Position_0 H0 #define Position_1 H1 #define Position_2 H2 #define Position_3 H3 #define Position_4 H4 #define Position_5 H5 #define Position_6 H6 #define Position_7 H7 #define Position_8 H8 #define Position_9 H9 #define Position_10 H10 #define Ref_Pos H11 #define Position_6a H12

#define Auto_Speed_0 H20 #define Auto_Speed_1 H21 #define Auto_Speed_2 H22 #define Ref_Speed_0 H23 #define Auto_Speed_3 H24 #define Man_Speed_0 H25

#define Auto_Speed_4 H26 #define Auto_Speed_5 H27 #define Auto_Speed_6 H28

#define Position_Window H30

#define M_State H31 #define M_Fault H32 #define M_Merker H33

#define Pos_0 H35 #define M_Loading H36 #define M_Stacking H37

#define Load_Pos_0 H40 #define Load_Pos_1 H41 #define Load_Pos_2 H42 #define Load_Pos_3 H43 #define Load_Pos_4 H44 #define Load_Pos_5 H45 #define Load_Pos_6 H46 #define Load_Pos_7 H47 #define Load_Pos_8 H48 #define Load_Pos_9 H49 #define Load_Pos_10 H50 #define Load_Pos_11 H51 #define Load_Pos_12 H52 #define Load_Pos_6a H53

#define Bustyp H100 #define Le_PA_DATA H101 #define PA1 H102 #define PA2 H103 #define PA3 H104 #define Le_PE_DATA H110 #define PE1 H111 #define PE2 H112 #define PE3 H113

//================= INPUTS ========================================= //Onboard Inputs

#define E_DriveEnable DI00 #define E_DriveRel DI01 #define E_Touchp_1 DI02 #define E_Touchp_2 DI03 #define E_Spare_1 DI04 #define E_Spare_2 DI05

//Inputs Card DIO 11A

#define E_CupExtendedProx DI10 #define E_CupRetractedProx DI11 #define E_VacuumSwitch DI12 #define E_Spare_3 DI13 #define E_Spare_4 DI14 #define E_Spare_5 DI15 #define E_Spare_6 DI16 #define E_Spare_7 DI17

//Inputs Field Bus

#define E_Start_Cycle ((PA1 & 0b1)!=0) #define E_Stop_Cycle ((PA1 & 0b10)!=0) #define E_ArmRight ((PA1 & 0b100)!=0) #define E_ArmLeft ((PA1 & 0b1000)!=0) #define E_VacManMode ((PA1 & 0b10000)!=0) #define E_RelManMode ((PA1 & 0b100000)!=0) #define E_CupInOutManMode ((PA1 & 0b1000000)!=0) #define E_AutoMode ((PA1 & 0b10000000)!=0) #define E_LoadCycleStart ((PA1 & 0b100000000)!=0) #define E_ReferenceRack ((PA1 & 0b1000000000)!=0) #define E_Continue_Cycle ((PA1 & 0b10000000000)!=0) #define E_Reset_Cycle ((PA1 & 0b100000000000)!=0) #define E_Resume_Cycle ((PA1 & 0b1000000000000)!=0) #define E_Vacuum_On_Auto ((PA1 & 0b10000000000000)!=0)

//================= OUTPUTS =========================================

//Onboard Outputs

#define A_DriveReady DO01 #define A_DriveFault DO02

//Outputs Card DIO 11A

#define A_CupExtendSol 0 //DO20 #define A_CupRetractSol 1 //DO21 #define A_VacuumOnSol 2 //DO22 #define A_VacuumOffSol 3 //DO23 #define A_BlowOffSol 4 //DO24

//Outputs Fieldbus

#define PE1_Output PE1 #define A_StackerArmDown 0

_BitClear (PE1_Output, A_ArmReferencePos); _BitClear (PE1_Output, A_ArmProbePos); _BitClear (OptOutpIPOS, A_CupExtendSol); _BitClear (OptOutpIPOS, A_CupRetractSol); }

switch (M_State) {

case 1:

_SetSys( SS_ACTPOS, Pos_0 ); _BitSet(H484,1); _Wait(2);

ActPos_Mot = 0; TargetPos = 0; _Wait(2);

_BitClear(H484,1);

_TouchProbe( TP_EN1 );

V_MotorRight = V_MotorLeft = Auto_Speed_0; _SetSys (SS_POSSPEED, V_MotorRight); _GoAbs (GO_NOWAIT, Position_1); M_State = 2 ; break ;

case 2: //Check Drive Stopped, Start Position not Found if (StatusWord & Bit_19) {

( M_State = 3 ); } break ;

case 3: //Start Position Not Found _AxisStop( AS_RSTOP );

_BitSet(PE1_Output, A_StackerFault); _TouchProbe( TP_DIS1 ); M_State = 0 ; M_Fault = 1 ; break ;

case 4: // Start Position Found if (!E_ReferenceRack) {

M_State = 5 ; }

else {

M_State = 8 ; } break ;

case 5: // Move to Rack Reference Position V_MotorRight = V_MotorLeft = Auto_Speed_1; _SetSys (SS_POSSPEED, V_MotorRight);

_GoAbs (GO_NOWAIT, Ref_Pos); // Rack Reference Position M_State = 6 ; break ;

case 6: // Release Rack Reference Motion (ge鋘dert: Stadelmeier if ((StatusWord & Bit_19) && E_CupExtendedProx) // 15.09.03)

{

M_State = 7 ;

_BitSet(PE1_Output, A_ArmReferencePos); _BitSet(PE1_Output, A_ArmProbePos); } break ;

case 7:

if (E_Continue_Cycle) {

if (!E_ReferenceRack && (M_Stacking == 1)) {

_BitClear (OptOutpIPOS, A_VacuumOnSol); _BitSet (OptOutpIPOS, A_VacuumOffSol); _BitSet(OptOutpIPOS, A_BlowOffSol); _Wait(500);

_BitClear (PE1_Output, A_ArmReferencePos); _BitClear (PE1_Output, A_ArmProbePos); M_State = 8 ; } }

else if (M_Loading == 1) {

_Wait(500);

_BitClear (PE1_Output, A_ArmReferencePos); _BitClear (PE1_Output, A_ArmProbePos); if (!E_VacuumSwitch)

{

M_State = 8 ;

_BitSet(PE1_Output, A_VacuumFault); } else {

M_State = 8 ; } } break ;

case 8: // move to End Position if (M_Stacking == 1) {

V_MotorRight = V_MotorLeft = Auto_Speed_4; _SetSys (SS_POSSPEED, V_MotorRight);

_GoAbs (GO_NOWAIT, Position_10); //End Position M_State = 9 ; }

else if (M_Loading == 1) {

V_MotorRight = V_MotorLeft = Auto_Speed_5; _SetSys (SS_POSSPEED, V_MotorRight);

_GoAbs (GO_NOWAIT, Load_Pos_0); //End Position M_State = 9 ; } break ;

case 9:

if (StatusWord & Bit_19) // in Position {

( M_State = 0 ); } break ; }

} // End AutomaticMode()

/*================================================ Task2 Program PositionStateMachine.

Hier werden die binary Output zur R點kmeldung der Istposition gesetzt.

=================================================*/ PositionStateMachine()

//******* //******* {

if (E_AutoMode && (M_State >= 5) && (M_Stacking == 1)) // Stacking Active {

if ((ActPos_Mot > Position_3) && (ActPos_Mot <= Position_4)) {

_BitClear (OptOutpIPOS, A_VacuumOffSol); // Vac On _BitSet(OptOutpIPOS, A_VacuumOnSol); }

if ((ActPos_Mot > Position_4) && (ActPos_Mot <= Position_5)) {

}

if ((ActPos_Mot > Position_5) && (ActPos_Mot <= Position_6)) {

/* _BitClear (OptOutpIPOS, A_CupExtendSol); // Vac Cup Ret*/ /* _BitSet(OptOutpIPOS, A_CupRetractSol);*/ }

if ((ActPos_Mot > Position_6) && (ActPos_Mot <= Position_7)) {

V_MotorRight = V_MotorLeft = Auto_Speed_2; // Slow Speed _SetSys (SS_POSSPEED, V_MotorRight);

if (A_CupExtendSol && (!E_VacuumSwitch)) // Check Vac Switch _BitSet(PE1_Output, A_VacuumFault); }

if ((ActPos_Mot > Position_6a) && (ActPos_Mot <= Position_7)) {

/* _BitClear (OptOutpIPOS, A_CupRetractSol); // Vac Cup Ext*/ /* _BitSet(OptOutpIPOS, A_CupExtendSol);*/ _BitClear (OptOutpIPOS, A_CupExtendSol); }

if ((ActPos_Mot > Position_7) && (ActPos_Mot <= Position_8)) {

if ((M_State >= 8)) {

_BitClear (OptOutpIPOS, A_VacuumOnSol); // Vac Rel _BitSet (OptOutpIPOS, A_VacuumOffSol); _BitSet (OptOutpIPOS, A_BlowOffSol); } }

if ((ActPos_Mot > Position_8) && (ActPos_Mot <= Position_9)) {

_BitClear (OptOutpIPOS, A_VacuumOffSol); // Blow-Off Off _BitClear(OptOutpIPOS, A_CupExtendSol);

V_MotorRight = V_MotorLeft = Auto_Speed_1; _SetSys (SS_POSSPEED, V_MotorRight); }

if ((ActPos_Mot > Position_9) && (ActPos_Mot <= Position_10)) {

_BitClear (OptOutpIPOS, A_BlowOffSol);

_BitSet (PE1_Output, A_ConvRel); // Conv Release _BitClear (OptOutpIPOS, A_CupExtendSol); _BitSet(OptOutpIPOS, A_CupRetractSol); }

} // End Stacking Active

if (E_AutoMode && (M_State == 6) && (M_Loading == 1)) // Loading Active {

if ((ActPos_Mot > Load_Pos_1) && (ActPos_Mot <= Load_Pos_2)) {

_BitClear (OptOutpIPOS, A_CupExtendSol); // Vac Cup Ret _BitSet(OptOutpIPOS, A_CupRetractSol); }

if ((ActPos_Mot > Load_Pos_2) && (ActPos_Mot <= Load_Pos_3)) {

// V_MotorRight = V_MotorLeft = Auto_Speed_2; // Slow Speed // _SetSys (SS_POSSPEED, V_MotorRight); }

if ((ActPos_Mot > Load_Pos_3) && (ActPos_Mot <= Load_Pos_4)) {

_BitClear(OptOutpIPOS, A_CupRetractSol);

_BitSet (OptOutpIPOS, A_CupExtendSol); // Vac Cup Ext _BitClear (OptOutpIPOS, A_VacuumOffSol); // Vac On _BitSet(OptOutpIPOS, A_VacuumOnSol); }

} // End Loading Up Active

if (E_AutoMode && (M_State == 9) && (M_Loading == 1)) // Loading Down {

if ((ActPos_Mot > Load_Pos_6) && (ActPos_Mot <= Load_Pos_5)) {

_BitClear(OptOutpIPOS, A_CupExtendSol);

_BitSet (OptOutpIPOS, A_CupRetractSol); // Vac Cup Ret V_MotorRight = V_MotorLeft = Auto_Speed_6; // Low Speed _SetSys (SS_POSSPEED, V_MotorRight); }

if ((ActPos_Mot > Load_Pos_6a) && (ActPos_Mot <= Load_Pos_6)) {

V_MotorRight = V_MotorLeft = Auto_Speed_2; // Med

Speed

*******************************

_SetSys (SS_POSSPEED, V_MotorRight); }

if ((ActPos_Mot > Load_Pos_7) && (ActPos_Mot <= Load_Pos_6a)) {

V_MotorRight = V_MotorLeft = Auto_Speed_4; // Hi Speed *******************************

_SetSys (SS_POSSPEED, V_MotorRight); }

if ((ActPos_Mot > Load_Pos_8) && (ActPos_Mot <= Load_Pos_7)) {

V_MotorRight = V_MotorLeft = Auto_Speed_4; // Hi Speed _SetSys (SS_POSSPEED, V_MotorRight); _BitClear(OptOutpIPOS, A_CupRetractSol);

_BitSet (OptOutpIPOS, A_CupExtendSol); // Vac Cup Ext }

if ((ActPos_Mot > Load_Pos_9) && (ActPos_Mot <= Load_Pos_8)) {

V_MotorRight = V_MotorLeft = Auto_Speed_2; // Slow Speed _SetSys (SS_POSSPEED, V_MotorRight); }

if ((ActPos_Mot > Load_Pos_10) && (ActPos_Mot <= Load_Pos_9)) {

_BitClear (OptOutpIPOS, A_VacuumOnSol); // Vac Rel _BitSet (OptOutpIPOS, A_VacuumOffSol); _BitSet(OptOutpIPOS, A_BlowOffSol); }

if ((ActPos_Mot <= Load_Pos_10)) {

_BitClear (OptOutpIPOS, A_VacuumOffSol); // Blow Off Off _BitClear(OptOutpIPOS, A_CupExtendSol); _BitClear (OptOutpIPOS, A_BlowOffSol); _BitSet(OptOutpIPOS, A_CupRetractSol);

_BitSet (PE1_Output, A_ConvRel); // Conv Rel }

} // End Loading Active

if ( E_Touchp_1 ) // Arm Down Signal {

_BitSet (PE1_Output, A_StackerArmDown);

_BitClear(PE1_Output, A_VacuumFault); // Reset Vacuum Fault } else {

_BitClear (PE1_Output, A_StackerArmDown); }

if ( E_CupExtendedProx ) // Cup Extended Signal {

_BitSet (PE1_Output, A_CupExtendSwitch); } else {

_BitClear (PE1_Output, A_CupExtendSwitch); }

//Signal VacuumCups retract Switch => SPS if ( E_CupRetractedProx ) {

_BitSet(PE1_Output, A_CupRetractSwitch); } else {

_BitClear(PE1_Output, A_CupRetractSwitch); }

if ( E_VacuumSwitch ) // Vacuum Confirm Signal {

_BitSet (PE1_Output, A_VacuumConfirm); } else {

_BitClear (PE1_Output, A_VacuumConfirm); }

Cycling ();

} // End PositionStateMachine()

/*============================================= Main Program (IPOS-Eintrittsfunktion)

===============================================*/ main() {

/*------------------------------------- Initialization

--------------------------------------*/ Initialize();

_SetInterrupt( SI_TOUCHP1, Interrupt);

_SetTask2(T2_START, PositionStateMachine);

/*------------------------------------- Main Program

--------------------------------------*/ while(1) {

_GetSys (Bustyp, GS_PODATA); //PA-Data from Field Bus in Var.H102-H104

if (!E_AutoMode) {

M_Fault = 0; M_State = 0;

_BitClear (PE1_Output, A_StackerFault);

_BitClear (PE1_Output, A_ArmReferencePos); _BitClear (PE1_Output, A_ArmProbePos); _TouchProbe( TP_DIS1 ); ManualMode(); }

if (E_AutoMode) {

AutomaticMode(); }

if (E_AutoMode && !E_Stop_Cycle && !E_VacuumSwitch && (M_State == 0) && (M_Fault == 0 )) {

/* _BitClear (OptOutpIPOS, A_CupExtendSol); _BitSet(OptOutpIPOS, A_CupRetractSol);*/ }

_SetSys (SS_PIDATA, Le_PE_DATA); //Variablen H111-113 as PE-Data back to Fieldbus } }

本文来源:https://www.bwwdw.com/article/to97.html

Top