Setting up the software obviously starts with installing Mach3 and KMotion (with the KMotion Mach3 plugin). Installation procedures for those two programs can be found on their support sites. A third helpful program (if using the Yaskawa V1000 VFD) is DriveWizard Industrial (https://www.yaskawa.com/pycprd/produ...ard-industrial). It helps in saving the default VFD configuration from Shopbot and then modifying the few parameters needed for this modification.
Once KMotion is up and running, there are a four C programs that need to be created and compiled which will be used by the KMotion Mach3 pluggin (see the KMotion Mach3 setup guide). KMotion comes with example C programs which can be modified. I have included the four programs needed for the BT32 conversion.
InitShopbot3Axis.c
This file configures the input and output channels of the KMotion board. In this file, 3 axes channels are configured for the X-axis (ch0), Y-axis (ch1), and Z-axis (ch2). These axes labels refer to the original Shopbot axes with the gantry being the Y-axis, table being the X-axis and of course the spindle on the Z-axis. These channels also correspond to the cable wiring and pinout between the KFlop board and the Shopbot breakout board. In other words, no swapping of the axes has been done at this point.
Towards the bottom of this file, there is a line that defines the coordinate system...
DefineCoordSystem(1,0,2,-1);
.This tells the plugin which output drive channel corresponds to which Mach3 axis. The syntax for this command is DefineCoordSystem(X-axis channel, Y-axis channel, Z-axis channel, A-axis channel). The number entered into each of these fields in the KFlop stepper output channel number. A -1 means the axis is not used. Most users would use (0, 1, 2, -1). However, since I wanted to swap X and Y axis on the machine, I define X-axis to use ch1 which is Shopbots old Y-Axis...the gantry.
Two more lines were added to this file to configure an output pin that will control the Spindle 1 relay on the Shopbot breakout board...
ClearBit(45);
SetBitDirection(45, 1);
The output bit is first cleared, then the bit direction is configured as an output.
SpindleMach3.c
Whenever a spindle start, stop, direction change, or speed change command is issued in Mach3, this program is called. For the most part, this file is the same as the default file provided with KMotion with the addition of controlling the output bit for the Spindle 1 relay control (IO45).
HomeShopbot3Axis.c
This file provides a homing routine for the shopbot. Mach3 calls this program when any home action command is issued. The routine for each axis is...
- Disable soft limits
- Move the axis towards zero (lower left corner) at a slow rate until the limit switch is activated
- Move back in the positive direction 0.25" off the sensor
- Zero the axis
- Restore the soft limits for the axis
At the time of this writing I did not have the Z-axis limit switches installed yet so the routine for the Z-axis is commented out.
NotifyMach3.c
Mach3 calls this program for a number of reasons. You can configure Mach3 to notify the plugin for custom requirements. One common use for this program is the probe function. The file can be used the way it comes with KMotion. The only change I made was to change the active state of the probe in the definition line...
#define PROBE_ACTIVE_STATE 0
This is what the KMotion plugin configuration screen looks like...
The "Offline" box is configured to drive IO44 when Mach3 is set to "Offline" mode. This turns off the motor drivers and allows the stepper motors to free spin. Of course when you go back to online mode you will need to re-home the machine.
The next step is configuring Mach3 Ports & Pins. Attached are screen shots of the necessary tabs...
Next came Motor Tuning. The Shopbot website provides information about each axis in the "Units and Values' datasheet (Google search). Here are the settings I used for each axis. These settings seem to work pretty well, but may be tweaked in the future...
X-Axis and Y-Axis
Steps per: 1833.465
Velocity: 400
Acceleration: 30
Z-Axis
Steps per: 2291.831
Velocity: 100
Acceleration: 20
At this point, Mach3 can now move each axis and is ready to go. I have attached the four C programs and my Mach3 XML setup file.