Beckhoff twincat procedure advice

plcstu1980

Member
Join Date
Oct 2010
Location
1
Posts
27
Hi, ive started using beckhoffs twincat. Can anyone advise me the the best practise to create a program using Twincat?? Any help greatly appreciated.

Stu
 
start with the traffic light as in the book.
and you can ask any question at www.3s-software.com (codesys)
or give me any idea you want and i will make you a startprogram.
first set the simulation under online ON.
then you can play for very long.
 
Thanks for your quick reply. Ive gone through a few small examples using structured text. I think what i trying to ask is, when you create a project do you set hardware first, then create a program. Or is there a specific way of doing this e.g. set up hardware, give input outputs a name, map them to the hardware etc.

How do you set-up a project and then c arry it through to the finish??
 
all in and outs are in the global vars.
then i make a small flowchart (smartdraw) of what i intend to do.
then i make a start with PLC_PRG here i put everything in that should be updated as fast as possible. (freewheel)
and i make some tasks with cyclic for what i am doing.
if you give me an email address i will send you a not finished project.
 
all in and outs are in the global vars.
then i make a small flowchart (smartdraw) of what i intend to do.
then i make a start with PLC_PRG here i put everything in that should be updated as fast as possible. (freewheel)
and i make some tasks with cyclic for what i am doing.
if you give me an email address i will send you a not finished project.

PM sent
 
As a simple first start:

In TwinCAT-PLC, under Resources tab - Global Variables - Global_Variables, declare I/O variables:

VAR_GLOBAL
(* the variables below must be linked to I/O channels of each module in System Manager. When adding a new one, Rescan in System Manager to associate, otherwise a VAR_CONFIG warning *)
DI1 AT %I*: BOOL; (* digital in ch1, False = low, True = high*)
DO1 AT %Q*: INT; (* digital out ch1, False = off, True = on *)
AI1 AT %I*: INT; (* analog in ch1, -32768 to 32767 = -10 to +10 V *)
AO1 AT %Q*: INT; (* analog out ch1, -32768 to 32767 = -10 to +10 V *)
END_VAR

The "%I*" is a cryptic notation meaning an input variable and the exact memory location will be automatically specified later. You can also declare exact memory locations, as in old-fashioned PLC's, but that is tedious and error-prone. "Q" must mean output in German.

Next, use these variables in PLC code that executes every cycle. Under POUs tab - Main, enter Structured Text:
DO1 := DI1;
AO1 := 2 * AI1;
Save as "TestProject", then Project - Rebuild All.

In System Manager, start a new project w/ 1 ms cycle time.
Under "Route Settings", "Broadcast Search" for your PLC "brain" (might be on same PC), and set a "static" Route.
Under "IO Devices", right-click "Scan Devices", then "Scan Boxes", etc.
Under "IEC 1131", right-click "Scan Project" and select "TestProject.tpy" you built above.
Under "Standard - Inputs", dbl-click DI1 and AI1 and link to a real input channel. Select a terminal's channel "Value", not a status bit such. Ditto for "Outputs".
To make sure the I/O links work, view the "Online" tab and input voltages to the channels and force outputs (in "Free Run" mode).

To load your PLC code, in TwinCAT-PLC - Online - Login and select your PLC brain's "runtime". I recall you must set PLC to "run" mode in System Manager first, and perhaps use "Choose Run-time" first. Download the PLC code, then "Run". You can Logout or stay there to view PLC values. Create a "Boot Project" so it runs each time the PC boots up.

When you apply a voltage to DI1 channel, the DO1 channel should change to a high state. Whatever voltage you apply to AI1 channel, you should see double out of the AO1 channel.

This is all from memory and certainly some bugs and missing items above, but this is the general flow.
 
Last edited:
As a simple first start:

In TwinCAT-PLC, under Resources tab - Global Variables - Global_Variables, declare I/O variables:

VAR_GLOBAL
(* the variables below must be linked to I/O channels of each module in System Manager. When adding a new one, Rescan in System Manager to associate, otherwise a VAR_CONFIG warning *)
DI1 AT %I*: BOOL; (* digital in ch1, False = low, True = high*)
DO1 AT %Q*: INT; (* digital out ch1, False = off, True = on *)
AI1 AT %I*: INT; (* analog in ch1, -32768 to 32767 = -10 to +10 V *)
AO1 AT %Q*: INT; (* analog out ch1, -32768 to 32767 = -10 to +10 V *)
END_VAR

The "%I*" is a cryptic notation meaning an input variable and the exact memory location will be automatically specified later. You can also declare exact memory locations, as in old-fashioned PLC's, but that is tedious and error-prone. "Q" must mean output in German.

Next, use these variables in PLC code that executes every cycle. Under POUs tab - Main, enter Structured Text:
DO1 := DI1;
AO1 := 2 * AI1;
Save as "TestProject", then Project - Rebuild All.

In System Manager, start a new project w/ 1 ms cycle time.
Under "Route Settings", "Broadcast Search" for your PLC "brain" (might be on same PC), and set a "static" Route.
Under "IO Devices", right-click "Scan Devices", then "Scan Boxes", etc.
Under "IEC 1131", right-click "Scan Project" and select "TestProject.tpy" you built above.
Under "Standard - Inputs", dbl-click DI1 and AI1 and link to a real input channel. Select a terminal's channel "Value", not a status bit such. Ditto for "Outputs".
To make sure the I/O links work, view the "Online" tab and input voltages to the channels and force outputs (in "Free Run" mode).

To load your PLC code, in TwinCAT-PLC - Online - Login and select your PLC brain's "runtime". I recall you must set PLC to "run" mode in System Manager first, and perhaps use "Choose Run-time" first. Download the PLC code, then "Run". You can Logout or stay there to view PLC values. Create a "Boot Project" so it runs each time the PC boots up.

When you apply a voltage to DI1 channel, the DO1 channel should change to a high state. Whatever voltage you apply to AI1 channel, you should see double out of the AO1 channel.

This is all from memory and certainly some bugs and missing items above, but this is the general flow.

Thats what i want, thank you very much (y)
 

Similar Topics

Hi everyone, This is my first time posting, so please forgive any omissions or mistakes. I am attempting to control the velocity of a stepper...
Replies
18
Views
998
Hello, I was wondering if anyone know how to upload a PLC program to the Beckhoff TwinCAT 3 from a file? i.e. without having the development pc...
Replies
0
Views
755
Hi anyone got any tips and tricks?? I'm at a stage wherei need to tidy up my hmi project and give all objects sensible names, I did start this...
Replies
0
Views
959
Hello, I have a System running a beckhoff IPC with twincat 2 software on it, Also i have no original source code. Is it possible with the...
Replies
1
Views
1,266
Hi all, I've inherited someone else's program and can't for the life of me figure out his use of the # symbol in one of his structured text...
Replies
5
Views
1,919
Back
Top Bottom