PDA

View Full Version : Mach3 VFD control via Modbus using brain file



A_Camera
25-08-2016, 02:26 PM
This thread is for those who are interested in trying out Modbus, using only two thin twisted pair wires and Mach3 brains feature. So if you are not interested, save the time and leave now because it can be boring and too long for you.

Most people use 0-10V and inputs of their VFD to control the spindle speed and direction. That simple straight forward solution has been around for ages and widely spread, but has some disadvantages because it demands a good and reliable, very linear 0-10V PWM generator and several wires, all these may be noise sensitive, causing unexpected behavior as well as using up several digital inputs and outputs of the VFD and the BoB. I don't know why so few people are interested in other ways of controlling the VFD, perhaps it is because they think it is too complicated, or don't know better and do as they always done, or as others seem to do. Some of those who try a different approach are trying to find plugins for their VFD and that is not always possible and definitely not necessary, because Mach3 has a ready made function for this, which is fairly easy to adapt to any VFD, but it is pretty badly documented.

With my 40 years of engineering career, mostly in the fields of datacom related and computing business, using digital inputs and outputs and a crappy, unreliable and nonlinear 0-10V DAC felt very strange and stone age, but not knowing better, I thought, this is what most people use, so this MUST be the best way... then I though NO WAY if there is a communication line use THAT... and so like many other, I started to look for plugins for my VFD... realizing that my VFD (Bosch Rexroth EFC 5610) is far from what most amateurs are using, so there is no chance of find anything, I have to make my own, but writing C++ code takes time and I don't have that much of that thing. Then about a week ago I discovered the unknown territory of Mach3 brains and thought that THIS IS IT!

Of course, this ended pretty quick after a day or two in a disappointment because I found some serious limits in the functionality and implementation, so I started thinking that part of my problem can be solved by a macropump macro, which is acceptable if necessary and much faster than I can write a plugin in C++. This was about a week ago, however continued work resulted in finding solutions in Mach3 brain and I have now solved everything I needed to solve and abandoned the macropump use.

A Mach3 brain file is all that is needed to control a VFD and a spindle if only basic functions are needed. Any VFD can be controlled with my solution, using a simple USB - RS485 converter and two wires connected between that and the VFD. Normally a shielded twisted pair wire should be used, but right now I have what I have, which is just a lamp wire, between my PC and the VFD. Of course, that will be replaced with real communication wire later on, but that is not the highest priority now.

Start with wiring and plugging in the RS485 dongle, or connect to RS232 if that is what you want. I can't help with the RS232, I use a simple USB interface, this is the one I bought (http://www.ebay.com/itm/231570466384?_trksid=p2057872.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT). I only know of the VFD I have, so I can't help you with connecting yours, you have to ask the seller or consult your manual or the web. Configure the port in Windows and check that it is recognized and working. I have Windows 10 Pro 64 bit on my computers and the dongle is plug and play, no driver needed. As far as I know, there are dongles which may not work under Windows 10, so that is something you have to check out, but I had no issues with mine.

Once you have it all wired up and working in Windows you have to create a Modbus configuration file. Open your manual and find the relevant information. Note that if you are only interested in basic functions (CW/CCW/Stop/RPM) than you only need Cfg #0 and #1. The rest of my configuration is bonus, which I explain later. This is how my configuration looks like, but you need to alter the addresses to suit your VFD:

19094

When you have your manual in hand you can test each address and command if you click on the "Test ModBus" on the top right of the window. Don't continue unless you manage to control the spindle through the test function. From there you should be able to run the spindle CW and CCW and to stop it as well. Remember that for the spindle to spin you must set or send a frequency as well. Remember also that you need to configure your VFD so that it reacts to commands from the communication line. Normally the default is the control panel, but there should be a setup or a DIP switch or a jumper to change that. Again, this is not something I can help with, only if you are using the Rexroth I have, or the other models which are compatible with it.

The brain view looks like this:

19093

Note again that if you are only interested in basic functions (CW/CCW/Stop/RPM) than you only need what is connected to Cfg #0 and #1, which are the two first lobes, i.e. the ones marked CW, CCW and OFF, plus the one where it says "S-word from Mach3". I have edited in some explanations in red, and those I think are pretty simple to understand. Ask if something is not so clear, I'll be glad to explain. Start up brain editor and create your own file using mine as guidelines. I will not post the brain file itself because this way you'll learn more in my opinion.

Basic functions:

Basic functions are: running CW/CCW and stop plus the spindle RPM. These functions are very easy to implement.

The brain reads OEM LEDs for CW, CCW and Run, and sends a data to Modbus output port according to the commands for these rotation controls. The modbus address for this is defined in Cfg #0.
In my VFD data value 129 is the command for starting the spindle in CW direction, 133 is for starting in CCW direction, and 136 is for stopping the rotation. This command data must be sent to holding register address #32512.

