Hello Guest it is June 09, 2024, 10:35:27 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.


Messages - Steelbarz

Pages: 1 2 3 4 »
1
Mach4 General Discussion / Re: Script to Orientate Spindle
« on: March 22, 2024, 10:13:15 AM »
Check how we a servo on the spindle here:
https://www.cnc4pc.com/blog/post/configure-an-step-and-direction-servo-as-spindle-on-mach4-using-the-ethernet-smooth-stepper-and-c82

Thank you, that was last week's problem...lol just getting the spindle to work.  But now I am hoping to control the spindle so that I can position its orientation a set number degrees off the index mark.

2
Mach4 General Discussion / Re: Script to Orientate Spindle
« on: March 19, 2024, 02:32:41 PM »
Here is an example of the orientate macro we're running on one of our mills.

Thank you, That gave me the code to start and stop very helpful, but I still cant get it to stop on the index signal

3
Mach4 General Discussion / Script to Orientate Spindle
« on: March 18, 2024, 11:57:04 AM »
Does anyone have simple code or a macro to orient a spindle to a certain position.  My axis has encoders and spindle index signals all working and Mach4 can see them.  I can accurately control the spindle to 1rpm

I have Mach4 and ESS/MB3 if it helps

I would like it to do something like this:
Rotate spindle CW at 10rpm and when the index signal is high stop (effectively 0 degrees) then rotate spindle 90 degrees and stop and lock the spindle.


4
These instructions are for my setup which; if you are like me wanted a CNC then had to learn how to build one.  Hope this helps someone.

The Mill is a PM833TV which has been converted to CNC - The machine doesn't matter but this is what I am working with.
https://www.precisionmatthews.com/shop/pm-833tv-ultra-precision-milling-machine/

I use an MB3/ESS combination
https://cncroom.com/en/product/ess-mb3/

And for Servos the cheap generic ones available on eBay or AliExpress
https://www.ebay.com/itm/392911210777?var=661819044574

AASD 30 1.8Kw 3000rpm 6Nm Nema42 Servo is what I have – It will fit on the existing motor mount but you will have to drill and tap new holes for the mounting screws for the motor since they don’t line up with stock ones.

I got a new 5M 60T pulley for the servo so the spindle spins 1:1 and a matching 20mm, 5M-620mm belt
https://www.aliexpress.com/item/1005003661659624.html?spm=a2g0o.order_list.order_list_main.16.2e431802knRtHM
https://www.aliexpress.com/item/1005004218515558.html?spm=a2g0o.order_list.order_list_main.5.2e431802knRtHM

Also a 300W 200ohm Breaking Resistor:
https://www.aliexpress.com/item/32846478258.html?spm=a2g0o.order_list.order_list_main.40.2e431802knRtHM

The hardest part of this is getting the servo encoder to talk to the ESS/MB3 and all the settings that have to be input to make it work right.  Modifications to the MB3 board are required.  The encoder from The AASD servo controller outputs 5V so some soldering is needed so that the ESS/MB3 can see the pulses from the ASSD Servo.

Page 33 – This must be done or the MB3 won’t see the encoder pulses.  YES You have to do this.
https://cncroom.com/wp-content/uploads/downloads/MB3-Owner-Manual-E20R2.pdf

Close the solder-bridge for each input (X310/X311/X312/X313/X315) I use this group because the optocouplers on these inputs are fast compared to the others. (not all encoder outputs are used but I hooked them up anyway, I had the room YMMV). (I did all 5 to keep things simple but you can get away with soldering just 2 MB3 pins for A and B encoder signals just follow the manual to isolate the other 3)

Power these 5 ports with 5V! do not use 24V for this bank anymore.
Add a Jumper wire from CM.D to 5V – Very important!

Once that is done the wiring is simple Hook the wires from the AASD servo to the MB3 pins
MB3 > ASSD
X311   > P20      PA+   A Encoder signal output         
0V   > P19      PA-               
x312   > P18      PB+   B Encoder signal output         
0V   > P17      PB-            
X313   > P15      PZ+   Z Encoder signal output         
0V   > P16      PZ                  
Y310   > P22      OZ   Spindle Index signal output
0V   > P1              GND            

