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

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...