VFD control
The Emerson Commander SK works great with the Mesa 7i76 spindle control outputs. Change parameter 16 to VOLT for 0-10v control. You should read through the setup manual and they have an advanced user guide that covers everything you can access through modbus. I spent a couple of days trying to write a modbus driver before deciding I would just stick with the analog control. I do use modbus to pull stats from the drive though.
I have a braking resistor from ebay (300W 40 ohm Wired Braking Resistor) that allows the VFD to stop the motor extremely quickly. I noticed that when the VFD is "inhibited" that the spindle doesn't slow down using the braking resistor, it just cuts all power to the drive and the motor will coast to a stop. I wanted the spindle to slow down as fast as possible when the estop was hit or it was told to stop. The VFD has two "Run" type inputs. Terminal B4 is the Enable input and B5 is the Run terminal. I ended up wiring B4 to a dedicated switch that allows me to "inhibit" or "ready" the drive manually. Linuxcnc controls the B5 Run terminal and the B6 Fwd/Rev terminal.
Physical VFD connections
* T1, T2, T3 are the 0V, 0-10v, 10V hookups for the control from the computer. You hook these to the Mesa 7i76.
* B1 is 0v
* B2 is 24v
* B3 is used for the power drawbar lockout. It outputs high when at 0 rpm. See parameter 35
* B4 is the Enable terminal. This should be hooked permanently to a 24v source. I would just jumper B2 to B4. The only downside is the drive might start when you don't want it to. It shouldn't, because you have to send signals to B5 and B6 but it's not "inhibited", just "ready". I originally had this connected to the same output as B5 which means when linuxcnc sent a spindle off command the drive would be inhibited but an inhibited drive coasts to a stop whereas a drive that remains "ready" but is told to stop uses the injection braking.
With the Mesa 7i76 and it's analog outputs, if you tie B4 and B5 together then if linuxcnc is not running it will be inhibited. The only downside is the pncconf by default makes a config that has the run terminal enabled the whole time the machine is on. I changed it so the spinena pin is set high only when the spindle is commanded on/spinning. I ran the B4 terminal to a physical toggle switch for safety concerns. If the switch is not on, the VFD will not run regardless of what linuxcnc is telling it.
Snippet from custom.hal to only run spindle when it is commanded to run
## This will change the spindle enable so it's not## always trying to run whenever it's on
## Find this line in NAME.hal and replace it with the line two lines below
#net machine-is-enabled => hm2_5i25.0.7i76.0.0.spinena
net spindle-on => hm2_5i25.0.7i76.0.0.spinena
Snippet from NAME.hal to make fwd/rev work with abs hal component
## UPDATE - This needs to be in NAME.hal or abs will complain it's already loaded
## This enables the spindle to go forward and reverse with proper controls
loadrt abs names=abs.spindle_output
addf abs.spindle_output servo-thread
net spindle-vel-cmd => abs.spindle_output.in
net spindle-vel-cmd-abs abs.spindle_output.out => hm2_5i25.0.7i76.0.0.spinout
## Under the spindle section of the NAME.hal file comment out this line
#net spindle-vel-cmd => hm2_5i25.0.7i76.0.0.spinout
* B5 is the Run terminal. You need to set this high for the spindle to even think about running.
* B6 is the fwd/rev terminal. I didn't have to invert the pin in HAL to make it work but I did have to change the hal code so fwd/rev worked with the abs component
* B7 is hooked to the thermistors from the motor and the B1 0V output.
Modbus RTU
To pull stats from the VFD I used a usb to RS-485 converter from amazon and an ethernet cable. Just cut the end off an ethernet cable and then connect the orange and white/brown cables (Pins 2 and 7) to the RS485 converter.
* Emerson uses the following parameters by default
* 19200 baud (parameter 43 controls the baud rate. I set it to 38400 for max speed)
* 1 start bit, 8 bits data, 2 stop bits
* You can test with the Windows CTSoft software Emerson has for setting parameters and running the drive.
In Linuxcnc I used the mb2hal module to poll the VFD for some temperature, load, status statistics. I then display these in a PyVCP panel.
I wanted to write my own hal driver for controlling the VFD but I don't write C code that well and I experienced issues controlling the drive while testing with python modbus control. Enough issues that I was unsure about having rock solid control of the VFD at all times. If you truly want full control of the VFD over a single modbus cable I would recommend using a VFD that is already supported by LinuxCNC and has a hal module.