Jump to content

Issues setting bits with a state machine


Recommended Posts

First time poster so excuse me if I missed something basic. I have been looking through the forum and it sounded like I needed a state machine in one subroutine. The problem I'm having is that for some reason I can't set bits in my states. Here are some code snippets:

 

post-26369-0-10813300-1417550296_thumb.jpg

post-26369-0-85978600-1417550296_thumb.jpg

 

As you can see whether I'm using a direct coil (state pointer = 10) or a set coil (state pointer = 30) MB 10 stays low. I have a counter before the only coil that resets MB 10 so I know that it's not switching too fast for me to see it. Is there a simple explanation as to what's going on?

 

As a side note I hope my photos are visible, They should be plenty large enough, but in preview post I only see tiny thumbnails. If that's a problem tell me what I've done and I'll try to fix it.

Link to comment
Share on other sites

Hi endevor100.

 

 

You cannot use two or  more different coils for the same MB. The scan will take the value of the last coil so for example if you called two time this MB and you activated on a net and after that there is another net where the output is not activated, the PLC will assume it is not activated.

In the pictures I notice that the logic has one coil and one set coil for MB10. Why use in one part a regular coil and in another a set coil?

Do you activate this MB -MB10- somewhere else on the logic? Which coil do you use to activated it?

 

It is possible for you to send us the application?

sent it to support@unitronics.com

Link to comment
Share on other sites

I used a direct coil in one place and a set coil in another to see if it made any difference, generally I would use a set coil. I use this MB all over the program, but there is only one reset coil in the entire project so I don't believe that the MB is getting contradicting information in a single scan. I'm using a V130 if it matters and the subroutine in question is the Homing one. MB 10 activates a MODBUS read in the main routine which is the rung that has the only reset coil. When I run the program DW 0 (Total Sessions) doesn't increment and that's why I'm pretty sure that MB 10 is never going high.

camera dolly.vlp

Link to comment
Share on other sites

  • MVP 2023

It's okay (if the logic is correct) to use Set and Reset coils in multiple places in your project, but NEVER use multiple direct coils with the same address. In your case, you're trying to trigger something off multiple conditions. Use a separate direct coil (or Set coil, if appropriate) for each condition, then at the end of your subroutine, place all those separate MBs as contacts in parallel to trigger MB10.

 

You can easily check for multiple coils of the same address by right-clicking on the Operand (when NOT Online) and selecting "Find...". All the instances of the operand will be listed at the bottom of the screen and you can double-click on any of them to take you to the location.

Link to comment
Share on other sites

I only use set and reset coils for this MB. The direct coil was merely an experiment when my program wasn't working. The only reset coil for this MB in the entire program is after the MODBUS send in the main routine and that send isn't getting called so I feel like the MB is never going high. Am I missing something?

Link to comment
Share on other sites

  • MVP 2023

The direct coil was merely an experiment when my program wasn't working.

 

A direct coil isn't necessarily the best thing to use in this type of troubleshooting. It can turn on and then off again too fast for you to see, or within one PLC cycle. Try placing an Increment of an MI and watching it for changes.

Link to comment
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...