Hello Guest it is March 29, 2024, 10:02:56 AM

Author Topic: Reference all home help.  (Read 11217 times)

0 Members and 1 Guest are viewing this topic.

Reference all home help.
« on: November 27, 2017, 04:12:39 PM »
Hello. Would anyone be able to help me piece together a simple homing script. Clicking reference all home homes all axiis X Y Z. Great. How can i have X then move like 10 inches to center the table? seems pretty simple and is pretty normal on industrial machines.... i found some mention of using something like a Gcode execute in the homing sequence in load screen? nothing seems to work and anything mach4 / lua "noob" documentation is few and far between... :-\  I have successfully got psychical cycle start feed hold stop buttons programmed and working (cant figure out single block tho..) Any help with getting this thing working correctly would be so awesome.!

- Nick

Pictures of my machine build for internist!!





Re: Reference all home help.
« Reply #1 on: November 28, 2017, 01:26:16 AM »
Hi,
very clean tidy build, congratulations.

Couple of ways to do want you want:
1) Add code to the Ref All Home script
2) Add a button that goes to the center of the table

I think in the first instance I would add a button. Gives you the chance to do some coding without modifying too greatly any existing functions of Mach.
If you screw it up just delete your work and Mach is back to normal. Once you've got the code spot on and had a chance to use it you could then graft it
onto the Ref All Home script if you still think it desirable.

I don't know what screenset you use, mine is based on wx4.set. Immediately under the DRO block on the Program Run Tab there are five buttons and a couple of
LEDs. One of the buttons is blank. May I suggest using it....rename it and attach your code. You can make your own button of course but the screen is already pretty full,
its not easy trying to squeeze another button in anywhere.

Your machine looks like its got a button block, if there is a spare one you could use that instead or even as well as a screen button.

Does that idea appeal?

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Reference all home help.
« Reply #2 on: November 28, 2017, 01:37:03 AM »
Hi,
go to Edit screen I renamed the button...

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Reference all home help.
« Reply #3 on: November 28, 2017, 07:01:02 PM »
Hello Joeaverage! Thanks for the response. I will fill you in with where Im currently at in my "lua" journey. Wx4 screen set.

I have psychical Cycle start, feed hold, stop buttons coded and working as they should..  I also have coolant and "mist" buttons working correctly and triggering mach. Single block appears to work as well! Everything I have come up with so far is self modified / figured out versions of code that i have copied from around the web. After much head scratching i have made some small success. I will post all the code i have currently to make the buttons work, could you look at them and see if anything is crazy out of sorts? Everything appears to be working great.

The Homing part is what i do not understand. I like you idea for mapping to to one of my spare buttons on the HMI. I would like for the script to be in the homing sequence so it does it automatically... regardless of how it happens is the code the same? Something like after homing, X axis moves to center of table and Y axis moves a few inches... "reference complete". I sure do appreciate you time, let me know what you thoughts are!

The picture you posted.. Did you create this button? or is this a factory feature I'm not seeing?

Thanks again - Nick


