CAD CAM EDM DRO - Yahoo Group Archive

re:g-code parsers

on 2001-01-03 16:27:59 UTC
Les,

I didn't know what all you were looking for, but I'm sure you get the
idea. scanf() and sscanf() are std. 'C'. If you have a token, and you
expect a numeric parameter, then "scanning" the token string for the
float is a simple way to get the number out (or telling you if you
didn't get it).

The key is getting a nice stream of tokens (and non-tokens, the numeric
parms), and implementing a parse tree in state code to deal with them.
Not sure how useful strspn() would be here, but then there are always
TONS of ways to do things! I'm also sure you could use YACC and
generate an elaborate parser, but I find I can build up parsers for
simple structures like this with out much difficulty. Then again, I
don't need it to parse EVERY variation of gcode, just what I like (gcode
generated by Vector CAD/CAM {ISO 001}, and drives MaxNC and FlashCut, my
touchstones).

Yes, by looking for the token 'G', then a following parm '1', (or 1.1,
for example when codes get expanded), the "parse tree" is simplified.

Did you pick up on the Modal groups? Example, you can only have a G0,
G1, G2 *OR* a G3 on a line at one time, they are all in modal group 1.
Similarly, group 2 is G17, G18 or G19. And you want to set a flag to
say you saw a "move" group command, and at least one axis parm (X,Y,Z
etc) to act upon.

If you can get the tokens, you can even pass them to an expression
evaluator, and then have variables, labels, loops... a real
"interpreted" language!

Now as soon as I can wrap my brain around rotations in other then
XY_PLANE! More to do! And then I'll want to convert my linear and
circular interpolations to drive Mariss' "black box"!

The sparse data and curve fitting routine sounds interesting, I wasn't
going to go that far, but...

Have fun! I am!

Alan KM6VV


Les Watts wrote:
>
> Wow what quick responses!
>
> <snip>
> Allan, I had looked at sscanf() in my borland compiler stuff but it was not
> very well documented. It seems that it might be particularly suited to the
> task as I don't expect fixed fields- G01 for example could be written as g1
> as I read the standard. As a first stab I was using strspn() and some of the
> macros in ctype.h. It seemed to progress into what would be a can of worms-
> possible but long.
>
> Using sparse data and a curve fitting routine really is a form of look
> ahead. To know the precise next move with many splines one has to know the
> next several vertex points. It's a digital
> filter with group delay.
> <snip>
> Thanks!
>
> Leslie Watts

Discussion Thread

Les Watts 2001-01-03 13:41:18 UTC g-code parsers andy@o... 2001-01-03 14:18:43 UTC Re: g-code parsers Alan Marconett KM6VV 2001-01-03 14:28:54 UTC Re: [CAD_CAM_EDM_DRO] g-code parsers Les Watts 2001-01-03 15:43:11 UTC re:g-code parsers Jon Elson 2001-01-03 16:27:55 UTC Re: [CAD_CAM_EDM_DRO] re:g-code parsers Alan Marconett KM6VV 2001-01-03 16:27:59 UTC re:g-code parsers Alan Marconett KM6VV 2001-01-03 16:35:27 UTC Re:g-code parsers Les Watts 2001-01-03 17:44:11 UTC Re: [CAD_CAM_EDM_DRO] re:g-code parsers Carlos Guillermo 2001-01-03 19:56:00 UTC RE: [CAD_CAM_EDM_DRO] re:g-code parsers ballendo@y... 2001-01-03 19:57:06 UTC re:re:g-code parsers Alan Marconett KM6VV 2001-01-03 20:00:39 UTC Re: [CAD_CAM_EDM_DRO] re:g-code parsers ballendo@y... 2001-01-03 20:06:04 UTC re:Re: re:g-code parsers