Hello Guest it is April 26, 2024, 10:31:10 AM

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 - Cbyrdtopper

361
Mach4 General Discussion / Re: get and set the G54 ,G55..
« on: January 03, 2019, 06:34:18 PM »
#4014 Is your current offset.
Did some testing.  You can change it, but it is a little weird...
Put this in MDI and it will change offset:  

#4014 = 540  Sets G54
#4014 = 550  Sets G55

I was writing a probing macro and found this information.
Starting at #4002 - #4018 there are several machine settings.

362
Mach4 General Discussion / Re: Mach4 Coolant Toogle Problems
« on: January 03, 2019, 06:28:53 PM »
Daniba73,
You have to make your e stop shut off outputs.
Put the input in your Signal Library just like an input. 
Then put the conditions, if E Stop = true or 1 then Turn stuff off.

363
Mach4 General Discussion / Re: Add or edit Mach4 Lathe screen
« on: January 02, 2019, 08:28:00 AM »
That right there is your example.  
You've figured it out with this example, however, instead of having it toggle coolant on and off, just keep it off.
So in your Reset Button Input, just add this part of code:

         local OSigCool = mc.mcSignalGetHandle (inst,mc.OSIG_COOLANTON)
         mc.mcSignalSetState(OSigCool,0)
         --mc.mcCntlSetLastError(inst, "Coolant Off")  --(this is just a message keep this if you like.)

This will turn it off and not toggle it on and off.

364
Mach4 General Discussion / Re: Auto tool z- probe
« on: January 02, 2019, 08:13:31 AM »
You have this input mapped to "Probe" in Mach4?

365
Mach4 General Discussion / Re: Axis 0 Commanded while disabled
« on: January 02, 2019, 08:10:41 AM »
I'm not sure.  From what you are saying, A, B, and C are set up as 0, 1, and 2; this should work.
Maybe go into the config and disable all other motors just to be sure.

366
Mach4 General Discussion / Re: Add or edit Mach4 Lathe screen
« on: January 02, 2019, 08:07:07 AM »
You have to add that functionality in the signal library for the your external reset button.  

367
Mach4 General Discussion / Re: Automatic tool change script/Macro?
« on: January 01, 2019, 01:20:27 PM »
I don't know where you found wx examples.  These are all .mcs files.
But, here is the code out of one of the examples.

function m6()

--Non-Random automatic tool changer
--This file assumes that you have G54 X0 Y0 Z0 to be setup as the Y-offset distance from tools and the correct height for picking
--up/dropping a tool as well as the correct X location for entering the tool changer.


----------Variables----------
local inst = mc.mcGetInstance() --Get the instance of Mach4

local hReg = 0

local ToolInColletSig = mc.ISIG_INPUT0 --These outputs/inputs will be configured by the user depending what outputs/inputs they have setup in Mach config.
local MotorSig = mc.OSIG_OUTPUT0
local CloseColletSig = mc.OSIG_OUTPUT1

