Twincat PLC - how declare variable

derickloo

Member
Join Date
Mar 2015
Location
Malaysia
Posts
36
I'm new in PLC programming. I have a small project which have 15 temperature sensor. How I should declare the variable for this 15 sensor.

I try code below

temp0 AT %IW10: INT;
temp1 AT %IW12:INT;

May I know it's correct to declare like that/

I also have 15 controller which use to control the temperature. How I should declare this 15 controller also?
 
temp0 AT %I*:INT;
temp1 AT %I*:INT;

This is valid, however depending on how you want to manipulate the data in your program you can also declare it as an array

temp AT %I*:ARRAY[1..15] OF INT;

Ending up with temp[1] thru [15] which can be addressed indirectly
 
May I know what the meaning of 10?
temp0 AT %IW10: INT;

Can I declare like below
temp0 AT %IW10: INT;
temp0 AT %IW11: INT;

or it must even number?
 
The AT %IW10 means Input Word number 10. The AT % means it's an address in the process image.
Since INT and WORD are both 16 bits in size (1 byte = 8 bits) we declare the address as Input Word and not Input Int.
The next empty address would therefore be IW12. (10+11 for the first Word, 12+13 for the next)

But instead of keeping track of all the addresses yourself, you can and should use AT %I* and TwinCAT will assign a suitable area for you. If you are using regular Inputs and Outputs, use this. Only use specific areas if you really need to, like with Modbus TCP or likewise.
 

Similar Topics

I'm new in PLC programming. I have a small project which have 12 temperature sensor. How I should declare the variable for this 12 sensor. I...
Replies
4
Views
2,449
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
760
Hi All I am not very skilled on TwinCat This is the situation: We are switching from phisical PLC (CX5120) to softPLC (we use HMI, that is a...
Replies
3
Views
1,492
Hello. I have been using CODESYS for years and had taken for granted that the PLC part was very similar to TwinCAT. but just found one issue that...
Replies
1
Views
1,969
Hi, I have no knowledge of TwinCat:shoot: We have a system running TwinCat PLC v.2.11 on a XP computer, EtherCAT BECKHOFF EK1100, 8 24 vOLTS i/O...
Replies
10
Views
3,301
Back
Top Bottom