Hello Guest it is April 25, 2024, 10:46:02 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 - rhtuttle

Pages: « 1 2 3 4 5 6 7 8 9 »
51
General Mach Discussion / Flat bottom Hole
« on: December 29, 2017, 03:07:54 PM »
Need some recommendations how to drill a flat bottom hole on a lathe.  I have a .375" x 1.75" hole.  I peck with a 118 degree twist drill to 1.75.  So far have tried using a .375 2 flute end mill pecked from 1.6" depth to get the flat bottom.  The end mill fills too quickly and the spindle over torques and shuts down.  The end mill is not creating chips but rather dust.  Last effort was  s700 f.25 peck of .05

What approach should I take instead?

TIA

RT

52
Mach4 General Discussion / Home Signal
« on: December 29, 2017, 11:28:46 AM »
When you set up a motor you define a home signal pin and whether that motor homes.  Is there an api that will allow you to turn on/off, mapping enabled or input name?

On my lathe I have my spindle configured to be either run by a motor for the spindle function or alternately driven by a stepper (belt change, motor 3, drive C) to act as a rotary/indexer.  I use input 12 as the spindle index pulse and as the homing signal for the C drive.  When used as a spindle the C drive homing signal is sent on each revolution.  It doesn't affect performance but the log has a message sent for each revolution.  I know I could just use two profiles but that creates other issues (re-referencing all axes).

TIA

RT

53
Mach4 General Discussion / mc.mcAxisSetMachinePos
« on: December 10, 2017, 04:15:25 PM »
Isn't this supposed to set the axis machine position?  When I run this from a button script the z axis dro machine pos does not get set to zero.  Is it doing something else that I am misunderstanding? The return value is 0.

wx.wxMessageBox(tostring(mc.mcAxisSetMachinePos(mc.mcGetInstance(),mc.Z_AXIS,0.0)))

TIA

RT

54
Mach4 General Discussion / List of Mach4 error codes
« on: December 09, 2017, 05:49:24 PM »
Can someone point me to a list of the error codes?  I'm getting a -2 as a return code and it doesn't match up with the api examples listed

55
Mach4 General Discussion / Creating your own homing script
« on: December 02, 2017, 02:44:25 PM »
build 3841, pmdx411, gecko g540, lathe

I just finished installing a stepper to use my lathe spindle as an indexer and it works great.  I would like to be able to home this.  I have a single slot timing signal on the slot for rpm when using the spindle normally but thought I should be able to use it to home when the stepper is in use.  The following code actually stops at the same place each time but the pmdx411 sometimes throws off an error message 'can't transition from MDI RUNNIG to STOP'.  When I don't get that message the C axis dro gets set to zero but the machine position doesn't get set to zero and the led doesn't turn green.

First, is my approach logical/correct?
Second, can you spot any errors in the calls or signals
Third, is there another approach that doesn't include adding more sensors or wiring?

Code: [Select]
local function myhome()
  local inst=mc.mcGetInstance()
  local rc,sState
  local hSig,rc=mc.mcSignalGetHandle(inst,mc.ISIG_INDEX)
  if rc==mc.MERROR_SIGNAL_NOT_FOUND  then
    wx.wxMessageBox('wrong Signal')
  end
  sState=mc.mcSignalGetState(hSig)
  mc.mcCntlMdiExecute(inst,'g1 h366 f5000')
  while mc.mcSignalGetState(hSig)==1 do
    wx.wxMilliSleep(25)
  end
  mc.mcCntlCycleStop(inst)
wx.wxMilliSleep(500)
  mc.mcAxisSetPos(inst,mc.C_AXIS,0.0)
  mc.mcAxisSetMachinePos(inst,mc.C_AXIS,0.0)
  hSig,rc=mc.mcSignalGetHandle(inst,mc.ISIG_MOTOR3_HOME)
  mc.mcSignalSetState(hSig,1)
end


myhome()

TIA

RT

56
Mach4 General Discussion / Mach4 Spindle Speed Linearity Hack
« on: November 21, 2017, 07:32:06 PM »
Nice to be able to contribute something instead of asking everyone else for help solving my problems.
For those of us that don’t have VFD’s or spindle motors that are particularly linear in their speed ramps this will get you a lot closer.  Much like Mach3’s linearity.dat. 

