Tải bản đầy đủ (.pdf) (56 trang)

Tc3 trainingexercises rc1b

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (3.8 MB, 56 trang )

<span class="text_page_counter">Trang 1</span><div class="page_container" data-page="1">

Contents

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

</div><span class="text_page_counter">Trang 2</span><div class="page_container" data-page="2">

TwinCAT XAE User Interface

</div><span class="text_page_counter">Trang 3</span><div class="page_container" data-page="3">

PLC 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.

<b>Select TwinCAT XAE (TcXaeShell) </b>

<b>File >> New >> Project </b>

<b>(XML Format)” template </b>

Enter your desired Project Name. Eg. Tc3PlcExercise

Explorer.

On the General Tab, click on

<b>[Choose Target] </b>

</div><span class="text_page_counter">Trang 6</span><div class="page_container" data-page="6">

12 Scan I/O Devices.

Right click on I/O Devices, select

<b>“Scan” </b>

depending on hardware used.

<b>Select “Device1 [EtherCAT]” </b>

only.

connected IO boxes (eg.

EtherCAT coupler, IO terminals).

<b>Click [YES] </b>

I/O check.

</div><span class="text_page_counter">Trang 7</span><div class="page_container" data-page="7">

17) 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

<b>18) Save the Solution File. Click File >> Save All </b>

PLC Exercise 2: Creating PLC project and Declaring Global Variables

<b>Right click on PLC icon, select “Add New Item” </b>

<b>Template”. </b>

<b>Enter the name: Plc1 </b>

</div><span class="text_page_counter">Trang 8</span><div class="page_container" data-page="8">

3 Create a Global Variable List (GVLs).

<b>Right click on the GVLs folder, Select Add >> Global Variable </b>

bSwitch1 AT %I*: BOOL; bSwitch2 AT %I*: BOOL; bSwitch3 AT %I*: BOOL; bSwitch4 AT %I*: BOOL;

nResistor1 AT %I*: INT; nResistor2 AT %I*: INT; //Analog Output

nVoltmeter1 AT %Q*: INT; nVoltmeter2 AT %Q*: INT; END_VAR

Declare global variables for I/O Save the Solution file.

<b>Click FILE >> Save All. </b>

<b>Click Build >> Build Solution </b>

Ensure there’s no error before proceeding to next step.

</div><span class="text_page_counter">Trang 9</span><div class="page_container" data-page="9">

PLC Exercise 3: Linking the Variables and Activate Configuration

Right click on the Channel1 Input of EL1014

<b>select “Change Link” </b>

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.

<b>Click TWINCAT >> Activate Configuration. </b>

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

</div><span class="text_page_counter">Trang 10</span><div class="page_container" data-page="10">

Tips 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.

</div><span class="text_page_counter">Trang 11</span><div class="page_container" data-page="11">

PLC Exercise 4: Downloading and Running PLC project

<b>Click PLC >> Login. </b>

<b>Start. </b>

monitor the online value Test and check that the IO links are correct.

pressing the Push Button. Output can be triggered by

<b>“Write Values” in Prepared </b>

Value column

<b>Click PLC >> Logout. </b>

PLC Exercise 5: Creating Function Block (FB_Blinker)

under POUs folder Right click on the POUs

<b>folder, select Add >> POU. </b>

</div><span class="text_page_counter">Trang 12</span><div class="page_container" data-page="12">

2 Name: FB_Blinker Type : Function block Implementation Lang: FBD

the network rung

accordingly

</div><span class="text_page_counter">Trang 13</span><div class="page_container" data-page="13">

5 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

</div><span class="text_page_counter">Trang 14</span><div class="page_container" data-page="14">

PLC Exercise 5a: Adding a Latching Circuit using Ladder Diagram (Digital)

Logic.

<b>Select FBD/LD/IL >> View >> View as Ladder Logic </b>

<b>and “Insert Network” </b>

the Latching Circuit as shown

on the FB_Blinker to bStartBlink.

Login and test the program

</div><span class="text_page_counter">Trang 15</span><div class="page_container" data-page="15">

PLC Exercise 6: Creating Function (F_Scale)

folder

Right click on the POUs folder,

<b>select Add >> POU. </b>

</div><span class="text_page_counter">Trang 16</span><div class="page_container" data-page="16">

