ruben2024
Is there a way to make a function block in C that would be able to encrypt MODBUS addresses? I know you can make function blocks with Structured Text but I'm not sure if actually implementing a program that encrypts is actually possible here. Can anyone please let me know if it is?
Reply 0 0
thiagoralves
https://openplc.discussion.community/post/ladder-logic-how-can-i-implement-random-numbers-in-a-ladder-logic-progarm-11981211?pid=1328858655&highlight=random
Reply 0 0
Phoenix
Hello. I did not fully understand. Is it possible to write a function block entirely with C code?

My goal is to write a Modbus function block. I almost have the C code for it, but I need to know how to convert the C code into a block.

If you have any advice, I would appreciate it if you could tell me.
Reply 0 0
thiagoralves
Yes, you can write the entire function block code in C, as long as your code is wrapped in pragmas ( the “{“ and “}” symbols )
Reply 0 0
Phoenix
I did that for a sum block for the test, but the code doesn't compile correctly. How can I solve the problem?
(error: 'SUM' has no member named 'Variable names')

Another question I have is how can I call the functions I wrote myself when writing the function block code in C language and where should I put the file of these functions.
Reply 0 0
thiagoralves
IEC languages are not case sensitive, but C is. Therefore you must write your variable names with uppercase (all caps), like ENABLE, FIRST_VAR, etc. That is how the compiler distinguishes between C and IEC variables.

To use your function block, simply drag it from the left panel menu to your main program
Reply 0 0
Reply