To control the RPM the frequency value must be sent with two decimals in integer format, so 24,000 RPM = 400Hz and the data to be sent will be 40000 to holding register address #32513. In my picture the spindle RPM is set to 16,300 and to get there Mach3 must multiply that with 0.6 and send 27166, corresponding to 271.66 Hz. The decimals are truncated, but that doesn't really matter, the RPM is accurate enough.

Bonus functions:

I will explain the rest of the brain if there is an interest for it, but this starting post is long enough now, so I stop here for the time being, except that the rest demands some modification to Mach3 screens as well and also modification of M3 and M4 macros.

magicniner
25-08-2016, 08:16 PM
Thanks A!
I for one have printed this to hard copy and filed it in my Mach3 workshop folder.
Do continue,
Regards,
Nick

A_Camera
26-08-2016, 08:17 AM
Thanks A!
I for one have printed this to hard copy and filed it in my Mach3 workshop folder.
Do continue,
Regards,
Nick Thank you. I will continue as soon as I can.

I am actually pretty surprised how little interest there is in both Mach3 brains and the use of RS484 Modbus to control and monitor VFD. It is an industry standard and very common there for a reason. It is an extremely reliable way of controlling machines in generally noisy environment, suitable for many purpose, not only controlling VFDs, but it allows easy adding other type of inputs/outputs which have RS485 interface and Modbus protocol. Even in home environment, for hobby use, I think is very suitable and much better than the one wire one input/output type of solution which is widely spread. OK, as discussed elsewhere, like in every other serial communication, there is a delay introduced, but to be honest, the few milliseconds lost because of the serial communication can be ignored in this type of slow machinery. Advantages definitely overweight the disadvantage of that delay. It is pretty cool to be able to make the VFD do all the things with only two thin wires instead of several relays, using up many inputs and outputs and connecting several thicker wires, which still will NEVER allow the same kind of control and monitor as the Modbus allows. The expansion possibilities are large, adding other extra units with additional digital or analog inputs and outputs is pretty simple as well, just hanging these on the same pair of communication line, since each are addressed, so there is no conflict, each unit knows which one is asked and which one supposed to send an answer.

Reading back values like real RPM, frequency, temperature, output voltage, current, torque or whatever else you are interested to read back is impossible unless you use a communication line. OK, one digital output on my VFD is a pulse output, so I think that could be used for some of that, as well as one analog output cold be configured for another of those values, but it would be so much more complicated to read those two and would need two more wires...

Anyway, I will DEFINITELY use Modbus over RS485 as far as that is possible and see no reason not to. Until recently, I thought that the use of Modbus was out of the question for me, unless I write a plugin to Mach3, so I am pretty happy that this assumption was wrong and nothing more than some configuration and creation of brain file is needed. OK, for the additional functions, what I call "Bonus functions", there is a need for modification of Mach3 windows and some simple macro changes, but that is no big deal, anyone can do it with the free software provided by Artsoft.

magicniner
26-08-2016, 08:55 AM
I am actually pretty surprised how little interest there is in both Mach3 brains and the use of RS484 Modbus to control and monitor VFD. It is an industry standard and very common there for a reason.

I suspect many people will shy away from Modbus because the documentation for the cheaper Chinese VFDs is only just adequate to support manual and, if you're lucky 0-10V speed control ;-)

- Nick

m_c
26-08-2016, 04:26 PM
The bigger reason is Modbus is seen as being complicated. Which for somebody non-techy, it is. Get a single setting wrong, and it won't work, or at least not as expected, with no easy way to test why for your average home CNC'r.

Combine that with VFDs and Modbus equipped VFDs traditionally being expensive, meaning basic 0-10V DC speed controllers were far more commonplace, and you can see why 0-10V is the more commonly used method for home CNC. Plus it's easier to diagnose, as you only need a multimeter to narrow down where the problem lies.

Clive S
26-08-2016, 04:53 PM
Well said it is much better with KISS as everybody is not from a techy background

Neale
26-08-2016, 05:30 PM
I'm very interested in this, but then, I am a techy...

It's not because of the start/speed control aspect, as this is pretty straightforward if you have a BOB or motion controller with adequate analogue output. OK, linearity might not be absolutely spot-on but I doubt that for most practical purposes that matters. However, the idea of being able to read back VFD parameters (spindle speed, etc) to display on the PC screen sounds attractive. Personally, I would not have considered this because I had no idea what a Mach3 brain was so would have never gone looking for this kind of information. I've probably missed something obvious, but I don't find the Mach3 documentation leaps out at me. Easy enough to do the basics but you seem to be somewhat on your own if you go just a little off-piste. For example, do a Google search for "mach3 brain" and the best result seems to be a YouTube video. Personally, I would rather have a decent manual in front of me!

But maybe I've just missed some hidden site full of Mach3 docs, so if anyone can tell me where it is... In the meantime, I shall follow this thread with interest.

Clive S
26-08-2016, 05:51 PM
But maybe I've just missed some hidden site full of Mach3 docs, so if anyone can tell me where it is... In the meantime, I shall follow this thread with interest

A bit of info here http://www.machsupport.com/forum/index.php/topic,8211.0.html

