Hello Guest it is June 17, 2019, 03:38:48 PM

Author Topic: MACH4 - Modbus  (Read 49595 times)

0 Members and 1 Guest are viewing this topic.

Offline smurph

*
  • *
  •  1,094 1,094
  • "That there... that's an RV."
    • View Profile
Re: MACH4 - Modbus
« Reply #30 on: May 09, 2014, 03:44:04 PM »
Wow...  I have Win7-64 and I have no issue.  It must be something on your machine.  Modbus is not doing anything special with TCP.  It is just a connection like any TCP app would make.  Good luck figuring that one out!

For a bit more explanation:

A "connection" in the plugin is a connection to a device.  So you would have a connection to each PLC or VFD.  Each connection can use TCP or serial but not both.

Then, for each connection, you can have up to 100 functions defined.  The functions require a starting register.  The functions that read/rite multiple register all for a count to be added as well.  When these functions are created, they create Mach registers or I/O, depending on the type of the modbus function.  Theses are modbus resources.  You must name these.  The names will show in the Mach input and output signals mapping for I/O or, for registers, be available for the script environment.

The RS485 check box currently does nothing in the plugin that you have.  I have tied it in for the next update.

Steve

Offline simpson36

*
  •  1,374 1,374
    • View Profile
Re: MACH4 - Modbus
« Reply #31 on: May 09, 2014, 07:11:26 PM »
Wow...  I have Win7-64 and I have no issue.  It must be something on your machine.  Modbus is not doing anything special with TCP.  It is just a connection like any TCP app would make.  Good luck figuring that one out!

Ready for this?  Run as Administrator and it started working on Win7 Pro 64 . . . go figure.

Edit: working to my device, that is. I have not revisited the sim on this machine yet.

Edit #2: Sim works also . . .

Quote
For a bit more explanation:

A "connection" in the plugin is a connection to a device.  So you would have a connection to each PLC or VFD.  Each connection can use TCP or serial but not both.

Then, for each connection, you can have up to 100 functions defined.  The functions require a starting register.  The functions that read/rite multiple register all for a count to be added as well.  When these functions are created, they create Mach registers or I/O, depending on the type of the modbus function.  Theses are modbus resources.  You must name these.  The names will show in the Mach input and output signals mapping for I/O or, for registers, be available for the script environment.

The RS485 check box currently does nothing in the plugin that you have.  I have tied it in for the next update.

Thanks, I figured most of that stuff out by poking around. I also discovered that you cannot use registers to toggle binary I/O. I used the sim for that because my code only uses 'holders' at this point.

Also I have an Arduino DUE  talking to MACH4 to write and read back a single holding register I/O. I'm sure the reason the DUE is working is because the new MEGA board arrived today . .  ::)

I'll have to clean up the code for the Arduino DUE board (about 5x faster than the previous MEGA and cheaper to boot.), make an RTU and TCP version and add coils and so on, but I think I'm good to go for now.  I have all of these posts printed out and in my 'manual' for reference. I will add to that and post anything particularly interesting. Looking forward to seeing what MACH4 has to offer to my applications.


Oh well, a huge THANK YOU to EVERYONE who contributed to getting me out of the dead calm.  :D
« Last Edit: May 09, 2014, 07:16:07 PM by simpson36 »

Offline simpson36

*
  •  1,374 1,374
    • View Profile
Re: MACH4 - Modbus
« Reply #32 on: May 10, 2014, 08:54:02 AM »
Update and one question.

Update:

I've added coils and have the faster DUE board taking to MACH4 thru TCP reading and writing coils and 'holders'. All functions are working except 16 and I *think* I know what the problem is there. Buttons on screen are connected to coils and the processor is triggering inputs by sending coils. DRO's are displaying register data generated by the processor board and so on.

Observations:

MACH4 locks up frequently when closing the plug-in config screen. Usually when something 'illegal' is entered into the config.

MACH4 sometimes leaves a process running and will not start again until the process is killed with the task manager.

Only one time a plug-in config change wiped out the config. All that was left was the 'connection'. I found the backups and it was a quick fix. Just FYI

Have not tried scripting to/from Modbus yet and I'm out of time for this round.

Question:

How does one write to a single register other than #1? I cannot find a way to do that.

It seems there should be a way to create a function that write only 'holding register #4.

