Jump to content

Recommended Posts

hi,

i got a subroutine call when MB 0 is on. In this subroutine i want to catch a falling edge of MB1.

if i set MB 0 then i set MB1. Then i reset MB 0

the subroutine isn't call anymore. I now reset MB1.

When i set MB0 again i call the subroutine and then the falling edge is "activate". Is this a normal behaviour?

i first thought that the rise and fall edge where decided at the start of the scan cycle? but it seems it is net dependent !

It's maybe an rfc something rule but i am not aware enough of those rules. I just wnat a confirmation it's a normal thing and not a bug...

Thanks

Share this post


Link to post
Share on other sites

Hi,

For the transition, [N] or [P], O/S keep previous state and current state of MI or other bit.

If there is change in state between previous and current scans, O/S activate [N] or [P] contact for 1 scan.

Mean of scan in this case is not a System scan, but two sequential entryes into subroutine.

So you have to take care about this.

B.R.

Share this post


Link to post
Share on other sites

It is generally understood no matter whose platform you use that the transitions are based off WHEN in the program that bit of memory gets written resulting in a change of state.

It is not (should not be) be directly related to the "housekeeping" portion of the scan.

However, if you are reading physical Inputs, then those are updated only during the "housekeeping" portion of the scan.

Unless of course you use an immediate IO read to sample the hardware IO before the "housekeeping".

Since MB bits are internal, there is no housekeeping necessary for them, therefore the end of the scan is irrelevant.

In addition, if you have conditionally executed subroutines in a PLC (which should normally be avoided for a host of reasons) your code may completely miss transitions that came and went because the transitional instruction you are using will base that off of the evaluation of that instruction the previous time it was exectued.

On the flip side, you could have the same bit (MB) of memory trigger positive and negative transitions multiple times in one single scan.

Share this post


Link to post
Share on other sites

After actually playing around a bit, it appears that the transistions in Visilogic do not function anything like I thought they did either.

As Alex hints at, it appears that the memory bits associated with change of state are sampled on each and every subroutine, including the main subroutine.

This means that if you call the same subroutine twice or more within one total PLC scan, any transitional within will only be evaluated true the first time through.

However, that transition will still be detected by the calling subroutine and subsequent other subroutine calls within the global scan.

If you then have combinations of SET and RESET on those bits outside the subroutine calls, depending on order and placement you can create anamolous and unpredictable behavior.

In some cases, even disregarding subroutines, I saw evidence of transitionals being affect by changes being made to the bits within that same scan. In other instances it was not tied to the scan.

For example, I put two identical --|n|--[iNC+]-- networks in consecutive networks incrementing unique integers. Both would count.

However if I put a reset coil of the bit with the referenced N transition above between these two identical networks, the second of them would stop counting. It did this even though there was no difference in the change of state. Therefore just having overwritten the same state to said memory area the transition was lost. Which means it was updated immediately with the reset coil and not the subroutine.

I was also able to create situations where it recogized transitions within routines, but did not recognize those transition in the main subroutine.

Can we please get a concise and detailed description of exactly how and when the transitional contacts are updated and evaluated?

Based on the observed behavior, the description in the help file is actually incorrect/incomplete.

  • Upvote 1

Share this post


Link to post
Share on other sites

Hi Damian,

How transition contact works?

Behind the transition "contact", in fact there are 3 more internal bit registers - one for P contact, one for N contact and one for "buffer". That's why the number of transition contacts is limited.

When the scan comes to specific transition contact (P or N), it compares the value of the linked to this contact bit (let's say MB0) with the value of the buffer.

If:

1. bit = 0 & buffer = 0 -> P = 0 and N = 0 no transition detected

2. bit = 1 & buffer = 0 -> P = 1 and N = 0

3. bit = 0 & buffer = 1 -> P = 0 and N = 1

4. bit = 1 & buffer = 1 -> P = 0 and N = 0 no transition detected

After updating P & N contacts, controller copy the value of the bit to the buffer and con tinue the scan.

As result - if in previous scan we had case 2 and P = 1; in the current scan we will have case 4 and P contact will be reset back to 1.

This way transition contact by definition are active only one scan.

Important note: proceeding the transition contact in the way described above is when the scan is comming to this specific contact in the application. If, for ecample specific subroutine is not scanned for some time and the transition contact is inside, it will be activated only when the subroutine is scanned again.

I hope this makes sense. Let me know if you need any additional info.

  • Upvote 2

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