Hello Guest it is April 23, 2024, 07:27:37 AM

Author Topic: Modbus plugin from VB Script? Interfacing TWO modbus devices?  (Read 7840 times)

0 Members and 1 Guest are viewing this topic.


 I'm trying to figure out the best way to do things...

 I have a spindle control (VFD) with a Modbus interface, and a PLC for controlling the tool changer, also with modbus.  Is there any way to talk to them both?  Note that one is RS-232 only (no RS485).  It is simple enough to have two serial ports on the PC, but is there any way to get Mach to use them?  What is the "Port/Address" entry in the modbus plugin spreadsheet?  Is this a Com port setting?  If so, how can I set the baud rate separately for each port?

 When writing new M6 code, is there a way to directly access Modbus plugin I/Os from the VB Script?  Does one need to use a brain to stuff values into DRO's, and then read them from the VB script? 

 Is there any documentation for this stuff?  It seems to be all scattered around newsgroups, a wiki, and some very outdated pdf files that don't really get into the modbus stuff... I'm happy to read manuals, I just can seem to find them :'-(

Thanks for any help!

Best Regards,

-Peter

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: Modbus plugin from VB Script? Interfacing TWO modbus devices?
« Reply #1 on: June 12, 2009, 09:26:33 AM »
Peter,

    Here is what I do,  have your PLC talk Modbus to your VFD.
It would depend on what kind of PLC you have.  I.e. if your using ADC stuff, what I do is get an extra serial com module and have the PLC connect to the VFD.
OR, if you VFD can have its 232 configured at the drive, configure it to the "Programming port" and have mach hook to the Port2.

   The most stable I found is, (again using ADC), get an ethernet module to have mach talk to your PLC, then use Port 2 to talk to your VFD.

scott
fun times
Re: Modbus plugin from VB Script? Interfacing TWO modbus devices?
« Reply #2 on: June 12, 2009, 11:03:53 AM »

 So what I'm hearing is that Mach3 cannot use two serial ports.  Shame, but there are work-arounds like you suggest (is there a feature-request place for Mach3, because multiple serial ports is a feature I would want to request  ;D )

 Has anybody tried using a third-party Modbus activex control?  Does VB Script allow persistent variables from one call to the next?  I could use a third-party modbus ActiveX control to do my own talking to the VFD.  I see in the manual that the scripting language supports CreateObject to create the modbus communications object... will the variables I create persist from one call to the next, if I declare them global or something?  Otherwise I'll need to create a new communication object in every M3 and M4 call... not the end of the world, but slower than necessary.  (I've programmed a lot of VB, but never used the scripting version....)

 Thanks for all the help!

Best Regards,

-Peter

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: Modbus plugin from VB Script? Interfacing TWO modbus devices?
« Reply #3 on: June 12, 2009, 05:33:28 PM »
Pete,
     
   depending on what the Vars are you want to keep, if they are numeric, you can put them into Mach3 "Vars", or UserDROs, and use UserLables to store you "strings"..   OR, you could also just create, read and write a "file"
the scripting allows the reading and writing of files also, so it is a cheap way to store and read/write persistant vars.........

BUT, within the "Macro" or VB script itself, the vars in it are local. You would have to do the above to make them persist.

OR:  you could do a C++ plugin and tie it in with your screen/macro........

scott
fun times
Re: Modbus plugin from VB Script? Interfacing TWO modbus devices?
« Reply #4 on: June 12, 2009, 08:03:32 PM »
 
 Thanks Scott, that's what I needed to know.  Since the variable in question is the modbus communications object (activex), I'll just need to recreate it every time the macro is run.  Fortunately, an extra fraction of a second for an M3 or M4 command is not a problem.  I don't think I want to take the time to learn how to do the plugin stuff right now, at least not until I've tried other options first.

 I thought of another solution: I can get a couple cheap RS232 to RS485 converters, and then run both devices off the same bus.  They only cost $6 each, so I ordered a pair just to try.  I'll do the ActiveX thing in the meantime to see how that works.

 Cheers,

-Peter
Re: Modbus plugin from VB Script? Interfacing TWO modbus devices?
« Reply #5 on: June 12, 2009, 11:40:36 PM »
By the way, do you know if it's possible to access Modbus _plugin_ pins from either VB Script or the Ports-and-pins setup?  How does one convert the config number to a port number on the ports-and-pins?  ???

Thanks,

-Peter