Machsupport Forum

Mach Discussion => Mach Screens => Topic started by: Kenneth on January 23, 2013, 12:11:59 PM

Title: Half the DRO
Post by: Kenneth on January 23, 2013, 12:11:59 PM
i'm using mach3 and machscreen 1.56. don't know if possible with script or
brain, but can i make a button that would half the DRO readout. on the manual mill DRO(wizard550),
i have that option. i 1/2 and then select the axis. it's then halved.
like DRO 4.....would change to DRO 2
Thanks for any help !!!

kenneth
Title: Re: Half the DRO
Post by: Kenneth on February 12, 2013, 10:07:58 AM
did i do this right. is this the wrong place for this post ? was there something else i needed to
do before posting ?  i posted this almost three weeks ago and got nothing. not even what i may
have did worng. new to the forum and still learning. Thanks for any help.
Title: Re: Half the DRO
Post by: Tweakie.CNC on February 12, 2013, 12:44:56 PM
Hi Kenneth,

Welcome to the forum.
You haven't done anything wrong, it is just that your posting has for some reason gone un-noticed, my apologies.

I have read your post a couple of times and I am still unsure what you are asking.

You could add a button to a Mach screen (as long as the screen .set is not protected) which could read a DRO value, half it, then write the new value but I don’t think you could do this within a wizard (although I stand to be corrected). The function would, of course only happen each time the button is pressed.

Tweakie.
Title: Re: Half the DRO
Post by: Klaus1311 on February 12, 2013, 12:47:12 PM
Hi Kenneth

if you just want to display the half of a DRO value when a button is clicked, you could try the following:
place your DRO for holding the value / 2,  give it an user defined id e. g. 1500
place a button, double click "Function" in the propertybox of MachScreen , select "Execute Basic-Script", double click the value field in the "Execute code" line
EDIT:

value = GetOEMDRO(800)    ' e.g X POS
SetUserDRO(1500, value / 2)

exit the editor  File -> use data and close
save your screenset


Klaus


Title: Re: Half the DRO
Post by: Kenneth on February 12, 2013, 12:50:11 PM
Thanks for your reply Tweakie.CNC ,
i want to touch one side of the stock and zero the DRO....then move to the other side
of the stock and touch again....then select an axis and click my button. that would half my
DRO display so that when i move the axis to the center of the stock, the DRO would read zero.
THANKS again !
Title: Re: Half the DRO
Post by: Kenneth on February 12, 2013, 12:51:02 PM
OOPS....i'm sorry Klaus1311
THANKS!!!!!!!!!!!!!!!!!!!
Title: Re: Half the DRO
Post by: Kenneth on February 12, 2013, 12:52:31 PM
D###, i need to read before i post. Thanks Tweakie.CNC AND Klaus1311 !!!!
Title: Re: Half the DRO
Post by: Kenneth on February 12, 2013, 01:04:17 PM
Thanks Klaus1311,
i have the buttom configured as you say and it does nothing when i click the button.
and would that just zero X DRO ? i tried selecting a DRO and clicking the button...nothing.
i did save the set and even restarted mach3.

Hi Kenneth

if you just want to display the half of a DRO value when a button is clicked, you could try the following:
place your DRO for holding the value / 2,  give it an user defined id e. g. 1500
place a button, double click "Function" in the propertybox of MachScreen , select "Execute Basic-Script", double click the value field in the "Execute code" line
EDIT:

value = GetOEMDRO(800)    ' e.g X POS
SetUserDRO(1500, value / 2)

exit the editor  File -> use data and close
save your screenset


Klaus



Title: Re: Half the DRO
Post by: Klaus1311 on February 12, 2013, 01:48:20 PM
Hi Kenneth

could you please try the attached mini screen and have a look, what is different to your screenset.  



Klaus
Title: Re: Half the DRO
Post by: Kenneth on February 12, 2013, 02:02:47 PM
ok. you have two dro's. oem and user.
i have oem. so i will need two dro's for each axis ?
i need to make another dro(user 1500) to get it to work.
so this will only half X? i will need the same for YZ ?
Thanks

Kenneth
Title: Re: Half the DRO
Post by: Kenneth on February 12, 2013, 02:07:29 PM
with the added DRO, it works.
but wasn't looking for so many DRO's on one screen :)
Thanks Klaus1311
Title: Re: Half the DRO
Post by: Klaus1311 on February 12, 2013, 02:30:53 PM
Hi Kenneth,

