46 NC-PTP Exercise 5: Creating simple PTP Move Program ..... Click File >> Save All PLC Exercise 2: Creating PLC project and Declaring Global Variables Right click on PLC icon, select “A
Trang 1Contents
PLC Exercise 1: Creating XAE Project and IO Configuration 3
PLC Exercise 2: Creating PLC project and Declaring Global Variables 7
PLC Exercise 3: Linking the Variables and Activate Configuration 9
PLC Exercise 4: Downloading and Running PLC project 11
PLC Exercise 5: Creating Function Block (FB_Blinker) 11
PLC Exercise 5a: Adding a Latching Circuit using Ladder Diagram (Digital) 14
PLC Exercise 6: Creating Function (F_Scale) 15
PLC Exercise 7: Configuring Auto Start of the Control Unit 17
PLC Exercise 8: Working with several Tasks 17
PLC Exercise 9: Troubleshooting PLC program using Scope 20
PLC Exercise 10: Creating Persistent Data 24
PLC Exercise 11: Uploading Source Code 25
PLC Exercise 12: Reading System Date and Time 26
PLC Exercise 13: STRING function (Delete, Concat, Len, Sizeof) 28
PLC Exercise 14: STRUCTURE and EXTEND 29
PLC Exercise 15: ALIAS 30
PLC Exercise 16: ENUMERATION 31
PLC Exercise 17: UNION 32
PLC Exercise 18: ARRAY 34
PLC Exercise 19: CASE statement 35
PLC Exercise 20: FOR loop 36
PLC Exercise 21: Creating a simple Visualisation page 37
NC-PTP Exercise 1: Setting up Stepper Axis (EL7031) 38
NC-PTP Exercise 2: Setting up Servo Axis (EL7201-9014) 41
NC-PTP Exercise 3: Commissioning the Motor with NC 44
NC-PTP Exercise 4: Creating NC Scope to monitor Axis 46
NC-PTP Exercise 5: Creating simple PTP Move Program 48
Trang 2TwinCAT XAE User Interface
Trang 3PLC Exercise 1: Creating XAE Project and IO Configuration
Disclaimer: The steps given here serve as an example from using CX5130-0135 from Beckhoff Automation For other Beckhoff PC-based controller, the device interfaces may varies depending on the hardware setup/architecture
the System TaskBar
Select TwinCAT XAE (TcXaeShell)
File >> New >> Project
Trang 5Click [OK]
Trang 612 Scan I/O Devices
Right click on I/O Devices, select
“Scan”
depending on hardware used
Select “Device1 [EtherCAT]”
only
connected IO boxes (eg
EtherCAT coupler, IO terminals)
Click [YES]
I/O check
Trang 717) Now Test all individual I/O points
Digital Input Term2(EL1014) Channel 1 ~ 4, Input Switch S1 ~ S4
Digital Output Term3(EL2014) DIG Outputs, Channel 1 ~ 4, Output LED Lamp H1 ~ 4
Analog Input Term6(EL3102) Channel 1 ~ 2, Value Potentiometer P1, P2
Analog Output Term7(EL4102) Channel 1 ~ 2, Output Voltmeter A1, A2
18) Save the Solution File Click File >> Save All
PLC Exercise 2: Creating PLC project and Declaring Global Variables
Right click on PLC icon, select
“Add New Item”
Template”
Enter the name: Plc1
Trang 83 Create a Global Variable List
(GVLs)
Right click on the GVLs folder, Select Add >> Global Variable List
Enter the Name: IO
4 {attribute 'qualified_only'}
VAR_GLOBAL
//Digital Input
bSwitch1 AT %I*: BOOL;
bSwitch2 AT %I*: BOOL;
bSwitch3 AT %I*: BOOL;
bSwitch4 AT %I*: BOOL;
nResistor1 AT %I*: INT;
nResistor2 AT %I*: INT;
Click FILE >> Save All
Click Build >> Build Solution
Ensure there’s no error before proceeding to next step
Trang 9PLC Exercise 3: Linking the Variables and Activate Configuration
Right click on the Channel1 Input of EL1014
select “Change Link”
Refer to the table below for the actual mapping between IO channels and PLC IO vars
Tips: Use the “Search” function
to filter out relevant IO variables
Click TWINCAT >> Activate Configuration
Enter the Security code if prompted
Mapping between PLC Variables and I/O process image
bLed1 Term3(EL2014), DIG Output, Channel 1, Output LED H1
bLed2 Term3(EL2014), DIG Output, Channel 2, Output LED H2
Trang 10Tips 1# An Output byte can be declare and use for linking to 8-ch Output terminal eg EL2008
Note: “All Types” and “Continuous” checkbox is used
Tips 2# Use “Change Multi-Link ” for efficient Variables linking
Tips 3# Option to possibly create a structure from mapped Process data of a IO terminal
Trang 11PLC Exercise 4: Downloading and Running PLC project
Click PLC >> Login
Start
monitor the online value Test and check that the IO links are correct
pressing the Push Button
Output can be triggered by
“Write Values” in Prepared
Value column
Click PLC >> Logout
PLC Exercise 5: Creating Function Block (FB_Blinker)
under POUs folder Right click on the POUs
folder, select Add >> POU
Trang 122 Name: FB_Blinker
Type : Function block Implementation Lang: FBD
the network rung
accordingly
Trang 135 Create a Program
Name: Digital Type : Program Implementation Lang: FBD
Digital Program using Input Assistant [F2]
Optional:
Instantiate fbBlinker2 with
a different delay time and bLed output
Trang 14PLC Exercise 5a: Adding a Latching Circuit using Ladder Diagram (Digital)
Logic
Select FBD/LD/IL >> View >> View as Ladder Logic
and “Insert Network”
the Latching Circuit as shown
on the FB_Blinker to bStartBlink
Login and test the program
Trang 15PLC Exercise 6: Creating Function (F_Scale)
folder Right click on the POUs folder,
select Add >> POU
Type: Function Return type: REAL Implementation Lang: ST
Trang 164 Create a Program
Name: Analog Type : Program Implementation Lang: ST
Program using Input Assistant [F2]
MAIN Program
Build Solution and make sure
no error
Login to PLC and test F_Scale
Optional: set Breakpoint to monitor temporary variable in the function
Tips 1# Breakpoints are generally used for finding errors in the program You can set breakpoints at certain positions
in the program in order to force an execution stop there and observe the variable values Take note that all Outputs are turned off when the program has been stopped by breakpoint
Trang 17PLC Exercise 7: Configuring Auto Start of the Control Unit
System Run Mode
In the Settings tab, check “Run Mode (Enable)” radio button Then, click “Apply” button
make sure that “Autostart Boot Project” is checked Then, “Activate Boot Project”
PLC Exercise 8: Working with several Tasks
select Add >> Referenced Task
Trang 182 Create a new task name:
“FastTask”
Name: FastProg Type : Program Implementation Lang: ST
referenced task “FastTask”, select Add >> Existing item Choose the FastProg within the Input Assistance
Trang 196 Adjust the Priority and Cycle
Ticks
Then “Activate Configuration”
same counter logic
bStartCnt and monitor online the Counter values in both MAIN and FastProg using WatchList
PLC >> Windows >> Watch1
Tips 1# A separate Task is normally used for Communication or Motion or Fast Sampling function
Tips 2# Be careful of multi-task data access synchronization in PLC When the same data is accessed by multiple tasks, the tasks may access the same data simultaneously, depending on the task/realtime configuration If the data is written by at least one of the tasks, the data may have an inconsistent state during or after a change To prevent this, all concurrent accesses must be synchronized so that only one task at a time can access the shared data
Trang 20
PLC Exercise 9: Troubleshooting PLC program using Scope
select Add >> New Project
Wizard” template
Trang 214 Choose “Variables”
IO.bSwitch1 IO.bLED1 Analog.fScaledValue
…etc
Trang 227 Choose “YT Chart”
Trang 2310 Start Recording
Trang 24PLC Exercise 10: Creating Persistent Data
Code the program
program
Start and Stop the counting Remember the last value of nCounter
Switch Off power to Training Kit and wait till PWR Led is off Then, switch On power to Training Kit and wait till TC Led turns Green
Login PLC and check nCounter value
<Tc2_Utilities> library FB_WritePersistentData
Trang 25PLC Exercise 11: Uploading Source Code
solution file, close the solution
file now Click FILE >> Close Solution
To upload the Source code,
click File >> Open >> Open Project From Target
Runtime System
“UploadProj” on Desktop and
[Select Folder]
Trang 264 The complete Project has
been uploaded
PLC Exercise 12: Reading System Date and Time
Trang 286 Call the action in the MAIN
Program
Login PLC and test ACT_ReadTime by Write Value bEnable to TRUE
Check the ACT_ReadTIme result against the System Time
on Windows System Taskbar
PLC Exercise 13: STRING function (Delete, Concat, Len, Sizeof)
Trang 29PLC Exercise 14: STRUCTURE and EXTEND
Trang 31PLC Exercise 16: ENUMERATION
folder
Name: E_Week Type: Enumeration
Trang 32PLC Exercise 17: UNION
Name: ST_Bits Type: Structure
Trang 34PLC Exercise 18: ARRAY
Name: F_Sum Type: Function Return Type: DINT Implementation Lang.: ST
2 FUNCTION F_Sum : DINT
FOR i := LOWER_BOUND(aData,1) TO UPPER_BOUND(aData,1) DO
nSum := nSum + aData[i];
Trang 356 Build Solution
PLC Login and check the result
PLC Exercise 19: CASE statement
Program Name: “Act_CaseStm”
bVar1 := NOT bVar1;
Write the Codes in the action Act_CaseStm
Trang 36END_VAR
program
PLC Login and check the result
by changing the value of nVar
PLC Exercise 20: FOR loop
Program Name: “Act_ForLoop”
Trang 375 Build Solution
PLC Login and check the result
by set nVar1 to 1 nErg result is 32
PLC Exercise 21: Creating a simple Visualisation page
the VISU folder
Visualisation library Check the
“Active” button and press [OPEN]
Trang 383 From the Toolbox,
Drag-and-Drop the PushSwitch and Lamp symbol into the
NC-PTP Exercise 1: Setting up Stepper Axis (EL7031)
The data given here serve as an example for a stepper motor type AS1010-0000 from Beckhoff Automation running
on 24V DC power supply setting For other motors the values may vary, depending on the application
1
Refer to “PLC Exercise 1” for the procedures
• Start New Tc3 Solution
• Select CX runtime target
• Switch to CONFIG mode
• Scan IO device
• Scan Motors
• Append Drives to NC Configuration
• Activate Free-run mode
Trang 392 Adaptation of current and
Microstepping is set to 1/64 and cannot be changed
However, the base frequency can be changed
Speed range (Index 0x8012:05) ➔ default: 2000
Change the display unit under Settings to degree
Trang 405
Vmax = base freq / motor freq = (2000 FullSteps/s) / (200 FullSteps/rev) =
Reference Velo.: 3600deg/s Maximum Velo.: 3600deg/s
The dead time compensation
can be adjusted on the Time Compensation tab of
Axis1_ENC
It should theoretically be 3 cycles of the NC cycle time, although in practice 4 cycles are preferable
Therefore, the settings of the
parameters Time Compensation Mode Encoder
should be ‚ON (with velocity)‘
and Encoder Delay in Cycles
‘4’ frequency
7
Calculation of the scaling factor
with encoder, 4-fold evaluation:
SF = distance per revolution / (increments x 4) = 360° / (1024 x 4) =
“Axis1_Enc” and tab
“Parameter in the NC The value is calculated with the formulas specified below EL7031 is without encoder The internal counter is use for position feedback
Scaling Factor Numerator: 0.028125
Trang 418 Position Lag Monitoring
The position lag monitoring function checks whether the current position lag of an axis has exceed the limit value The position lag is the difference between the set value (control value) and the actual value reported back If the terminal parameters are set inadequately, the position lag monitoring function may report an error when the axis
is moved During commissioning, it may therefore be advisable to increase the limits of the Position lag monitoring slightly
In order to pass through any resonances that may occur as quickly as possible, the ramps for the acceleration time and the deceleration time should
be as steep as possible Acc./Decc Time: 0.5s
Solution File
• Activate Configuration
NC-PTP Exercise 2: Setting up Servo Axis (EL7201-9014)
The data given here serve as an example for a servo-motor type AM8111-0F10 from Beckhoff Automation running
on 24V DC power supply setting For other motors the values may vary, depending on the application
The EL72x1 Servo Axis is automatically added to Axis_2 during the scan in previous exercise
Several parameters have to be set before the motor can be started up The values can be found in EL72x1 manual
Trang 421 Under I/O devices, find the
EL72x1-xxx terminal that have been scanned in by the system
Select the “Drive Manager” tab
“24VDC” under “Power Management”
Parameters”, change Feed Constant to 360 degree Click [Set NC Parameters]
All required parameters are adjusted automatically The setting only becomes active once the configuration is activated
Change the display unit under Settings to degree
Trang 43The dead time compensation
can be adjusted on the Time Compensation tab of
Axis2_ENC It should be theoretically be 3 cycles of the
NC cycle time, although in practice 4 cycles are preferable
Default setting for EL72x1-xxx
is 20 single-turn bits
Trang 44NC-PTP Exercise 3: Commissioning the Motor with NC
button
Trang 453 Press the Function key to
manually jog the motor F2/F3: slow jog
F1/F4 : fast jog F5: Move Absolute F6: Stop
F8: Reset F9: Home (DO NOT USE!!)
the axis via Functions tab
• Select as Reversing Sequence as the start type
• Enter the required Target Position2, e.g 12000°
• Enter the required Target Velocity, e.g 1200°/s
• Enter the required Target Position1, e.g 0°
• Enter the required Idle Time, e.g 2 s
• Select Start
The motor now turns to pos 2, remains there for 2 sec and return to pos 1 This is repeated until Stop is pressed
commissioning steps for Axis_2
Optional:
Try out other Start Mode Eg
Trang 46NC-PTP Exercise 4: Creating NC Scope to monitor Axis
Measurement Project File >> New >> Project
DataPool [Hint: use SHIFT to select]
IndxGrp 0x4101 is for Axis1, IdxGrp 0x4102 is Axis2, IdxGrp 0x410n is Axis n and so on
Trang 473 Go to the Properties
Window
Change the Target system to the name of the CX/IPC
Optional:
Try changing the Kv factor and also try changing the
Trang 48NC-PTP Exercise 5: Creating simple PTP Move Program
Trang 494 Select “Tc2_Mc2.lib” Click
Trang 508 Create FB_Axis
Name: FB_Axis Type: Function Block Implementation Lang: ST
Trang 51to called at the beginning of each PLC cycle
Axis has to be ready before executing other MC commands
Trang 52“Done” output is set once the target position has been reached
Trang 5316 Create a new Data Unit Type
(DUTs)
Name: E_MoveState Type: Enumeration
Declare the following variable
in the MAIN program
19 fbAxis1( stAxis:= GVL.Axis1);
Trang 55(* axis error requires reset*)
online for download