Shop OBEX P1 Docs P2 Docs Learn Events
CNC --> Egg & Cookie painting bot — Parallax Forums

CNC --> Egg & Cookie painting bot

Got the idea from @"Christof Eb." over here: https://forums.parallax.com/discussion/174485/

Going to attempt to turn an ancient CNC into an egg/cookie painting bot.
The GRBL code from @mwroberts has the CNC taking gcode commands from PC:
https://forums.parallax.com/discussion/173498

Kids think should start with eggs, so here's the current idea:

1434 x 1113 - 188K

Comments

  • Is your rotary axis the 4th GRBL cnc axis? If it is, I think we can add code to P2 GRBL to get it to display the A axis positions on UGS.

  • RaymanRayman Posts: 14,632

    I think it should be as 4th axis, not exactly sure how to make that happen though...

  • RaymanRayman Posts: 14,632

    I'm thinking the egg hardware is very close to being ready

    1512 x 2016 - 1M
  • Nice!

  • RaymanRayman Posts: 14,632

    Getting close to being able to do something...
    Made this program to interface with the GRBL code

    1051 x 747 - 37K
  • Since you switched to the version with jog functionality, in RealTimeStatus() you need to uncomment the code that outputs A axis positions...

  • RaymanRayman Posts: 14,632

    First test is promising. Need to figure out how to rotate at different speeds than XYZ...
    At least, can now do spirals pretty well (but there are some gaps where marker left the egg). Seems Z was a hair too high.

    1512 x 2016 - 1003K
  • RaymanRayman Posts: 14,632

    @mwroberts A axis status working thanks.

    Think figured out a couple things...
    1. Should change zero from end of egg to center of egg for better egg to egg reproducibility
    2. Need marker to freely move up and down in holder. Added some weight to help with that, like somebody mentioned in a different thread...

  • RaymanRayman Posts: 14,632

    Think have spiral drawing figured out. Now, on to try something fancier...

    1512 x 2016 - 771K
    1512 x 2016 - 776K
  • RaymanRayman Posts: 14,632

    Some hiccups, but think zig-zag is working now.

    1512 x 2016 - 729K
  • Nice!

  • RaymanRayman Posts: 14,632

    Think close to having it do what want for eggs, but running out of time and eggs...

    1512 x 2016 - 692K
  • RaymanRayman Posts: 14,632
    edited 2024-03-28 21:57

    Got a wave working but something is wrong with serial interface...
    Seems locked up after completion...

    For now, can close serial port and open back up to fix...

    1051 x 747 - 73K
  • RaymanRayman Posts: 14,632

    Need to increase period, but wave is pretty good...

    1512 x 2016 - 907K
  • Nice!
    Some questions:
    How do you generate the g code?
    Does the tip follow the shape only by weight or do you move the height axis?
    Christof

  • @Rayman
    I assume you don't use y axis?
    if you disconnect motor leads to y and do a circle in the g17... x-y plane, you will get a sinusoid output on x axis...
    could be good for waves...
    run this line 10 times per egg turn...
    G91G3G17A36i10f500 will do a circle with X&Y and translate a

  • RaymanRayman Posts: 14,632
    edited 2024-03-29 13:56

    @"Christof Eb." The C++ dialog based GUI shown in post#14 creates and sends GCode.
    At the bottom of GUI is a section for creating a X-Z profile of the egg for precise Z control.
    But, figured out that, with the weight, the same profile can be used for all the eggs...
    Profile I'm using is attached with zero being tip just above center of egg.

  • RaymanRayman Posts: 14,632

    @mwroberts Thanks. I think this code generates a sine wave, just not sure that's the best. Hemispherical might be better. At least need to reduce period...

    void CCNCCTRLDlg::OnBnClickedPattern4()
    {//Execute Egg Pattern #4 Wave
    
        float x, z;
        char mess[1000];
        int a = 0;
    
        if (ProfileSize < 2)
        {
            AfxMessageBox(L"Profile too short.");
            return;
        }
        //Zero A
        OnBnClickedButzeroa();
    
        //Move to starting position
    
        UpdateData(true);
        x = _wtof(m_sMinX);
        float zoff = _wtof(m_sProfileZOff);
        z = InterpolateProfile(x) + 10;
    
        SendString("G01G90Z10F400.0;\r\n\0");
        sprintf_s(mess, "%s%.1f%s%.1f%s", "G01G90X", x, "Z", z, "A0.0F400.0;\r\n\0");
        SendString(mess);
        Sleep(1000);
        z = InterpolateProfile(x) + zoff;
        sprintf_s(mess, "%s%.1f%s%.1f%s", "G01G90X", x, "Z", z, "A0.0F400.0;\r\n\0");
        SendString(mess);
        Sleep(1000);
    
    
        //for (int i = 0+2; i < 31; i++)
        float xend = _wtof(m_sMaxX);
        float xwidth = xend - _wtof(m_sMinX);
        float x0 = x;
        int direction = 1;
        float af = 0;
        while (af < 360)
        {
            af += 1.0;
    
            float afr = af * 3.14159 / 180;
    
            x = x0 + xwidth * (1.0 - cos(afr * 10));
    
            z = InterpolateProfile(x);
            z += zoff;
            sprintf_s(mess, "%s%.1f%s%.1f%s%.1f%s", "G01G90X", x, "Z", z, "A", af, "F400.0;\r\n\0");
            SendString(mess);
            Sleep(250);
    
    
    
    
        }
    
        SendString("G01G90Z20F400.0;\r\n\0");
        Sleep(500);
    }
    
  • @Rayman
    The character stream that gets sent to GRBL has a carriage return and/or line feed at the end... no zero. I'm not sure how tolerant my P2 GRBL is to zero's in the incoming stream.
    There are some special characters, single byte, not followed by any terminating characters like carriage return, LF or zero... that invoke an immediate response, like a question mark, a Tilda, an exclamation mark...
    Did increasing the buffer size if FSD help with the lockup?
    I have a cog that reads the incoming character stream and does stuff with it like parsing it for moves and adding them to the head of the circular CNC move buffer, of sending out a status packet when a question mark is received...
    A second cog feeds the third cog "PASM pulse generator interpolator" moves from the tail of the cnc move buffer as it needs them...
    A fourth cog runs FDS.
    So the cog reading the incoming character stream isn't too overloaded. It reads into a 128 byte array to create strings to parse when it sees a carriage return or line feed.
    So, more than 128 characters without a linefeed or carriage return would be bad.
    I added an error message if this happens. Didn't upload anything yet.
    A cnc move has an execution time. It is the distance divided by the feed rate. If these times are too small, a lot of text has to stream over in a short period... so move execution times are better if they are bigger than 50mSec or 100mSec ish??

  • RaymanRayman Posts: 14,632

    Had to add \0 to get serial sender to recognize the end of string
    Don’t think actually gets sent…

  • I wonder, if you could make a holder for several pens with offsets in Y (the unused axle) for automatic colour change. The inactive pens could not reach the egg if the offset is sufficient.

  • RaymanRayman Posts: 14,632

    @"Christof Eb." Maybe. But, I think what would be better is to add a tool change feature to the P2 GRBL. Maybe next Easter...

  • RaymanRayman Posts: 14,632

    Ready to try cookies. Just as soon as the frosting hardens enough...

    480 x 640 - 186K
  • RaymanRayman Posts: 14,632

    Ok, this week learned that need "royal icing" and then learned today it takes 8 hours to dry :(
    This is really putting a damper on my CNC plans for today...

    Tried putting one in the freezer. That looked like it was going to work for a second. Then, water condensed on it and it made a mess...

  • @Rayman said:
    Ready to try cookies. Just as soon as the frosting hardens enough...

    Clamping looks solid! B)

  • RaymanRayman Posts: 14,632

    My 2D patterns seem to come out 3/5 the size they should be...
    Have to tweak something somewhere...

  • RaymanRayman Posts: 14,632

    Cookies finally cooperating...
    Trying some random clipart from UGS

    1512 x 2016 - 887K
Sign In or Register to comment.