Hello Guest it is November 27, 2021, 04:33:26 PM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - SimonRafferty

Pages: 1
Works in progress / (Mach4) wxLathe TouchScreen Friendly Version
« on: December 19, 2020, 07:12:46 AM »
The touch screen on my Lathe is fairly small (11") and I was struggling to see the text on buttons / controls.  Also, my fingers are big enough to press several buttons at the same time.

This is the standard wxLathe screen with the buttons enlarged, moved around a bit (to suit the way I like to use it) and the text size increased to make it all more readable.

I've removed some of the controls I tend not to use to make more space.

I've only made one small change to the page load script to make it run, having removed a control it referenced (spindle ratio).  Other than that, everything is as standard.

I've been using it for a couple of weeks, making tweaks here & there - but it seems to be OK.  Let me know if you find otherwise or if you think of a better way of doing something!

Mach4 General Discussion / Mach4 Lathe - which motion controller?
« on: December 15, 2020, 02:31:15 PM »
I have a mill, running with Mach4 and a CSMIO/IP-M and I have few complaints about it.

This year, I decided to convert my Denford Cyclone with Fanuc OTB and servos to run Mach3 / 4 - and figured I'd buy another IP-M controller, but I'm starting to regret that decision!
The plugin for Mach3 was flaky as hell.  It worked OK with Mach3 Mill but refused to cooperate with Mach3 Turn.  OK, neither the plugin nor Mach3 are supported so I decided to go for Mach4 instead.
Unfortunately, their V3 Mach4 plugin also has problems.  Mainly with connectivity but when it does connect, the pulse-stream it generates is lumpy / jerky. They suggested a faster PC.  Made no difference.
Cut a long story short - I'm now at the point of abandoning CSMIO and buying something else!  I want to continue with Mach4 as I like it!

Ideally, I'd like:
  • 24v differential inputs & outputs
  • Threading with single pulse or Encoder
  • Proven ability to play nicely with Ultra3000 Servo Drives
  • 2 x Analog inputs
  • 1 x Analog 0-10V output
  • Ethernet connectivity (that works)
  • Mach4 Plugin that actually works!!!

Today I've looked at:
  • Pokeys57cnc - Although people have made it work - there are also a lot of people expressing problems.
  • Vital Systems HiCon Integra - Looks good but quite expensive.  Once I've bought the analog upgrade & threading it comes to $1120 + shipping, duty & VAT = over £1,000
  • UC300 - doesn't support Lathes
  • CNCDrive AXBB-E - Looks OK but very little info on line. No obvious Mach4 driver nor threading
  • PMDX-424 - Looks OK.  Shame it's USB but it ticks most other boxes
  • ESS - Has threading now, but people still finding problems with it.  I had an ESS, probably 10 years ago and had a lot of problems with the Mach3 driver loosing contact and hanging half way through a job.  Hopefully it's better now?

Is there anything decent I've missed?  Do any of you have a Lathe with Treading & Mach4 with Servos?

Feeling that I've wasted £500 (£1500 if you include buying a new PC unnecesarily) - I would value any advice you have on not wasting any more!


Mach4 Toolbox / Mach4 Serial Pendant
« on: May 25, 2020, 05:50:20 PM »
I had wondered how to make a more functional Pendant controller than the ones that you can buy off the shelf.  By more functional, I mean including DROs that are updated from Mach4 and confirmation lights on buttons, again controlled by Mach4 - so you know it has received and understood the instruction.

In place of Buttons, I've used a Capacitive Touch LCD (which works with wet fingers, unlike Resistive screens).

It uses an Arduino Nano as a USB Serial Device.  When a button is pressed, it sends a (short) Serial Message to Mach4.  When Mach4 receives it, it enacts it and sends back the state of the thing it changed (Coolant for example) which in turn causes the button to Illuminate.

The MPG Wheel Sends "I" for Increment & "D" for Decrement.  If the DRO value for an axis changes, it's sent back to the Pendant for display.  With the short messages and fast serial (115200bps) the lag is minimal making the pendant very responsive.

While this is not just a 'script', the scripts it contains may well be useful, particularly for anybody wanting to communicate externally using Serial.  Most of the heavy lifting with the serial was done by Mike https://www.machsupport.com/forum/index.php?topic=42084.msg274487#msg274487

I used a variant of his code to talk to my Servo Drive - then adapted it for this. 
DanTheGaz's posts & particularly videos were invaluable discovering what's under the covers of Mach4

I'm sure I've done some of it the 'wrong' way - but life is for learning!

I've uploaded all the code, including Arduino to GitHub:

Mach4 General Discussion / Recommend me a high quality MPG Wheel?
« on: May 07, 2020, 05:17:43 AM »
I've bought a couple of MPG Wheels & encoders over the years, but none of them had the same, nice, feel as Fanuc or Heidenhain wheels. 

What makes a good one?  Enough mass that when you spin it, it will keep going for a turn or so, with enough damping that it will stop.  Soft detents so you can feel each click, but they don't interfere with spinning.  Nice finish.  It probably doesn't need a scale on it - as it changes with the jog increment.

I don't need a complete pendant - i'm going to build that!

My plan for the pendant, inspired by this post on Instructables:

I'm not keen on the touch screen - I'd like buttons I can feel & operate without looking at them!
My plan (which may or may not work!) is to use the Lua Serial plugin to talk through a wireless USB Extender, to an Arduino on board the pendant. 
I'll write a PLC script which will establish 2 way comms with the pendant - sending axis positions and reading the MPG & buttons.  If that doesn't work, an arduino at both ends with X-Bee comms and feed the MPG + Buttons into the BoB as if it were connected directly. 

I'm not keen on the keystroke injection method most seem to use - it's dirty!

First step though is a nice MPG Wheel!

Thanks in advance,


Mach4 Toolbox / EMCO PCMill100 or VMC100 Toolchange Macro M6
« on: May 07, 2020, 04:21:06 AM »
The PCMill100, VMC and several other EMCO mills use the spindle to drive the toolchange turret.
After you Home Z, if you continue raizing Z, the tool disengages and after 90mm (on mine, check on yours!) the spindle engages with a bevel gear and then can turn the turret.

Originally, the machines use a hybrid Analog / Pulse+Direction drive for the spindle.  I couldn't get it to do either and suspect it needed the original PC to send it someting via RS485 to activate as well as setting the input pins.

With this example, you can drive it just using a simple VFD driving the original spindle motor.

There's a video of it operating here:

The turret has an index sensor, detecting magents set into the rear.  There is one for each tool, the rising edge of the sensor pulse coresponds to the tool being correctly located.  There is an extra magnet between tool 10 & 1.  This is used to determine the position of tool 1, just using a timer.

Initially the turret is turned and the max time between index pulses measured.  If a pulse comes along, with less than 75% of the max time - that must be the extra magnet - so the next pulse indicates tool 1.

Then it just counts up the number of pulses  / tools until the right one is reached.

There's not much on line about converting these machines.  Ping me a message if you need more info on my approach.  I'm using CSMIO/IP-M with Mach 4.

Code: [Select]
local inst = mc.mcGetInstance()
local profile = mc.mcProfileGetName(inst)
local path = mc.mcCntlGetMachDir(inst)

package.path = path .. "\\Modules\\?.lua;" .. path .. "\\Profiles\\" ..  profile .. "\\Modules\\?.lua;"

function m6()
------ Toolchange Macro for EMCO PCMill 100 ------
--                                              --
-- Simon Rafferty May 2020                      --
--                                              --
-- This will allow you to control the spindle   --
-- with a simple VFD, rather than the hybrid    --
-- servo spindle (which I failed to reverse     --
-- Engineer).                                   --
-- Don't run the turret too fast or Mach4's     --
-- Macro pump will miss the indexing pulses     --
-- That said, it will execute a toolchange      --
-- reasonably quickly                           --
--                                              --
-- Run from a program or MDI using "T?? M06"    --

local SelectedTool = 0
local CurrentTool = 0
local CurrentTime = 0
local MaxTime = 0
local TurretHome = false
local ToolCounter = 0
local TimeInterval = 0
local rc = 0 --Return Code

-- mc.ISIG_INPUT0  used to read turret index sensor - Change this to the input you've used

SelectedTool,rc = mc.mcToolGetSelected(inst)
CurrentTool,rc = mc.mcToolGetCurrent(inst)

if(SelectedTool ==   CurrentTool) then
rc = mc.mcCntlSetLastError(inst, "Next tool = Current tool")


if((SelectedTool<11) and (SelectedTool>0)) then
------ Tool number valid ------
rc = mc.mcCntlSetLastError(inst, "Changing Tool")

-- Move Z to Home
--rc = mc.mcAxisHome(inst, 2)
rc = mc.mcCntlGcodeExecuteWait(inst, "G00 G90 G53 Z0.0\n")

-- Start the spindle turning slowly to aid the gears meshing nicely
--rc = mc.mcCntlGcodeExecuteWait(inst, "M03 S20\n")
-- Move Z +93 - the position above Z home switch where the gears are fully meshed
rc = mc.mcCntlGcodeExecuteWait(inst, "G01 G90 G53 Z90 F400\n")

--Increase the speed of the spindle a bit, to speed up the process.  Don't go too fast or Mach will miss the index pulse
rc = mc.mcCntlGcodeExecuteWait(inst, "M03 S50\n")

--We need to measure the time interval between each index pulse
--The turret has an extra magnet between tool 10 and 1
--First rotate the turret and determine the longest interval between pulses.
--If the time interval is less than the max, it must be the extra magnet passing - so we are just beyond tool 10

rc = mc.mcCntlSetLastError(inst, "Homing Tool Turret")

while( TurretHome==false )
--Measure the time between each pulse of Input 0

CurrentTime = mc.mcCntlGetPoundVar(inst, 3001)
--rc = mc.mcSignalWait(inst,hTurretIndex,mc.WAIT_MODE_HIGH,10.0) --Wait for the index to go high
rc = mc.mcSignalWait(inst,mc.ISIG_INPUT0,mc.WAIT_MODE_HIGH,50.0) --Wait for the index to go high
if(rc==0) then
rc = mc.mcSignalWait(inst,mc.ISIG_INPUT0,mc.WAIT_MODE_LOW,50.0) --Wait for the index to go low
if(rc~=0) then
print("ERRROR2 RC=", mcErrorCheck[rc])

TimeInterval = mc.mcCntlGetPoundVar(inst, 3001)-CurrentTime --How long did we wait

--Update the longest interval between index marks
if(TimeInterval>MaxTime) then
MaxTime = TimeInterval

--If the interval is less than 75% of the max, this is probably the home index
if(TimeInterval<(MaxTime*0.75)) then
--This indicates the home pulse
TurretHome = true  --This will terminate the loop
rc = mc.mcCntlGcodeExecuteWait(inst, "M05\n") --Stop Turret

print("ERRROR1 RC=", mcErrorCheck[rc])

--rc = mc.mcCntlSetLastError(inst, "Turret Homed")
--At this point the turret is homed and the next tool is #1

rc = mc.mcCntlGcodeExecuteWait(inst, "M03 S50\n")  --Slow down turret a bit
ToolCounter = 0  --Set to zero as next index pulse will indicate tool 1

while (SelectedTool~=ToolCounter) --keep the turret turning until we reach the required tool
--Just wait while the turret rotates & Count the number of tools passing
if(ToolCounter==(SelectedTool-1)) then
rc = mc.mcCntlGcodeExecuteWait(inst, "M03 S20\n")  --Slow down turret

rc = mc.mcSignalWait(inst,mc.ISIG_INPUT0,mc.WAIT_MODE_HIGH,50.0) --Wait for the index to go high

if(rc==0) then
--At this point, the index input has gone HIGH so increment the tool count
ToolCounter = ToolCounter + 1
print(string.format("Found Tool No: %.0f", ToolCounter))
if(ToolCounter==SelectedTool) then
rc = mc.mcCntlGcodeExecuteWait(inst, "M05\n")  --Stop turret

--Wait until turret index goeS low before continuing

rc = mc.mcSignalWait(inst,mc.ISIG_INPUT0,mc.WAIT_MODE_LOW,50.0) --Wait for the index to go low
if(rc~=0) then
print("ERRROR4 RC=", mcErrorCheck[rc])
print("ERRROR3 RC=", mcErrorCheck[rc])

--When we get to here, the required tool has been found and the turret is in position.
--The turret location does not have to be that precise as the drive disconnects before the
--tool is in the socket.  It will self align if not too far off.
--Return Z to the home position
--rc = mc.mcAxisHome(inst, 2)
rc = mc.mcCntlGcodeExecuteWait(inst, "G00 G90 G53 Z0.0\n")

--Lastly change the active tool number in Mach4
rc = mc.mcToolSetCurrent(inst, SelectedTool)
rc = mc.mcCntlSetLastError(inst,string.format("Selected Tool: %.0f", SelectedTool))
rc = mc.mcAxisHome(inst, 2)
rc = mc.mcCntlEStop(inst)   
rc = mc.mcCntlSetLastError(inst, "ERROR: Tool number out of range!")
do return end

if (mc.mcInEditor() == 1) then
--If you get a 'not found' error here, change the path below to where load_modules.mcs lives
--If, like me, you don't have a copy, you can download it here:

dofile (path .. "\\Profiles\\" .. profile .. "\\Macros\\load_modules.mcs")

Mach4 General Discussion / Axis as a Spindle using Jog? (or Serial??)
« on: November 19, 2019, 05:41:43 PM »
I have an EMCO PCMill100 which uses the spindle to move the tool turret.  Originally, the servo drive had analog and pulse/dir inputs with a line to swap mode.  Unfortunately the motor was fizzed when I bought it.  I replaced the spindle servo with a DMM Dyn4 + 750W motor which was the same frame size.  It works just fine in either step/dir or analog - but you have to send RS232 Serial commands to it to change mode.  I failed to make the Lua Serial library play nicely - so I thought up a different solution.

I'm trying to use Jogging - via the mcJogVelocityStart(inst, 3, mc.MC_JOG_POS) function inside M3,4,5 Macros (attached).
It works fine from the Lua IDE - but will not work from the MDI or GCode.  It clearly starts to run as the mcCntlSetLastError is displayed - but does not jog the axis.

Is there something in Mach4 which prevents Jog Velocity from running once the macro has terminated - i.e. is the jog running in a process, terminated at the end of the macro?

If that is the case (and it will not work no matter what), do any of you have an example of sending Serial data via Lua?

P.S. You might ask why I'm not using an OB Axis, which is intended for just this?  I'm using a CSMIO/IP-M which doesn't support OB.  They have (helpfully) suggested I buy an IP-A which does support it.  I figured a work-around was worth a go first!  At the very least, I've learned a lot about the inners of Mach4!

A few years ago I (more accurately, my company) bought a nice, clean Interact with a Heidenhain 370 controller dating from around 1994.  It worked pretty well until one day the X-Axis servo drive stopped working.

Finding a replacement for a Control Techniques MIDI Maestro proved a challenge.  I wound up buying one from a 'dealer' of such things for £700 with a generous 7 day warranty.  It worked OK for about six months, then the X and Z axis drives died  :-[

Although I use the machine a lot for prototyping - I just could not justify spending another £1400 on something with no guarantee of it working for long.  I decided to bite the bullet and convert it to Mach3.

Previously I had converted my Lathe to Mach - and I love it - so there was only one choice really.

I have to thank the many people including Hood & JH Choppers who offered advice before I started.

With the heidenhain, I used a Panasonic Toughbook CF18 notebook to run the CAM software.  These are ideal for workshop use as they are coolant and swarf proof and have a good touch-screen built in.  These days you can pick them up for a little over £100.  I decided to use it to control the mill and use a Smoothstepper to interface between USB and the breakout boards.

The Bridgeport had SEM DC Servo motors fitted as standard, operating at about 140v, 25A maximum.  I therefore needed fairly high voltage servo drivers.  I could limit the power and go for Gecko Drives (my preferred option) or buy Dugong Drives from CNCDrives.

I had a chat with the makers of the Gecko, who very kindly suggested that something bigger such as the Dugongs would be a more sensible option.  I ordered 3 x Dugong drives, one of their HDBOB (Heavy Duty Breakout Boards) from CNCDrives and a Smoothstepper from Warp9.

The SEM servo motors use an optical encoder which is only really compatible with heidenhain controllers.  There is a place on eBay who sells converters to allow these to talk to a modern digital drive - but they were way too expensive to be viable.  Instead, I bought AMT103 capacitive encoders from Digikey.  CNCDrives also sells them - but they are 2x the price of Digikey.

I also had a relay board, bought from eBay for something else (made in China and very inexpensive).  It connects to the Parallel port and has 10, 15A relays on board.  I've used these for enable lines, mains power, spindle, coolant, lube pump.  It does the same job as a BOB / Relay board - but for a fraction the cost.

Converting the motors to use the AMT Encoders turned out to be easy.  Once you have stripped out the old encoders from under a cover on the end of the motor, there is a shaft with a M12 thread sticking out.  I just turned up an adaptor with a female M12 thread and an 8mm spiggot on the other end for each motor.  Drilled a 13mm hole in the end cap and screwed the encoders to the outside of the end caps.  Sorry, didn't take any photos - but once you take the end off the motor, the solution is more than obvious!

I stripped out most of the original wiring, labelling as many of the wires that connect to important things like the servo motors as possible.

I fitted the Smoothstepper, Relay Board, HDBOB and three Dugongs, wired them up over a couple of days and remarkably, when I first powered it up - all three axes moved and the spindle ran, first time!

Once all the bits had arrived, it only took a week to have the machine running - but that's where the fun really started!

I'm in the process of Mach-converting a Bridgeport Interact 1Mk2 which has a Mentor2 Spindle VFD.

The spindle motor has a tacho output which connects directly to the Mentor2.  It appears the way the Bridgeport used it was to send the Mentor a voltage (0 to 10v as usual) and when the Mentor achieved the requested speed, it closed a relay - allowing the CNC controller to move to the next line.

Since the Mentor's PID parameters are nicely tuned to the machine - it makes sense to use it in this mode.

Can Mach accept a 'speed achieved' input instead of a spindle tacho?

Alternatively, would I be better just fitting another tacho and connecting that to Mach as normal?


Pages: 1