That’s it for the encoder now to make the servo work. Now wire the servo to the 6th motor axis (C) as a step and direction motor on the MB3.  It has to be Motor C since this is the channel that the MB3 will be considering the spindle with the settings made later.

MB3 > ASSD
CS+   > P3      PP+ STEP   
CS-   > P14   PP- STEP   
CD-   > P4      PD+ DIR   
CD+   > P5      PD- DIR

2 more wires are need for my setup
Y101   > P6      SigIN1: SRV-ON   - The signal that will turn the servo on - this can be done in the servo settings saving a pin on the MB3
X206   > P11   SigOUT1: Servo ready.

This wiring setup works for me   and is what I put together from reading tons of web articles.
Some parameters are required to be set in the servo drive.  The manual is challenging to understand but these are the only ones that I had to change.  A similar set up is used for all 3 Axis servos except the parts dealing with the encoders  and enabling the drive.

The encoder feedback 2500p/r,15 line increment model, differential output has been geared down to 100.            
Spindle Servo Parameters see the manual for how to change.
            
PN001   15   (the actual motor number 110st_m06030 – Yours may be different)         
PN002   2            
PN003   0   (Servo Enabled Y101 - P6 - Set to 1 to save a pin on the MB3.  Servo will always be on, wont rotate freely)      
PN005   5            
PN006   3

These setting change the pulse output of the encoder, so it does not overwhelm the ESS.  The encoder pulses at 2500 this will scale it down to 100 pulses per revolution.   
         
PN016   25   
PN017   4   
PN018   1

That takes care of the wiring and the servo drive now to configure the MB3/ESS.  We need to tell Mach4 that we have a new spindle and we hook it up as an SS Motor.

https://warp9td.com/index.php/gettingstarted/setting-up-the-smoothstepper-and-mach4#EssSpindle


In SS Motor Mode you will be able to make your spindle run as Step/Dir. SS Motor will automatically use MOTOR 5 for the spindle. You must assign motor tuning values to Motor 5 in the Mach Config, and then assign step and dir pins to motor 5 in the ESS Output Signals tab.  The SS Motor is preferred for Step/Dir mode compared to the Mach OB motor.

ESS plugin configuration.  My settings are:

SPINDLE TAB
SS Motor
Delay 0.010
Spindle Encoder A
Averaging 1.00
Yes to report spindle RPM
Prescaler 1
Effective PPR 100
Nothing changes in PID

PINS CONFIG
Port1 Pin1 – Active High – Spindle Enable (This can be set in the servo drive so the pin can be saved but you loose some safety I feel)
Step and direction pins are already set for the MB3
Port2 Pin 16 – Active low – CS (set to low so my spindle turns the right way)
Port 2 Pin 17 – Active High -  CD
These pins are for the encoders.
Port3 Pin 10 – X311 – Spindle Index
Port 3 Pin 11- X311 - PA+
Port 3 Pin 12- X312 - PB+
Port 3 Pin 13- X313 - PZ+

INPUT SIGNALS TAB
Encoder Spindle Phase A – X311
Encoder Spindle Phase B – X312
Spindle Index – X311 (you can use the signal from the servo index Pin22/Y310 or Phase Z but I didn’t)
Input11 – X206 (Any open input can be used but I used 11)

OUTPUT SIGNALS
Spindle ON – Enabled – Y101

Now to configure MACH4

GENERAL TAB
Enable – Feed hold stops spindle
Enable – Exiting Feed Hold Restores Spindle

MOTORS Tab
On Motor 5 my settings are
Counts Per Unit – 500
Velocity – 3000
Acceleration – 1000

AUX POSITIONS tab
Enable motor 5
Encoder – ESS/Encoders/ Encoder Spindle
(Do not enable motor 5 in AXIS MAPPING)

SPINDLE tab
On line 0
MAX RPM – 3000
Accel Time – 1
Decel Time – 1
Max Spindle Motor RPM – 3000
Spindle Override Delay – 25
Step/Dir – None
Enable – Enable Step/Dir spindle rigid tapping

That’s it, it should work. 

