抖音粉丝群1
『7x24小时有问必答』

Abstract
In this paper,a soft PLC is used to control at third-party servo supporting EtherCAT , realizing servo point-to-point control,such as jogging,relative motion and absolute position motion.The PLC program uses the Tc2_MC2 motion control library.This is Eric.Zhous WeChat Official Account  Changzhou Electrical Engineer.

1.  Software and Hardware Versions

1.1.  Computer

1.1.1.  Controller Hardware

An ordinary computer with Windows operating system
Intel network card with PCIE interface

1.1.2.  Control Software

The ordinary computer is based on TwinCAT V3.1 Build 4024.35.

1.2.  Third-part servo

1.1.3.  Servo System Hardware

Servo system with EtherCAT interface,including servo driveservo motorlimit sensor

2.  Preparations

2.1.  Communication Wiring and Power Supply

The servo system is supplied by AC220V, and the DIO port of the servo drive is supplied by 24V.The servo drive and the Intel network card are connected via an Ethernet cable.    
1.png
Figure  2-1  Ethernet cable connection              
2.png
    Figure2-2  Power Connection

2.2  Description File

Copy the ESI(EtherCAT Slave Information) file for EtherCAT provided by the third-part servo,i.e.,the xxx.xmld slave device description file,to the path  C:\TwinCAT\3.1\Config\Io\EtherCAT  on the programming PC, then restart  TwinCAT  3.

2.3.  Upload I/O Configuration

Open TwinCAT XAE(TcXaeShell)
3.png
Create new project
4.png
Right-click I/O in the Solution Explorer and select Scan from the shortcut menu.can.
5.png
A pop-up window will ask whether to connect to NC-Configuration. Select OK.
Itll automatically create a servo axis named Axis1 and associate it with the physical servo device.
6.png
  

2.4.  <b>Configure Servo Parameters

Navigate MOTION-->Axes-->Axis 1-->Parameter-->Monitoring-->Position Lag Monitoring,and change the value from the default  TRUE  to  FALSE.
7.png
  
Set Manual Velocity(Fast) in Manual Motion and Homing to 2, and Manual Velocity(Slow) to 1.
Navigate to  MOTION-->Axes-->Axis1-->Enc-->Parameter-->Scaling Factor Numerator, and change the value from the default 0.0001 to 1.
Navigate to  MOTION-->Axes-->Axis1-->Enc-->Parameter-->Scaling Factor Denominator(default:1.0), and change the value from the default 1.0 to 131072.
Here, 131072 is 2 to the power of 18. For a 17-bit servo motor encoder, the encoder resolution is 131072 pulses per revolution.
8.png
  
All parameter configuration is completed. At this point, you can perform manual debugging via  MOTION-->Axes-->Axis 1-->Online.
9.png
  

2.5.  Add Tc2_MC2 Library File

Select myPLC-->myPLC Project-->Referencesright-clickand choose  Add library....
10.png
In the Add Library dialog box, select  <b>Motion-->PTP-->Tc2-MC2, then click OK.
11.png
  

2.6.  Configure PLC and Visualization

Right-click PLCselect  Add New Item-->Standard PLC Project.The soft PLC is created.
12.png
  
Expand the newly created myPLC, find VISUs, right-click it, and select Add-->Visualization.... The soft HMI is now created.
13.png
  

3.  Programming Operations

Create a visualization interface including: servo enable button, servo enable status indicator, left jog button, right jog button, current position value display, relative position move button, absolute position move button, relative movement distance value setting, and absolute position address value setting.This is Eric.Zhous WeChat Official Account  Changzhou Electrical Engineer.
14.png
3.1.  Variable Definition and Association
Define an axis reference variable in the PLC. Compile the program to deploy the variable to the entire solution.
MyAxis:axis_ref;
15.png
Open the property page tab of  MyAxisSettings-->Link To PLC...and select MAIN.MyAxis.The axis reference variable MyAxis is now associated with the physical servo axis.
Define 5 BOOL variables in the PLC for enable, left jog, right jog, relative position move, and absolute position move:
MC_Enable,L_jog,R_jog,bRelative,bAbsolute:BOOL;
Define two DINT variables in the PLC for relative position distance and absolute movement position:
Relative_Distance:DINT;Absolute_Position:DINT;

3.2.  Associate Visualization   Variables with PLC Variables

