Hello Guest it is May 12, 2024, 03:14:58 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: mach 4 tool change
« on: January 04, 2019, 08:25:35 AM »
If you are using the stock tool change, it will require you to press cycle start to complete the tool change and then it will update the current tool dro.   Do some tests in mdi.
Also, are you turning on the tool height offsets?  G43 H T (T is current tool number)

362
Mach4 General Discussion / Re: get and set the G54 ,G55..
« on: January 03, 2019, 06:49:03 PM »
Did some more testing.
This is acting strange.
If you watch the status bar above the message bar; changing #4014 will update the Current Work Offset on the status bar, but it doesn't seem to change the core.
I set X offset for G54 to 1.00 G55 to 2.00 etc... and changed #4014 to 540, 550, 560, etc.. just to test all offsets, it won't update the position, it only changes what is displayed in the status bar.
So, I'm not really sure why you're able to change this and it update the status bar but not what Mach actually sees.

363
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.

364
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.

365
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.

366
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?

367
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.

368
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.  

369
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

370
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.