CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Thu Dec 13, 2018 5:57 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 15 posts ] 
Author Message
PostPosted: Wed Nov 28, 2018 2:05 am 
Offline

Joined: Mon Jan 22, 2018 10:07 am
Posts: 45
Hi,
I'm trying to address some input and output lines not directly by a statement like this:
Code:
INPUT_START_BUTTON1               AT %IX0.0   : BOOL;

but something like
Code:
INPUT_START_BUTTON1               AT [MYSTRING]   : BOOL;


and finally I need to pass my I/O declaration variables to a function like

Code:
function(parameter1, [MY I/O Assigned by a String]); 


How can I achieve this?

Thanks


Top
   
PostPosted: Wed Nov 28, 2018 4:15 pm 
Offline

Joined: Fri Feb 23, 2018 3:41 pm
Posts: 64
Hi,

go to your IO card, then edit IO/mapping tab. If you have bits, they may be grouped, so expand it to see each individual ones.

Then, just map the tag to the bit.

Regards,
dFx


Top
   
PostPosted: Thu Nov 29, 2018 1:30 am 
Offline

Joined: Mon Jan 22, 2018 10:07 am
Posts: 45
I need this functionality because we are going to implement many systems in different places so through a txt file we will release the same system but with the file we will arrange "dynamically" the address and in case of plc exchange we are able to address again the right I/O...
so I need to obtain a way to do that.
thank you


Top
   
PostPosted: Thu Nov 29, 2018 4:11 pm 
Offline

Joined: Wed Dec 28, 2016 11:00 pm
Posts: 66
Hi,

Take a look at https://store.codesys.com/io-mapping-tool.html.
That will probably solve many of your issue's:

"With the IEC library “IO Mapping Tool”, the inputs and outputs of a program can be remapped via a visualization in runtime mode."

I know that this can be done visually (online) and programmaticly (offline), the settings can also be saved to disk.

Good Luck!


Top
   
PostPosted: Thu Nov 29, 2018 4:38 pm 
Offline

Joined: Mon Apr 28, 2014 7:05 pm
Posts: 94
Is there a way to link variables in a separate file just like in TwinCAT when declaring IOs like this:

myInput AT%I*: BOOL;
myOutput AT%Q*: BOOL;

I am sure there is a way to do it, I just don't know how. I am mostly using TwinCAT but I would really like to be able to do this in CODESYS.

Thank you.


Top
   
PostPosted: Fri Nov 30, 2018 1:22 am 
Offline

Joined: Mon Jan 22, 2018 10:07 am
Posts: 45
Hermsen wrote:
Hi,

Take a look at https://store.codesys.com/io-mapping-tool.html.
That will probably solve many of your issue's:

"With the IEC library “IO Mapping Tool”, the inputs and outputs of a program can be remapped via a visualization in runtime mode."

I know that this can be done visually (online) and programmaticly (offline), the settings can also be saved to disk.

Good Luck!

I'm not sure what the library really do. The example attached did not help me.
Is there a simpler solution without any libraries?


Top
   
PostPosted: Fri Nov 30, 2018 2:20 pm 
Offline

Joined: Fri Feb 23, 2018 3:41 pm
Posts: 64
So, you want to late bind.

I would proceed as follow :
1) Define array for my I/Os : binaryInput[0..99] and map it to I/Os, same for outputs and analog
2) Define mapping array : FunctionMapping[0..99]
3) OPTIONAL FOR CODE READABILITY
Define constant for each function, that would be index of mapping array : exemple PUMP_BREAKER := 1, PUMP_HIGH_PRESSURE:=2
4) Use in code, binaryInput[FunctionMapping[PUMP_BREAKER]] when you need it in program
5) Configure your program I/Os by setting the rigth value in FunctionMapping array, knowing the constant values and your I/Os (that may come from a string)


Top
   
PostPosted: Mon Dec 03, 2018 1:32 am 
Offline

Joined: Mon Jan 22, 2018 10:07 am
Posts: 45
Could you show me an example of what you are explaining me?
Thank you


Top
   
PostPosted: Mon Dec 03, 2018 5:08 pm 
Offline

Joined: Fri Feb 23, 2018 3:41 pm
Posts: 64
Attachment:
1.png

Attachment:
2.png

Attachment:
3.png

Attachment:
4.png

Attachment:
5.png


To correctly map your inputs to the wired inputs, just change the value of :
IoMapDO[MAP.PUMP_RUN]
IoMapDI[MAP.PUMP_REQUEST]
IoMapDI[MAP.PUMP_FAULT]

to the index of your input.

Sample project attached.