You must have a spindle speed encoder for this to generate the linearity.csv file by running one of the scripts but you could generate one by hand as well.  The format of the file consists of 4 columns: Pulley/Gear, Speed you request, value from 0 to 100, Speed you need to enter to get the speed you want.  The value between 0 to 100 is not used by my script but could be used by those with modbus.  The entries in the file look like this

0,49,6,105
0,84,8,140
0,119,10,175
0,153,12,210
0,189,14,245
0,223,16,280
0,259,18,315
0,294,20,350
0,330,22,385
0,365,24,420
This was done on Mach4 build 3481 on the wxLathe screenset but I believe it will work for the mill as well.
The process consists of a few steps. 

1.     CREATE A PACKAGE of your current profile: Help->Support->Package Current Profile

2.   Create a button somewhere on your screen and copy the script below into the Left Up Script.  It is currently set to run from 6% to 80% by steps of 2 and spins at those steps for 5 seconds each to get the spindle to equilibrium.  You can modify those settings if you wish.  I don’t use my lathe at more than 80% power and it doesn’t really turn at less than 6%. Save the screen.  This script will generate a list of settings for the gear and put it in the History Log.  Clear the history log. This will lock up your screen while it runs!  Do this for each pulley/gear you have.  Save the file to ‘Linearity.csv’.  Open it with excel and save it.  You should be able to now open it with notepad and get the 4 columns for each gear.

3.   Copy the ‘spindlespeed.mcs to your profiles macro folder.  You’re now ready to go.  If you run an MDI of m3 s400 you should see the actual RPM very close to 400 but the command RPM will be something else.

4.   If you want to have the command and requested RPM’s visible do the following.  Create a register in gRegs0 called ssCMND, give it a value of one and I made it persistent.  I moved/sized the Spindle Tab items so that I could fit another DRO above the existing ‘PGM RPM’ dro.  Set the PG RPM dro to read only with a gray background and a black foreground set its height to 20 so that it looks more like a text than a dro.  Name the new DRO ‘ssCMND’.  Select it’s ‘Register’ property to the ‘gRegs0/ssCMND’  from the drop down list box.  In its Left Up Script enter this code:  mc.mcCntlMdiExecute(mc.mcGetInstance(),'s'..tostring(scr.GetProperty('ssCMND','Value')))

Now when you change the spindle speed through the mdi, gcode or through the ssCMND dro the old PGM RPM dro will show the speed necessary to get the requested speed and the ssCMND dro will show what speed was commanded.  If anyone knows of a way to improve it please feel free to help.   Hope this is clear enough and of use to someone else.

Code: [Select]
--spindlspeed.mcs
local inst = mc.mcGetInstance()
  local profile = mc.mcProfileGetName(inst)
  local mcPath = mc.mcCntlGetMachDir(inst)
  local nGears=10
  local tblSS = {}
  local gear=1
  local cmdSS=2
  local pctSS=3 
  local newSS=4
 
  function parseLine(s)
    local gr,cmd,pc,nw
    local i=1
for w in s:gmatch("([^,]+)") do
      if i==1 then
        gr=tonumber(w)
  elseif i==2 then
    cmd=tonumber(w)
  elseif i==3 then
    pc=tonumber(w)
  elseif i==4 then
    nw=tonumber(w)
      end
  i=i+1
    end  
    return gr,cmd,pc,nw
  end
 
  function interpolate(x,x0,y0,x1,y1)
      return y0+(x-x0)*(y1-y0)/(x1-x0)
  end
 
  function ssmLoadTable()
    local fName=''..mcPath.."\\Profiles\\"..profile.."\\Modules\\Linearity.csv"
local ssFile=io.open(fName,"r")     
    if ssFile==nil then
      wx.wxMessageBox("File: "..fName.." Not Found")
  return 0
    end
for i=1, nGears do
  tblSS[i]={}
end
  i=1
    local gr,cmd,pc,nw
local currGR=1
for line in ssFile:lines() do
      gr,cmd,pc,nw=parseLine(line)
  if currGR~=gr then
    i=1
