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. 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:
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:
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.
The main VFD program is contained in the processor's firmware & not normally accessible to the variable frequency drive user. A parameter is a variable associated with the operation of the VFD that can be programmed or adjusted. 5axis BOB, PWM speed control, Mach 3 and a partridge. Discussion in.up recommended by Hytech2k work? Once I get out of the hospital I'll try the setup, thats if you haven't yet. If using VFD, disregard the output labeled PWM on the Chinese BOB. Converter on the front end of the 12-24v input or the back end of the 0-10v Spindle output.
Massive confusion. Lucky you who did not purchase HuanYang VFD because with that it ended up being the most time consuming part of the whole MechMate project. [Obviously not MechMate problem as I chose myself to go with that somewhat nice looking, should-be-ok spindle+VFD and not much research] If I knew, like you do right now, I would have gladly paid 200-300 bucks more for a nicer VFD. Problems are as follows:
1. HuanYang VFD is NOT trully modbus compliat. [get the Mach3 plugin]
2. At least half of the units that leave the factory do not have the 485 interface chip on board. Supposedly its an option and you have to MAKE SURE it's on the invoice when you order. Yey, they saved 2 cents and I'm pulling my hair out.
Luckily, there are tons of us with such problem and the community always finds a way even if it means soldering our own 485 chip [$2 on ebay] onto the VFD where it should be.
I will keep you posted. My local store sent me USB-Serial controller instead of USB-RS485 with adapter. Another 2-3 days of nail-biting before I can go back to experiments.
It's still the most exctiting electro-mechanical project I have ever undertaken. 'Never give up. Never surrender.'
1. HuanYang VFD is NOT trully modbus compliat. [get the Mach3 plugin]
2. At least half of the units that leave the factory do not have the 485 interface chip on board. Supposedly its an option and you have to MAKE SURE it's on the invoice when you order. Yey, they saved 2 cents and I'm pulling my hair out.
Luckily, there are tons of us with such problem and the community always finds a way even if it means soldering our own 485 chip [$2 on ebay] onto the VFD where it should be.
I will keep you posted. My local store sent me USB-Serial controller instead of USB-RS485 with adapter. Another 2-3 days of nail-biting before I can go back to experiments.
It's still the most exctiting electro-mechanical project I have ever undertaken. 'Never give up. Never surrender.'