Hello Guest it is March 29, 2024, 03:21:08 AM

Author Topic: Adding Physical button check code Take 2  (Read 714 times)

0 Members and 1 Guest are viewing this topic.

Offline DAAD

*
  •  103 103
    • View Profile
Adding Physical button check code Take 2
« on: December 30, 2020, 10:42:47 AM »
At the moment i'm implementing some Physical buttons for easier acces to some of my most used functions.

2 of them are Park and goto zero, both of the use an input signal from the button to run some g code.
Problem is that it's possible to press both buttons after each other which is no good news for my machine!

I've tried to solde this with an axisisstill api, but it's not working smoothly at the moment. If i press the button when the machine moves, it does what it's need to do (nothing + return error axis moving). But when i press the button when the machine is not moving, it starts whit a little yerk and moves into the correct spot. But it also returns the error "machine is moving"

I've already added a millisleep, to overcome this, but the problem persists.

Any idea howto implement this the correct way?

Code: [Select]
mc.ISIG_INPUT4 = Function (state) -- Park Button

local MotorIsStillX = mc.mcAxisIsStill (inst, 1)
local MotorIsStillXs = mc.mcAxisIsStill (inst, 3)
local MotorIsStillY = mc.mcAxisIsStill (inst, 0)

if (( state==1) and (MotorIsStillX == 1) and (MotorIsStillXs == 1) and (MotorIsStillY == 1)) then
wx.wxMillisleep (500)
local msg = " G00 G53 X3100 Y1200"
mc.mcCntlSetLastError(inst, "Goto Park")
mc.mcCntlGcodeExecute(inst, msg)

else

mc.mcCntlSetLastError (inst, "Machine is moving")

end
end,





Keep Safe & Best wishes for the year to come!

Adam
Re: Adding Physical button check code Take 2
« Reply #1 on: December 31, 2020, 11:17:54 AM »
Better way would be to look at the state machine in Mach4.. You can see if you are in Idle or not.
Fixing problems one post at a time ;)

www.newfangledsolutions.com
www.machsupport.com

Offline DAAD

*
  •  103 103
    • View Profile
Re: Adding Physical button check code Take 2
« Reply #2 on: January 04, 2021, 05:40:06 AM »
Thanks for the pointer!

Machine setup and working as i want.

Many thanks