Jump to content
Adamkse

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

Share this post


Link to post
Share on other sites

Noticed that my PID_HLT output was called "PID Output bit" and not "PID Output" as I had.

Still the same problem but the oposite way round "HLT1 OUT" is always 0 even if "PID Output bit" is changing.

 

 

HLT PID 2.png

main 2.png

Share this post


Link to post
Share on other sites

What's happening in the real world at the actual heater?  Perhaps it is pulsing very rapidly and the "limited" bandwidth for monitoring is not keeping up?

Aus

Share this post


Link to post
Share on other sites

Hi all

I figured it out. In real life the heater was off as the code suggested. The issue was related to the set/reset coils not functioning properly. The do not work as local, function in or function out tags. Only global tags.

Share this post


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

Share this post


Link to post
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

×