4 Create a Program Name: Analog Type : Program

Implementation Lang: ST

Program using Input Assistant

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.

</div><span class="text_page_counter">Trang 17</span><div class="page_container" data-page="17">

PLC Exercise 7: Configuring Auto Start of the Control Unit

System Run Mode.

<b>In the Settings tab, check “Run Mode (Enable)” radio button. Then, click “Apply” button. </b>

<b>make sure that “Autostart Boot Project” is checked Then, “Activate Boot Project” </b>

PLC Exercise 8: Working with several Tasks

<b>select Add >> Referenced Task. </b>

</div><span class="text_page_counter">Trang 18</span><div class="page_container" data-page="18">

2 Create a new task name:

<b>referenced task “FastTask”, select Add >> Existing item Choose the FastProg within the Input Assistance. </b>

</div><span class="text_page_counter">Trang 19</span><div class="page_container" data-page="19">

6 Adjust the Priority and Cycle Ticks.

<b>Then “Activate Configuration” </b>

same counter logic

bStartCnt and monitor online the Counter values in both MAIN and FastProg using WatchList

<b>PLC >> Windows >> Watch1 </b>

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.

</div><span class="text_page_counter">Trang 20</span><div class="page_container" data-page="20">

PLC Exercise 9: Troubleshooting PLC program using Scope

<b>select Add >> New Project </b>

<b>Wizard” template </b>

</div><span class="text_page_counter">Trang 21</span><div class="page_container" data-page="21">

4 <b>Choose “Variables” </b>

IO.bSwitch1 IO.bLED1

Analog.fScaledValue …etc

</div><span class="text_page_counter">Trang 22</span><div class="page_container" data-page="22">

7 <b>Choose “YT Chart” </b>

</div><span class="text_page_counter">Trang 23</span><div class="page_container" data-page="23">

10 Start Recording

</div><span class="text_page_counter">Trang 24</span><div class="page_container" data-page="24">

PLC Exercise 10: Creating Persistent Data

Modify the Variable

Declaration for MAIN program

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

</div><span class="text_page_counter">Trang 25</span><div class="page_container" data-page="25">

PLC Exercise 11: Uploading Source Code

solution file, close the solution

<b>file now. Click FILE >> Close Solution. </b>

To upload the Source code,

<b>click File >> Open >> Open Project From Target. </b>

Runtime System

“UploadProj” on Desktop and

<b>[Select Folder] </b>

</div><span class="text_page_counter">Trang 26</span><div class="page_container" data-page="26">

4 The complete Project has been uploaded

PLC Exercise 12: Reading System Date and Time

</div><span class="text_page_counter">Trang 27</span><div class="page_container" data-page="27">

Open action “Act_ReadTime” Write the codes

</div><span class="text_page_counter">Trang 28</span><div class="page_container" data-page="28">

6 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)

</div><span class="text_page_counter">Trang 29</span><div class="page_container" data-page="29">

PLC Exercise 14: STRUCTURE and EXTEND

</div><span class="text_page_counter">Trang 31</span><div class="page_container" data-page="31">

Login PLC and check the result Hint: remove ‘strict’ attribute

</div><span class="text_page_counter">Trang 33</span><div class="page_container" data-page="33">

Login PLC and check the result Write value into the Union. Eg. 5, 255, 256, 4096

</div><span class="text_page_counter">Trang 34</span><div class="page_container" data-page="34">

FOR i := LOWER_BOUND(aData,1) TO UPPER_BOUND(aData,1) DO nSum := nSum + aData[i];

</div><span class="text_page_counter">Trang 35</span><div class="page_container" data-page="35">

6 Build Solution

PLC Login and check the result.

PLC Exercise 19: CASE statement

<small> bVar1 := NOT bVar1; </small>

Write the Codes in the action Act_CaseStm

</div><span class="text_page_counter">Trang 36</span><div class="page_container" data-page="36">

<b>END_VAR </b>

program

PLC Login and check the result by changing the value of nVar

PLC Exercise 20: FOR loop

</div><span class="text_page_counter">Trang 37</span><div class="page_container" data-page="37">

5 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].

</div><span class="text_page_counter">Trang 38</span><div class="page_container" data-page="38">

3 From the Toolbox,

