[hackpgh-discuss] Re: Awesome article on how to read G-code

  • From: Simon Heath <icefoxen@xxxxxxxxx>
  • To: hackpgh-discuss@xxxxxxxxxxxxx
  • Date: Wed, 26 Oct 2016 09:29:09 -0400

Thanks for this article, it's very cool!  Just one question...

With the "clockwise motion" and "counterclockwise motion" codes, how is
the curve defined?  Does it have to be a circular curve, or can you make
it do an ellipse or a spline or some other kind of curve?

Interesting to read this, 'cause from a computer science point of view,
this is a state machine... naturally, since you're setting the state of
the machine.  The main difference I see in G code is it has to say how
to get from one state to another...  computers are discrete, so when you
switch states a computer just does it.  The real world is continuous, so
when you tell a machine to go from one state to another it has to
actually move through all the space between them.  :-P

State machines are often used as controllers for mechanical systems,
from vending machines to robot arms, so I'm not super surprised, but
they also get used in scanning text and other such things.  Regular
expressions are a state machine for matching patterns in text, for instance.

Simon

On 10/25/2016 06:07 PM, Andrew C. wrote:

Ryan-

Depends on how much complexity you want. I havent done much of this type
of gcode- as this is often Mcodes (condition codes). they're basically
the same types of things as codes, but it's a letter m instead of g.
they change the way parts of the machine operate, and some are
conditional triggers as you mentioned though these are often not used in
general machining.

There is a 3rd type of machine code that hasnt been mentioned that is
used for what you want to do: macro code.

I can read some of it, but it's not normally ever used in machining. it
is the C code behind subroutines, basic if then nor not type
programming. all conditional statements. I see it scroll by in the
hundreds of lines running my tool probe subroutines. I cannot code with
it, as it is totally linked to variable output and input parameters of
the machines themselves in binary.

My guess is that many of you could fluently read and write this type of
code as I call it something different, but it looks like simple C to me.
I just cant code in C yet, but I get the logic of how the statements are
read by the machine, I just cant follow what its doing as there are
hundreds of statements all interrelated calling upon each other.

example code I can get you, or look on Haas website for omp-40 spindle
probe routine code.

This is the kind of code that looks for binary state of switches in the
machine, if they are 0 or 1, on or off, and does things with that info
based on referencing those parameters. a lot of square brackets!

if you want to do something complex like these conditional triggers with
machine readable code in a normal cnc machine, youd probably do them
with a lot of lines of these codes, or interlinked these with the few M
codes that do some of this too.

Don't know if that helps or confuses.

-Andrew


On Tuesday, October 25, 2016, Andrew C. <soshumasamune@xxxxxxxxx
<mailto:soshumasamune@xxxxxxxxx>> wrote:



    On Tuesday, October 25, 2016, Andrew C. <soshumasamune@xxxxxxxxx
    <javascript:_e(%7B%7D,'cvml','soshumasamune@xxxxxxxxx');>> wrote:


        Its honestly not difficult guys, what's difficult is selecting
        safe tools to cut with, and spinning them at correct speed and
        moving them at correct rate (feed) at a safe depth through
        material. That's the knowledge part behind machining, and that
        is what takes more time to learn.


    Wow. Ok, sorry. rereading that made me finally realize how I feel
    when the coders of C and pc code make me feel when they say the same
    thing to me- "it's not hard". A bit stupid, as I don't have an
    understanding of the framework yet.

    What I did mean was genuinely, machine code for basic parts really
    doesn't take long to learn. Even with no experience at all, I could
    teach someone to write a working simple program in an afternoon. not
    long to show codes, a little time to show how to combine them to
    make a working program you could make a simple part with.

    For simple parts made of just linear moves at different depths, you
    could learn to program it in an afternoon.

    After a week, if you're paying attention, programming to do
    threadmilling even isn't difficult to pick up.

    I'm happy to show people how to do it if anyone's ever interested.
    Maybe this is another class though?

    -Andrew


Other related posts: