Sign in to follow this  
Followers 0
pszczepan

FB - CX simulator and real PLC

5 posts in this topic

Hi ! I have a FB which looks like: During one scan the condition which set value of Msg11ID is off - it is inactive. So - the value of Msg11id should not be changed, but when I pass this FB the value Msg11ID is changing to "0". Is this behaviour only in Cx Simulator or real PLC change the value to 0 every scan the condition changing value is off. How I should write FB if I want to leave value of Msg11ID the same as long as I do not change condition which set new value of Msg11ID

Share this post


Link to post
Share on other sites
Hi, Not sure but I would try checking the 'retain' check box for the output variable in the FB configuration. Nibroc Edited by Nibroc

Share this post


Link to post
Share on other sites
I never use CX-Simulator for timed FB processing. Its not reliable for that, use a real PLC for timed FB and FB that require more than one scan to complete (PID etc)

Share this post


Link to post
Share on other sites
Hi I use CJ2H I've tried retain and it does not work. I attached short code with this FB and if look into you will see that Msg11ID can be set to 0 when Msg11Reset is On or W303.03 is ON (sometimes) FB_output_test.cxp If I start Cx simulator I cannot set any value to Msg11ID - only if I set breakpoint at the beginning, but when I run step by step when the FB is finished every time Msg11IG goes automatic to "0" I have to overwrite some code and PLC already works and I cannot change it online. First I have to prepare something offline and test on CX-Simulator. Could you confirm that if I have some value in Msg11ID it will be there as long as I do not change it using Msg11reset flag - I mean real PLC. thanks Pawel Edited by pszczepan

Share this post


Link to post
Share on other sites
Hi. I have your answer, but I think I'll credit YOU with it as you kinda said it above. No, the value in Output parameter "Msg11ID" will NOT be there as long as you don't change it !! What is happening is the FB "Output" variable "MsgNumber" is being created with (your defined) default value of 0. During the FB, nothing else is setting it, so remains 0. At the end of the FB, "MsgNumber" is being copied to the output parameter i.e. Msd11ID. So this is why you are geting 0 all the time. A very quick fix for this would be to make "MsgNumber" variable an "In Out" variable instead of just "Output". This means the value is passed in to start with, and is then passed back out - whether it was set inside the FB or not !! If this seems simple don't be too put out - it still took me 20 minutes to figure out what was happening Regards, Bertie.

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
Sign in to follow this  
Followers 0