Then for fun I added this-
https://documentation.warp9td.com/Hardware/ESS/Software_Mach4/lua/luaEncoderInDegreesWithZero.htm

Thank you to everyone who added to the knowledge base so I could figure this out.  This is me trying to pay it forward.  Next project Rotary Axis A and a tool changer to supplement my power draw bar - what a great hobby.  Spend months and years building a machine and never make anything...lol.

5
Mach4 General Discussion / Re: Setting up and running surface mapping
« on: January 27, 2024, 12:53:24 PM »
For Reference I have these versions and surface mapping works.  Attached is a Picture of my 1st attempt once I got the probe to work.

Mach4 build 4089
ESS plugin 285
Screen Mach 5036
And I use an MB3 Board

If you cant download original files let me know I can send to you

6
Mach4 General Discussion / Re: Setting up and running surface mapping
« on: January 24, 2024, 03:28:59 PM »
Nice suggestion, I started from scratch. Backed everything up. Went to Warp9 sight to download the ESS plugin. Was reading over the install procedure again (it's been a while since I installed it). Ran across this notice-

NOTE!!!! Build 5000 is having probing issues with the ESS plugin... Mach4 Build 4809 with ESS 283 is what we are recommending at the moment. January 15th, 2023

ESS build 284 was released November 20th for use with Mach4 build 5000.  Not recommended at the moment

Seeing everything else is working good I think I'll wait until they get this bug fixed.
I wonder if ESS 284 will work with the new Mach4 build 50036 (284 is the ver. I am running)


Yes that's the thing that they're saying use a specific build number. Use the ESS plugin and the version of Mach they recommend right there and it works. Any other combination you'll be scratching your head for hours
On the flip side of that you can use the screen from the 5000 which is a little nicer than the mach version suggested

7
Mach4 General Discussion / Re: Setting up and running surface mapping
« on: January 24, 2024, 10:20:50 AM »
Finally had time today to hopefully get this figured out. I have entered the Z Start and Probe Distance. Same thing, the machine goes to home, the probe comes down and makes contact. The probe light comes on at the ESS board, but the probe never raises. It just drags it to the next position, stops, does not raise, then moves to the next position, over and over.
Thank you for the response, got any ideas?
Chris

I had the exact same issue it drove me absolutely nuts. What I ended up doing was a clean install with the recommended settings from the ESS website for which plug-in version and mach version to use. If I could figure out how to send you my profile I would cuz I know how frustrating it is. The other thing that helped at one point although I resolved was to add a little debounce to the probe trigger it would let me get two or three probe strikes before it failed LOL but it's definitely a plug-in for the ESS and Mach version issue.

8
This is the answer I came up with to my original post.

function m6()
   
-----------------------------------------------------------------------------
-- Name:        M6 Custom Tool Change Macro ESS/MB3 PM833TV Mill
-- Author:      Tom Millay (Steelbarz)
-- Modified by:
-- Created:     01/14/2024
-- Copyright:   (c) 2024 McMill Construction.
-- License:     BSD (Free as in REALLY free!)
-- Synopsis:    M6 too change macro that allows for semi autonoumous tool changes
--              with user promps to allow for customization on the fly of distance traveled.
-----------------------------------------------------------------------------

local inst = mc.mcGetInstance();
--mc.mcToolSetCurrent(inst, 2) -- DELETE THIS WHEN WORKS
local didStrike = 0

local touchPlateXPos = 12; --X position (in machine coord) of the touch plate
local touchPlateYPos = 169; --Y position (in machine coord) of the touch plate
local touchPlateHeight = 65 -- the hight of the tool setter off the table bed in MM
local SpindleNoseOnToolSetter = -387.66 -- if the spindle tip passes this the limits will trip
local SpindleNoseZlimitMinZ = -395 -- if the spindle tip passes this the limits will trip
local TableSurface = SpindleNoseOnToolSetter - touchPlateHeight -- -452.66

local toolChangeZ = -100; -- abs Z height to move the head for manual tool change by operator
local fColletAtProbeZCoordinate = -387.66; --This is the z position where the end of the spinde is about to touch the sensor, leave about 0.1in clearance
local noToolLen = 140; --Length to use if tool lenght = 0 (make sure NO tools can be longer than this);

local zRaiseForToolChange = -100;
local FinalSafeZ_AfterChange = -100;

local RapidRate =400 ---speed to move during positioning
local probeCode = "G31.1"; --G code of the probe to use
local fProbePrepSpeed = 50;
local fProbeSpeed = 50;
local ProbeOperationDistance = -160; -- Length of Probe move before giving up
local fExtraProbeDistance = 10;

--define motors mapping
local xAxisNb = 0;
local yAxisNb = 1;
local zAxisNb = 2;

--Track original X/Y/Z position
local orgX = mc.mcAxisGetPos(inst,xAxisNb);
local orgY = mc.mcAxisGetPos(inst,yAxisNb);
local orgZ = mc.mcAxisGetPos(inst,zAxisNb);



--------- Get machine position --------------
--function GetMachPos(Axis)
--   if (Axis == 'X') then
--      XMach = mc.mcAxisGetMachinePos(inst, mc.X_AXIS)
--   elseif (Axis == 'Y') then
--      YMach = mc.mcAxisGetMachinePos(inst, mc.Y_AXIS)
--   elseif (Axis == 'Z') then
--      ZMach = mc.mcAxisGetMachinePos(inst, mc.Z_AXIS)
--   end
--end

----------- Get Work position --------------
--function GetWorkPos(Axis)
--   if (Axis == 'X') then
--      XWork = mc.mcAxisGetPos(inst, mc.X_AXIS)
--   elseif (Axis == 'Y') then
--      YWork = mc.mcAxisGetPos(inst, mc.Y_AXIS)
--   elseif (Axis == 'Z') then
--      ZWork = mc.mcAxisGetPos(inst, mc.Z_AXIS)
--   end
--end


local requestedTool = mc.mcToolGetSelected(inst);
local newToolDesc = mc.mcToolGetDesc(inst,requestedTool);

local currenttool = mc.mcToolGetCurrent(inst);
local currentToolLen = mc.mcToolGetData(inst,mc.MTOOL_MILL_HEIGHT,currenttool);

------------------------------------------------------------------------------
xHomed = 1
yHomed = 1
zHomed = 1

--Ensure we are fully homed on all axises
local xHomed = mc.mcAxisIsHomed(inst,xAxisNb);
local yHomed = mc.mcAxisIsHomed(inst,yAxisNb);
local zHomed = mc.mcAxisIsHomed(inst,zAxisNb);
if (xHomed == 0 or yHomed == 0 or zHomed == 0)
then
   
   mc.mcCntlSetLastError(inst,"M6 – Tool change : At least one axis is not homed");
   mc.mcCntlEStop(inst);
   
return;
end


mc.mcCntlSetLastError(inst,"Machine is homed - Tool change may proceed.");
-----------------------------------------------------

mc.mcCntlSetLastError(inst,"M6 – Processing tool change from "..currenttool.." to "..requestedTool);

--Ensure a tool change is needed
if requestedTool == currenttool

then
   
   mc.mcCntlSetLastError(inst,"M6 – Current tool and Requested tool are the same, nothing to do");
   return;
   
end;

   

if (currentToolLen <= 0.1)
then
   currentToolLen = noToolLen;
   mc.mcCntlSetLastError(inst,"Tool length not identified default tool length being used :"..currentToolLen);
end

MyNum = wx.wxGetNumberFromUser("Confim current tool tip to spindle nose is LESS than", "Tool Length: Tip to spindle nose:", "Tool Length Confirmation", currentToolLen, 0, 300)--Default, min, max

  if (MyNum <= 0) then  --1 is cancel
   
      mc.mcCntlSetLastError(inst,"Tool Length not set.");
      mc.mcCntlEStop(inst);
   
       
   return
    
   elseif (MyNum >= 0.1) then
 
   currentToolLen = MyNum
   
    mc.mcCntlSetLastError(inst,"Tool Length set to: "..currentToolLen)
   
 end
 
 
    -------------------------------------------------
   ---AirBlast ON Script

   mc.mcCntlSetLastError(inst,"Air Blast On")
   
   local hsig2, rc2 = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT0) -- RELAY FOR TOOL SETTER AIR BLAST
   mc.mcSignalSetState(hsig2, 1); --sets OUTPUT_0 to True
   
   local ActivateSignalTime2 = 1000 --Time in milliseconds that we want the signal to be active.
   wx.wxMilliSleep(ActivateSignalTime2)
   
   mc.mcSignalSetState(hsig2, 0); --sets OUTPUT_0 to True
   mc.mcCntlSetLastError(inst,"Air Blast Off")

   -----------------
 