Neale
27-08-2016, 11:38 AM
Thanks, Clive - there's a pointer in there that ends up with a few Mach3 tutorial videos which gave some background. However, I also had a hunt around for something about the HY inverters and Modbus, as the HY manual mentions it in passing but gives no specific information on what you can control or monitor. Apparently, HY have used their own very non-standard interpretation of the Modbus standard and although someone has produced a Mach3 plugin which gives access to some of the HY inverter features, I have not yet found the kind of information needed to use with a Mach3 brain.

Still, it has all thrown a bit of light on the "brain" feature, and I'm now wondering if that could be used to, for example, provide a custom Mach3 facility for master/slave homing which my CSMIO-IP/M does not do. Too many distractions from actually getting on and finishing the router...

A_Camera
28-08-2016, 06:42 PM
I suspect many people will shy away from Modbus because the documentation for the cheaper Chinese VFDs is only just adequate to support manual and, if you're lucky 0-10V speed control ;-)

- NickPerhaps you are right. However, many people use other VFDs than the cheapest ones, so in that group there should be some interest. Even most of the cheaper VFDs have Modbus support, but sure, you must have a technical interest or some knowledge to start with it.

A_Camera
28-08-2016, 07:09 PM
I decided to make some changes since I discovered some Brains features which are useful in the design of Brains file. I have also decided to split the file into two parts, one is the basic control and the other is the "bonus features". I think this makes it simpler for others to reuse my idea and adjust the necessary changes.

I have also made a short video which could be used as a simple guide. This video is just the first part. At the end of the video there are three pictures showing the brain file with the basic controls with three Mach3 commands: M3 S3000, M4 S9000 and M5.


https://youtu.be/AFbH6ps0hVY

For best detail, please watch in full screen mode. It is 19 minutes long, so if you just want to see the Brain file views you can jump directly to the last 40 seconds.

A_Camera
28-08-2016, 07:32 PM
I'm very interested in this, but then, I am a techy...

It's not because of the start/speed control aspect, as this is pretty straightforward if you have a BOB or motion controller with adequate analogue output. OK, linearity might not be absolutely spot-on but I doubt that for most practical purposes that matters.

There is one HUGE disadvantage with using 0-10V, at least with the BoB's I have, is that if Mach3 is not fired up and the BoB is getting power then it will output 10V and random states for the digital outputs. This creates a dangerous situation since the spindle can start spinning when your hands are too near. This situation can never happen if you use Modbus.


However, the idea of being able to read back VFD parameters (spindle speed, etc) to display on the PC screen sounds attractive. Personally, I would not have considered this because I had no idea what a Mach3 brain was so would have never gone looking for this kind of information. I've probably missed something obvious, but I don't find the Mach3 documentation leaps out at me. Easy enough to do the basics but you seem to be somewhat on your own if you go just a little off-piste.

I agree, this is another major advantage of using Modbus, and I will cover that in my next video. I am reading parameters like Output voltage, current, torque, power, temperature, real RPM, RPM stable... and there are plenty more, but to read those and have some use for them you also need to modify Mach3 screens used, otherwise you won't be able to see those. I have just started with this, so I am no expert, but used Screen4, which can be downloaded from Mach. I find it pretty buggy, crashes fairly often, so frequent backup of the changes is really important, but it is free, so why complain? In any case, to make modifications to existing screens is pretty simple.


For example, do a Google search for "mach3 brain" and the best result seems to be a YouTube video. Personally, I would rather have a decent manual in front of me!

But maybe I've just missed some hidden site full of Mach3 docs, so if anyone can tell me where it is... In the meantime, I shall follow this thread with interest.

Yes, I would also prefer a decent manual, but that is hardly going to happen now that Mach3 is dead. The Brains territory is even less documented than the rest. I managed to gather quite a bit of documentation spread around on the Internet about Mach3 macro programming, use and parameters, as well as about some other bits and pieces, but very little about Brains, so that is not really like skiing off-piste, more like skiing off-piste uphill. Yes, the best I could find was also Youtube video, but unfortunately not enough to help me, so I made my own. I don't know if I will write some kind of user documentation later on, because it takes quite a lot of time, but at least I will document my workflow which can be use by others to figure out what to do and how to solve their problems.

Neale
28-08-2016, 09:20 PM
There is one HUGE disadvantage with using 0-10V, at least with the BoB's I have, is that if Mach3 is not fired up and the BoB is getting power then it will output 10V and random states for the digital outputs. This creates a dangerous situation since the spindle can start spinning when your hands are too near. This situation can never happen if you use Modbus.

I can't disagree, although in my case I am using a CSMIO-IP/M which is held in e-stop mode by the safety relay until it is explicitly re-enabled. I think that it stays in standby until it starts communicating with Mach3 as well - I'll have to unplug the Ethernet cable while it is running and see what happens!

As I am currently using a Huanyang VFD and given its poor support for Modbus, I'm not going down that path. Still, if it blows up one day and I have to replace it, then I might well look for something that both supports the official Modbus standard and also has a usable manual!

Good luck with this project - I shall follow it with interest.