Beckhoff TwinCat starting out. Help

g.mccormick

Lifetime Supporting Member
Join Date
Jul 2012
Location
IN
Posts
961
Ok working on TwinCat for first real time.

I cannot seem to find a way to do a compare in the ladder.

The way our driver works (from our control system to the plc) we cannot use bits, we must use 32bit DINT.

So I will be reading and writing to/from a bunch of memory words, then using logic in the PLC to turn on outputs if certain things are ok.

In the PLC logic, I need to see if a request is on, then turn on a logical of BOOL type. I can't use a DINT in a NO contact in ladder as it is not a BOOL, I can't figure out how to do a compare in the ladder editor

I'm learning how to do this in ST.
Example in ST:
Global variables
Request1 AT %MD4: DINT;

Logical1: BOOL;


IF Request1>= 1 THEN Logical1:= TRUE; ELSE Logical1:=FALSE; END_IF


I can't figure out how to do >= in ladder.
 
it is called GE from greater equal. it is a function.
others are EQ, LE,GT LT.
insert a Function block with enable.
press F2 (assistant) and insert a FBD. now you see a list with all types of functions and FB.
this can also be used in FBD and CFC.
 
it is called GE from greater equal. it is a function.
others are EQ, LE,GT LT.
insert a Function block with enable.
press F2 (assistant) and insert a FBD. now you see a list with all types of functions and FB.
this can also be used in FBD and CFC.


Thanks. I didn't realize that it would be in the FBD list of operators.
 
Ok all. I'm further along with this and trying to now put plc code and io together in CX8090.

Attached is my plc code along with tsm file. I have a bunch of IO connected to this device.

When I try to put the project into the plc, then go to run is the System Manage I gives and error and does not go into run. (I can't remember the error and I am not connected now.).

Normal operations steps.
1. Created PLC logic.
2. In TSM I connected to plc.
3 .Scanned for IO.
4. appended PLC project.
5. Mapped some of the PLC projects inputs to physical IO points. (not all of them yet)
6. Activated config.
7. Triied to run and failed.

Am I missing a step? Do I have to do all of the mappings before I can load?
At one point, I saw an error about boot loaders, do I need to create a boot loader somehow?


Thanks
 
When I try to put the project into the plc, then go to run is the System Manage I gives and error and does not go into run. (I can't remember the error and I am not connected now.).


Am I missing a step? Do I have to do all of the mappings before I can load?
At one point, I saw an error about boot loaders, do I need to create a boot loader somehow?
I took a quick look and didn't see anything obvious that stood out to me. You do not have to map everything, just a single point is sufficient. The Boot Loader you may be referring to is the Boot Project. After you download the program, you will need to create a boot project so the program stays after a power cycle.

The error you get in System Manager will help us point you in the right direction.
 
I took a quick look and didn't see anything obvious that stood out to me. You do not have to map everything, just a single point is sufficient. The Boot Loader you may be referring to is the Boot Project. After you download the program, you will need to create a boot project so the program stays after a power cycle.

The error you get in System Manager will help us point you in the right direction.

Thanks Archie. I will be back at this tomorrow, will be sure and capture the errors.

Do you have to load the plc project seperate from the tsm "activeate configuration"?
 
Do you have to load the plc project seperate from the tsm "activeate configuration"?
I have only worked with TC2, but I am assuming this still applies. After you Activate Configuration using System Manager, you will then use the PLC programming environment to download the program and create a boot project.

Something to understand about TwinCAT that is different than typical PLCs is that is has two parts, a "System" and a "PLC" program. Before you can download a PLC program, the system must be in run mode. After you download the PLC program, you must then put the PLC in run mode also.
 
I have only worked with TC2, but I am assuming this still applies. After you Activate Configuration using System Manager, you will then use the PLC programming environment to download the program and create a boot project.

Something to understand about TwinCAT that is different than typical PLCs is that is has two parts, a "System" and a "PLC" program. Before you can download a PLC program, the system must be in run mode. After you download the PLC program, you must then put the PLC in run mode also.


OK. That may be what I am missing. I did not load the plc program via the plc configuration. I only "activated configuration" in the system manager (I was abbreviating twincat system manager to tsm).

I am using TwinCat 2.


Hopefully I can get a change to clear out contractors and try this before too long.
 
Ok so I have made some progress today. I stripped down my IO count and the PLC project.

I also figured out that I was not actually loading th ePLC code into the CX. I have gotten all of this to work now, I have not yet created the boot so it loses the project on power cycle.

I have one problem now though, I am using EL5152 for counting the pulses from some totalizing meters. I finally figured out how to get the 5152 to count up. The problem is that the count will reset with power cycle, the value is not persistant in the terminal.

I know I need to create a retained value in plc code, but I can't figure out how to do that.

I have mapped the terminal count value to a variable.
Example
In9 AT %ID32: DINT;

In the Global_variables, I have create
VAR_GLOBAL RETAIN
totCntr1 : DINT;
END_VAR


In my code I need to keep updating totCntr1 as the total non-resetting count. Any help with what that code should look like?
 
I'm getting closer. Attached is pdf of project info. I have created a count value that updates from a timer. I thought that I made this variable so that it would stick during a power cycle, but that is not what it is doing. It totCntr1 is getting rezeroed during a power cycle. WHat am I doing wrong?
 
Ok. I've read the link, but honestly don't know what to do. I have made my totCntr1 to be persistant instead of retain. What exactly do I do with that function? Do I call it every second or something?
 
Well I think I've got somethig that works now. I emailed Beckhoff for an example and the sent one.


I'm starting to catch on to this codesys and twinCat a little. Attached is what I have ended up with. Tomorrow I will hopefully be putting this CX back on the large amount of IO and finalizing the mappings of the various points.

Thanks for the help all. Feel free to tell me if you think i have done a crappy job on my little program.


I can't upload the whole thing (To large even as zip?). If anyone is interested, let me know what file i need to upload.
 
Last edited:
As I see you've done the job but for more clarification I've attached a sample program for Cx8090 for persistent memory. You should just add TcSystemCx8090 library and use the "FB_S_UPS_CX80xx"function block to activate ups.After that you should declare PERSISTENT variable which I declared in Global part. That's all
 
Beckhoff sent me an example and I implemented it. Totally new to this and codesys, did not really know what Ineeded to do to use the FB_S_UPS_CX80XX function block.


Next question.
What is the diffenerence with the three different network ports (X001, X101, X102)?

I have been connedted to the X001 via DHCP. In System Manager, I just assigned it a static IP address. Any reason that I should or should not use X001? I will be talking to this controller via AmsAds from my host control system. Should that link be X101/X102 for some reason?
 

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
1,000
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
756
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,920
Back
Top Bottom