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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hermsen hat geschrieben:
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?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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 …)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
a plc on a site must manage for example a tank with 1 valve (output) and 1 feedback (input)
a plc must manage a tank with 2 valves (2 outputs) and 2 feedbacks (inputs)
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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)
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There is a free package in the Codesys store for this. That package is very very powerful. I have used this package in a project and using it was a breeze.
Apart from providing a mechanic for free arrangeable IO channels, with different datatypes (BOOL, BYTE, WORD etc etc), it can restore previous made configurations and store current configurations onto disk.
Hi,
I'm trying to address some input and output lines not directly by a statement like this:
but something like
and finally I need to pass my I/O declaration variables to a function like
How can I achieve this?
Thanks
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
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
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!
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.
I'm not sure what the library really do. The example attached did not help me.
Is there a simpler solution without any libraries?
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)
Could you show me an example of what you are explaining me?
Thank you
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)
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
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 …)
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.
give us at least 3 exemples sites
ok
a plc on a site must manage for example a tank with 1 valve (output) and 1 feedback (input)
a plc must manage a tank with 2 valves (2 outputs) and 2 feedbacks (inputs)
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.
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 :
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
Hi
Another solution
Create an FB_dio.
Inside, put an (which could be static) pointer to array[0..1024] of usint (call him iomem).
Create two persistent vars:
Index:int
Bit:int
In your fb code, if is an dinput.
Iomem:= adr(ib0);
Out:= iomem^[index] and (shl(1, bit))<>0.
Changing index and bit, you can, programaticaly change your map.
Best regards
Sent from my Moto G (5S) Plus using Tapatalk
There is a free package in the Codesys store for this. That package is very very powerful. I have used this package in a project and using it was a breeze.
Apart from providing a mechanic for free arrangeable IO channels, with different datatypes (BOOL, BYTE, WORD etc etc), it can restore previous made configurations and store current configurations onto disk.
https://store.codesys.com/io-mapping-tool.html
Plus, it's open source so you can take a look inside the library to learn more about it's mechanics
Watch this:
https://www.youtube.com/watch?v=cN_Jz9ziUTM m