<b>Drag-and-Drop the PushSwitch and Lamp symbol into the </b>

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

</div><span class="text_page_counter">Trang 39</span><div class="page_container" data-page="39">

2 <b>Adaptation of current and voltage </b>

Search for EL7031 terminal under I/O Devices

Adapt the motor setting and cannot be changed. However, the base frequency

</div><span class="text_page_counter">Trang 40</span><div class="page_container" data-page="40">

The maximum velocity can be calculated from the base frequency and the motor frequency.

Reference Velo.: 3600deg/s Maximum Velo.: 3600deg/s

The dead time compensation

<i>can be adjusted on the Time Compensation tab of </i>

<i>Axis1_ENC. </i>

It should theoretically be 3 cycles of the NC cycle time, although in practice 4 cycles are preferable.

Therefore, the settings of the

<i>parameters Time </i>

<i>Compensation Mode Encoder </i>

should be ‚ON (with velocity)‘

<i>and Encoder Delay in Cycles </i>

‘4’. frequency 7

<b>Calculation of the scaling factor </b>

<i>with encoder, 4-fold evaluation: </i>

<b>SF = distance per revolution / (increments x 4) = 360° / (1024 x 4) = </b> “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

</div><span class="text_page_counter">Trang 41</span><div class="page_container" data-page="41">

8 <b>Position Lag Monitoring </b>

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

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

</div><span class="text_page_counter">Trang 42</span><div class="page_container" data-page="42">

1 Under I/O devices, find the EL72x1-xxx terminal that have been scanned in by the

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

</div><span class="text_page_counter">Trang 43</span><div class="page_container" data-page="43">

5

<b>Reference Velocity = (Motor Max Velo / 60sec) * Distance </b>

<b>Reference Velocity </b>

The maximum permitted velocity is calculated based on the maximum motor speed and the distance.

The dead time compensation

<i>can be adjusted on the Time Compensation tab of </i>

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.

</div><span class="text_page_counter">Trang 44</span><div class="page_container" data-page="44">

8 <b>Scaling Output </b>

Enter the value 32 in the Parameter tab for the drive

<i>settings under Output Scaling (Velocity) </i>

Solution File

• Activate Configuration

NC-PTP Exercise 3: Commissioning the Motor with NC

button

</div><span class="text_page_counter">Trang 45</span><div class="page_container" data-page="45">

3 Press the Function key to manually jog the motor

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.

</div><span class="text_page_counter">Trang 46</span><div class="page_container" data-page="46">

NC-PTP Exercise 4: Creating NC Scope to monitor Axis

<b>Measurement Project. File >> New >> Project </b>

DataPool. [Hint: use SHIFT to

</div><span class="text_page_counter">Trang 47</span><div class="page_container" data-page="47">

3 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

</div><span class="text_page_counter">Trang 48</span><div class="page_container" data-page="48">

NC-PTP Exercise 5: Creating simple PTP Move Program

</div><span class="text_page_counter">Trang 49</span><div class="page_container" data-page="49">

4 Select “Tc2_Mc2.lib”. Click

Declare the I/O structure variables between NC and PLC.

2.

</div><span class="text_page_counter">Trang 51</span><div class="page_container" data-page="51">

Create Instance of MC Function Block and MCOutputs

Write the FB_Axis codes ReadStatus() action updates the type ST_AxisStatus and has to called at the beginning of

“Status” output indicates operational readiness of the axis.

Axis has to be ready before executing other MC commands.

</div><span class="text_page_counter">Trang 52</span><div class="page_container" data-page="52">

MC_Stop stops an axis with a defined braking ramp and locks it against other motion position to an absolute target position and monitors the axis movement over the whole travel path.

“Done” output is set once the target position has been reached.

</div><span class="text_page_counter">Trang 53</span><div class="page_container" data-page="53">

16 Create a new Data Unit Type

Declare the following variable in the MAIN program

19 fbAxis1( stAxis:= GVL.Axis1); fbTon1(PT:= T#2S);

(* move axis using a state machine *) CASE eState OF

E_MoveState.INIT :

Code the Forward/Reverse Sequence program in the Main

</div><span class="text_page_counter">Trang 55</span><div class="page_container" data-page="55">

(* axis error requires reset*)

Try adding STOP state to stop the running Axis

online for download

</div>

Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×