Thanks!
Re: MACH4 - Modbus
« Reply #33 on: May 10, 2014, 10:20:40 AM »
I've noticed using the simulation program that it only updates in real time for the first 16 outputs, if I leave the I/O coil Outputs screen and then come back to it then the outputs are correct, just wont scan for anything above 16, so not sure if that is a Mach4 issue or the simulation program.
Re: MACH4 - Modbus
« Reply #34 on: May 10, 2014, 10:47:00 AM »
The other issue I find is that I can only add 0 thru 31 outputs (mbo 0 thru 31)
on adding and using mbo32 it turns on address 2 in the simulation modbus Coil outputs
Nothing else can be added above 32 outputs (modbus configure limits me to 32 working outputs)

Offline simpson36

*
  •  1,374 1,374
    • View Profile
Re: MACH4 - Modbus
« Reply #35 on: May 12, 2014, 08:20:01 AM »
Comments:

1) config does not keep input/register selection if done with other changes. Must go back in afterward and set just the input/reg selection separately.

2) No convenient way found to stream data TO Modbus registers using the new screen editor.
    i.e. cannot set up slider with data streaming going to a Modbus register
        cannot set up a DRO with data echo to a Modbus register

3) no way found to write a selected single register - defaults to reg1 and not configurable - essentially useless

4) on Startup MACH checks Modbus function before screens are up. If there is a Modbus problem - Mach4 does not start - no message.

5) Mach4 frequently locks up exiting Modbus config screen. -or-
      Mach4 continues to run, but Modbus Diag and Reg Diag inoperative.
      Once this happens, MACHG4 GUI process must be killed with Task Manager before MACH4 can start up.

Offline smurph

*
  • *
  •  1,094 1,094
  • "That there... that's an RV."
    • View Profile
Re: MACH4 - Modbus
« Reply #36 on: May 12, 2014, 12:40:40 PM »
1)  What config?  Modbus or Mach?
2)  Use the PLC script and scr.* API.
3)  I'm not getting this one.  Can you explain what you are wanting to do?
4)  Can you provide and example?  With say the Mod_RSSim modbus simulator?  I can set up connections to the simulator, not run the simulator (like the PLC is off) and it works fine.  
5)  I have never seen this!  I will try and find it.

BTW, some of the bug stuff needs to be posted in the bugs thread.  That way we can track it.

Steve

Offline simpson36

*
  •  1,374 1,374
    • View Profile
Re: MACH4 - Modbus
« Reply #37 on: May 12, 2014, 07:08:38 PM »
1)  What config?  Modbus or Mach?
Modbus . . increase regs count, enter data ; type, name, descriptions, exit.   Close MACH4, Reopen MACH4, go to Modbus Config for the function you kust edited and all types have defaulted to input. Change them to registers again, exit, and this time they stick.

Quote
2)  Use the PLC script and scr.* API


OK, will do. Note I said no CONVINIENET way. Would be nice to have a third data rounting check box to stream data to a Modbus reg.  . . . . I'm just being lazy 

Quote
3)  I'm not getting [selected single register ] this one.  Can you explain what you are wanting to do?

Want to Write a single register OTHER than #1. No way to do it. You mentioned earlier about putting addresses into the config correctly (i.e. 1 and not 40001), but I have  not found any place to enter addresses at all.

Quote
4)  Can you provide and example?  With say the Mod_RSSim modbus simulator?  I can set up connections to the simulator, not run the simulator (like the PLC is off) and it works fine.
MACH4 appears to test the Modbus before startup (before screen loading anyway). I can see the polling MACH4 is doing. If the Modbus is healthy, the test takes a few seconds and MACH4 starts. If the Modbus is OFF (as in your example) MACH4 logically would not be able to test, so it just starts.  However, if Modbus is Active but is sick or if the user just configures it incorrectly, MACH hangs trying to get a good response from Modbus. The only way to recover (that I found) was to revert to an earlier backup .ini

My suggestion  is that if Modbus is active, have MACH4 start and then test the Modbus. If there is a problem, MACH4 should provide and error message to theuser and ignore Modbus so that the user aq) knows what the problem is and B) can re-configure to correct an error without knowing how to retrieve backup .ini and so on.

I think it would be beneficial to both myself and Artsoft from a SUPPORT standpoint. People will be calling in sayng MACH4 won't start and there will be no indication why.

Quote
5)  I have never seen this!  I will try and find it.

I suspect there are not a lot of folks working with the Modbus at this point . .  or ever for that matter.

#3 is a problem. The rest are minor inconveniences and #5 is a potential support problem so those are just FYI.

