Touch Screen and panel controls using ModIO
I have never been very pleased with my sheetmetal work so decided to see if a touch-screen allows efficient operation of a mill with minimal "real" controls.
By using a virtual keyboard on the screen details here it was possible to run Mach3 with no additional devices except for a E-Stop button.
I doid however find three real controls greatly improved my accuracy and speed:
- Manual Pulse Generator (MPG)
- Feed-rate override control knob
- Switch to indicate position of belt on two step spindle pulley.
These might not be your ideal control but suit my work with a lot of setting up and no real repetitive production.
The MPG and axis selection
My original trials interfaced a conventional MPG through a parallel port. The active axis can be selected by a cycle button on the Jog screen and is indicated by screen LEDs
There are three problems with this when jogging to a touch position. One wants needs to change axes quite frequently as one approaches the touch, it is too easy to turn the MPG with the wrong axis selected and it is best to disable the jogging before a part-program ir run.
I provided four push switches with built-in LEDs.
When a button is pressed then its axis is selected for MPG jogging and the LED in the button is lit. If the button for the currently selected axis (i.e. on whose LED is lit) is plressed the Mach3 goes out of MPG jog mode into Step mode so the jog buttons can do small incremental jogs.
The buttons and MPG are all easily used while watching the tool and the work and it is very quick to jog to a workpiece corner when using a laser pointer to indicate the spindle centerline.
If I find that I have misjudged a feedrate I find it difficult to quickly correct this using on-screen controls.
The control panel has a potentiometer giving feed override from 5% to 100% (Note: increasing feeds is risky as Mach3 cannot always respect motor tuning maxima when "bending time" to increase feedrates)
The advantages of the physical knob is that it is easy to find quickly and persistent in its setting.
I had originally implemented an on-screen toggle to select high and low pulley ratios but found that I frequenly failed to press it after changing belt position. I decided that a switch physically adjacent to the cover for the belt and pulleys should be more ergonomic.
The MPG, its push buttons and the pully switch would be easy to implement using a second parallel port and this would not need a sophisticated breakout board. The feed override knob would however be more difficult. It could be a small encoder into the parallel port but this would not be reliably persistent and have a maximum and minimum position.
I chose a ModIO board from Peter Homann (details here). This provides MPG counting, power drivers for outputs, analog inputs and a built-in regulated power supply. It interfaces to the serial (RS-232) port of the PC using the Modbus protocol. It was designed for implementing control panels.
Mechanical arrangement of prototype
This pictures below show the inside of the "panel" - which, being a prototype, is housed in the case of a failed PC power supply and uses a massive MPG reclaimed from a scrap machine.
Schematic of wiring
The diagram shows how the MPG, potentiometer and switches are wired to the ModIO.
This is slightly tricky because the ModIO needs to be configured, Mach3 needs four OEM trigger inputs to be defined, four output pins to be configured to the ModIO and several macros to be installed.
If you try any of this setup and, as a result of your experience, can help improve the explantions please do dive in with the wiki editor.
The control of the MPG itself is entirely handled by Mach3. I find Velocity mode is by far the best for jogging to a touch. Steps, if required, are done by screen buttons when no MPG axis is selected.
As one needs to detect and act upon button presses the best architecture is to associate the buttones with OEM triggers and to run a trigger macro (i.e. OEM Trigger 301 and Call SetTriggerMacro).
All the macros have to be put in the folder corresponding to the profile you are going to use with the ModIO. I like to clone my own from Mach3Mill so it is preserved when updates are installed. Suppose this profile is called ModIOPendant. The macros will be in the folder:
The macro associated with the trigger (let us assume it is called M991.m1s) is:
Option Explicit ' Macro M991 for MPG jogging. This is called for OEM trigger inputs 301 in Mach3 Const OEMTriggerBase = 29 ' where OEM triggers start numbering Const OutputBase = 16 ' where output signals start numbering Const AxisLEDBase = 59 ' where MPG axis screen LEDs start numbering Const StepButt = 275 ' OEM for selecting Step jog mode Const AxisButtBase = 185 ' where the MPG jog button OEM codes start Const MPGJogLED = 57 ' Screen LED indicates MPG jog mode selected Const CycleJogModes = 245 ' OEM for cycling Jog modes ' what would be nicer is an OEM code to select MPG mode but we can workaround.. Dim i as integer Dim j as Integer Dim iAxisSelected as Integer ' misc counters For i = 0 To 3 ' hunt through the 4 axes DeActivateSignal Outputbase + i ' switch off the real LED in case ON If IsActive (OEMTriggerBase + i) Then iAxisSelected = i ' which switch is pressed? ' highest axis if multiple presses Next i If GetOEMLED (AxisLEDBase + iAxisSelected) Then ' axis was selected for MPG already so put MPG OFF DoOEMButton StepButt ' go to step mode on Keyboard Else ' this axis is not selected so put it ON for MPG DoOEMButton AxisButtBase + iAxisSelected ' select the axis ActivateSignal OutputBase + iAxisSelected ' light the real LED in switch For j = 0 to 2 ' workaround to go to MPG jog mode If NOT GetOEMLED (MPGJogLED) Then ' not in MPG mode so cycle modes DoOEMButton CycleJogModes ' because there is no button to select it End if Next j ' three shots should be enough unless there is no MPG when who cares! End If ' dealt with the button press
The easiest way to set up the OEM triggers to call this M991 macro is to create a macro that will be run when Mach3 is initialized (lets call it M999.m1s). The macro contains one line of actual code. I have added a comment too.
Rem Init macro in M999.m1s SetTriggerMacro (991)
Put the command M999 in the Initialization string on Config>State with any other codes already there.
The LEDs are configured as Mach3 Outputs 7 to 10 connected using Ports & Pins Output Signals tab to the ModIO as Port 0 Pins 0, 1, 2 and 3. These are configured as active Hi.
Potentiometer and Pulley Switch
The Potentiometer is connected to ModIO Analog1 input. This is read in the Macropump macro and the value stored in the Feedrate Override DRO. You may wish to add two user LEDs to your screens to indicate the pulley setting (1050 is high speed, 1051 is low speed). The macro does not require these.
The code of the macro is:
' Macropump for setting Freed rate override ' and reading pulley switch on PCNC - Revised 14 Oct 2005 Option Explicit Dim fro As Integer Const Input1Sig = 18 fro = GetInput (64) ' read Analog1 fro = (fro * 95.0)/1024.0 setDRO 21, fro+5 ' range is now 5 to 100% ' now read pulley switch If IsActive (Input1Sig) Then Call SetOEMDRO (56,2) ' pulley 2 Low speed Call SetUserLED (1051,1) ' LEDs used to indicate pulley range on screens Call SetUserLED (1050,0) Else Call SetOEMDRO (56,1) ' pulley 1 High speed Call SetUserLED (1051,0) Call SetUserLED (1050,1) End If
This is a great way to use mpg's. Once John helped me find my faulty typing it worked wonerfully. Randy T