Hello Guest it is April 23, 2024, 06:08:49 PM

Author Topic: Mach4 Modbus with arduino UNO  (Read 5111 times)

0 Members and 1 Guest are viewing this topic.

Mach4 Modbus with arduino UNO
« on: May 23, 2019, 04:49:29 PM »
Hello! im trying to find some info about modbus in mach4.. im trying to use an old Waterjet machine.

What i got is Waterjet > Mach 4 > Arduinos > Drivers > Step Motor.

So far, the waterjet is kinda working. The mach4 and the arduino are connected but i cant do things in mach and edit the registers... the other components are working "just fine".

Can you guys help me to get this working :c ?

An issue i have is that in Output signals and input signals does not appear my registers. What i am doing wrong?
Re: Mach4 Modbus with arduino UNO
« Reply #1 on: May 24, 2019, 03:37:19 AM »
Hi,
not quite sure what you are trying to achieve but Modbus cannot be used to control axis motors in realtime.

The correct way to control your machine is:

Mach4>>external motion controller (like an ESS or UC300 or Hicon)>>breakout board (if required by your motion controller)>>
Step/Dir servo or stepper drivers.

When you use the Mach Modbus plugin it will create registers, it is the 'owner' of the registers. If you want to access them
for anywhere in Mach you can using:

value, rc = mcRegGetValue(
      number hReg)

and

rc = mc.mcRegSetValue(
      number hReg,
      number value)

For instance if you wish to set a Mobus register to the same as a Mach output, (Machs outputs are owned by Machs core):

local hsig=mc.mcSignalGetHandle(inst,mc.OSIG_OUTPUT12)
local DesiredVariable=mc.mcSignalGetState(hsig)
local hreg=mc.mcRegGetHandle(inst,"Modbus0/YourVariableName")
mc.mcRegSetValue(hreg,DesiredVariable)

and so on.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Mach4 Modbus with arduino UNO
« Reply #2 on: May 24, 2019, 10:32:24 AM »
Hi,

What i was trying to do is using an arduino (In fact, 3 arduinos connected by ethernet) as a external motion controller. What you are saying is that i can not use it for that porpouse.

Im looking the Ethernet SmoothStepper (B-ESS), using that and its plugin im going to be able to control my drivers?

The reason im doing all of this is because i didnt know how to connect my Mach4 to my drivers.
Re: Mach4 Modbus with arduino UNO
« Reply #3 on: May 24, 2019, 11:28:00 AM »
Hi,
you could use Arduinos to connect Mach4 to your drivers but the effort involved is huge.

Mach4 is a trajectory planner. It produces streams of numbers that describe the P(osition) and V(elocity) over
T(ime) in one millisecond slices. The motion controller takes that numerical data and converts that into pulse streams
for the drivers.

The external motion controllers I've mentioned have either microcontrollers, an FPGA or DSP chips on board or sometimes all
three. The combination is very much more powerful than an Arduino.

You could replicate what they have done but it would be thousands of hours worth of programming to write both the plugin
that lives in Mach4 to adapt it to your controller and also the software for the Arduinos themselves. Remember that the Arduinos
will be required to handle all the realtime functions like homing, probing, limits, THC, lathe threading......etc autonomously.
Making your own motion controller is a HUGE undertaking.

Using Arduinos as a Modbus node is entirely doable. The node could control a spindle or maybe a tool changer, in fact that
is the ideal application for the Modbus protocol.

What Modbus cannot do is transmit simultaneously pulse streams from Mach to your drivers. One is that Mach does not
produce pulse streams but rather PVT data. Two is that Modbus cannot transmit data to multiple devices simultaneously,
or in less than a few micro seconds.

Quote
Im looking the Ethernet SmoothStepper (B-ESS), using that and its plugin im going to be able to control my drivers?

The reason im doing all of this is because i didnt know how to connect my Mach4 to my drivers.

There are a number of motion controllers that you might consider, other than making your own out of Arduinos,
including the Darwin Parallel port. The Darwin Parallel Port ($25 license fee applies) is a software driver that lives on your PC
within the kernel and produces pulse streams for the drivers out of a DB25 parallel port plug. Like the Mach3 parallel port
that it resembles it to must run on a 32 bit Windows OS PC of Windows 7 or earlier. Also like the Mach3 parallel port driver
it has the same limitations like competing software running on the PC causing stuttering and stalling of Mach. Additionally
the Darwin parallel port does not do certain realtime functions like THC and lathe threading. Art Fennerty, who wrote
Darwin has long since stated the Darwin will NEVER have those advanced realtime functions.