-----------------------
--Keep of copy of the current postion mode, units, feed as we are going to change them
local positionMode = mc.mcCntlGetPoundVar(inst,4003);
local units = mc.mcCntlGetPoundVar(inst,4006);
local feedRate = mc.mcCntlGetPoundVar(inst, 2134);


--Move Z to safe pos
MyNum = zRaiseForToolChange
MyNum = wx.wxGetNumberFromUser("Confim Z Movement and Movement over Tool Setter", "Z Axis will move spindle nose up to Z machine coordinate: ", "Z Movement Confirmation", zRaiseForToolChange, -600, 600)--Default, min, max

  if (MyNum == -1) then  --1 is cancel
   
      mc.mcCntlSetLastError(inst,"Z move cancelled");
      mc.mcCntlEStop(inst);   
       
   return
    
   elseif (MyNum < -1) then
      
   zRaiseForToolChange = MyNum
   mc.mcCntlSetLastError(inst,"Z Axis moving to :"..zRaiseForToolChange);
   
   --mc.mcCntlGcodeExecuteWait(inst,"G21 G90 G53 G1 Z"..zRaiseForToolChange.."\nM5 F"..700)
   mc.mcCntlGcodeExecuteWait(inst,"G21 G90 G53 G1 Z"..zRaiseForToolChange.." F"..700)
 
 end


   mc.mcCntlSetLastError(inst,"Moving tool over tool setter X"..touchPlateXPos.." Y"..touchPlateYPos);
   mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G1 X"..touchPlateXPos.." Y"..touchPlateYPos.." F"..RapidRate);