Note that these issues are happening on my development system which MACH4 may not be happy with for some reason, so some of this stuff may be local to my desk . I'm just recording it via post when I encounter it.

Quote
BTW, some of the bug stuff needs to be posted in the bugs thread.  That way we can track it.

No problem. In fact, I just echoed some stuff to the 'new features' thread from here. I'm just not sure what is a bug and what is operator error at this point. If it turns out the problem is not my own ignorance, then certainly I'll repost in the bug section so that it will get collected.

Thanks very much for this response.. I have all Modbus functions working now via TCP (except item #3 here (single reg write), which works, but is stuck at reg1).


Steve
[/quote]

Offline smurph

*
  • *
  •  1,094 1,094
  • "That there... that's an RV."
    • View Profile
Re: MACH4 - Modbus
« Reply #38 on: May 12, 2014, 08:17:37 PM »
Here is a screen shot of where to put the register number.  It is the highlighted text field.  If you need to read multiple consecutive registers, then use a function that reads multiple regs.  Input the starting register in the highlighted field and then enter the number of regs to read in the count field.  The count includes the register defined in the register field.

If you don't need consecutive registers, then do separate single register functions.

Steve

Offline simpson36

*
  •  1,374 1,374
    • View Profile
Re: MACH4 - Modbus
« Reply #39 on: May 13, 2014, 07:16:24 AM »
Here is a screen shot of where to put the register number.  It is the highlighted text field.

Another mystery solved.  8)    I thought this was the 'Modbus address'. i.e. the companion to the 'Slave Address' since there can be multiple Modbus ('connections') and multiple Slaves. It can be confusing that in MACH4 speak, for example 'Functions' are numbered sequentially regardless of which actual Modbus function number is contained in them. I assumed because of the title of the field, that the 'Modbus Address' was the 'connection' number and worked the same. ex.: if you have configured multiple 'connections' of MACH4 Modbus 0 thru 5 and then say the 'connections' Modbus2 and Modbus4 pointed to the same physical device which was physical Device at Modbus Address 1, then the field labeled Modbus Address would be used to point to the correct device. This seems to be how the Slave Address works.

In any case, it never occurred to me that 'Modbus address' was the Register Number.

SUGGESTION;

This was my bad and when the documentation catches up, it might be clarified. However, entering the Register Number in field labeled Modbus Address is not intuitive and might be another support hotspot.

Since MACH4 uses Register NUMBERS instead of ADDRESSES, it might be a good idea to make MACH4 Modbus labeling consistent with that new method and also to highlight the change for upgraders from MACH3 to MACH4. I also think it would be preferable to use a term other than 'Function' because it means something different in the Modbus and MACH4 vernaculars. 'Process' or 'Group' or 'Action' pretty much anything other than 'Function' would be better. Perhaps instead of 'modbus0, modbus1, etc', MACH4 could use the term 'Device0, Device1' or again, any term that does not create a dual definition. MACH4 Modbus vs the Modbus spec. MACH4 Function vs Modbus Function and so on. That's just a suggestion. I'm thrilled that the feature is there and that I just did not know how to get to it.

FWIW, there was a span of about 15 years where I was responsible for supporting CAD software and if you throw out software bugs, then confusing terminology was the primary driver of support calls. Don't even mention Adobe . . .  software written by counter-intelligence agents.   ::)  

 
Quote
If you need to read multiple consecutive registers, then use a function that reads multiple regs.  Input the starting register in the highlighted field and then enter the number of regs to read in the count field.  The count includes the register defined in the register field.


BUG?

Write multiple register is the last function that I got working with MACH4 on my end. Your last post prompted me to tinker with different starting register numbers in the Write Multi Reg function and it uncovered an unusual behavior. The attacxhed screen shot shows that a Mach4 Modbus Function has been created to write two Holding Regs starting with #6. Both are 'Type' Register, yet only one shows up in the MACH reg Diagnostic window. I have not played with it enough to know if this is random or if it is limited to skipping the first reg in the sequence.

BUG or SFU?  (Simpson Foul UP).    If it turns out to be a bug, then I'll post it over in the appropriate section.

EDIT: hold off on this one . . it may be related to using duplicate reg names. MACH4 just dumped the whole Function on its own    Went back into MACH4 and the Function is just gone.  ???

I'll mess with this some more. Lookig more like an SFU at this point.


Thanks again for responding to my questions. Now that the 'mechanics' are all sorted out, I will move on to play with scripting.

« Last Edit: May 13, 2014, 07:25:23 AM by simpson36 »