local CurrentTool = mc.mcToolGetCurrent(inst)
local NextTool = mc.mcToolGetSelected(inst)
local YOffsetDistance = 14.25------------DEFINE Y OFFSET DISTANCE
local numtools = 4
local ToolPositionIO = {}
-----------------------------
function ToolChange(NextTool)
   --------------------------INPUT CHECKING-----------------------------
   if (NextTool > numtools) then
      return "That tool does not exist", false
   end
   
   hReg = 0 --reset hReg to 0 each time before reading it so you know if you get an error.
   hReg = mc.mcIoGetHandle(inst, ToolInColletSig)
   if hReg == 0 then
      return "Could not locate tool in collet signal!", false
   end
   
   hReg = 0
   hReg = mc.mcIoGetHandle(inst, MotorSig)
   if hReg == 0 then
      return "Could not locate motor signal!", false
   end
   
   for i = 1, numtools+1 do
      ToolPositionIO = 0
      ToolPositionIO = mc.mcIoGetHandle(inst, "Position"..tostring(i))
      if ToolPositionIO == 0 then
         return "Could not locate tool position signal!", false
        end
   end
   
   hReg = mc.mcIoGetHandle(inst, CloseColletSig)
   if hReg == 0 then
      return "Could not locate collet close signal!", false
   end
   ----------------------END INPUT CHECKING-----------------------------
   
   local rc = mc.mcIoGetState(ChuckhReg)
   if rc == 1 then --If rc equals 1, then there is a tool in the chuck
      --Put the tool away.
      rc = mcCntlGCodeExecuteWait(inst, "G54 X0 Y0 Z0") --Move to the offset zone.
      if rc ~= mc.MERROR_NOERROR then return "Could not complete GCode motion", false end
      --We are now at the offset line, and need to move the correct Y Distance so we can drop off the tool.
      mcCntlGCodeExecuteWait(inst, "G91 Y"..YOffsetDistance)
      if rc ~= mc.MERROR_NOERROR then return "Could not complete GCode motion", false end
      
      hReg = 0
      hReg = mc.mcIoGetHandle(inst, CloseColletSig)
      if hReg == 0 then
         return "Could not locate close collet signal!", false
      end
      mc.mcIoSetState(hReg, 0) --Release the tool
      mcCntlGCodeExecuteWait(inst, "G54 X0 Y0 Z0")--Move back to the offset line
      if rc ~= mc.MERROR_NOERROR then return "Could not complete GCode motion", false end
   else
      mcCntlGCodeExecuteWait(inst, "G54 X0 Y0 Z0")--Move to the offset line
      if rc ~= mc.MERROR_NOERROR then return "Could not complete GCode motion", false end
   end
   
   --At this point, we are at the offset line, and there is no tool in the chuck.   
   hReg = 0
   hReg = mc.mcIoGetHandle(inst, MotorSig)
   if hReg == 0 then
      return "Could not locate motor signal!", false
   end
   mc.mcIoSetState(hReg, 1) --Turn on the motor until we are at the desired tool change position.
   
   local loop = true
   while(loop == true) do
      local a,b = mcIoGetState(ToolPositionIO[NextTool])
      if(b == true) then
         if(a == true) then
            loop = false   
            hReg = 0
            hReg = mc.mcIoGetHandle(inst, MotorSig)
            if hReg == 0 then
               return "Could not locate motor signal!", false
            end
            mc.mcIoSetState(hReg, 0)--the tool changer is now rotated to the correct location.
                                  --so we turn off the motor.
         else
            wx.wxMilliSleep(100) --Sleep for 100 milliseconds, and then recheck input.
         end
      else
         hReg = 0
         hReg = mc.mcIoGetHandle(inst, MotorSig)
         if hReg == 0 then
            return "Could not locate motor signal!", false
         end
         mc.mcIoSetState(hReg, 0)
         return "Unable to get state of motor IO", false
      end
   end
   
   mcCntlGCodeExecuteWait(inst, "G91 Y"..YOffsetDistance) --Move into the tool changer
   if rc ~= mc.MERROR_NOERROR then return "Could not complete GCode motion", false end
   
   hReg = 0
   hReg = mc.mcIoGetHandle(inst, CloseColletSig)
   if hReg == 0 then
      return "Could not locate collet close signal!", false
   end
   mc.mcIoSetState(hReg, 1) --grab the tool.
   
   mcCntlGCodeExecuteWait(inst, "G54 X0 Y0 Z0")--Move back to the offset line
   if rc ~= mc.MERROR_NOERROR then return "Could not complete GCode motion", false end
   return "Tool change complete!", true
end

local a, b = ToolChange(NextTool)
mc.mcCntlSetLastError(tostring(a))--Prints status of tool change.
if(b == true) then
   mc.mcToolSetCurrent(inst, NextTool)
end

end
if (mc.mcInEditor() == 1) then
   dofile ("load_modules.mcs")
    m6()
end

368
You can try and put some code in the PLC Script that will continuously update a DRO with your RPM Result. 
If you can figure out the formula to get the Velocity into RPM then you can put that result in a DRO.  It will update on every PLC Scan.   

369
Mach4 General Discussion / Re: Automatic tool change script/Macro?
« on: January 01, 2019, 11:45:24 AM »
Hello,
In the Mach4 Folder on your computer there is a folder called "LuaExamples".  In this folder there is another folder called "Toolchanger"  Check those codes out and see if they can give you a good starting place.  Once you look at those and get a baseline, this forum can be very helpful, a lot of great people on here.

370
Mach4 General Discussion / Re: Mach 4 not stopping at manual tool change
« on: January 01, 2019, 11:39:47 AM »
I am using the stock tool change m6 on a mill at work.  It works fine for me.  Do as Craig suggests and do some testing to be sure you have the T as Next Tool like Craig and Stuart have suggested.

Also, there is a Mach4 fusion post processor.  I asked Autodesk to add a G30 option instead of G28 and they got it put in the post for me.  This way you can set a Custom Rest Position to your machine.  I don't like my Z going to Z home at every tool change, so I made my G30 Z position about 8 inches below home and G30 X position in the middle of the travel for the end of program.