Hello Guest it is November 22, 2019, 02:07:37 AM

Author Topic: How to Address Modbus Outputs if you have more than 20  (Read 14840 times)

0 Members and 1 Guest are viewing this topic.

How to Address Modbus Outputs if you have more than 20
« on: April 19, 2014, 09:58:25 AM »
Hi everyone, we are building a machine that needs 50 discrete outputs. We are planning to daisy chain 7 of Peter Homann's ModIO boards together. I have been able to use a brain to assign Mach3 Outputs to the ModIO output holding registers. So far so good.

The problem is that I can only find 20 outputs within Mach3. So I can set the first 20 outputs using brains, but I don't know how to address outputs 21-50.

My idea was to use custom M codes which would map to VB scripts as in this post: http://www.machsupport.com/forum/index.php?topic=15179.0.

That will work great for the first 20, but anyone have any ideas how to set the rest?

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: How to Address Modbus Outputs if you have more than 20
« Reply #1 on: April 19, 2014, 12:47:29 PM »
Hi shangJie

If I understand your requirement correctly, I *think* you may be going about this in an overly complicated way. If it were me I'd be looking at something like an Arduino mega and have Mach simply send the number of the colour you want across modbus.

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: How to Address Modbus Outputs if you have more than 20
« Reply #2 on: April 23, 2014, 11:51:44 AM »
guess not then...
Re: How to Address Modbus Outputs if you have more than 20
« Reply #3 on: April 28, 2014, 10:10:11 AM »
Hi stirling,

Sorry to get back late here! Thanks so much for your recommendation. I hadn't heard of that board. Looks like something I need to check out. Obviously from my questions a lot of this stuff is new to me. Really appreciate the help.

We had already purchased several ModIO boards when I made the previous post, so we will need to use the ModIO to make it work on this machine. Got a suggestion from Peter Homann to set UserLEDs in a VBscript and then to use a brain to translate these UserLEDs into output signals on the ModIO. There are a whole lot more UserLED signals available than there are Mach3 Outputs. This seems to be working beautifully. We were able to get three boards up and receiving commands from VBscript tonight.

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: How to Address Modbus Outputs if you have more than 20
« Reply #4 on: April 28, 2014, 11:08:40 AM »
Hi shangJie

Thanks for getting back. Good you're getting it sorted.

Just for completeness - this would have been the detail of my suggestion. The Arduino Mega has 54 outputs and can be programmed with open source software to be a MODBUS slave.

You could then send the number of the output you wanted activating via MODBUS using a single register and the GCode S word (normally for spindle speed but it's just a number) so no VB macros needed. Then your Brain would be ONE rung like:

CmdSpindleRpm ->NOP -> MODBUS register

Anyway - you're up and going so no worries

Ian
Re: How to Address Modbus Outputs if you have more than 20
« Reply #5 on: April 28, 2014, 09:23:05 PM »
Hi Ian,

Thanks so much for your detailed response and ideas. We are hoping to build several more machines in the future, so the Arduino Mega will be on our list of potential candidates as we evaluate machine #2. Considering that for 50 outputs we need 100 different vbscripts (one to turn on, one to turn off for each output) it would be nice to use just an S word. Perhaps Mach 4 will support passing arguments to VB macros?

Am I correct in understanding that if we want to use the Arduino Mega I would need to learn a bit of C programming?

One thing that has been really nice about using the ModIO is the great customer support that Peter Homann provides.

Thanks so much,
Sam

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: How to Address Modbus Outputs if you have more than 20
« Reply #6 on: April 29, 2014, 03:54:05 AM »
No need to wait for Mach4, Mach3 macros take parameters.

Yes - an understanding of C would certainly help.

Cheers

Ian
Re: How to Address Modbus Outputs if you have more than 20
« Reply #7 on: April 29, 2014, 06:20:33 AM »
You are blowing my mind! Thank you so much! This could save me lots of time.

I thought from this post in 2010 that you had to put your parameters in a filename and then make a bunch of different files: http://www.machsupport.com/forum/index.php/topic,15179.0.html

Is there a thread out there that discusses how to pass parameters through Gcode?

But I'm getting off the topic of Modbus. Feel free to censor this thread if need be!

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: How to Address Modbus Outputs if you have more than 20
« Reply #8 on: April 29, 2014, 08:08:48 AM »
You are blowing my mind! Thank you so much! This could save me lots of time.

I thought from this post in 2010 that you had to put your parameters in a filename and then make a bunch of different files: http://www.machsupport.com/forum/index.php/topic,15179.0.html

well it's a way - no doubt about that...  ::)

Is there a thread out there that discusses how to pass parameters through Gcode?
I think maybe you should have a read of the various programming docs here http://www.machsupport.com/help-learning/product-manuals

But parameters are pretty straightforward. You can have up to 3, namely P, Q and R. e.g. M1000 P7 will pass 7 into the macro. Then you retrieve them in the macro with the functions param1(), param2() and param3() so in this example (P) you'd retrieve it with param1().

Offline poppabear

*
  • *
  •  2,233 2,233
  • Briceville, TN, USA
    • View Profile
    • S S Systems, LLC
Re: How to Address Modbus Outputs if you have more than 20
« Reply #9 on: May 01, 2014, 07:54:09 AM »
Just as a side note:

Another option would be to build Integer numbers 16 bit, that each bit represents and output.
If using Peters Board(s) those numbers would be output registers (one per board).
If using Arduino or a PLC for that matter you could use bit shifting plus "AND" masking (also known as Bit of Word in PLC land).
to do what you want.

Scott
Commercial Mach3 & Mach 4, Design/Build/Retrofit CNC and Industrial machines.
http://www.ss-systems-llc.com/