Martzis USB HID Interface card for LinuxCNC and Mach 3

This page contains information about Martzis USB HID Interface (MUHI) card. Card is connected to PC via USB bus and operating systems recognizes it as two joystick devices both having 32 buttons and 4 axes.

Card is a generic Human Interface Device (HID) so it is supported on most operating systems including Windows and Linux. The card is primarily developed to be used with LinuxCNC software. Although, I have also made a plugin wich makes card Mach 3 compatible. Card works also with Mach 3 keygrabber without encoder support.



Scematic, PCB layout and Firmware are available for DIY builders. Check the bottom of this page.

Inputs:


64 digital inputs (LS TTL)
4 analog inputs (0-5V)
4 encoder inputs (1x or 2x)
All 64 digital 5V logic inputs are pulled up via LS TTL internal resistors. A simple switch can be connected directly between input and groud.

4 analog inputs can measure a voltage between 0-5V. A potentiometer can be connected directly to these inputs. The center wire is connected to the input pin and two other wires to ground and 5V connectors.

4 encoder inputs can be configured to work in 1X or 2X mode. Compatible encoders are for example these:

http://www.damencnc.com/
http://homanndesigns.com/

Encoder inputs can also be used as pulse counters. In 1X mode A channel counts either rising or falling edges if B channel is connected permanetly to 5V or ground. In 2X mode card counts both rising and falling edges if the signal is connected to both A and B channel

Jumpers:

Card has 5 jumper connectors which configures card functionalities during card startup:

JP1 = Disables analog channels. Minimizes USB traffic if analog inputs are not needed.

JP2 = 1X mode for encoder channels 1 and 2.

JP3 = 1X mode for encoder channel 3.

JP4 = 1X mode for encoder channel 4.

JP5 = Invert digital inputs.

Linux CNC


Ominaisuudet:

Features:

64 digital inputs (input.[0-1].btn_[1-32]
analog inputs are shows as absolute value between 1-254 (input.0.abs_[1-4])
enkooder inputs increase or decrease input value (input.1.rel[1-4])

Configuration in Ubuntu 10.04 & Python 2.6


Create /etc/udev/rules.d/40-permissions.rules file and add this line to it:
SUBSYSTEM==”input”, ATTRS{idVendor}==”04d8?, SYSFS{idProduct}==”0666?, MODE:=”0660?, GROUP=”plugdev”
(do not copy paste this line, ” characters shown in this page are not compatible with rules file)
You can also download file here:
http://www.martsola.com/files/python2.6 ... ions.rules

For correct naming of the inputs linux_event.py (linux_event.py) requires minor changes. Modified version is copied to folder/usr/lib/python2.6/dist-packages/. You can obtain modified version from here:
http://www.martsola.com/files/python2.6/linux_event.py

Tämä HAL-komento lataa kortin käyttöön:
loadusr -W hal_input Martzis:0 Martzis:1

Configuration in Ubuntu 8.04 & Python 2.5


/etc/udev/rules.d/40-permissions.rules needs the following line:
SUBSYSTEM==”input”, GROUP=”plugdev”, MODE=”0660? (do not copy paste this line, ” characters shown in this page are not compatible with rules file)

For correct naming of the inputs linux_event.py (http://git.linuxcnc.org/gitweb?p=emc2.git;a=blob_plain;f=lib/python/linux_event.py;hb=HEAD) requires minor changes. Modified version is copied to folder /usr/lib/python2.5/site-packages/. You can obtain modified version from here: http://www.martsola.com/files/python2.5/linux_event.py

This HAL command enables the card:
loadusr -W hal_input Martzis:0 Martzis:1

Adjustments


Absolute axes have a dead in the middle zone by default. It shall be disabled with following commands:
setp input.0.abs-1-flat 0
setp input.0.abs-2-flat 0
setp input.0.abs-3-flat 0
setp input.0.abs-4-flat 0

It is possible to add bigger hysteresis for the analog axes. Normally this is not needed
setp input.0.abs-1-fuzz 5
setp input.0.abs-2-fuzz 5
setp input.0.abs-3-fuzz 5
setp input.0.abs-4-fuzz 5

MPG configuration example


Link to Finnish CNC site: http://www.cnc-tekniikka.com/CNC-forum1 ... 94#msg3794

Mach 3 & Muhi Plugin (Windows XP SP2/SP3)


MUHI card works also with Mach 3 software. The functionalities of the card are configured via Mach 3 plugin configuration interface. Plugin supports all 64 digital inputs. Encoder and potentiomer inputs can be configured to to alter Mach3 internal MPG counter and to adjust Feed and Spindle Override and many other settings.

Plugin can be downloaded from here:
http://Muhi.m3p

Configuration interface:


MPG wheel window (SHIFT/TAB):



Configuration of the plugin to work with an MPG wheel



Encoder wheel must produce 5V TTL signal and it must have +5V, GND, A and B connectors. These are connected to corresponding connectors on Muhi card. A and B wires are connected to some ancoder channel, for example E1A and E1B. Some encoders may have also inverted (/A and /B) outputs. These are not needed.

Mach plugin is installed by double clicking to file. Mach 3 will install it automatically. Connect the card to the USB port and start Mach. You should see the following status line:



Open Config Plugins menu:



Select Muhi plugin:



Rotate the encoder wheel. The number on corresponding encoder channel should change. Verify that one mechanical encoder step alters the number by one. If one mechanical step causes increment or decrement of two, then change the Mode of the channel to 1X mode via jumper. If two mechanical steps are needed to alter the number by one, then change the channel to 2X mode. If you change the jumper you have to plug the card off from USB until the change happens.

Select MPG 1 as a function of the encoder channel. MPG 2 and 3 do not work on Mach 3 plugin API. I am hoping that the author of Mach 3 software would fix this some day.



Go to Ports and Pins menu:



Activate MPG 1:



Open the settings tab (Alt-6) and you should see MPG 1 value antering when the wheel is turned.

Then press Tab button and change settings like in picture below:



Yellow light is moved to correct position by pressing Job Mode button. Multi-Step must be also selected. The Axis is selected via Alt A button. Notice also that Multi-Step is the only mode where Mach moves the axis exactly same amount that encoder has been moved. If you are rotating encoder faster than you canfig allows moters to run, then the motors will continue the movement until they have reached correct position even if the encoder wheel is already stopped. If your motors and motor drivers can handle higher speeds you can fix this issue from Config-> Motor Tuning menu.

Mach3 & Keygrabber (Legacy option, not recommended)


This was the method to get card working in Mach before Muhi plugin.

Digital inputs are working
Analog inputs work similar like any other joystick (you can adjust for example feed rate and spindle speediä)
encoders are not working



Windows Controlpanel->Game Controllers shows encoder movement corretly byt Keygrabber does not recognise it. In keygrabber encoders are detected as absolute joystick axes. The result is that fast encoder movement is detected as a very small movement of the joystick.



Picture above shows how potentiometer can be configured to adjust Spindle Speed, Feed Rate or other values. Using 20% gain you can adjust the value between 1-199%.

Board and firmware


PCB in Eagle format and microcontrollercode for PIC16C745: MuhiBoardFirmware.zip