Mcah4 was always intended to be complemented by an external hardware motion controller. There are five US and European
made controllers ranging from about $125 to about $600. Galil also do a Mach4 compatible controller but expect to pay over $2000
for a three axis controller.

If you are looking at cheap Chinese made controllers there are none that work with Mach4. There is one company who claim
to have a Mach4 compatible controller, XHC, but it doesn't work.......avoid like the plague.

At the current time the Ethernet SmoothStepper ($190) is the stand-out controller for Mach4 in the 'value for money segment'
of the market. It has recently acquired all the realtime functionality including Backlash Comp, single point Lathe Threading,
realtime THC, spindle PID etc. It has matched and exceeded the Hicon Integra ($600 from Vital Systems) in realtime
functionality and leaves all its competing controllers in its own price bracket like the UC300 and 57CNC in the dust
in terms of realtime functionality.

Mach4 is very good software but to get the most from it really requires an external motion controller like I have described.
Thus Mach4, an ESS and couple of cheapo bi-directional BoBs will set you back about $450-$600.
Mach3 is $175 and you can use a number of motion controllers from Mach3's parallel port driver for free and a number
of cheap, if you tolerate Chinese rubbish, controllers from $50 upwards.

Craig

« Last Edit: May 24, 2019, 11:40:29 AM by joeaverage »
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Mach4 Modbus with arduino UNO
« Reply #4 on: May 24, 2019, 12:11:43 PM »
Well, you are being very helpful.


I´ll use Mach4 because that´s the license i have at this moment.

Okay, the arduinos are out of the picture.
I researched some info and actually download the plugin so i can understand a lot more what you are talking about. For what i understand right now, the ESS will be able to control my axis (X1,X2 and Y step motors, and Z DC motor), my limits switches and E-Stop. The part i do not understand is why i will need a BoB.

The way i´m going to work this will be:

Mach4 > ESS > Drivers > Step motors
                    > Relay > DC Motor (This is because the motor is 24Vdc)

My drivers need Step, Direction and the X1 and X2 drivers need Gate (I don´t know why)
Re: Mach4 Modbus with arduino UNO
« Reply #5 on: May 24, 2019, 01:07:32 PM »
Hi,

Quote
The part i do not understand is why i will need a BoB.

A BoB, or breakout board is not absolutely essential. The main device on the ESS board is the FPGA and is a 3.3V device.
You can hook direct to it but all your control circuitry but would have to be able to work with 3.3V TTL logic. If one
driver feeds back anything more than 3.3V the FPGA blows up.

The main point of having a, or several BoBs, is to provide isolation between the ESS and the real world of drivers and limit switches
and a safe and convenient means to attach the wires. The BoB's themselves don't add any logic or other capability.

The C10 from CNC4PC is a cheap ($23) bi-directional board. You would need one at least for your machine. One BoB would
provide 12 outputs and five inputs. If you want more you could add another BoB which would give you (assuming you set the
bi-directional capacity of the second BoB to 'input') 18 inputs and 16 outputs. That should be plenty.

Note that the C10's are pretty simple. They don't have opto-isolators or relays or PWM to analogue circuits. If you need or
want some of those you would have to make them yourself and add them to the BoB's.

https://www.cnc4pc.com/c10-bi-directional-parallel-port-interface-card.html

I use a pair of Homann Designs BoB's, very similar to the C10's but Aussie made.

https://www.homanndesigns.com/index.php?main_page=product_info&cPath=54_22&products_id=59&zenid=f5jiqild0t71ocv07ujtl80r43

There are more sophisticated BoB's that have all that extra circuitry built in, at greater cost. Also you are then required to
accept the BoB manufacturers solution as to the correct balance of inputs/outputs and the circuitry associated with each.

A good example is the MB3 of CNCRoom, it is specifically for the ESS, it has all three ports of the ESS developed with a balance
of opto-isolated inputs/outputs, differential and single ended inputs/outputs, relays and PWM circuits. Cost $180.

https://www.cncroom.com/interface-cards/mb3?zenid=bjg2fff5vgaekcvvaquepcint7