you could minimize the number of controls, if you 'd use 3 buttons, one for each axis and one dro showing the value / 2.




Klaus
Title: Re: Half the DRO
Post by: Kenneth on February 12, 2013, 02:32:29 PM
that made a whole lot of sense as i read that. just use my user DRO
Thanks
Title: Re: Half the DRO
Post by: Kenneth on February 12, 2013, 02:39:47 PM
trying it in mach3. the oem dro move when i X+ or X-.
the user(dro) doesn't change til i half it. so i will need two DRO's
for each axis. one to show movement and one to show when i half.
this sounds right ?
Title: Re: Half the DRO
Post by: Klaus1311 on February 12, 2013, 03:22:00 PM
Hi Kenneth,

yes, that would be simplest solution. For each axis 2 DRO's and 1 button.


Klaus
Title: Re: Half the DRO
Post by: Overloaded on February 12, 2013, 04:36:54 PM
..... i want to touch one side of the stock and zero the DRO....then move to the other side
of the stock and touch again....then select an axis and click my button. that would half my
DRO display so that when i move the axis to the center of the stock, the DRO would read zero.

Why show the User DRO at all ? ::)
Just script a button beside each to half the X and Y Pos. DRO's and be done with it.
I may have overlooked something and do not completely understand. ???
Looks simple to do.

or, the Auto Calculator, or the Keyboard (/2) as other options.
Russ :) :)
Title: Re: Half the DRO
Post by: Overloaded on February 12, 2013, 05:04:19 PM
Just playin', here is a cobbled up example ...

VALUE = GetOEMDRO(800) 'For X axis
HALF = VALUE / 2
SetOEMDRO(800,HALF)   

Russ

Title: Re: Half the DRO
Post by: Kenneth on February 13, 2013, 05:48:08 AM
the thing i have is the oem dro changes when i jog the axis. the user dro doesn't change
till i half the axis. after i half the axis, the user dro stays at half while the oem changes
as i jog the axis. so i have 
oem =  4
user = 4
half axis
oem = 4
user = 2
Title: Re: Half the DRO
Post by: Kenneth on February 13, 2013, 06:06:44 AM
i had to do this to get it to work as i want.
value = GetOEMDRO(800)
SetOEMDRO(800 , value / 2)
Thanks
Title: Re: Half the DRO
Post by: Kenneth on February 13, 2013, 06:11:02 AM
well, almost right. that just moves the axis to the center.
it havles it but when i half it gose to x =2 from 4 but the table didn't move.
so i'm at x = 6 really. trying........
Title: Re: Half the DRO
Post by: Kenneth on February 13, 2013, 07:00:55 AM
shouldn't the USER DRO move as the OEM DRO ?
as i jog the table, the user's doesn't change.
don't sound right to me boss :)
Title: Re: Half the DRO
Post by: Overloaded on February 13, 2013, 07:40:11 AM
it havles it but when i half it gose to x =2 from 4 but the table didn't move.
Are you expecting the axis to actually move ?
If so, you will have to add to the button script.
Like:
value = GetOEMDRO(800)
SetOEMDRO(800 , value / 2)
While IsMoving
Wend (needed here maybe)
Code "G0 Z0"  (or inc. move to clear part)
While IsMoving
Wend
Code "G0 X0"  (move to center)
End
No, the user dro will not show movement as you jog, it only updates when the button is pressed.


Title: Re: Half the DRO
Post by: Kenneth on February 13, 2013, 07:47:21 AM
what i'm trying to do is....
touch edge of stock on one side and zero dro.
move to other side of stock,touch egde then half dro so that when i move to
center of stock dro reads zero.
Title: Re: Half the DRO
Post by: Kenneth on February 13, 2013, 09:04:04 AM
that script halves the X axis and then moves to zero.
but the zero is at bottom-left of stock, not center.
the work is set to half. so if i go to x3. i'll half that and move to
zero. and the dro is zero. but i got to mach coor it is 1.5.
so if i go to center of stock, dro says 1.5.
Title: Re: Half the DRO
Post by: stirling on February 13, 2013, 09:25:04 AM
Kenneth - with respect if I understand your requirements correctly I'd suggest you're going about this in a rather tortured way.

Why not...

touch off one side - zero that DRO
touch off the other side and then have simple button code to...

raise to safe Z
move to the mid point
zero the axis

job done - one button - no DROs - simples.