--Compute the z position we need to move the head before probing
--touchPlateHeight = 65
--fColletAtProbeZCoordinate = -388.0; --this is the lowest number the tool tip can be at b4 crashing

   local probestart = fColletAtProbeZCoordinate + fExtraProbeDistance + currentToolLen;
-------------------------------------------------------------------------------------------
   MyNum = probestart
   MyNum = wx.wxGetNumberFromUser("Confim Movement to Tool Setter", "Probing commencing.  Z Axis will move tool tip down to Z machine coordinate and probing will commence at: ", "Z Movement Confirmation", probestart, -600, 600)--Default, min, max

  if (MyNum == -1) then  --1 is cancel      
      
      mc.mcCntlSetLastError(inst,"Probe move cancelled");
      mc.mcCntlEStop(inst);      
         
   return
    
   elseif (MyNum < 0) then
   
   probestart = MyNum

-------------------------------------------------------------------------------------------
---- Crash Protection
-- touchPlateHeight = 65 -- the hight of the tool setter off the table bed in MM
-- SpindleNoseOnToolSetter = -387.66 -- if the spindle tip passes this the limits will trip
-- SpindleNoseZlimitMinZ = -395 -- if the spindle tip passes this the limits will trip
-- TableSurface = SpindleNoseToolSetter - touchPlateHeight
-- touchPlateHeight = 65 -- the hight of the tool setter off the table bed in MM
-- SpindleNoseOnToolSetter = -387.66 -- if the spindle tip passes this the limits will trip
-- SpindleNoseZlimitMinZ = -395 -- if the spindle tip passes this the limits will trip
-- TableSurface = SpindleNoseToolSetter - touchPlateHeight
   --local TipMath = (TableSurface - probestart)*-1
   
   --local TopOfTouchPlateMachineCoord = (TableSurface+touchPlateHeight) *-1
   
   --local OpenDistance = ((probestart*-1)-TopOfTouchPlateMachineCoord)
   
   --local TipMath = (TopOfTouchPlateMachineCoord + probestart) - touchPlateHeight
   TipMath = (probestart-SpindleNoseOnToolSetter)
   
   if (TipMath <= currentToolLen) then  --1 is cancel
      
         wx.wxMessageBox("Crash Detected.  Probe move cancelled.  Tool Length: "..currentToolLen.." is too long.");
         mc.mcCntlSetLastError(inst,"CRASH! tool change canceled");   
         
         return
       
   elseif (TipMath > currentToolLen) then
   
         mc.mcCntlSetLastError(inst,"PHEW!");
         mc.mcCntlSetLastError(inst,"Spindle Nose will be "..TipMath.."mm Above the Tool Setter when probing starts.");
         
   end
