Tutorial 02 PLC PDF
Tutorial 02 PLC PDF
The variety of uses for the hardware, software and firmware (hereinafter “Products”) described
in this Documentation, mandates that those responsible for the application and use of those
Products must satisfy themselves that all necessary steps have been taken to ensure that each
application and actual use meets all performance and safety requirements, including any
applicable laws, regulations, codes and standards in addition to any applicable technical
documents.
In no event will Rockwell Automation, Inc., or any of its affiliate or subsidiary companies
(hereinafter “Rockwell Automation”) be responsible or liable for any indirect or consequential
damages resulting from the use or application of the Products described in this Documentation.
Rockwell Automation does not assume responsibility or liability for damages of any kind based
on the alleged use of, or reliance on, this Documentation.
Throughout this manual we use the following notes to make you aware of safety considerations:
Identifies information about practices or circumstances that can cause an
explosion in a hazardous environment, which may lead to personal injury or
death, property damage, or economic loss.
Labels may be located on or inside the drive to alert people that dangerous voltage
may be present.
Labels may be located on or inside the drive to alert people that surfaces may be
dangerous temperature
Before you begin
This lab will demonstrate and help guide you on how to use and program a Micro850 controller using the CCW
software.
Please note:
CCW is an all-encompassing software package for component class controllers (or- small / micro controllers). It
contains the application programming environment for the Micro800 Programmable Controllers (PLC), Drives
(Variable Frequency Drives or VFD’s which use AC voltage, converted to DC, generate a Pulse Width Modulated
(PWM) signal to control AC induction Motors) Human-Machine Interface (HMI) displays for control, feedback to
an operators panel and some Safety PLC’s.
With that- all User Manuals are included in CCW as well as a very extensive Help menus.
At any time that you need help or reference to any item, component or object, simply click on the help pulldown
Learn about Variables and Data Types
In this section, we will discuss what a Variable is, and the different Data Types available.
A variable is a unique identifier of data. A basic example of a variable is what we have already been referencing in
the lab for Embedded I/O points. The Embedded I/O variables are Boolean data types that are direct references to
the embedded input and outputs on the controller. They are identified by variables that start with the prefix
_IO_EM, and are globally scoped. We will discuss variable scope a little later.
Micro800 controllers also have System Variables of varying data types that reference internal system values of the
controller that a user may want to use in their programming, or for troubleshooting purposes. System Variables start
with the prefix __SYSVA. An example of a system variable that is commonly used is the __SYSVA_FIRST_SCAN
variable. This is a Boolean variable that is TRUE when the Micro800 controller is going through its first scan of the
program – typically used for programming startup routines.
Variables can be created dynamically as you need them, and they can be named anything you want (as long as it’s
not a reserved name). You can also create variables for local program use only, or you can create them for Global
use (for all programs to use) – this is what we refer to as variable scope. Global Variables are created in the Global
Variables list, and Local Variables are created in the Local Variables list of the specific program.
Being able to create variables dynamically and use custom names provides you, as a programmer, great flexibility
and customization that will help you create code and troubleshoot faster.
Data types
When you create a variable, you have to specify its data type. A data type defines the type of data that the variable
represents, such as an integer, real (floating point), Boolean, time, double integer, etc. Data types can also be data
structures of an Instruction Block.
CCW supports the 19 elementary IEC 61131-3 data types below.
In this section of the lab, you will learn how to create variables for use in your program. The variables you create in
this section of the lab will be used in the next section of the lab.
1. Double-click Local Variables in your Motor_Circuit program to launch the Variables panel.
3. Create a variable called Motor_On_Time_ms of Data Type INT and with an Initial Value of 5000.
4. Create a variable called Motor_Timer of Data Type TON.
A TON data type is actually the data structure of a Timer-on-Delay Instruction Block. We will discuss
Instruction Blocks in the next section.
5. You have completed creating variables to be used in the next section of the lab.
Learn how to Implement an Instruction Block
An Instruction Block is essentially a function block that has been predefined to perform a specific task or function.
Instruction Blocks include functions such as Timer-on-delay, Timer-off-delay, Math instructions, Data-type
conversions, Motion instructions, and so forth.
In this section of the lab, you will learn how to implement a Timer-On-Delay Instruction Block (TON). This
instruction block will be inserted into your motor circuit and will turn on the motor coil, and then automatically turn
off the motor coil after 5 seconds.
You will also learn how to implement an ANY_TO_TIME Data Conversion Instruction Block to convert an Integer
to a Time value, mathematical comparisons and turning ON and OFF
1. Open Tutorial Project PLC Basics from Tutorial 1 > Program should look as follows
2. Drag-and-drop a Branch instruction to right side of the rung, wrapping around the coil instruction.
3. Locate the Block instruction in the Toolbox.
4. Drag-and-drop this Block instruction into the branch that you just added.
5. The Instruction Block Selector will appear. This is where you can select the type of Instruction Block you would like
to use. As you can see, there is a long list of different types of instruction blocks that you can choose from. Feel free
to take a minute to scroll through this list to see what types of instruction blocks are available.
6. You can filter the instruction blocks by Name, Category, or Type. Since we want to use a Timer-On-Delay
instruction block, type TON in the Name filter box at the top of the Name column. This will filter the choices to only
Instruction Blocks that start with TON.
7. Highlight the TON Instruction Block – this is the Timer-on-Delay. Then at the bottom select the Instance combo
box pull-down, and select your previously created Motor_Timer > click OK
8. Your ladder program should look like the following.
07
9. Next, hover the mouse cursor over the PT parameter of the Motor_Timer TON instruction. You will notice a light
blue highlighting the box..
10. Click this box, and a pull down combo box will appear. Find and select the variable Motor_On_Time and then press
the Enter key.
12. Insert a Reverse Contact after the _IO_EM_DI_01 Reverse Contactor, as shown below.
13. The Variable Selector will display. Select the Local Variables – Motor_Circuit tab, and then click the empty cell
shown below.
14. Expand the variable, Motor_Timer > Select Motor_Timer.Q > click OK.
15. Your ladder program should look like the following.
18. Insert a Block instruction into the rung you just created, and select the ANY_TO_TIME Instruction Block. Then
click OK.
The ANY_TO_TIME instruction block is being used to convert an integer value into a time value that is used as
the preset time for the Motor_Timer. The integer value represents time in milliseconds.
19. Your program should look like the following.
07
23. Build your program, and download it to the Micro850 (if you forgot how to do this, go back and reference the section
Build and Download your Micro850 Application).
24. After completing the download, put the program into Debug mode by clicking the play button (or pressing the F5
key).
25. Now test your program. Turn the DI0 switch on, and watch the DO7 light turn on. After 5 seconds, the light should
turn off.
26. Debugging: Double Click on Local Variables under Program 1 > Change the logical value of the variable,
Motor_On_Time_ms, to change the amount of time the light stays on to 10 seconds (remember we enter the value
in milliseconds). Make sure to press enter after changing the value. The program will update on the fly.
27. Now test your program again. Turn the DI0 switch on. The DO8 light should now stay on for 10 seconds, before
turning off.
28. Click the Stop button to exit Debug Mode (or press Shift+F5).
Part 2: Now we will add a few more lines of code to turn on a separate light after a DI0 has been pressed a certain
amount of times.
i. Setting a Variable Alias: Aliases can be used to provide a clearer understanding what the I/O
Embedded Address is operating.
1. Double Click on the Local Variables > I/O Select Micro 850 > Set the following
ii. Create a variable Counter > Data Type = Int > Initial Value = 0
iii. Create a variable CounterReset > Data Type = Int > Initial Value = 0
Submission:
A. Show/Video program working (Show computer screen and PLC Board) B.