Jump to content

UDFB output function value doesn't match the connected variable


Recommended Posts

Hi,
I have a PID function block  with an embedded PWM  function which should turn a heater on and off with a duty cycle. However it is always set on (1). When I monitor the PID UDFB the output from the PWM is 0 but the main ladder has it as a 1. If i drill down further in the PWM UDFB then that is also 0. I don't  understand what is happening.

Any help would be great.

HLT PID.png

Main.png

Link to post
Share on other sites

Hi.

Value types, like integers, Bits, Real, are being passed by value (Meaning, their value is being passed to the function, and not the pointer to the value) when used in a function-in.

So any attempt to change their value within a function code will only affect the value inside the function.

 

Arrays and structs are being passed by Reference, so if you change a value of a bit or a number inside it from a function code, then it will affect the value outside the function.

 

You have 2 options: Passing an array/ struct, or pass the number / bit as a function-out (which means that it will be passed as a reference).

I hope this information helps.

  • Upvote 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...