Ian
Title: Re: Half the DRO
Post by: Kenneth on February 13, 2013, 09:29:25 AM
that's what i been looking for just didn't know what to
use to get it done :)
Title: Re: Half the DRO
Post by: Kenneth on February 13, 2013, 09:42:13 AM
how do i use the value of SetOEMDRO?
code " g0 x(SetOEMDRO) "
Title: Re: Half the DRO
Post by: stirling on February 13, 2013, 09:45:11 AM
OK I think maybe this is the common problem of folks asking how to implement THEIR solution rather than asking for A solution to a problem. No worries - happens all the time. ;D

Put the following code into the button of your choice...
Code: [Select]
X = getOEMDRO(800)
If X <> 0 Then 'x has changed
  Code "G0 X" & X/2
Else
  Y = getOEMDRO(801)
  If Y <> 0 Then 'y has changed
    Code "G0 Y" & Y/2
  End If
End If

and then do this...

1) touch off your first side and zero both X and Y via the buttons next to the axis DROs
2) touch off your other side AND THEN RAISE Z to a SAFE HEIGHT
3) hit the button. The axis will move to the mid-point and show its coordinate of course in the DRO
4) Zero the DRO

Of course this could be automated even more and various safeguards put in place but it's a starter.

My usual terms & conditions - you use this code at your own risk - if it breaks anything including your heart you get to keep the pieces.

If you want to try it BEFORE you stick it in a button just run it from the CB editor.

Ian
Title: Re: Half the DRO
Post by: Kenneth on February 13, 2013, 10:07:51 AM
thanks stirling
when i run that. xy go to half and when i zero the axis, the display in toolpath gose to
lower-left position. not the center of stock. in my test i did g0x2. it went to x1 and stopped.
i zeroed the axis and the spendle moved to lower-left and the table stayed at x1.
Title: Re: Half the DRO
Post by: stirling on February 13, 2013, 10:10:18 AM
Well it will because you've zero'd in the centre of the stock!

maybe you need to rewind and explain again WHY you want to position the tool in the centre of the stock
Title: Re: Half the DRO
Post by: Kenneth on February 13, 2013, 10:24:07 AM
i put my stock on the mill(cnc). i find the center to cut a pocket(and drill any holes)
in the middle of stock.  any stock the is oversiized i cut on another mill(manual). some times i don't have a
big enough stock to just eyeball center.
Title: Re: Half the DRO
Post by: Kenneth on February 13, 2013, 11:17:36 AM
guess what i'm saying is that after i find the edge of all four sides,
if i move to the center of the stock, i want the dro to read zero
on XY.
Thanks again for ALL ya'll help !
Title: Re: Half the DRO
Post by: stirling on February 13, 2013, 11:44:25 AM
 ;D ;D ;D ;D ;D ;D but that's exactly what the code I posted does.... it finds the centre and calls it 0,0  ;D ;D ;D ;D ;D
Title: Re: Half the DRO
Post by: Kenneth on February 13, 2013, 11:55:26 AM
:):):)  but in the toolpath it shows the spindle at the lower-left.
if i go to zero, it's at the lower-left not the middle of the stock
Title: Re: Half the DRO
Post by: Kenneth on February 13, 2013, 11:59:42 AM
i want the toolpath to look as the actual mill is working.
this way it may be cutting in the middle of the stock but
the toolpath is not moving as the mill
Title: Re: Half the DRO
Post by: Overloaded on February 13, 2013, 12:11:44 PM
that script halves the X axis and then moves to zero.
but the zero is at bottom-left of stock, not center.
the work is set to half. so if i go to x3. i'll half that and move to
zero. and the dro is zero. but i got to mach coor it is 1.5.
so if i go to center of stock, dro says 1.5.

This has nothing to do with mach coords, you are using part coords ... an offset from mach coords.
Title: Re: Half the DRO
Post by: Kenneth on February 13, 2013, 12:19:11 PM
i'm sorry i couldn't explain it better and i do appreciate ya'll time.
THANKS
Title: Re: Half the DRO
Post by: Kenneth on February 13, 2013, 02:40:52 PM
do i really need the While ........ Wend ? the code works without it.
if it does something needed then i'll leave it there.

value = GetOEMDRO(800)  ' get value of X DRO
SetOEMDRO(800 , value / 2)  ' half X value
While IsMoving ( )
Wend
Code "G0 Z.5"  ' or inc. move to clear part
While IsMoving( )
Wend
Code "G0 X0" & x/2  ' move to center
End