You are not registered yet. Please click here to register!

plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
Try our online PLC Simulator- FREE.  Click here now to try it.

New Here? Please read this important info!!!

Go Back - Interactive Q & A > - Interactive Q & A > LIVE PLC Questions And Answers

Thread Tools Display Modes
Old September 14th, 2021, 07:04 PM   #1

Psnikta is offline
Join Date: Mar 2020
Location: QLD
Posts: 15
ST - Changing an input value of a UDF in code.

Hi All,

I am currently at the beginning of a new project for writing a PLC program (using CCW) for an old sugar centrifugal.

Most of our factory is Honeywell CEE function chart so I am wanting to make something resembling what would normally done in the CEE (Which would be individual Control modules for the devices that are controlled by a Sequential Control Module).

Building the UDF (device control block that handles the command, input status and permissive and override interlocks) is relatively straight forward, the only thing I am struggling with is the Input command to the UFD itself.

Typically what would happen in CEE for example if State0 was requested on the InputCommand to the block and an override interlock for another state was ON or the state0 permissive was OFF the block would reject the change to the InputCommand.
Another scenario would be that if the block was in State0 and the override interlock for State1 turned ON the InputCommand would then need to be set to State1 as well.

The problem is, is that the ST in the UFD cannot change the value of a variable that is on the input side... so I am at a loss for what to do about this.

Any thoughts?

Note: I do have a ladder program for one of these centrifugals (would require a bit of modification) but ladder is very problematic for the electricians and myself to easily identify operational problems.
  Reply With Quote
Old September 15th, 2021, 03:23 AM   #2
Lifetime Supporting Member

TurpoUrpo is offline
Join Date: May 2008
Location: Switzerland
Posts: 1,532
If you think about it, that does all the sense to not be able to modify input value of a block from inside the block doesn't it?

So what you need, is either inout, or some other mechanism.

Be cautious about the calls also. When the block is called, its inputs are assigned, so did you also change the command in a way, that it wont try again?

Maybe a question: where is the command originating from? HMI/Scada? and how?
  Reply With Quote
Old September 15th, 2021, 08:27 AM   #3
United Kingdom

parky is offline
parky's Avatar
Join Date: Oct 2004
Location: Midlands
Posts: 3,473
That is the reason why there are In/Out variables so they can be modified within the function block as well as outside in the calling block.
The input parameters are passed to local variables just as in any programming language & the outputs are passed from the local to the required variable (possibly global) however, this also varies as in most IDE's the variable used as an input could be a local to the main block calling the function.
For example
Global variables are available to all blocks
Local variables are only available to the block it is declared in, however, it can be passed to a function that is called within that block.
Many years ago I used to create what now would be considered function blocks, this was done in the code by creating a program using say a range of variables then in a program block transfer the "IN variables to the ones allocated in the program used as a function block, jump to the block, on return transfer any variables required back.
Mitsubishi actually do this now so that it is compatible with the older ladder system where all variables are fixed i.e. D0 to D7000 for registers & M0 to M7000. What they do is reserve say D9000 to D10000 & M9000 to M10000 for variables that have no physical address in the IDE to make it compatible with the newer ways of creating symbolic variables rather than using actual physical memory areas, so creating a symbolic variable without an actual address when compiled, a physical address is allocated at compile time and will be in the range as mentioned above.
Temporary variables for created function blocks also use this allocated area.
The only downside is that any communication i.e. an HMI variables must use allocated physical addresses
  Reply With Quote
Old September 15th, 2021, 05:48 PM   #4

Psnikta is offline
Join Date: Mar 2020
Location: QLD
Posts: 15
Looking at CCW your only options for UDFs are Var,VarOutput,VarInput.
So I have come up with a workaround to do what I want it to do kind of.

So the command to the block is an INT, using the same format at a CEE DEVTCL block the values are:
0 = No command
4 = Request State 0
5 = Request State 1

So I have put in some code records the previous value of the command and compares it to the current one and it will only perform command actions for a single execution provided the two values are different, this means that when making a command request to the block you will need to set the command to 0 first and then set it to the value for the state you want (4 = Shut, 5 = Open for example).

The next problem I have run into is that I mistakenly thought that CCW has SFC lanuguage... it doesn't so will have to come up with a structured text version.
  Reply With Quote
Jump to Live PLC Question and Answer Forum


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
RSLogix 500 - I/O mapping question toads LIVE PLC Questions And Answers 8 September 25th, 2019 12:40 PM
Checking a 4 line ST code. (For TOFR Timer) karthhic LIVE PLC Questions And Answers 4 June 10th, 2016 08:04 AM
1762-IF2OF2 Analog Input Problem davidgay LIVE PLC Questions And Answers 22 August 14th, 2013 05:25 AM
State machines in ST (Siemens SCL) bara_hence LIVE PLC Questions And Answers 12 April 9th, 2010 03:06 PM
Analog input code examples fluidpower LIVE PLC Questions And Answers 9 July 14th, 2003 09:42 AM

All times are GMT -4. The time now is 09:20 AM.