-------------------------------------------------------------------------------------------   
   
      
   local GCODE = "G90 G53 G31.1 G1 Z"..probestart.." F"..RapidRate
    GCODE = ""..GCODE.." \n G91 G0 Z0 F"..fProbePrepSpeed.." \n G91 G31.1 Z"..ProbeOperationDistance.." F"..fProbeSpeed

   mc.mcCntlSetLastError(inst,"Moving to probe position and probing");
   mc.mcCntlSetLastError(inst,"Spindle Nose will be "..TipMath.."mm Above the Tool Setter when probing starts.");
-- Move to probe position and probe   
   mc.mcCntlGcodeExecuteWait(inst,GCODE)
   TipMath = 0
   
 end    
-----------------------------------------------

   
--Make sure the probe made contact
didStrike = mc.mcCntlProbeGetStrikeStatus(inst);

if (didStrike == 0)
then
   
   mc.mcCntlSetLastError(inst,"Probe did not make contact");
   mc.mcCntlEStop(inst);
   return
   
end


mc.mcCntlSetLastError(inst,"Probe strike occured Tool Change to continue.");
--------------------------------------------------

-- Sets the height for the 1st tool
local currentToolZ = mc.mcAxisGetPos(inst,2);

-- Move Z back to safe pos for tool change
-------------------------------------------------------------------------------------------
MyNum = toolChangeZ

MyNum = wx.wxGetNumberFromUser("Confim Movement to Safe Z height", "Z Axis will move UP to Z machine coordinate: ", "Z Movement Confirmation", toolChangeZ, -600, 600)--Default, min, max

  if (MyNum == -1) then  --1 is cancel
   
      mc.mcCntlSetLastError(inst,"Move up to safe Z cancelled");
      mc.mcCntlEStop(inst);
   
       
   return
    
   elseif (MyNum < 0) then
      toolChangeZ = MyNum
      mc.mcCntlSetLastError(inst,"Moving to machine Z"..toolChangeZ);
      mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G1 Z"..MyNum.." F"..RapidRate..""); ;
      
 end    
   
   
   
-----------------------------------------------

--Prompt user

if (newToolDesc == "") then

   newToolDesc = "New Tool"
   
end



--------------------------------------------------------------



--Enter code here to activate Pnumatic Tool Changer
wx.wxMessageBox("Please change to tool number "..requestedTool.." ("..newToolDesc..") and press ENTER to continue");


--------------------------------------------------------------

--At this point, the tool has been changed, recalc new values
currenttool = requestedTool;
currentToolLen = mc.mcToolGetData(inst,mc.MTOOL_MILL_HEIGHT,currenttool);


-- Makes sure you dont crash the tool into the tool setter
if (currentToolLen <= 0.1)
then
   --currentToolLen = noToolLen;
   --mc.mcCntlSetLastError(inst,"No tool length identified, Default tool length being used: "..noToolLen);
   MyNum = noToolLen
   MyNum = wx.wxGetNumberFromUser("No tool length identified", "What is the length from spindle nose to tool tip?: ", "Tool length From Spindle Nose to Tool Tip", noToolLen, 0, 600)--Default, min, max


   currentToolLen = MyNum

end


--Calculate new tool probe Z
probestart = fColletAtProbeZCoordinate + fExtraProbeDistance + currentToolLen;
MyNum = probestart

MyNum = wx.wxGetNumberFromUser("Confim Movement to probing Z height", "Z Axis will move DOWN to Z machine coordinate: ", "Z Movement Confirmation", probestart, -600, 600)--Default, min, max

