I have a quite basic understanding of how PLC programming works. However I keep getting stuck on 1 problem
I could not get my head around.
The problem is as follow:
I have a PLC with 60 IO (20 inputs, 40 outputs). Each IO is defined as a function block.
Furthermore I have an external IO card connected trough a CanBus connection.
This IO card has 4 analog input channels (USINT), 4 digital inputs (Bool) and 4, digital outputs (Bool)
Because I have 2 different components which both has data have I made 4 arrays to store the data off every component in one variable.
PLC_Input: Array [1..20] of BOOL;
PLC_Output: Array [1..40] of BOOL
IOCard_Input: Array [1..8] of BOOL
IOCard_Output: Array [1..4] of BOOL
Because the control and reading of the different in and outputs is done by a TCP connection I want
to use some kind of enumeration or struct to give each index a name so that my main would be a little bit more readable instead of all the magic numbers. Also this would make my program more dynamic for the furter in case I need to changes some in the IO nummers.
For example: pump is placed on the fysical terminal strip number place 54, which is the 3th output of the IO card in the program:
if I am sending a message with value 54 I would like to control IOCard_Output[3].
If there is a solution or methode to get this done, I can eventually do the following in my main program:
IOCard_Output[Pump].
I have tried the following: IOCard_Output[Pump - 51] with an enumration but this keeps raising an error
I hope some of you could help me further with this problem.
In gross lines: I want to couple all the different IO to a more readable name and this readable name should control the right Array index
Hello Folks,
I have a quite basic understanding of how PLC programming works. However I keep getting stuck on 1 problem
I could not get my head around.
The problem is as follow:
I have a PLC with 60 IO (20 inputs, 40 outputs). Each IO is defined as a function block.
Furthermore I have an external IO card connected trough a CanBus connection.
This IO card has 4 analog input channels (USINT), 4 digital inputs (Bool) and 4, digital outputs (Bool)
Because I have 2 different components which both has data have I made 4 arrays to store the data off every component in one variable.
PLC_Input: Array [1..20] of BOOL;
PLC_Output: Array [1..40] of BOOL
IOCard_Input: Array [1..8] of BOOL
IOCard_Output: Array [1..4] of BOOL
Because the control and reading of the different in and outputs is done by a TCP connection I want
to use some kind of enumeration or struct to give each index a name so that my main would be a little bit more readable instead of all the magic numbers. Also this would make my program more dynamic for the furter in case I need to changes some in the IO nummers.
For example: pump is placed on the fysical terminal strip number place 54, which is the 3th output of the IO card in the program:
if I am sending a message with value 54 I would like to control IOCard_Output[3].
If there is a solution or methode to get this done, I can eventually do the following in my main program:
IOCard_Output[Pump].
I have tried the following: IOCard_Output[Pump - 51] with an enumration but this keeps raising an error
I hope some of you could help me further with this problem.
In gross lines: I want to couple all the different IO to a more readable name and this readable name should control the right Array index
Thanks in advance,
George
Related
Talk.ru: 3
IF you create an ENUM
You should be able to access the array items like:
Last edit: TimvH 2024-09-28