HyCNC-4P(4 Axis) USB Motion Control Parallel Port Interface Instruction Manual HyTechWorks 2010 – V3.
Cautions HyTechWorks provides its products and services “as it is”. HyTechworks accepts no responsibility for performance of any machine or any damage or injury caused by using its products and services. All computer controlled machine tools are potentially dangerous if they are incorrectly designedor operated. It is your responsibility to insure that you understand the implications of your design and build and the compliance requirements with any legislation and codesof practice applicable to your country.
Contents Introduction ............................................................................................................1 Minimum System Requirements.........................................................................2 Shape and Connections ......................................................................................3 DB25 Connector............................................................................................3 X/Y/Z/A Stepping Pulses ....................................
Device Identification and Opening ................................................................59 Device Basic Information Reading .................................................................60 Motion Control ..............................................................................................61 Other Controls ...............................................................................................62 HyTechWorks 2010 – V3.
Introduction HyCNC-4P is a 4-axis machine tool motion control USB interface, replacing traditional PC parallel port. Its operation features are as the follows: Connect to PC via USB port, suitable for any netbook, notebook, desktop and tablet PC with USB ports. USB kernel mode driver compatible with 32/64 bit Microsoft Windows XP/Vista/7 OS. Compatible with Mach3 PC based CNC software, including version 3.043.066.
with 5V signal level. Working status LED. Motion control using a 32bit single chip microcontroller, greatly reducing real time requirement for PC OS. All control pulses are generated using on-chip hardware, eliminating motor vibration caused by control signal jitters. Reliable design that can work under severe conditions. Software watchdog monitors Mach3’s proper running. Providing Windows API to support special control system (i.e. motion control using LabView Windows).
Shape and Connections HyCNC-4P is assembled in a plastic cover with a DB25 and two fasten screws on one end, and an USB connector and working status LED on another end. Size: 74mm(L) x 58mm(W) x 24mm (D) DB25 Connector The DB25 connector has 17 control signals as the following figure. HyTechWorks©2013 – V3.
X/Y/Z/A Stepping Pulses X/Y/Z/A Stepping Pulses are 0-5V position pulse with raising edge effective. The minimum pulse width us 1uS(-250)or 2uS(-125) or 4uS(-60) or 8uS(-30). Each output can be used to drive 15mA push and pull. When connecting to a motor driver with low to high transaction, the following 4 HyTechWorks©2013 – V3.
connection should be used: When connecting to a motor driver with high to low transaction, the following connection should be used (5V is not isolated from the HyCNC-4P): X/Y/Z/A Direction Pulses High level(5V) represents positive direction movement and low level (0V) represents negative direction movement. Each output can be used to drive 15mA push and pull. The direction of a two-phase stepping motor can be changed by swapping connection of one of the coils.
capable to drive an optical coupler like stepping pulse outputs do. Relay Control Outputs (Original and B Type) OUt1 and OUT2 can be used to control 2 relays with relay drivers. Each output can be used to drive 15mA push and pull. OUT1 is mapped to Mach3’s digital output port 1 pin 0. OUT2 is mapped to Mach3’s digital output port 1 pin 1. RS485 Port (C Type) OUT1 – RS485+ OUT2 – RS485- Control Inputs There are X-axis zero, Y-axis zero, Z-axis zero, A-axis zero/tool setter and EStop 5 inputs.
USB Connector The USB connector is used to communicate with a PC. Please use a high quality USB2.0 cable for better resistance of disturbance. Working Status LED Flash Rate Status 1 flash/s Normal working,whithout motion instruction. 2 flash/s Normal working , with motion instructions (including zero motions). 5 flash/s Firmware update. HyTechWorks©2013 – V3.
USB Driver Install Attention: USB driver install requires “administrator” privilege. Double click install.bat under “USB Driver” directory. The install program will choose proper driver depends on the OS. The following window pops up. Click “Next”. Then the “Important Notice” window appears. Please read the “Important Notice” carefully. If agree, select “I accept” the click “Next”. 8 HyTechWorks©2013 – V3.
Windows Vista/7 will show the following warning. Click “Install this driver software anyway”. Then the driver install begins. The following window pops up when finish. Click HyTechWorks©2013 – V3.
“Finish”. When plug in HyCNC-4P for the first time, the “Found New Hardware Wizard” window pops up. Select “Yes, this time only” the click “Next”. 10 HyTechWorks©2013 – V3.
Select “Install from a list or specific location” then click “Next”. Select “Don’t search. I will choose the driver to install” then click “Next”. HyTechWorks©2013 – V3.
PC will show suitable drivers. Select “HyCNC-4P USB Interface” then click “Next”. PC starts installing the driver. 12 HyTechWorks©2013 – V3.
When finish, the following window poops up. Click “Finish”. HyTechWorks©2013 – V3.
For C type hardware, RS485 virtual COM driver is installed for the new hardware. “Found New Hardware Wizard” window pops up. Select “Yes, this time only” the click “Next”. Select “Install from a list or specific location” then click “Next”. 14 HyTechWorks©2013 – V3.
Select “Don’t search. I will choose the driver to install” then click “Next”. PC will show suitable drivers. Select “HyCNC RS485l Com Port” then click “Next”. PC starts installing the driver. HyTechWorks©2013 – V3.
When finish, the following window poops up. Click “Finish”. 16 HyTechWorks©2013 – V3.
RS485 COM port number can be view from the device manager. Open the device manager. Expand “Ports(COM & LPT)”. The “COM3” at the back of “HyCNC RS485 Com Port” is the RS-485 virtual com port number. Note: the latest USB driver can be downloaded from http://www.hytechworks.com/Downloads/HyCnc/HyCNC_4P/index_e.html Multiple Connection Total 127 USB device can be connected to a PC. They can be all HyCNC-4P if possible. The difference between 2 HyCNC-4P is the USB serial number.
Plug a HyCNC-4P in to PC. The open Windows’ “Devcie Manager” shown below. Expend “HyTechworks Hardware” to show all plugged in interface. Right click the interface, select “Properties”. Then click “Details” page and select “Device Instance Id”. The last 8 characters following the VID and PID number is the USB serial number. 18 HyTechWorks©2013 – V3.
HyTechWorks©2013 – V3.
Mach3 Configurations Please refer to proper materials regarding to Mach3 install. Mach3 software download: http://www.machsupport.com/downloads.php Mach3 document download: http://www.machsupport.com/documentation.php There is no need to install Mach3 parallel port driver, which is not functional under 64 bit Windows. Normal USB-parallel port adapter cables don’t work as well. The motion pulses have jitters because Windows’ scheduling. The following descriptions only address configuring HyCNC-4P for Mach3.
Note: the latest Mach3 plugin can be downloaded from http://www.hytechworks.com/Downloads/HyCnc/HyCNC_4P/index_e.html Click Mach3Mill icon on the desktop to start Mach3. The following window appear to allow user select proper motion control hardware. Select “HyCNC_4P” then click OK. If there is no suitable hardware to run HyCNC-4P, the following error windows appears. HyTechWorks©2013 – V3.
If there are more than on HyCNC-4P connected to the PC, another selection window appears. All available HyCNC-4P are listed in the window by their USB serial number. Select the one intend to use and click OK. If there is only one HyCNC-4P, no more windows will be shown and the only one HyCNC-4P will be used. The firmware version and the hardware serial number of the HyCNC-P cab be read by operate Mach3 main menu ”Config”->”Config PlugIns”. Click “CONFIG” behind HyCNC_4P and a new windows shows up.
FW is the firmware version and SN is the hardware serial number. Relay Output Config (Original/B Type) Operate Mach3 main menu’s “Config”->”Ports and Pins”. Then click on “Output Signals” page. Click to put green tick on “Enabled” column of the “Output #1” and “Output #2” row.
Coolant control can be used to test “Output #1” and “Output #2”. Click on page “Spindle Setup”. Set as the following figure for “Relay Control” and “Coolant Mist Control” blocks, in which “Output #1” is used to control mist and “Output #2” is used to control coolant. Then click Apply and OK to close the config window. Then switch to page “Diagnostics” of the Mach3’s main interface and type “M7↙” to switch on mist, 24 HyTechWorks©2013 – V3.
“M8↙” to switch on coolant, “M9↙” to switch both off. Check output change accordingly. X/Y/Z/A Axis Config Operate Mach3 main menu’s “Config”->”Ports and Pins”. Click on page “Port Setup an d Axis Selection”. Disable using “Port #1” and “Port #2” and keep “Kernal Speed” at 25000Hz. This is only associated with PWM frequency setting and has nothing to do with motion control using HyCNC-4P. HyTechWorks©2013 – V3.
Then click on page “Motor Outputs”. Put green ticks in column “Enabled” on “X Axis”, “Y Axis”, “Z Axis” and “A Axis” row and “Dir LowActive” according to the requirements. The other columns have no effect on HyCNC-4P’s operation. The length unit used by Mach3 can be set by operation the main menu “Config”->”Select Native Units”. The choose “MM’s” or “Inches” as needed. Finally, the motor operation characteristics need to be set. Operate the main menu “Config”->”Motor Tuning and Setup”.
Click on “X Axis” button on the upper right corner. Then fill in “Ster per” (mm/inch) according to the following equation step motor steps per revolution · driver microstep setting screw pitch For example, the step has 200 steps per revolution. The driver microstep is 20. The screw pitch us 4mm. Then 1000 should be filled in “Set per” box. “Velocity” is the maximum distance X-axis is allowed to move per minute. It is the maximum speed of G0 code. It also limits the maximum value for F code.
red-green box. If Mach3 is in reset state, click on “RESET” button to release the reset state (a steady green box encapsulate “RESET”). Press “X+” and “X-“ in the jogging window to check X movement. Press “Y+” and “Y-“ to check Y movement. Press “Z+” and “Z-“ to check Z movement and press “A+” and “A-“ to check A movement(if fitted). The jog response speed can be adjusted by “Jog Buffer” length in “HyCNC-4P” plugin’s “CONFIG” setting. The smaller the buffer is set, the faster response speed becomes.
Outputs”. Put a green tick on the “Spindle” row’s “Enabled” column. All other columns are not used by HyCNC-4P. Then click on page “Spindle Setup” page. If there is no circuit to control spindle rotating direction. Put a “X” on “Disable Spindle Relay”. If spindle’s rotating direction can be controlled by a H-bridge consisted by 2 relays, 2 relay outputs are needed.
The ratio between PWM1’s duty cycle and spindle speed is set by operating the main menu “Config”->”Pulley Selection”. “Min Speed” is for 0% duty cycle and “Max Speed” is for 100% duty cycle. If “Min Speed” is for 100% duty cycle and “Max Speed” is for 0% duty cycle, put “X” on “Reversed”. The spindle operation can be tested by select the main menu “Function Cfg’s”->”Spindle Calibration”. Put a test value in RPM box and click “Spindle On/Off” button to start spindle.
When PWM2 is not used for Mach3 watchdog status output, PWM2 ‘s duty cycle can be set by using a M code, i.e.” M101”. Create a new text file called m101.m1s under Mach3/Macros/Mach3Mill directory. Fill the following content by a text editor and save. Declare Sub PWM2_SetDutyCycle Lib "HyCNC_4P"(ByVal duty As Double) PWM2_SetDutyCycle(Param1()) PWM2_SetDutyCycle is a function declared in HyCNC_4P.DLL. It takes a double input value between 0.0 – 1.0 that controls the PWM2’s duty cycle.
Homing/Soft Limits The homing process is divided into 2 stages. The first stage is to seek the home switch with speed of G0 speed’s predefined percentage (plugin config’s “Home Speed%”) according to pre-defined direction. When the home switch is triggered, the moving speed is decelerated to 0 and the second stage starts. The second stage is to leave the home switch with the speed of predefined % of the first stage speed towards the opposite direction.
menu “Operator”-> “Edit Button Script”. The click on flashing “REF ALL HOME” to bring up the homingscript edit window. DoButton(22), DoButton(23), DoButton(24), DoButton(25), DoButton(26), DoButton(27) are used to execute auto zero on X/Y/Z/A/B/C axis. The above script execute homing on Z axis, then Y axis, then X axis and finally A axis. DoOEMButton(133), DoOEMButton(134), DoOEMButton(134) are used to reset X/Y/Z encoder. For the machine without encoder, these 3 line of script can be removed.
code("G0 Z5") While IsMoving() Sleep(100) Wend code("G0 X10 Y15 A90") This script execute homing like before. After homing is finished, it first fast moves Z axis to coordinate 5. After Z axis movement is finished, it fast moves to 10 on X axis, 15 on Y axis with 90 on A axis at the same time. After edit the script, save it to the system by operating menu “File” -> “Save”. Clicking “REF ALL HOME” can run the saved script. If homing needs to be run from a GCode file, save above script to a mXXX.m1s file (i.
Then operating the main menu “Config”->”Motor Home/SoftLimits”. For the axis equipped with a home switch that requires the homing process, put a green tick in their “Auto Zero” column (attention: A axis home switch input shares the same input as the auto tool setting input(If homing is enabled on A axis, the auto tool setting can’t be enabled). “Home Neg” column defines the location of the homing switch.
properly according to work range to avoid mechanical collision. For small CNC machine tools using step motors, home switches with soft limits provide an effective and low cost solution for safe machine operation. The first stage speed is defined by “Home Speed%” in plugin’s config. Operate Mach3 main menu “Config” -> ”Config PlugIns”. Click “CONFIG” behind HyCNC_4P and a new window shows up. 36 HyTechWorks©2013 – V3.
Set and test “Home Speed%”. It is percentage of the speed limits. Slave Axis A-axis can be used as a slave axis of X/Y/Z axis by clicking on menu “Config”’s “Slave Axis” item. When A-axis is used as a slave axis, the main axis’s pulse per (mm or inch), speed limitation, maximum acceleration and direction signal’s polarity are applied to the slave axis. The slave axis’ end-stop switches have no effect but the end stop switches of the main axis stop motion on both axis. HyTechWorks©2013 – V3.
When homing is carried out with a slave axis, machine seeks both home switches on the main and slave axis in the first stage. When both switches are triggered, machine decelerates to 0 and the second stage start. The machine also checks both homing switches in the second stage. The alignment error between the main and the slave axis is compensated during the deceleration stage. The alignment offset can be adjusted “Slave Axis Offset” in “HyCNC-4P” plugin’s “CONFIG” setting. 38 HyTechWorks©2013 – V3.
Auto Tool Setting Two commonly used auto tool setting processes are implemented. One for professional tool setter (one with retreatable spring loading surface) and one for low cost tool setter (one with hard non-retreatable surface). A professional tool setter normally has 2 wires, working like a precision micro switch. It uses magnets to stick on the bench top stably. When the tool presses the surface down to a fix point, the switch changes its status.
There is an improved low cost tool setter shown in the figure below. It requires the same connection and optical coupler circuit as the low cost tool setter described above. However, its setting method should be as same as the professional one. Two tool setting methods are selected by operating Mach3 main menu “Config” -> ”Config PlugIns”. 40 HyTechWorks©2013 – V3.
Click “CONFIG” behind HyCNC_4P and a new window shows up. Putting “X” before “ATS Stop on Touch” selects auto tool setting using low cost tool setter. Removing “X” before “ATS Stop on Touch” selects auto tool setting using professional tool setter. HyTechWorks©2013 – V3.
Process of using professional tool setter is similar to auto zero. The first stage is to seek tool setter with acceleration to G0 speed according to pre-defined direction. When tool setter is triggered, the moving speed is decelerated to 0 and the second stage starts. The second stage is to leaving the tool setter with acceleration to predefined % of the G0 speed towards the opposite direction.
“Control Inputs”). If the input is low level effective, put a green tick in “Active Low” column. Then click “Apply” and “OK” to save the settings. The operate the main menu “Config”->”Motor Home/SoftLimits”. The A-axis settings are used for tool setting operation. If the tool setter is located on the negative direction on Z-axis (moving negatively to seek tool setter), put a green tick in column “Home Neg”. “Speed %” defines the % of G0 speed on Z-axis slow movement.
The tool setter surface Z-axis coordinate is defined using “Gauge Block Height” box in main interface’s “Offset” page. Click on the box and type in the height and return, as shown below. 44 HyTechWorks©2013 – V3.
Finally, script for auto tool setting needs to be updated. Operate the main menu “Operator”->”Edit Button Script”. Then click on flashing “Auto Tool Zero” button, as shown below. Type the following script in the new window. Declare Sub AutoToolSetting Lib "HyCNC_4P"(ByVal ctool As Integer) AutoToolSetting(GetOEMDRO(824)) AutoToolSetting is a function define in HyCNC_4P.DLL. The input parameter is the tool number (the green circle in above figure), provided by GetOEMDRO(824) standard function.
The tool setting script can further adapted to the machine. For example, if the tool setter is fixed at a location, i.e. machine coordinate (100, 50) and new tool length is always used after tool setting, the script can be update as the following.
Wend AutoToolSetting(GetOEMDRO(824)) While IsMoving() Sleep(100) Wend code("G43 ") DoSpinCW(); Call M900 in GCode execute following operations: “G53 G0 Z200” moves the current to a safe height suitable for manual tool change. Then spindle is stopped. Then move to tool change located at machine coordinate (500, 500) by “G53 G0 X500 Y500”. The a window with confirm button pops up on the screen, waiting manual tool change to be carried out.
The EStop is enabled by operating the main menu “Config”->”Ports and Pins”, clicking on page ”Input Signals” and putting a green tick on EStop’s “Enabled” column. “Port #”, “Pin Number” and “Active Low” should be set according to physical connections (referring to chapter “Shape and Connections”, section “Control Inputs”). If the input is low level effective, put a green tick in “Active Low” column. Then click “Apply” and “OK” to save the settings. When EStop is trigged, the GCode execution is stopped.
Then click on “CONFIG” box behind the “HyCNC-4P” . HyTechWorks©2013 – V3.
When external EStop is triggered, the Mach3 will be locked to stop state even external EStop is released. The red “RESET” button continues having a green-red box flashing. Click on the “RESET” button to release Mach3’s internal stop state. If the external EStop is still engaged when the “RESET” button is clicked, the internal stop can’t be released. Mach3 Watchdog Configuration A software watchdog can be enabled to monitor the proper working of the Mach3. Operate the main menu “Config”->”Config PlugIns”.
Tick “Watchdog on PWM2” to enable the watchdog function. When Mach3 works properly, PWM2 output a 50% duty cycle signal. When Mach3 works abnormally, PWM2 output a 0 duty cycle signal. When watchdog is enabled, PWM2 can’t be controlled by a M code. As soon as watchdog is enabled, it can’t be disabled until USB interface’s power is recycled. To disable the watchdog, untick “Watchdog on PWM2”, exit Mach3, recycle the USB interface’s power and restart Mach3. HyTechWorks©2013 – V3.
RS485 (C Type Only) HyCNC-4P-xxxC has a RS-485 port to communicate with external modules, ie. VFC controller. It is emulated as a serial port on PC windows. The port has the following functions: 1. Automatic TX/RX modes changeover. TX mode has priority. Any sending data put RS-485 in TX mode until data is transmitted and RX mode is recovered. 2. Gavanlic isolation. 3. Virtual COM port emulation. 4. Baud rate 300-115200bps. 5. 1/2 stop bits, odd/even/none polarity bit supported. 52 HyTechWorks©2013 – V3.
Firmware Update The HyCNC-4P’s firmware can be updated online by the final users for function extension and bug fix. The latest firmware can be downloaded from http://www.hytechworks.com/Downloads/HyCnc/HyCNC_4P/index_e.html Normal Operation Run HyCncFlash.exe to start firmware updating process. First, select the firmware image file that need to be programmed into the HyCNC-4P interface. All firmware image files have extension of “fbl”. Please use firmware matching to the hardware.
When firmware update process finishes, the following window pops up. Click “OK”. When the firmware update process runs the first time on a PC, HyCncFlash.exe can’t run properly because the firmware update USB driver has not been installed. The following failure windows will appear. It is normal. Click “OK” to end HyCncFlash.exe. “New Hardware Wizard” window pops up. Click “Yes, this time only” and “Next”. 54 HyTechWorks©2013 – V3.
Then click on “Install from a list or specific location” and “Next”. Then click “Don’t search. I will choose the driver to install” and “Next”. HyTechWorks©2013 – V3.
“New Hardware Wizard” will find the suitable driver and list it. Click on “HyCnc USB Bootloader” and “Next”. 56 HyTechWorks©2013 – V3.
The USB driver is then installed to PC. When the installation is finished, the following window pops up. Click “Finish”. After install the USB driver, run HyCncFlash.exe again to perform firmware HyTechWorks©2013 – V3.
update. Firmware Recovery For any reason that HyCncFlash.exe fails to run properly in normal mode, firmware recovery need to be performed to force re-programming a correct firmware that can recover the normal working condition. First, disconnect HyCNC-4P from the PC’s USB. Then connect a 7-10V DC voltage source (i.e. using a 9V battery) between EStop (pin 10) and the ground (pin 18-25), as shown in the following drawing. Connect HyCNC-4P to PC USB.
Low Level API Windows programs can use HyCNC-4P to generate motion and other control signals via API functions. API consists of HyCNC_4P.LIB and its header file HyCNC_4P.H. The latest API can be downloaded from http://www.hytechworks.com/Downloads/HyCnc/HyCNC_4P/index_c.html The API has following functions.
Device Basic Information Reading BOOL HyCNC_GetStatus(HANDLE hUsb, LPOVERLAPPED olp, HyCNC_StatusStruct *status) HyCNC_GetStatus reads essential status from HyCNC-4P interface. hUsb – the handle of the HyCNC interface. olp – pointer to OVERLAPPED structure (see FileRead Visual C++ function for overlapped I/O access) status – status data read from HyCNC interface. If the function succeeds, the return value is true. Otherwise, it returns false.
fwv – firmware version sn1 – serial number 1 sn2 – serial number 1 sn3 – serial number 1 Motion Control BOOL HyCNC_SetMovement(HANDLE hUsb, LPOVERLAPPED olp, double *points, unsigned char axis, unsigned short num) HyCNC-4P generates interpolated stepping pulses with 1ms time base. HyCNC_SetMovement sends the motor 1ms based movement vector data to HyCNC-4P through USB. hUsb – the handle of the HyCNC interface.
hUsb – the handle of the HyCNC interface. coordinate – pointer to 4 element coordinate array that used to modify the coordinate counters. mode – pointer to 4 element mode array that defines the mode for coordinate counter modifications. 0 – relative mode – the coordinate value is added to current coordinate counter. 1 – absolute mode - the coordinate value is set to current coordinate counter. If the function succeeds, the return value is true. Otherwise, it returns false.
HyCNC_SetSpindle2 sets PWM2’s duty cycle. hUsb – the handle of the HyCNC interface. Duty Cycle = BOOL HyCNC_KickWatchdog(HANDLE hUsb) duty period This function send a normal working signal to USB interface. The first signals enable the watchdog if it is not enabled. This function needs to be called every 0.1 second. If it is not called in 0.5 second, the watchdog times out. hUsb – the handle of the HyCNC interface.
bit 2 – Z capture trigger. “1” sets and “0” has no effect. bit 3 – A capture trigger. “1” sets and “0” has no effect. bit 31 – tool setting capture trigger. “1” sets and “0” has no effect. hw_type – hardware type (see HyCNC_GetHardwareInfo). 1 – original type; 2 – B/C type. The switch input is evaluated every millisecond. The movement should be no more than 1 pulse per millisecond to achieve the best result when the trigger for that moving axis is set. This function is useful for homing or tool setting.