SigLib = {
[mc.OSIG_MACHINE_ENABLED] = function (state)
    machEnabled = state;
    ButtonEnable()
end,

[mc.ISIG_INPUT0] = function (state)
    if (state == 1) then
        CycleStart()
    end
   
end,

[mc.ISIG_INPUT1] = function (state)
   if (state == 1) then   
        mc.mcCntlFeedHold (inst)
        mc.mcCntlSetLastError (inst, "Do Feed Hold")
    end

end,

[mc.ISIG_INPUT2] = function (state)
    if (state == 1) then
        CycleStop()
    end

end,






----------Input 3------------
------Toggle Coolant---------
[mc.ISIG_INPUT3] = function (state)
if (state == 1) then
     local inst = mc.mcGetInstance();
     local sigh = mc.mcSignalGetHandle(inst, mc.OSIG_COOLANTON);
     local sigState = mc.mcSignalGetState(sigh);
     if (sigState == 0) then
         local OSigCool = mc.mcSignalGetHandle (inst,mc.OSIG_COOLANTON)
         mc.mcSignalSetState(OSigCool,1)
         mc.mcCntlSetLastError(inst, "Coolant On")
     else
         local OSigCool = mc.mcSignalGetHandle (inst,mc.OSIG_COOLANTON)
         mc.mcSignalSetState(OSigCool,0)
         mc.mcCntlSetLastError(inst, "Coolant Off")
     end
end
   
end,

----------Input 4------------
------Toggle MIST - AIR Coolant---------
[mc.ISIG_INPUT4] = function (state)
if (state == 1) then
     local inst = mc.mcGetInstance();
     local sigh = mc.mcSignalGetHandle(inst, mc.OSIG_MISTON);
     local sigState = mc.mcSignalGetState(sigh);
     if (sigState == 0) then
         local OSigMist = mc.mcSignalGetHandle (inst,mc.OSIG_MISTON)
         mc.mcSignalSetState(OSigMist,1)
         mc.mcCntlSetLastError(inst, "Mist On")
     else
         local OSigMist = mc.mcSignalGetHandle (inst,mc.OSIG_MISTON)
         mc.mcSignalSetState(OSigMist,0)
         mc.mcCntlSetLastError(inst, "Mist Off")
     end
end
   
end,

----------Input 5------------
------Toggle SingleBlock---------
[mc.ISIG_INPUT5] = function (state)
if (state == 1) then
     local inst = mc.mcGetInstance();
     local sigh = mc.mcSignalGetHandle(inst, mc.OSIG_SINGLE_BLOCK);
     local sigState = mc.mcSignalGetState(sigh);
     if (sigState == 0) then
         local OSigSingle = mc.mcSignalGetHandle (inst,mc.OSIG_SINGLE_BLOCK)
         mc.mcSignalSetState(OSigSingle,1)
         mc.mcCntlSetLastError(inst, "Single Block On")
     else
         local OSigSingle = mc.mcSignalGetHandle (inst,mc.OSIG_SINGLE_BLOCK)
         mc.mcSignalSetState(OSigSingle,0)
         mc.mcCntlSetLastError(inst, "Single Block Off")
     end
end
   
end,
Re: Reference all home help.
« Reply #4 on: November 28, 2017, 07:11:30 PM »
Hi,
no the button was already there but not named or assigned any function. I just renamed it.

Allows you to 'hang some code on it'. Whether you use a physical button or a screen button you will need some
code and it ocurred to me that this is a simple way to do it. Given that you've got your head around the signal scrpit/lib
then this code will be very very simple.

At work at the moment so won't try to write code on the fly. Will post some ideas tonite.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Reference all home help.
« Reply #5 on: November 28, 2017, 07:34:45 PM »
Awesome!!! Thanks Craig. Look forward to hearing from you!  - Nick
Re: Reference all home help.
« Reply #6 on: November 29, 2017, 01:01:19 AM »
Hi,
couple of preliminary items:
1) If the machine has not been referenced you CAN'T use the Go_Center function. When you first turn Mach on the machine co-ordinates could be any where.
If the machine drives to a specific machine co-ordinate location it could easily go outside its envelope and crash. Soft Limits won't help either as they ONLY make
sense and do any good once the machine has been referenced.
2) You will direct the machine to execute some Gcode but if one of the axes is not enabled then the machine can't do as you've asked and it will hang up and
you'll have to crash it to get it to unblock, not desirable. Before executing Gcode need to establish that all required axes have been enabled so the code doesn't block.
3) The machine co-ordinates of the center of the table should be held in registers. It makes it easy to tweak, just edit a register rather than delve into a script.
4) The Go_Center function should probably go in the screen load script rather than the signal script or a macro, the screen load script functions are visible throughout
Machs GUI. Having said that I propose to write it as a macro initially, it allows a convenient set of editing and debug functions.

Two API calls of use to us:
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Reference all home help.
« Reply #7 on: November 29, 2017, 01:03:50 AM »
Hi,
oops... posted before I'd completed...

Quote
LUA Syntax:
enabled, rc = mc.mcAxisIsEnabled(
      number mInst,
      number axisId)

and:
Quote
LUA Syntax:
homed, rc= mc.mcAxisIsHomed(
      number mInst,
      number axisId)

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Reference all home help.
« Reply #8 on: November 29, 2017, 01:28:52 AM »
Craig,

Lua is mostly greek to me, I have made it this far via trail error / copy paste. With that being said I'm hopeful.

This "go to center" function will only happen when the machine is homed. Like the machine is homed and ready to work.

I know nothing of registers currently, would this be apposed to something like G0 X10 Y-10 in the code?

What ever you recommend im all ears on how best to get it done. Warpt9 ess instructions say "a lua script is necessary to back of home switches after homing" I believe mach3 had this functionality, home axis.. back off prescribed amount. only on homing.
Re: Reference all home help.
« Reply #9 on: November 29, 2017, 02:36:19 AM »
Hi,
writing code as we speak.

Yes the function can only work IF the machine has been homed or referenced otherwise you could crash. Also trying to stop the function from running if
any of the axes are not enabled otherwise the GUI will block.

You could hard code the numbers in the code but if you ever wish to change them you'd have to delve into the code to change the numbers. If you use
registers you can use the Diagnostics of Mach and edit the numbers directly and easily, no messing around editing Lua code and recompiling.

If you go to Configure/Plugins/Regfile and create three new registers (the little green plus sign adds a new line)...

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'