Hello Guest it is March 28, 2024, 11:09:39 AM

Author Topic: /// Divide dro by 2 button ///  (Read 3059 times)

0 Members and 1 Guest are viewing this topic.

/// Divide dro by 2 button ///
« on: November 24, 2016, 01:26:55 PM »
 ??? I would like to add a button that divides a axis dro by 2 .I have a manual mill that has this feature. I can edge find one edge, move to the opposing side and edge find, hit divide by 2 and move to the center. People have said to look at the probing screen but i dont see that option and  it probing doesnt seem to work. Any help would be appreciated.
Re: /// Divide dro by 2 button ///
« Reply #1 on: November 25, 2016, 06:29:38 PM »
Hi


I did this by adding buttons to the Mach4 Offsets screen. As an example, the following code was used for the X/2 left up button script:

--. Halve X axis position for centring
if (machEnabled == 1) then
    local inst = mc.mcGetInstance()
    local val = mc.mcAxisGetPos(inst, mc.X_AXIS)
    local rc = mc.mcAxisSetPos(inst, mc.X_AXIS,  (val / 2))
end

I also found it convenient to add buttons to zero the axes. These are just copies of those on the Program Run screen. I've used this quite a  bit without problems. The buttons are arranged around the DROs  similar to those on a physical DRO.

Allan
Re: /// Divide dro by 2 button ///
« Reply #2 on: November 25, 2016, 07:44:06 PM »
Allen, you are the man!! I give you a virtual high five. Thanks for taking the time to help me out.
Re: /// Divide dro by 2 button ///
« Reply #3 on: November 25, 2016, 07:49:00 PM »
got me thinking???? would you know how to have another button move to that that divided by 2 position?   it would save having to manually jog to that position. not necessary but would be sweet.
Re: /// Divide dro by 2 button ///
« Reply #4 on: November 26, 2016, 05:39:51 AM »
I just use a button that calls the function GoToWorkZero(). This moves all axes to work zero. If you look at this function in the screen load script you will see how it works and can customise the code to suit your needs. For example, you could add a line to the above script to combine the half and zeroing functions for a single axis. Be sure the Z axis is first raised to clear your work unless you want a dead edge finder!

Allan
Re: /// Divide dro by 2 button ///
« Reply #5 on: November 26, 2016, 02:24:35 PM »
Allen, you are wise beyond your years. Thanks
Re: /// Divide dro by 2 button ///
« Reply #6 on: December 01, 2016, 12:48:07 PM »
That script would not work for me with the motion controller that i use. I use a Vital systems HiCON board and their plugin keeps updating Mach4 with the position reported from the motion controller. telling the motion controller to set the axis position without moving causes your axis to go out of band. I emailed Marc from vital systems and he provided me with the script to use with their motion controller. I have a X / 2 and Y / 2 button next the axis zero buttons.

X / 2 button Left up script

if(machEnabled == 1)then
    local inst = mc.mcGetInstance();
    local xPosition = mc.mcAxisGetPos(inst, 0);
    mc.mcCntlMdiExecute(inst, 'G0X' .. tostring(xPosition / 2));
end

Y / 2 button Left up script

 if(machEnabled == 1)then
    local inst = mc.mcGetInstance();
    local yPosition = mc.mcAxisGetPos(inst, 1);
    mc.mcCntlMdiExecute(inst, 'G0Y' .. tostring(yPosition / 2));
end
 
These buttons move the axis to to half of the dro readout when pushed, so make sure the Z is clear of the work when you use Them.  I Hope this helps someone out.
 
Re: /// Divide dro by 2 button ///
« Reply #7 on: December 01, 2016, 04:24:07 PM »
Hi

Interesting. I use a CS Labs CSMIO-IP/A which similarly provides continuous position feedback to Mach4 and I have no such issue. I'm a bit surprised by your result as the SetAxisPos() function only appears to change the fixture offset. It sounds as if the CS Labs controller works with machine coordinates and the Hicon works with user coordinates,orr something like that.

Anyway,I'm pleased you've got it to work and as you wanted to move to the mid point, you have saved a line of code.

Allan