Jump to content

UDFB output function value doesn't match the connected variable


Adamkse

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 comment
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 comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

This site uses cookies. By clicking I accept, you agree to their use.