The ESS is a good choice for an external controller but it does really require a BoB or you risk damaging the ESS.

The PMDX-424 is another choice, it has two ports worth of IO and has a built-in power supply and does not require
a BoB. It is a highly practical solution of very good quality and support/backup. It does not have all the realtime
functionality of the ESS however, things like spindle PID and THC for instance, but does support lathe threading.

https://www.pmdx.com/PMDX-424

If you are scanning around for external controllers, what they support and what they require regarding BoBs:

https://warp9td.com/
https://www.cncdrive.com/UC300ETH.html
https://www.poscope.com/product/pokeys57cnc/
https://www.pmdx.com/SmartBOB-compare
http://www.vitalsystem.com/portal/motion/hicon/hicon_integra/hicon_integra.php

The CSMIO probably belongs on this list but is so pricey and its Mach4 plugin is that buggy that I hesitate to recommend it.
Likewise the XHC product, it doesn't work at all well.

If you have heaps of money and want true industrial quality then consider

http://www.galilmc.com/motion-controllers/multi-axis/dmc-40x0
starts at $2000 for a three axis controller.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Mach4 Modbus with arduino UNO
« Reply #6 on: May 24, 2019, 01:24:49 PM »
Okay, i do understand more now! Enough i think.

Now i´m going to get the ESS and the BoB C25. Because i´m not going to need the ribbons cables. The workplace is kinda small. The part about the 3.3V and the 5V, is what confuses me... According to the product details of the ESS, all pins are rated for 0V to 5V... I assume that what you are saying is more accurate. The drivers I´m working with have isolators so the BoB is not essential right?
Re: Mach4 Modbus with arduino UNO
« Reply #7 on: May 24, 2019, 02:46:14 PM »
Hi,

Quote
The drivers I´m working with have isolators so the BoB is not essential right?

No, a Bob is not essential but one small slip and you will blow the ESS. Is that what you want?
The C25 is like having two C10's. Its a perfectly acceptable solution. The C10 is bi-directional so you can assign
the second C10 to use pins 2-9 as inputs OR outputs. Note the C25 has no optos or relays etc, but then neither
does the C10. The only thing that some users have found is that the LED and 220R current limit resistor across each
of the C25 inputs have dragged the inputs low unintentionally and some users have removed the 220R resistor or LED or
both to prevent them from loading the input.

Quote
The part about the 3.3V and the 5V, is what confuses me... According to the product details of the ESS, all pins are rated for 0V to 5V

No, you are correct, all IO is buffered through 5V TTL despite the FPGA being 3.3V

I work in the electronics field and get nervous when I encounter what amounts to unprotected inputs and outputs like
those on the ESS, one small slip on my part with a multimeter probe or oscilloscope probe can damage the device,
people bring me stuff to fix...not to break!

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Mach4 Modbus with arduino UNO
« Reply #8 on: May 24, 2019, 03:27:18 PM »
people bring me stuff to fix...not to break!

Im going to use that phrase a lot.

No, a Bob is not essential but one small slip and you will blow the ESS. Is that what you want?
The C25 is like having two C10's. Its a perfectly acceptable solution. The C10 is bi-directional so you can assign
the second C10 to use pins 2-9 as inputs OR outputs. Note the C25 has no optos or relays etc, but then neither
does the C10. The only thing that some users have found is that the LED and 220R current limit resistor across each
of the C25 inputs have dragged the inputs low unintentionally and some users have removed the 220R resistor or LED or
both to prevent them from loading the input.

Thank you for the input, i will have it in mind.
No, you are correct, all IO is buffered through 5V TTL despite the FPGA being 3.3V

I work in the electronics field and get nervous when I encounter what amounts to unprotected inputs and outputs like
those on the ESS, one small slip on my part with a multimeter probe or oscilloscope probe can damage the device,
people bring me stuff to fix...not to break!

That´s one reason i´m going to use a BoB with my ESS.

Well, for now i do not think i have more doubts... when i have my ESS and BoB running i´ll update about it.

Thanks Craig


Re: Mach4 Modbus with arduino UNO
« Reply #9 on: May 24, 2019, 04:36:05 PM »
Hi,
your welcome.

Mach4 and the ESS is going to blow your mind.....once you realize the potential you'll have machine designs and
control strategies for every situation!

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'