-------------------------------------------------------------------------------------------
---- Crash Protection
-- touchPlateHeight = 65 -- the hight of the tool setter off the table bed in MM
-- SpindleNoseOnToolSetter = -387.66 -- if the spindle tip passes this the limits will trip
-- SpindleNoseZlimitMinZ = -395 -- if the spindle tip passes this the limits will trip
-- TableSurface = SpindleNoseToolSetter - touchPlateHeight
-- touchPlateHeight = 65 -- the hight of the tool setter off the table bed in MM
-- SpindleNoseOnToolSetter = -387.66 -- if the spindle tip passes this the limits will trip
-- SpindleNoseZlimitMinZ = -395 -- if the spindle tip passes this the limits will trip
-- TableSurface = SpindleNoseToolSetter - touchPlateHeight
   --local TipMath = (TableSurface - probestart)*-1
   
   --local TopOfTouchPlateMachineCoord = (TableSurface+touchPlateHeight) *-1
   
   --local OpenDistance = ((probestart*-1)-TopOfTouchPlateMachineCoord)
   
   --local TipMath = (TopOfTouchPlateMachineCoord + probestart) - touchPlateHeight
   TipMath = (probestart-SpindleNoseOnToolSetter)
   
   if (TipMath <= currentToolLen) then  --1 is cancel
      
         wx.wxMessageBox("Crash Detected.  Probe move cancelled.  Tool Length: "..currentToolLen.." is too long.");
         mc.mcCntlSetLastError(inst,"CRASH! tool change canceled");   
         
         return
       
   elseif (TipMath > currentToolLen) then
   
         mc.mcCntlSetLastError(inst,"PHEW!");
         mc.mcCntlSetLastError(inst,"Spindle Nose will be "..TipMath.."mm Above the Tool Setter when probing starts.");
         
   end
-------------------------------------------------------------------------------------------   
--Move Z close the touch pad
-------------------------------------------------------------------------------------------
  if (MyNum == -1) then  --1 is cancel      
      
      mc.mcCntlSetLastError(inst,"Probe move cancelled");
      mc.mcCntlEStop(inst);      
         
   return
    
   elseif (MyNum < 0) then
   
   probestart = MyNum

   
   local GCODE = "G90 G53 G31.1 G1 Z"..probestart.." F"..RapidRate
    GCODE = ""..GCODE.." \n G91 G1 Z0 F"..fProbePrepSpeed.." \n G91 G31.1 Z"..ProbeOperationDistance.." F"..fProbeSpeed
   
   
    -------------------------------------------------
   ---AirBlast ON Script

   mc.mcCntlSetLastError(inst,"Air Blast On")
   
   local hsig2, rc2 = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT0) -- RELAY FOR TOOL SETTER AIR BLAST
   mc.mcSignalSetState(hsig2, 1); --sets OUTPUT_0 to True
   
   local ActivateSignalTime2 = 1000 --Time in milliseconds that we want the signal to be active.
   wx.wxMilliSleep(ActivateSignalTime2)
   
   mc.mcSignalSetState(hsig2, 0); --sets OUTPUT_0 to True
   mc.mcCntlSetLastError(inst,"Air Blast Off")

   -----------------    
   
--   GCODE = "G90 G53 G31.1 G1 Z"..probestart.." F"..fProbePrepSpeed
--    GCODE = ""..GCODE.." \n G91 G1 Z0 F"..fProbePrepSpeed.." \n G91 G31.1 Z"..ProbeOperationDistance.." F"..fProbeSpeed
   
--   GCODE = "G90 G53 G31.1 G1 Z"..probestart.." F"..fProbePrepSpeed
--    GCODE = ""..GCODE.." \n G91 G1 Z0 F"..fProbePrepSpeed.." \n G91 G31.1 Z"..ProbeOperationDistance.." F"..fProbeSpeed   
   mc.mcCntlSetLastError(inst,"Z Move down to probe position: "..probestart);
   mc.mcCntlSetLastError(inst,"Tool tip wil be "..TipMath.."mm above the table when probing starts.");
   mc.mcCntlGcodeExecuteWait(inst,GCODE)
   TipMath = 0
 end    
   
