Machsupport Forum
		Mach Discussion => Mach4 General Discussion => Topic started by: Screwie Louie on June 30, 2015, 03:11:50 AM
		
			
			- 
				This is in response to a request by Pedio. He would like to input a number value into a DRO and have the axis jog to that position instead of going to the MDI input page, writing the block and pressing Cycle Start. I believe his intent is to maximize time efficiency by jogging to a known position from his home page. ie "Enter value, press enter" => axis jogs to desired position. This example is simple without error checking or safety checking (ie. rc values, is axis homed, or is Z axis clear before movement, etc) To implement direct input into a DRO as a text box I will do my best to describe the instructions below. By the way, this was a great idea! Thanx Pedio (If you don't mind, I would like to add this feature to my Blackout Screenset --which is open code for everyone to use, edit, play, add their own features, repost, etc....) You guys are gonna be like "That's it?!?!?" Yep, gotta love m4! I demonstrate a mc.mcCntlMdiExecute function to jog to an absolute coordinate position (G90) and then using mc.mcJogIncStart function call instead of mc.mcCntlMdiExecute G91 command. Hope this helps!
 
 Absolute Position:[/color]
 1. Operator -> Edit Screen
 2. Add DRO --to wherever you would like for this MDI input to be
 3. DRO properties are: DRO Code = Blank, Editor = Keypad
 4. On Modify Script =
 local inst = mc.mcGetInstance()
 local gCode = ""
 local Xmove = scr.GetProperty('droXMdiAbs', 'Value')
 
 Xmove = tonumber(Xmove)
 if Xmove == nil then Xmove = '0' end
 gCode = gCode ..string.format("G0 G90 X%.3f\n", Xmove)
 
 mc.mcCntlMdiExecute (inst, gCode)
 
 Incremental Movement:[/color][/color]
 1. Operator -> Edit Screen
 2. Add DRO --to wherever you would like for this MDI input to be
 3. DRO properties are: DRO Code = Blank, Editor = Keypad
 4. On Modify Script =
 local inst = mc.mcGetInstance()
 local Xmove = scr.GetProperty('droXMdiInc', 'Value')
 
 Xmove = tonumber(Xmove)
 if Xmove == nil then Xmove = 0 end
 mc.mcJogIncStart (inst, 0, Xmove)
 
 [/color]
 That's it folks! I'll post some screen shots below in the next post to help you guys visualize the concept. It's pretty cool. Pedio had a great time-saving idea.
 
 --josh
 
- 
				well dude your hired you can start Monday 
			
- 
				hold on a sec...I need to work on the increment DRO (I am using both the absolute and increment  coordinates G90/G91 at the same time...let me work this through)
 
 I think I double posted...can a moderator delete the repeat post please?
 
 Dude, this is soooo gonna work!
 
 What's up Pedio? I sware you meant Pedro but Pedio? I think of PedioBear....lol! just kidding. Don't kick my ass...
- 
				very nice, but  i have one question 
 
 what do the [/color]  and [/color] [/color] functions do ?
- 
				They are just from the forum when selecting a font color.
 
 They are usually invisible but somehow got doubled up and pasted in this time.
 
 Russ
- 
				Sorry Pedio...sometimes I have a little whiskey, open my mouth and insert my foot.
			
- 
				Louie - No problem with the free use of the idea. I like having people innovate around M4. It can only help all of us!
 
 I intend to use this to move the head out of the way when I load work pieces and to move it to fixed fixturing locations on the table (I have a 7'X10' table it takes a good deal of time to move the head around when loading different size pieces. It will be great to say move X=48 to load the pieces. I also like to park the head for different functions (change tool, etc). Often it depends on where I will be working around the table.
 
 My name is Peter and Pedio is an derivative of Fabio. When I was at career day at High School the guidance councilor never even mentioned the career choice of "Romance Novel Cover Model". I would have soooooooo gone for that one!  (It is even funnier if you meet me in person)
 
 Is the code posted above ready for test by newbies like me?
- 
				Louie - just to be double sure. The absolute is the distance from the machine 0 and the incremental is from the current location of the head on the table?
 
 Also, the way I am reading it is that the script for absolute is to move the X axis. If I want to make another DRO for the Y axis I replace "X" with "Y" in the script. Is that correct?
 
 Thanks for this - it will make my life much easier.
 
 Finally, where do I find the Blackout Screenset? I would like to take a look.
 
- 
				Found the screen set below. Looks cool.
			
- 
				Yep! You're getting it.
 
 The absolute distance is from work coordinate position 0.0
 To utilize this script in machine coordinates you would use the G53 command; something like :
 gCode = gCode ..string.format("G0 G90 G53 X%.3f\n", Xmove)
 
 Be careful just replacing X with Y. You are right in a sense but notice in this function:
 mc.mcJogIncStart (inst, 0, Xmove)
 
 "0" is the X axis identifier for mach4, as you set it up in your config.
 
 You would change the function to:
 mc.mcJogIncStart (inst, 1, Ymove)
 
 "1" is the Y axis identifier.
 
- 
				I would just use G91 for an increment move. I'll post a screen shot soon with the screen set. I kinda want to have only one DRO input with the option for:
 a. Work Coordinates      Default movement from user's G54 offset
 b. Machine Coordinates  G53
 c. Absolute jog              G90
 d. Increment jog           G91
 e. Axis selection             X, Y, Z, A
 
 or just 3 basic DRO inputs for X, Y, Z axes....idk
 
 
- 
				Louie,
 
 I tried to implement your DRO box this evening. I think I am doing everything right but the machine is not moving. I have attached screen shots of the DRO setup and the code. I am very new to Lua so I am not sure if I am inadvertently doing something wrong.
- 
				it`s name needs to be the same as the scr.GetProperty
			
- 
				Here is the screenshot and the screen set with the embedded code. Add, modify, delete, PLAY :)
 Still working through G53 incremental commands. Mach4 doesn't allow G00 G91 G53 move. "Cannot execute G53 incremental". I'll figure a way.
 All moves are G00. If you want a G01 option, just let me know.
 
 --josh
- 
				to find what G is working  type it in to the MDI
			
- 
				Yea Success!!!!!
 
 I now can send X or Y flying all over the place. Thanks Louie
 
 One other question -- what does the Hidden box do? I tried to make a home button and place it over the LED on the main screen. That way the axis would home when you clicked on the red LED. I thought it would be easy as placing a button over the LED, hiding the button and then demoting the LED to level 1 to place it behind the LED. It did not work. I resorted to a small button on the top.
- 
				just delete the LED and replace it with a toggle button. Toggle buttons have a lot of features that you may want.
			
- 
				you can set toggle buttons to do stuff on up and down click, change color, different wording, flash they are quite fun to play with you could have I am not homed, then have I am homed anything really.
 but you wont to keep it as simple as possible if there is a function built in to the button or what ever use that save`s have to use code.
- 
				just delete the LED and replace it with a toggle button. Toggle buttons have a lot of features that you may want.
 
 
 Louie - I tried this but the toggle button did not know when the other toggle button was depressed. Remember I was trying to do this to change between continuous and incremental steps on the Jog. If the machine was on continuous and I pressed incremental the other button did not know what was happening and would continue to appear like it was on. Perhaps it is best to look at what I was trying to do (see attached).
 
 I am remedial and need REALLY big buttons to do common tasks or emergency tasks (like stop the machine).
- 
				the easiest way is to set the button state to 0 "of the opposite button" when the selected toggle button is pressed by using scr.SetProperty calls.
 
 examples are in the screenset code I posted. -> click on the MdiDro, On Modify Script.