currGR=gr
  end
  tblSS[gr+1][i]={}
      tblSS[gr+1][i][1]=gr
      tblSS[gr+1][i][2]=cmd
  tblSS[gr+1][i][3]=pc
  tblSS[gr+1][i][4]=nw
  i=i+1
    end
    ssFile:close()
-- wx.wxMessageBox("end of read")
return 1
  end

  function ssmGetNewSS(gear,cmd)
    if cmd==0 then
      return cmd
    end
    for i=1,#tblSS[gear+1] do
      if tblSS[gear+1][i][2]== cmd then
--      wx.wxMessageBox('equal:'..tostring(tblSS[gear+1][i][4]))-- case of exact match
      return tblSS[gear+1][i][4]
  end
  if tblSS[gear+1][i][2]>cmd then
        if i==1 then
--        wx.wxMessageBox('first entry')--case of first entry , can't go lower
      return tblSS[gear+1][i][4]
    end
--wx.wxMessageBox('interpolate')
        return interpolate(cmd,tblSS[gear+1][i-1][2],tblSS[gear+1][i-1][4],tblSS[gear+1][i][2],tblSS[gear+1][i][4])     
      end
    end
--  wx.wxMessageBox('over max: '..tostring(tblSS[gear+1][#tblSS[gear+1]][4]))-- case over the limit return limit
    return tblSS[gear+1][#tblSS[gear+1]][4]  --change 4 to 3 to return percent for a modbus number?
  end

function spindlespeed(rpm)
  local inst = mc.mcGetInstance();
  rpm = mc.mcSpindleGetCommandRPM(inst);
 
  local rslt=ssmLoadTable()
  if rslt~=1 then
    wx.wxMessageBox("load failure: "..tostring(rslt))
    return 0
  end
  local gear=mc.mcSpindleGetCurrentRange(inst)
  rslt=ssmGetNewSS(gear,rpm)
  mc.mcSpindleSetCommandRPM(inst,rslt)
  local hReg, rc=mc.mcRegGetHandle(inst,'gRegs0/ssCMND')
  if hReg~=nil then
    mc.mcRegSetValue(hReg,rpm)
  end
--  wx.wxMessageBox(tostring(rslt))
  mc.mcCntlSetLastError(inst,string.format("New SS: %.0f",rslt))
end

if (mc.mcInEditor() == 1) then
  spindlespeed();
end

Spindle Speed Macro

Code: [Select]
[/--spindlspeed.mcs
local inst = mc.mcGetInstance()
  local profile = mc.mcProfileGetName(inst)
  local mcPath = mc.mcCntlGetMachDir(inst)
  local nGears=10
  local tblSS = {}
  local gear=1
  local cmdSS=2
  local pctSS=3 
  local newSS=4
 
  function parseLine(s)
    local gr,cmd,pc,nw
    local i=1
for w in s:gmatch("([^,]+)") do
      if i==1 then
        gr=tonumber(w)
  elseif i==2 then
    cmd=tonumber(w)
  elseif i==3 then
    pc=tonumber(w)
  elseif i==4 then
    nw=tonumber(w)
      end
  i=i+1
    end  
    return gr,cmd,pc,nw
  end
 
  function interpolate(x,x0,y0,x1,y1)
      return y0+(x-x0)*(y1-y0)/(x1-x0)
  end
 
  function ssmLoadTable()
    local fName=''..mcPath.."\\Profiles\\"..profile.."\\Modules\\Linearity.csv"
local ssFile=io.open(fName,"r")     
    if ssFile==nil then
      wx.wxMessageBox("File: "..fName.." Not Found")
  return 0
    end
for i=1, nGears do
  tblSS[i]={}
end
  i=1
    local gr,cmd,pc,nw
local currGR=1
for line in ssFile:lines() do
      gr,cmd,pc,nw=parseLine(line)
  if currGR~=gr then
    i=1
currGR=gr
  end
  tblSS[gr+1][i]={}
      tblSS[gr+1][i][1]=gr
      tblSS[gr+1][i][2]=cmd
  tblSS[gr+1][i][3]=pc
  tblSS[gr+1][i][4]=nw
  i=i+1
    end
    ssFile:close()
-- wx.wxMessageBox("end of read")
return 1
  end

  function ssmGetNewSS(gear,cmd)
    if cmd==0 then
      return cmd
    end
    for i=1,#tblSS[gear+1] do
      if tblSS[gear+1][i][2]== cmd then
--      wx.wxMessageBox('equal:'..tostring(tblSS[gear+1][i][4]))-- case of exact match
      return tblSS[gear+1][i][4]
  end
  if tblSS[gear+1][i][2]>cmd then
        if i==1 then
--        wx.wxMessageBox('first entry')--case of first entry , can't go lower
      return tblSS[gear+1][i][4]
    end
--wx.wxMessageBox('interpolate')
        return interpolate(cmd,tblSS[gear+1][i-1][2],tblSS[gear+1][i-1][4],tblSS[gear+1][i][2],tblSS[gear+1][i][4])     
      end
    end
--  wx.wxMessageBox('over max: '..tostring(tblSS[gear+1][#tblSS[gear+1]][4]))-- case over the limit return limit
    return tblSS[gear+1][#tblSS[gear+1]][4]  --change 4 to 3 to return percent for a modbus number?
  end

function spindlespeed(rpm)
  local inst = mc.mcGetInstance();
  rpm = mc.mcSpindleGetCommandRPM(inst);
 
  local rslt=ssmLoadTable()
  if rslt~=1 then
    wx.wxMessageBox("load failure: "..tostring(rslt))
    return 0
  end
  local gear=mc.mcSpindleGetCurrentRange(inst)
  rslt=ssmGetNewSS(gear,rpm)
  mc.mcSpindleSetCommandRPM(inst,rslt)
  local hReg, rc=mc.mcRegGetHandle(inst,'gRegs0/ssCMND')
  if hReg~=nil then
    mc.mcRegSetValue(hReg,rpm)
  end
--  wx.wxMessageBox(tostring(rslt))
  mc.mcCntlSetLastError(inst,string.format("New SS: %.0f",rslt))
end

if (mc.mcInEditor() == 1) then
  spindlespeed();
end
[code]

[code]

HTH

RT[/code][/code]

57
Mach4 General Discussion / m3 gets special treatment?
« on: November 19, 2017, 06:21:05 PM »
Here is the code for two macros, identical except one is the  m3.mcs file and the other is m300.mcs file code

If the 'm3 s500' is called from the mdi hParam == nil, if the 'm300 s500' is called from the mdi hParam ~= nil.
Does m3 get stripped of it's parameters?  If so why and how do you capture the requested s value?

function m3(hParam)
   if (hParam ~= nil) then
      wx.wxMessageBox('hParam~=nil')
   else
      wx.wxMessageBox('hParam==nil')
   end   

end

if (mc.mcInEditor() == 1) then
    m3()
end

function m300(hParam)
   if (hParam ~= nil) then
      wx.wxMessageBox('hParam~=nil')
   else
      wx.wxMessageBox('hParam==nil')
   end   

end

if (mc.mcInEditor() == 1) then
    m300()
end


tia

RT

58
Mach4 General Discussion / Actual Spindle Speed DRO delay
« on: November 13, 2017, 01:46:40 PM »
Running PMDX 411 and Gecko G540 on build 3481 on a lathe.

I have a cheap opto sensor on my spindle that works very well reporting the actual spindle speed as verified with a tach.

I noticed that when I issue a M5 that the Dro that shows the actual speed does not return to zero for about 3-5 seconds from the time that the spindle actually stops spinning.

Does anyone know if this is due to the opto, PMDX or Mach4 not updating?

I was using this DRO value to check to see if the spindle had overloaded and stopped and it was not disabling movement promptly.

Is there a better way to handle this? (I am electronically challenged so hopefully I don't have to create some citrcuit ;D)

TIA

RT

59
Mach4 General Discussion / Check if Enabled
« on: November 10, 2017, 03:28:24 PM »
What is the proper script language to check if Mach4 is currently enabled?

TIA

RT

60
Mach4 Plugins / Check if is enabled
« on: November 10, 2017, 01:49:07 PM »
What is the proper script language to check if Mach4 is currently enabled?

Pages: « 1 2 3 4 5 6 7 8 9 »