-----------------------------------------------
   -- Set Z to old tool probed Z for correct z height for new tool
   mc.mcAxisSetPos(inst,2,currentToolZ);
   
--Make sure the probe made contact
didStrike = mc.mcCntlProbeGetStrikeStatus(inst);

if (didStrike == 0)
then
   
   mc.mcCntlSetLastError(inst,"Probe did not make contact");
   mc.mcCntlEStop(inst);

end


mc.mcCntlSetLastError(inst,"Probe strike #2 occured Tool Change to continue.");
--------------------------------------------------

-- Change tool enditing
local rc = mc.mcToolSetCurrent(inst,requestedTool);
local newlyToolIdx = mc.mcToolGetCurrent(inst);

-- Move back to a safe Z position
MyNum = FinalSafeZ_AfterChange
MyNum = wx.wxGetNumberFromUser("Confim Movement to safe Z height", "Z Axis will move UP to Z machine coordinate: ", "Z Movement Confirmation", FinalSafeZ_AfterChange, -600, 600)--Default, min, max

  if (MyNum == -1) then  --1 is cancel
   
      mc.mcCntlSetLastError(inst,"Move up to Safe Z cancelled");
      mc.mcCntlEStop(inst);
   
       
   return
    
   elseif (MyNum < 0) then
   
   FinalSafeZ_AfterChange = MyNum
   

   mc.mcCntlSetLastError(inst,"Z Move UP to Safe Z: "..FinalSafeZ_AfterChange);
   
   mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G1 Z"..FinalSafeZ_AfterChange.." F"..RapidRate..""); -- Moves Z asis up to clear new tool
   

 end    
   
-----------------------------------------------

-- Move X/Y back to org

wx.wxMessageBox("Moving tool over original position X"..requestedTool.." Y"..orgY.." press ENTER to continue");
--fix this
mc.mcCntlSetLastError(inst,"Moving tool over original machine coordinates position X"..orgX.." Y"..orgY.."");
mc.mcCntlGcodeExecuteWait(inst, "G90 G1 X"..orgX.." Y"..orgY.." F"..RapidRate.."");
--mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G1 Z"..MyNum.." F"..RapidRate..""); ;
--Move to zero Z with new tool

wx.wxMessageBox("Moving tool tip to original Work Offset Z "..orgZ.." press ENTER to continue");
mc.mcCntlSetLastError(inst,"Moving tool original work coordinate Z "..orgZ.."");

mc.mcCntlGcodeExecuteWait(inst,"G90 G1 Z"..orgZ.." F"..RapidRate.."");; -- Move Z to org pos

--Restore Position mode, units & feed
mc.mcCntlSetPoundVar(inst,4003,positionMode);
mc.mcCntlSetPoundVar(inst,4006,units);
mc.mcCntlSetPoundVar(inst,2134,feedRate);

-- Execute some G code to force modal label UI to refresh
-- else, ui and interal settings are out of sync which can cause operator errors
mc.mcCntlGcodeExecuteWait(inst,"G"..units);


mc.mcCntlSetLastError(inst,"Tool Change Complete!");

end

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

9
Mach4 General Discussion / Re: Setting up and running surface mapping
« on: January 06, 2024, 02:46:39 PM »
in the "Traverse z" box enter the machine coordinates of the height you want the probe to move at (clears the surface at all points) in the "Max Prob dist" box put how far you want the probe to move from "traverse z" down to the surface.

10
Mach4 General Discussion / Re: m6 macro
« on: January 13, 2023, 10:29:10 PM »
The error attachment is the error on the m6.mcs bottom window box , after i load mach4 4809 ? . The 2 nd attachment is the m6 macro i copied from a mach 4 video on youtube. When i run a m6 command from MDI window , , it goes to the correct position in the script , but when i hit the OK to probe , it says it is probing but no movement from the Z axis and the diagnostic window on Mach 4  does not show the probe active . Is there something missing from the script ?  .  Mach 4 --Smoothstepper ESS -- Gecko 540  .

      Thanks

        Ed

Check out

https://www.machsupport.com/forum/index.php?topic=46818.msg294807#msg294807

Pages: 1 2 3 4 »