Jump to content

Recommended Posts

Hello,

I am struggling to understand Visilogic's MODBUS tools.

Say I would like to turn a light on and off from the master PLC, while the output is attached to the slave PLC. 

What would be the best function block to do this? I keep using the FB #5 and I will get the bits set high, but then they will stay high. I am practicing so I can use PTO utilities to control steppers instead of lights. First, I need assistance in understanding why things like MODBUS FB (5) sets and doesn't reset.

The attachments are just HMI lights telling you if you get the commands from the Master PLC. (You get them only if the 2 bits begin in RESET using the online mode)

Otherwise, O5 in the picture is the LED I am trying to turn off and on from the master.

Thank you!

 

 

 

20200104_100900.jpg

MASTER MODBUS TEST.vlp SLAVE MODBUS TEST.vlp

Link to comment
Share on other sites

  • MVP 2023

Thank you for posting your code.

There are many example projects that install with VisiLogic that will be helpful to you.  Look at Help->Examples to see what's there.

1.  In the Master you are continually calling the Modbus commands, which is like beating a kid with a stick to do the dishes.  Every time he goes to pick up the brush you whack him with the stick again and knock it out of his hands.  Use a positive transition and check the busy bit before calling the command, which will trigger it only once.  

2.  Command 5 (Force Coil) is exactly that; force the bit to a given state.  The bit in the Slave doesn't turn itself off again unless you write logic to make it so.

3.  Using SB1 (Always 1) when turning a bit on remotely and SB0 (Always 0) is more clear when you're trying to drive the bit to a known state. 

4.  There's no logic in the Slave to actually control O5.  I added logic to drive the bit and to act on the bits from the Master to control the output and then turn themselves off after a short time.

You've got to truly think like the PLC - it will only do what you tell it.  I followed your lead with the separate ON and OFF bits in the attached files, but a better solution is to modify one bit in the Master and send that when either button is pressed.  I'll leave this to you as an exercise.  

Your baud rate is pretty high, too, at 115200.  I'd dial it down to 19200 on both sides.

Load these programs into your PLCs and let us know what happens.

Joe T.

 

SLAVEMODBUSTEST JT.vlp MASTERMODBUSTEST JT.vlp

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