Parametric Gcode programs using Notpad

This is the place for queries that don't fit in any of the other categories.

Parametric Gcode programs using Notpad

Postby Fleck » Thu Mar 27, 2014 1:09 am

I am a total newbie, I have written a handful macros through CNC control software for my lathe and see how powerful they can be. I would like to create them through something like notepad with a box for variable/measurement assignments to coincide with different gcode macros for gcode moves. I have been playing around with the debugging portion of python and I can get the variables to function the way that I would like. I am having a hard time envisioning how to get this install into a program with a variable box that measurements can be assigned to the variables. Maybe write macros in open office and have code post in notepad? I have been teaching programming to myself over the past few years when using my cnc machines, I am sure I am thinking about the process incorrectly as I lack all fundamentals.
Any help is much appreciated
Fleck
 
Posts: 5
Joined: Thu Mar 27, 2014 12:45 am

Re: Parametric Gcode programs using Notpad

Postby stranac » Thu Mar 27, 2014 10:29 am

I don't really understand.
What is it exactly you want to achieve?
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1096
Joined: Thu Feb 07, 2013 3:42 pm

Re: Parametric Gcode programs using Notpad

Postby Fleck » Thu Mar 27, 2014 3:01 pm

Thanks,
Sorry, I know I am all over the map and using the wrong terms to describe things. In a nutshell. I would like to create a program that will create simple tool-path based on measurements that would be input into a "Boxes" (not sure if that is the right term) . Like a box (Length) and input your measurement in another box next to it (2.75") these would be associated with different Macros for different commonly used simple tool-path like pocketing etc...
Where would I store the Macros to be called on?
Where should I be looking for a program template to build this onto. Is this what QT is? I guess I was thinking I could use Notepad or Open Office.
Hope it makes a bit more sense, I have a lot more reading to do.
Thanks
Fleck
 
Posts: 5
Joined: Thu Mar 27, 2014 12:45 am

Re: Parametric Gcode programs using Notpad

Postby stranac » Thu Mar 27, 2014 3:14 pm

The problem here is I know nothing about G-code.
So I have no idea what things like tool-path, macros or pocketing mean here...

So give me an example:
  • what would you input?
  • what would the result be? (be as specific as you can)
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1096
Joined: Thu Feb 07, 2013 3:42 pm

Re: Parametric Gcode programs using Notpad

Postby Fleck » Thu Mar 27, 2014 7:57 pm

Thanks for the reply. Gcode is grid coordinates for example. X would move a tool from left to right and Y front to back. There is also a Z axis but I am leaving it out. Code for a 2" by 2" square would be.
Code: Select all
G01(linear Move) X0 Y0(Starting point) F5 (Feedrate of tool 5 inches per minute)
X2 Y0 (MOVES TOOL 2" IN +X DIRECTION)
X2 Y2 (MOVES TOOL 2" IN +Y DIRECTION)
X0 Y2 (MOVES TOOL 2" IN -X DIRECTION)
X0 Y0 (MOVES TOOL 2" IN -Y DIRECTION)


A macro for a lathe to remove a certain amount of material might have a user assigned name like M19 and behind the M19 call in the gcode would be these arguments. You would utilize data input boxes to fill the variable measurements.

Code: Select all
#XD = [#XStock/2 - #XPart/2]/ #Cuts
#XRemove = [#XStock-#XPart]/2

(Cut spacing math)
While #XRemove/2 + #XPart/2  > #XPart/2  Do

(Relative positioning)
G52(Temporary tool offset) X#XPart/2

M03

(XMath)
#XRemove=#XRemove-#XD
(Subtract)
G00(Rapid linear move) X#XRemove+.1 Z0
G01(Linear move) X#XRemove F#F
Z#ZPart.1 *-1
G00(Rapid linear move) X#XRemove +.1   Z0
EndWhile

(Relative positioning Reset)
G52 X#XPart*0
G28 (Tool Change reference point)


Thanks
Last edited by stranac on Thu Mar 27, 2014 8:12 pm, edited 1 time in total.
Reason: Added code tags.
Fleck
 
Posts: 5
Joined: Thu Mar 27, 2014 12:45 am

Re: Parametric Gcode programs using Notpad

Postby stranac » Thu Mar 27, 2014 8:18 pm

What is a macro in gcode?
What are variable measurements?
What do you want to happen to that second piece of code?

Also, please read this to learn how to post code.
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1096
Joined: Thu Feb 07, 2013 3:42 pm

Re: Parametric Gcode programs using Notpad

Postby Fleck » Thu Mar 27, 2014 9:58 pm

What is a macro in gcode?

It would be the code/script that is called when in my case "M19" is passed within the Gcode
What are variable measurements?

Measurements that would define variables in the macro like #Xdiameter=2.5
What do you want to happen to that second piece of code?

The second piece of code is the macro represented by, in my case an "M19" within the Gcode.

Got it, sorry bout the code post wont happen again.
Thanks
Fleck
 
Posts: 5
Joined: Thu Mar 27, 2014 12:45 am

Re: Parametric Gcode programs using Notpad

Postby stranac » Thu Mar 27, 2014 10:08 pm

Fleck wrote: The second piece of code is the macro represented by, in my case an "M19" within the Gcode.

I get that part, but what happens with it?

If you want to run a python script, have that code generated and saved to a file, you can use any GUI toolkit to get the inputs from the user(or you can just get them from the terminal...)
If you want the generated code to be inserted into code you're editing, I would recommend using an editor that supports extending with python(such as sublime text or vim), and writing a simple plugin for it.
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1096
Joined: Thu Feb 07, 2013 3:42 pm

Re: Parametric Gcode programs using Notpad

Postby Fleck » Thu Mar 27, 2014 11:26 pm

Thanks very much for the information, I think this points me in the right direction and is the information I am looking for. I would like to have the knowledge to be able to do both.

I get that part, but what happens with it?


I would like a user to be able to choose commonly used products in my industry that need to be installed into precisely cut pockets from a program, then they can input machine position information (machine Zero) and desired depth of cut. This would save time for the user because they can change the product route/cut without effecting the rest of the Gcode on the fly without having to walk away from the machine back to the CAM program or hand input G code

Thanks
Fleck
 
Posts: 5
Joined: Thu Mar 27, 2014 12:45 am


Return to General Coding Help

Who is online

Users browsing this forum: Bing [Bot] and 2 guests

cron