Post by jackbrady on Function Blocks and arrays of function blocks
CODESYS Forge
talk
(Post)
Hello, I am new to Codesys and PLC programming in general (please go easy ha!) I'm not looking for code to be written for me just some help and pointing in the right direction. I am writing some code to send commands to a relay based on input values (to put it simply). Quite basic stuff. I have wrote a function block that takes a global variable (Open_command:BOOL) and outputs to another global variable (Opened : BOOL). The function block is simulating a device so I'll eventually get the globals from that. I now need to create multiple versions of this function block/ device (lets say 100) but I need each iteration of that function block to reference it's own relevant global variable. I think that the best way of doing this would be to use arrays, although I could be wrong. I am aware that for up to 100 instances I could very well manually assign everything but that seems rather time consuming and I want a fancier way of doing it. Here is a very basic example of what I am looking to do, please note I have not written this in proper code it's just to show what I mean. Global Variables V[0-100] int Open_command [0-100] Bool Opened [0-100] Bool Function Block var input x : BOOL Var output y : BOOL if x then y = TRUE ELSE y = FALSE The input to my function block will be Open_command, output will be Opened Example code. If V[x] > 10 then Open_command [x] = TRUE ELSE Open_command [x] = FALSE (So when V1 goes above 10 I need Open_command1 = TRUE therefore initiating FB1 output. V2 > 10, open_command2 = True > FB2 output V3 > 10, open_command3 = True > FB3 output ... ... ) What I can't seem to figure out is how to tie all this together, I have read through the codesys documentation and if anything it has confused me more! ha. Apologies for the poorly written post but hopefully you understand what I am trying to get at. Thanks, Jack
Last updated: 2024-02-14
How to use FB_Init with nested Function Blocks?
CODESYS Forge
talk
(Thread)
How to use FB_Init with nested Function Blocks?
Last updated: 2023-08-30
Return a value in FBD POU-Function
CODESYS Forge
talk
(Thread)
Return a value in FBD POU-Function
Last updated: 2017-08-13
Variable number of arguments in a user-defined function
CODESYS Forge
talk
(Thread)
Variable number of arguments in a user-defined function
Last updated: 2012-01-08
Automation SDK - Reset pins on a function after inserting
CODESYS Forge
talk
(Thread)
Automation SDK - Reset pins on a function after inserting
Last updated: 2015-05-20
How can i set or reset an analog function?
CODESYS Forge
talk
(Thread)
How can i set or reset an analog function?
Last updated: 2019-07-29
Writing a VALUE into a input function value....Enquiry
CODESYS Forge
talk
(Thread)
Writing a VALUE into a input function value....Enquiry
Last updated: 2014-01-02
The VAR_INPUT stDirEntry for the function SysDirRead
CODESYS Forge
talk
(Thread)
The VAR_INPUT stDirEntry for the function SysDirRead
Last updated: 2008-06-24
add protecction to a fb or function
CODESYS Forge
talk
(Thread)
add protecction to a fb or function
Last updated: 2019-06-11
Creating library for Linking C function / program.
CODESYS Forge
talk
(Thread)
Creating library for Linking C function / program.
Last updated: 2014-11-14
Using function blocks to correctly obtain zenith besides OSCAT
CODESYS Forge
talk
(Thread)
Using function blocks to correctly obtain zenith besides OSCAT
Last updated: 2022-09-20
Properties displayed twice with extended function blocks and interfaces
CODESYS Forge
talk
(Thread)
Properties displayed twice with extended function blocks and interfaces
Last updated: 2018-06-30
rising edge not working when declared in other function fb
CODESYS Forge
talk
(Thread)
rising edge not working when declared in other function fb
Last updated: 2016-11-16
How to make the output of a function blok persistent?
CODESYS Forge
talk
(Thread)
How to make the output of a function blok persistent?
Last updated: 2020-11-09
How to run machine using function blocks
CODESYS Forge
talk
(Thread)
How to run machine using function blocks
Last updated: 2007-10-24
CSV utility does not function in PFC100
CODESYS Forge
talk
(Thread)
CSV utility does not function in PFC100
Last updated: 2020-07-07
Leap Year error in CAA DTUtils.GetDayOfWeek function
CODESYS Forge
talk
(Thread)
Leap Year error in CAA DTUtils.GetDayOfWeek function
Last updated: 2020-03-02
Function SIN, COS, TAN angle units?
CODESYS Forge
talk
(Thread)
Function SIN, COS, TAN angle units?
Last updated: 2013-12-17
How to pass init values to nested function blocks?
CODESYS Forge
talk
(Thread)
How to pass init values to nested function blocks?
Last updated: 2018-03-09
How to use the function sysfileopen
CODESYS Forge
talk
(Thread)
How to use the function sysfileopen
Last updated: 2007-06-25
How to get Codesys License number by using function call ?
CODESYS Forge
talk
(Thread)
How to get Codesys License number by using function call ?
Last updated: 2020-03-25
Function to Browse and Return File Name and Path
CODESYS Forge
talk
(Thread)
Function to Browse and Return File Name and Path
Last updated: 2012-04-26
Can external C function fill structure declared in CoDeSys?
CODESYS Forge
talk
(Thread)
Can external C function fill structure declared in CoDeSys?
Last updated: 2012-09-16
Einfach und effektiv Quelle einer FUNCTION oder FB finden
CODESYS Forge
talk
(Thread)
Einfach und effektiv Quelle einer FUNCTION oder FB finden
Last updated: 2009-04-30
Unable to set function code 0x780 for CANopen rxpdo5
CODESYS Forge
talk
(Thread)
Unable to set function code 0x780 for CANopen rxpdo5
Last updated: 2017-03-08
To search for an exact phrase, put it in quotes. Example: "getting started docs"
To exclude a word or phrase, put a dash in front of it. Example: docs -help
To search on specific fields, use these field names instead of a general text search. You can group with AND
or OR
.