For more code readability, but requiring more treatment, you may also copy every IO_DI/DO array value to the right tag (adding one more layer, but every access will have the same tag)


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Tue Dec 04, 2018 1:16 am 
Offline

Joined: Mon Jan 22, 2018 10:07 am
Posts: 45
Hi,
it is not my situation.
Let me explain in deep.
I need a solution to address the I/O on different systems that may differ between them.
For example one system may have only one valve and a feedback and the other may have three valves and some other feedback. The main program must be the same but via txt file I would like to "configure' the behaviour of the system, so a dynamic block could address different I/O based on the file.
I don't have to modify the application program. Just download to the destination PLC, change the txt file and... that's it.
Thank you


Top
   
PostPosted: Tue Dec 04, 2018 10:58 am 
Offline

Joined: Fri Feb 23, 2018 3:41 pm
Posts: 64
So you mean, you have different number of process instances ? -> just do a loop call for each instances, with variable count.
this exemple totally conforms with your needings, assuming you write by yourself TXT file reading and values setting from it (functionnal mapping, number of instances …)


Top
   
PostPosted: Wed Dec 05, 2018 5:57 am 
Offline

Joined: Mon Jan 22, 2018 10:07 am
Posts: 45
No no, maybe I'm not so clear...

I have to deploy many PLC in different sites.
Every sites can have a different configuration in term of I/O.
So the idea is to write one time the generic application program and configure the behaviour by a TXT file read at startup.
In the past I managed something like that but for parameters only, not for I/O.
So I need to be able to configure dynamically this I/O.


Top
   
PostPosted: Wed Dec 05, 2018 4:08 pm 
Offline

Joined: Fri Feb 23, 2018 3:41 pm
Posts: 64
give us at least 3 exemples sites


Top
   
PostPosted: Thu Dec 06, 2018 1:55 am 
Offline

Joined: Mon Jan 22, 2018 10:07 am
Posts: 45
ok

1. a plc on a site must manage for example a tank with 1 valve (output) and 1 feedback (input)

2. a plc must manage a tank with 2 valves (2 outputs) and 2 feedbacks (inputs)

3. a plc must manage two tanks with 1 valve each and 1 feedback each (2 outputs and 2 inputs)

in my idea I will develop only one application delivered to all plcs and send the plcs to the destination, remotely I will put the txt file and the application will arrange dynamically the addressing, that is my need
a text file like
I0.0
I0.1
I0.2
....
O0.2
O0.3
and the plc will address the relatives I/O.
if some input or output gate is going out for some reason a qualified person could switch physically to another and I remotely could change the txt file addressing correctly the new one.


Top
   
PostPosted: Thu Dec 06, 2018 9:05 am 
Offline

Joined: Fri Feb 23, 2018 3:41 pm
Posts: 64
What I purposed earlier totaly conforms in your needings.

So step 1 : create a generic plc program that address all I/Os (IO_DI/DOs arrays, Mapping arrays). You can forget about the constants.
Step 2 : create an array for each FB type you will have to use (tank with 1 outlet, tank with inlet+outlet …)
Step 3 : create fb call Inside a loop for each different fb you got, with a independant variable max loop count (1 for each fb type), using mapped I/Os as fb I/Os
Step 4 : just configure your program by whatever way you want (like reading txt file or settings manually values) by settings the right values in ioMap arrays and loop counts (loop count = 0 if you have no instance of this type)

exemple :
Code:
// FB calls
FOR index:=0 TO MaxFbTankOneValve DO
   FbTankOneValve[index] (ValveInput:=IO_DI[ioMapDI[0 + index]],
      ValveOutput=>IO_DO[ioMapDO[0 + index]]);
END_FOR;
FOR index:=0 TO MaxFbTankTwoValves DO
   FbTankTwoValves[index] (ValveInput:=IO_DI[ioMapDI[100 + index]],
      ValveOutput=>IO_DO[ioMapDO[100 + index]]);
END_FOR;


Assuming you will later set :
MaxFbTankOneValve as the count of instances of tanks with 1 valve
MaxFbTankTwoValves as the count of instances of tanks with 2 valves
ioMapDI[0] + MaxFbTankOneValve to the correct inputs indexes of tanks with 1 valve
ioMapDO[0] + MaxFbTankOneValve to the correct outputs indexes of tanks with 1 valve
ioMapDI[100] + MaxFbTankTwoValves to the correct inputs indexes of tanks with 2 valves
ioMapDO[100] + MaxFbTankTwoValves to the correct outputs indexes of tanks with 2 valves

Edited for code correction


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 15 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited