Hello Guest it is March 19, 2024, 01:12: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 - jevs

Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 »
91
This works, but it will stop doing the incremental move when you let off the button even if it has not finished the distance commanded. I know it is doing it because it instantly issues a velocity stop when you let go.
However, what is a good way to let this wait for the incremental move to get done?
I may need to revamp this layout for it to work, but it is almost there.....

Code: [Select]
[mc.ISIG_INPUT51] = function (state)
    if(state == 1) then
CPJogPlus()
else
rc=mc.mcJogVelocityStop(inst,0)
rc=mc.mcJogVelocityStop(inst,1)
rc=mc.mcJogVelocityStop(inst,2)
end
end,
--Control Panel Jogging +
function CPJogPlus()
local in44, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT44)
local axSelX = mc.mcSignalGetState (in44)
local in45, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT45)
local axSelY = mc.mcSignalGetState (in45)
local in46, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT46)
local axSelZ = mc.mcSignalGetState (in46)
local in47, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT47)
local axSel4 = mc.mcSignalGetState (in47)
local in48, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT48)
local axSel5 = mc.mcSignalGetState (in48)
local in49, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT49)
local axSel6 = mc.mcSignalGetState (in49)
local in19, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT19)
local jogSel1 = mc.mcSignalGetState (in19)
local in20, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT20)
local jogSelx1 = mc.mcSignalGetState (in20)
local in21, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT21)
local jogSelx01 = mc.mcSignalGetState (in21)
local in22, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT22)
local jogSelx001 = mc.mcSignalGetState (in22)
local in23, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT23)
local jogSelx0001 = mc.mcSignalGetState (in23)
local in24, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT24)
local contJog2 = mc.mcSignalGetState (in24)
local in25, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT25)
local contJog5 = mc.mcSignalGetState (in25)
local in26, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT26)
local contJog10 = mc.mcSignalGetState (in26)
local in27, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT27)
local contJog25 = mc.mcSignalGetState (in27)
local in28, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT28)
local contJog50 = mc.mcSignalGetState (in28)
local in29, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT29)
local contJog75 = mc.mcSignalGetState (in29)
local in30, rc = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT30)
local contJog100 = mc.mcSignalGetState (in30)
if axSelX == 1 and jogSel1 == 1 then
rc = mc.mcJogIncStart(inst,0,1)
elseif axSelX == 1 and jogSelx1 == 1 then
rc = mc.mcJogIncStart(inst,0,.1)
elseif axSelX == 1 and jogSelx01 == 1 then
rc = mc.mcJogIncStart(inst,0,.01)
elseif axSelX == 1 and jogSelx001 == 1 then
rc = mc.mcJogIncStart(inst,0,.001)
elseif axSelX == 1 and jogSelx0001 == 1 then
rc = mc.mcJogIncStart(inst,0,.0001)
elseif axSelY == 1 and jogSel1 == 1 then
rc = mc.mcJogIncStart(inst,1,1)
elseif axSelY == 1 and jogSelx1 == 1 then
rc = mc.mcJogIncStart(inst,1,.1)
elseif axSelY == 1 and jogSelx01 == 1 then
rc = mc.mcJogIncStart(inst,1,.01)
elseif axSelY == 1 and jogSelx001 == 1 then
rc = mc.mcJogIncStart(inst,1,.001)
elseif axSelY == 1 and jogSelx0001 == 1 then
rc = mc.mcJogIncStart (inst,1,.0001)
elseif axSelZ == 1 and jogSel1 == 1 then
rc = mc.mcJogIncStart(inst,2,1)
elseif axSelZ == 1 and jogSelx1 == 1 then
rc = mc.mcJogIncStart(inst,2,.1)
elseif axSelZ == 1 and jogSelx01 == 1 then
rc = mc.mcJogIncStart(inst,2,.01)
elseif axSelZ == 1 and jogSelx001 == 1 then
rc = mc.mcJogIncStart(inst,2,.001)
elseif axSelZ == 1 and jogSelx0001 == 1 then
rc = mc.mcJogIncStart(inst,2,.0001)
elseif axSelX == 1 and contJog2 == 1 then
rc = mc.mcJogSetRate(inst,0,2)
rc = mc.mcJogVelocityStart(inst,0,1)
elseif axSelX == 1 and contJog5 == 1 then
rc = mc.mcJogSetRate(inst,0,5)
rc = mc.mcJogVelocityStart(inst,0,1)
elseif axSelX == 1 and contJog10 == 1 then
rc = mc.mcJogSetRate(inst,0,10)
rc = mc.mcJogVelocityStart(inst,0,1)
elseif axSelX == 1 and contJog25 == 1 then
rc = mc.mcJogSetRate(inst,0,25)
rc = mc.mcJogVelocityStart(inst,0,1)
elseif axSelX == 1 and contJog50 == 1 then
rc = mc.mcJogSetRate(inst,0,50)
rc = mc.mcJogVelocityStart(inst,0,1)
elseif axSelX == 1 and contJog75 == 1 then
rc = mc.mcJogSetRate(inst,0,75)
rc = mc.mcJogVelocityStart(inst,0,1)
elseif axSelX == 1 and contJog100 == 1 then
rc = mc.mcJogSetRate(inst,0,100)
rc = mc.mcJogVelocityStart(inst,0,1)
end
end

92
Nevermind....I got it working!

Somehow I lost my pin assignment in the pokeys plugin for 44....or I forgot to turn it on. So simple and so much time wasted. Grr, my fault.

However I am also changing the way I am doing this. I am going to have the jog+ button and Jog- minus Siglib checks call up functions CPJogPlus() and CPJogMinus()......

In all of this digging and pulling hair, I learned how to make the switch state changing go to a function rather than trying to put the code within the siglib.....

This seems like a good win for the night and a good place to go to bed not frustrated :)

93
Please tell me why this will not work?
I am just trying to make my +Jog physical switch jog the X axis 1 inch when pressed IF the selector switch is in the X position (input 44 is on) and the Step Jog switch is set to x1 (input 19 is on). I am sure this should be and probably will be simple for a couple of you, but something so basic should not be so ridiculous to figure out. The switches are going through a Pokeys 57E and are registering properly with Pokeys Monitor (green when in position or pressed on, and white when not). I have the pokeys input pin number assigned to the same input number in the Mach4 settings.

Code: [Select]
[mc.ISIG_INPUT51] = function (state)
    if(state == 1) then
local inst = mc.mcGetInstance()
local XSelected = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT44)
local axSelX = mc.mcSignalGetState (XSelected)
local x1 = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT19)
local jogSel = mc.mcSignalGetState (x1)
if (axSelX == 1) and (jogSel == 1) then
rc = mc.mcJogIncStart(inst,0,1)
end
end
end,

If I get rid of these lines then it will jog 1 inch, but this defeats what I need:
local inst = mc.mcGetInstance()
local XSelected = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT44)
local axSelX = mc.mcSignalGetState (XSelected)
local x1 = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT19)
local jogSel = mc.mcSignalGetState (x1)
if axSelX == 1 and jogSel == 1 then 

Basically omitting the IF stuff where it does not check the other switches, then it will jog an inch. I just cannot get the If statements to work based on the input status of the other two switches no matter what I try so far.

One thing that is irritating is that you cannot use debug, it skips over these siglib and I just seem to get Nil values to show (when I have not created an error trying something).

94
I guess never mind. I exited out of Mach4 and came back in, now it works.....

95
Mach4 General Discussion / How to make an input do an incremental jog?
« on: August 22, 2019, 10:40:23 PM »
I cannot get a physical button to do an incremental jog. All the code I try does nothing.

Putting this kind of stuff in the screen script
Code: [Select]
[mc.ISIG_INPUT51] = function (state)
    if( state == 1) then
--rc = mc.mcJogSetType(inst,0,MC_JOG_TYPE_INC)
--rc = mc.mcJogSetInc(inst,0,.01)
rc = mc.mcJogIncStart(inst,0,.01)
--else
--rc = mc.mcJogIncStop(inst,0)
end
end,

I tried different versions of this and nothing seems to work. I know some stuff is commented out here, but I was trying different things and had to give up for the night.
I did get constant move to work kinda, but not incremental. I just need to get this to work, then I have to figure out how to make it work for all the different jog settings somehow. I also need to figure out how to do a function when two input signals are active and not just one...

96
I am trying to figure out how to set this up.
My pendant has a rotary switch for the axis selection (Off, X,Y,Z,4,5,6)
These 7 positions operate on 3 Pokeys inputs as follows (0=Off 1=On)

           Pin7   Pin3    Pin4
OFF       0        0        0
X           0        0        1
Y           0        1        0
Z           0        1        1
4           1        0        0
5           1        0        1
6           1        1        0

How would I make this work? It used to work with the Mach3 setup, but that was using a Machmotion plugin.

I also do not want these to take any action unless the "Deadman" or Pendant Enable Switch is on (Pin 12).

I am not sure if I should be trying to handle this with LUA code in Mach4 somewhere, or using the Pokeys plugin, or a combination of both.

I an get the MPG to work and select X and Y using the Pokeys Pendant settings, but there is no option to make an axis select with two pins being active, so that seems to be a bust.


I replaced the Pokeys 55 with a 57E and all the inputs work as they did with the 55, but now I seem to be on the fun part of getting it all to work from here. I have the E-Stop, Cycle Start, and Feed Hold working as they should, but I got stuck on this "Matrix" for the pendant axis switch. Everything else has single inputs (including the axis selector on the control panel).

I attached a spreadsheet of what I mapped out...

97
Mach4 General Discussion / Re: when to use rc = ?
« on: August 07, 2019, 09:07:17 PM »
So are you just monitoring the number of the variable rc = in the stack window with each line to see if returns something other than 0 that correlates to the code list (all negatives I believe).

98
Mach4 General Discussion / when to use rc = ?
« on: August 07, 2019, 07:00:16 PM »
Can someone point me to some information that explains where and when to use the rc = ?

I have been muddling through my code, but just ran into something where it would not seemingly work in simulation mode, but does work on the real machine. Adding in the rc =  seemed to fix it. On the simulation it would complete the line of code, but then just hang there for no apparent reason.

If it has the "rc =" in the LUA Syntax part of the API help for that command, does that mean I should use it anywhere that I use that API code?


99
Mach4 General Discussion / Re: Tool Table and Tool Changer question
« on: August 07, 2019, 01:15:56 AM »
The tool changer is working good now. I just finished and live tested the M6 tonight :)

I just have to decide if I want to change anything for auto tool height setting or dealing with more than 7 tools. I have never done either of these scenarios.

I will probably move on to figuring out the pokeys 57e conversion next.

Code: [Select]
function m6()

local inst = mc.mcGetInstance()
local selectedTool = mc.mcToolGetSelected(inst) --Gets selected tool
selectedTool = math.tointeger(selectedTool) --Converts selected tool to integer
local currentTool = mc.mcToolGetCurrent(inst) --Gets currently loaded tool
currentTool = math.tointeger(currentTool) --Converts currenlty loaded tool to integer

--Get positions before moving to do tool change
local valX, rc = mc.mcAxisGetMachinePos(inst, 0, mc.X_AXIS) --Get the position of the X axis in Machine Position
local valY, rc = mc.mcAxisGetMachinePos(inst, 1, mc.Y_AXIS) --Get the position of the Y axis in Machine Position
local valZ, rc = mc.mcAxisGetMachinePos(inst, 2, mc.Z_AXIS) --Get the position of the Z axis in Machine Position

--Turns off the spindle (includes decel time)
rc = mc.mcCntlGcodeExecuteWait(inst, "M05")

--Checks current tool to make sure it is a valid tool (1-7)
--Displays error and leaves M6 if not.
if (currentTool < 1) or (currentTool > 7) then
mc.mcCntlSetLastError(inst, "Current Tool Number Is Not Valid - Set To Current Tool Position (1-7)")
return
end

--Checks selected tool to make sure it is a valid tool (1-7)
--Displays error and leaves M6 if not.
if (selectedTool < 1) or (selectedTool > 7) then
mc.mcCntlSetLastError(inst, "Requested Tool Number Is Invalid - Select Valid Tool (1-7)")
return
end

--Displaces message if no tool change is needed
if selectedTool == currentTool then
mc.mcCntlSetLastError(inst, "This Tool Is Already Loaded - No Action Taken")

--Changes tool if needed
else
--Move the Z axis up
mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G0 Z0.0")

--Move the X & Y to tool height setter area
mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G0 X19.53 Y14.45")

-- turn off Z soft limit
    mc.mcSoftLimitSetState(inst, mc.Z_AXIS, mc.MC_OFF)

--Create variable for cycles
local changeNums=0

--Cycles the tool changer the correct number of times if selected tool is lower than current tool
if selectedTool > currentTool then
for changeNums = 1,(selectedTool-currentTool) do

--Moves Z to the top of the tool change area
mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G1 F70 Z5.775")

--Moves Z to the bottom of the tool change area
mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G1 F70 Z3.750")
end

-- Move back to Z home
mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G1 F70 Z0")

-- turn Z soft limit back on
mc.mcSoftLimitSetState(inst, mc.Z_AXIS, mc.MC_ON)

--Move back to X & Y initial location
mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G0 X" .. tonumber(valX) .. "Y" .. tonumber(valY))

--Message display tool status
mc.mcCntlSetLastError(inst, "Current tool == " .. tostring(selectedTool) .. "   Previous Tool == " .. tostring(currentTool))

--Sets the current tool to the new tool value
mc.mcToolSetCurrent(inst, selectedTool)

--Cycles the tool changer the correct number of times if selected tool is higher than current tool
else
for changeNums = (currentTool-selectedTool),6 do

--Moves Z to the top of the tool change area
mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G1 F70 Z5.750")

--Moves Z to the bottom of the tool change area
mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G1 F70 Z3.800")
end

-- Move back to Z home
mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G1 F70 Z0")

-- turn Z soft limit back on
mc.mcSoftLimitSetState(inst, mc.Z_AXIS, mc.MC_ON)

--Move back to X & Y initial location
mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G0 X" .. tonumber(valX) .. "Y" .. tonumber(valY))

--Message displace tool status
mc.mcCntlSetLastError(inst, "Current tool == " .. tostring(selectedTool) .. "   Previous Tool == " .. tostring(currentTool))

--Sets the current tool to the new tool value
mc.mcToolSetCurrent(inst, selectedTool)
end
end

end

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

100
I just figured out something that works.....

Code: [Select]
--Get positions before moving to do tool change
local valX, rc = mc.mcAxisGetMachinePos(inst, 0, mc.X_AXIS) --Get the position of the X axis in Machine Position
local valY, rc = mc.mcAxisGetMachinePos(inst, 1, mc.Y_AXIS) --Get the position of the Y axis in Machine Position

--Move back to X & Y initial location
mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G0 X" .. tonumber(valX) .. "Y" .. tonumber(valY))
   
abbreviated from my code, but this works! Took me about an hour and half to figure this out though...

Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 »