Macro Programs & Canned Cycles in PLC?

sean147

Member
Join Date
Jul 2020
Location
Canvey Island
Posts
2
Hi there,


I am new to PLC as I am studying it in my Mechatronic college course.


I came across this question that I can't get my head around to answer.


"Explain how to produce effective and efficient programmes to avoid unnecessary operations (including the use of macro programs and canned cycles, to reduce program size)."

[FONT=&quot]
[/FONT]
[FONT=&quot]When researching canned cycles specifically, it always comes up relative to CNC, to which I know to a certain extent is linked to PLC.[/FONT]
[FONT=&quot]
[/FONT]
[FONT=&quot]So my question is, how would I go about answering that question above. Really at an end on how to produce and implement things like that to a PLC application.[/FONT]
[FONT=&quot]
[/FONT]
[FONT=&quot]Thanks in advance,[/FONT]
[FONT=&quot]Sean
[/FONT]
 
I know the same as you about CNC but after a quick read, the use of canned cycles and macros can be readily applied to any software program, it's just that the terms used would be different.


Firstly I think you can dismiss the term effective from the discussion - effective is another way of saying 'produce the expected result', in other words, a program is effective if it works which we have to assume is the case.


Efficient covers a whole range of terms, but for your case I'm assuming it is the Efficient use of memory in the controller.



Consider the implementation of a task done by a long list of sequential instructions, say there are 1000 instructions. If the instructions fit into the controller memory and it does the job, it is effective and, if that is all it has to do you could argue that it is efficient as well.


The next task to be implemented requires 2000 instructions which exceed the storage capabilities of the controller.
To make more efficient use of the memory, you would have to familiarise yourself with all the canned (or in-built) features of the controller and then see how many of the 2000 instruction could be replaced by using canned functions instead.



Similarly, you could identify repeated sections of instructions for which there is no canned function, and create your own macro/subroutine/function and hence use fewer instrutions to do the same job. You have made more efficient use of memory.


I hope this will give you a starting point for answering your question.
 
Macros will not reduce the size of a PLC program but creating a function (Block) will, for example, a macro is just a way of re-using code already written so a macro is a set of instructions that when called creates another copy of that code . A function or function block (also known as a subroutine) means a set of instructions or code that resides only in one area of the memory, this can be called many times i.e. a subroutine. for example think of a valve or motor control, say it requires 400 instructions if you have 30 or so valves then re-creating them would require 12000 instructions, but calling a Function block
30 times where the relevant parameters are passed to the function block for each valve means that it only uses the one bit of code, so therefore you reduce the amount of program memory considerably, however, it will be more than 400 instructions as passing the parameters for each valve takes memory.
An example is below:
Call Valve_Handling // Call the valve block i.e. jump to the routine
Parameters)
Open Limit = PX01 // pass the valve bits to the FB (temporary memory
Closed Limit = PX02
Alarm Bit = M0.0
Alarm Time = 5 Sec
Status Word = D100
Output Valve_01_Solenoid // so perhaps it takes 10 instructions to pass parameters & call the function

Call Valve_Handling // call the block again
Parameters
Open Limit = PX03
Closed Limit = PX04
Alarm Bit = M0.1
Alarm Time = 5 Sec
Status Word = D101
Output Valve_02_Solenoid
Rest of program
........

END // End of cyclic program

Valve_Handling // here is the Function for valve handling
A Output AND Not Open_Limit
OR
AN Output AND Not Closed_Limit
.......
Rest of function

RET // return to program Returns back to where it left off
END
// The FB uses 400 instructions plus 10 to pass the parameters
the total memory used for say 30 calls then becomes
400 + 30 x 10 = 700 instructions instead of 12000
A big saving on memory.
So... in short..
Calling a function block passes the I/O addresses to the function (jumps to one instance of a subroutine if you like) processes the code then returns passing any I/O back)
A Macro is usually a stored set of instructions in the IDE where when compiled actually creates code in the main routine as many times as you call it. it is a mis-conception that a macro only produces one bit of code, instead it is a quick way of creating the same code many times.
 

Similar Topics

Hello, I'm new to a program EBpro and I have to find a way to make a numeric object's background change colors depending on read data from plc...
Replies
3
Views
297
Hello everyone, this is my first post. FactoryTalk View SE v.13 I have a macro defined in my project that I would like to call up when someone...
Replies
0
Views
302
Hello Guys, I have been trying to study a Machine that have Omron 3g3mv VFDs that is controlled by CJ1m CPU and SCU41-V1 communication card. The...
Replies
0
Views
474
Hello Guys, I have a packaging machine in the company that I work for that have 8 Omron VFDs (3G3MV ) that are controlled via Modbus with CJ1M...
Replies
1
Views
629
Hello there. How to transfer data from one memory area to another using macro? Data Type - Double Word Length - 4 Format - BIN Integer -...
Replies
0
Views
652
Back
Top Bottom