Jump to content

Modbus TCP sequencing Help


Recommended Posts

Morning group,

 

I am really new to Unitronics (I am a "brand x" who won't be mentioned guy)

I have followed along on the Modbus and Ethernet vides on the website and have successfully gotten the Modbus reads and writes used in the examples to execute.

Where I am having problems is how to get this to happen automatically within a program.

I have 2 V1040's on as client and one as server.

(I have the two programs attached)

1st net is SB2, PLC Name, TCP/IP INIT, TCP?IP SOCK INIT (Socket 3) then the Modbus IP config function.

I am using SB 13 as a trigger to open the socket of the server

The first step I am reading in 2 floats from the server (I did figure out how to disassemble and reassemble the floats) in step one.

In step two I am reading one integer and writing on integer.

Is there a thread or a tutorial that can guide me? 

The version I am using is 9.8.91 (This is the version of this specific customer and he is not receptive to changing to the newest version)

Thanks,

Jeff K

 

ModbusQuickTest.vlp ModbusQuickTestSlave.vlp

Link to comment
Share on other sites

  • MVP 2023

The way I typically do it when I want to perform two separate functions at regular intervals is to use a self-resetting timer and toggle a bit on each timer pulse. Then I will use a positive transition of the bit for the first operation and a negative transition for the second. If the timing is acceptable, you can use SB 3 or SB 7 instead of a self-resetting timer and toggle bit.

image.png.188602503cb6c402da47e1b715fab404.png

By the way, why are you using an X Bit? Do you understand how a PLC scan works? Your technique for connecting the socket and performing the MODBUS reads/writes is poor and likely to fail. I recommend reviewing the example files that came with your VisiLogic installation for proper technique.

Link to comment
Share on other sites

Hi flex,

Thanks for the advice. The Xbits are just markers for now until I get this work. The previous programmer didn't do such a good job with assignments of operands. The addition of the Modbus component is a part of trying to bit off smaller chunks at a time as I rewrite the existing program into something more user friendly.  The final program will not have X bits, Integers, well, anything X.

 

Thanks again

Link to comment
Share on other sites

  • MVP 2023

Hi Jeff, I don't do TCP modbus, only 485 RTU.  Although probably not what you need, keep this in mind....     My system for calls is different, as I have myriad devices that can need removal/addition on the loop.  I run a self-resetting counter, based on  SB15.  Once it reaches the specified end count, it resets to 0 and starts again.  Modbus calls are triggered by the rising edge of the count = whatever device I need to call to maintain enough info to run things correctly.  My devices mostly involve HVAC and delays on some reads are ok 30-40 seconds apart.  Others I update by inserting them into the count system at the appropriate shorter interval so that during the entire count sequence they might be read a few times.  Whatever the count is at sets the relevant call parameters in the same block.

The beauty of this system is that it is simple, it is observable,  does not use timers or interlinked multiples  thereof, and allows easy removal insertion of extra devices etc by adjustment of appropriate count values and insertion/removal of an =.   The count can be tweaked appropriately for length of read, to enable the quickest cycle through everything needed, although this should not be an issue for you on TCP.  Ages ago I did try an "automatic adjuster" of the basic count values when inserting/deleting/tweaking items, but I decided that the manual changes method was far easier and better as there is relatively so little to adjust.  (I actually now use a simple excel sheet to do this for me, to avoid errors through not enough coffee.)  After proving, the MIs involved get set as power up values.

cheers, Aus

Link to comment
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
×
×
  • Create New...

Important Information

This site uses cookies. By clicking I accept, you agree to their use.