Drag and drop 3 Rectangle elements, 1 Lamp1 element, and 5 Button elements into the visualization interface.
The first Rectangle displays the current actual position. Set its Texts.Text property to:MyAxieCurrentPos:%.4f,(The % is a placeholder to be replaced by the text variable.)
16.png
Set the Text variable to
17.png
The second Rectangle inputs the relative movement distance. Set its Texts.Text property to:%.4fSet the Text variable to: MAIN.Relative_Distance.In the input configuration, set OnMouseDown to Write Variable, input type to VisuaDialogs.Numpad, and the variable to edit to MAIN.Relative_Distance.
18.png
The third Rectangle inputs the absolute movement position. Set its Texts.Text property to:Absolute Position: %.4f. Set the Text variable to: MAIN.Absolute_Position. In the input configuration, set OnMouseDown to Write Variable, input type to VisuaDialogs.Numpad, and the variable to edit to MAIN.Absolute_Position.
Set the Variable property of Lamp1 to:MAIN.MyAxis.NcToPlc.StateDWord.20
19.png
For the button with Text property set to Servo Enable, set its Toggle.Variable property to MAIN.MC_Enable (note: use Toggle.Variable).The Text and Tap.Variable properties for the other 4 buttons are shown in the table below:
Text
Tap.Variable
L_jog
MAIN.L_jog
R_jog
MAIN.R_jog
Move Relative
MAIN.bRelative
Move Absolute
MAIN.bAbsolute

3.3.  Instantiate Motion Function

In the PLC variable definition window, instantiate the enable function  MC_Power  with the instance name  MC_PowerOn.
MC_PowerOn:MC_Power;//Shortcut for the input assistant: press F2
In the PLC variable definition window, instantiate the jog function  MC_Jog  with the instance name  jog.
jog:MC_Jog
In the PLC variable definition window, instantiate the relative motion function  MC_MoveRelative with the instance name  move_r.
move_r:MC_MoveRelative;
In the PLC variable definition window, instantiate the absolute motion function  MC_MoveAbsolute  with the instance name  move_ab.
move_r:MC_MoveAbsolute;
20.png
In the PLC program code section write the code as follows:
MC_PowerOn(
Axis:=MyAxis,
Enable:=MC_Enable,//Servo Enable button
Enable_Positive:=TRUE,
Enable_Negative:=TRUE,
Override:= ,
BufferMode:= ,
Options:= ,);
jog(
Axis:=  MyAxis,  
JogForward:=L_jog,//Left jog button
JogBackwards:=R_jog,//Right jog button
Mode:= ,  
Position:= ,  
Velocity:= ,  
Acceleration:= ,  
Deceleration:= ,  
Jerk:= , );
//move relative
move_r(
Axis:=MyAxis  ,  
Execute:=bRelative , //move relative
Distance:=Relative_Distance ,  
Velocity:=1 ,  
Acceleration:= ,  
Deceleration:= ,  
Jerk:= ,  
BufferMode:= ,  
Options:= ,);
//move absolute
move_ab(
Axis:=MyAxis  ,  
Execute:=bAbsolute , //  move absolute  
Position:=Absolute_Position ,  
Velocity:=1 ,  
Acceleration:= ,  
Deceleration:= ,  
Jerk:= ,  
BufferMode:= ,  
Options:= , );

3.4.  Debugging and Operation

Click Activate Configurationthen click the  Login to  button.The program will run.
21.png
Click the Servo Enable button, and you will see the yellow indicator light turn on.Press Left Jog and Right Jog, and you will see the servo lead screw move accordingly.The LED display on the servo drive changes from OFF to RUN.
Enter the value 2 into the Relative Movement Distance input box and click Move Relative.You will see the current position of the lead screw increase by 2 mm accordingly.
Enter the value 1 into the Absolute Position Address input box and click Move Absolute.You will see the current position of the lead screw change to 1 mm accordingly.
22.png
  
</b></b>

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

上一主题上一主题         下一主题下一主题
QQ手机版小黑屋粤ICP备17165530号

关于我们·投诉举报· 用户帮助· 联系我们 · 本站服务 · 版权声明· 隐私政策 · 投搞指南

法律保护:PLC技术网,plcjs.com,plcjs.net等字样
Copyright 2010-2030. All rights reserved. 


微信公众号二维码 抖音二维码 百家号二维码 今日头条二维码哔哩哔哩二维码