Effervecreanet

A better internet for a better world

Telecom, finance and computer science

First idea

I start to command the 3d printer in manual way to have a first idea on how I can print the piece. That first drawing being not unsuccessful I have to repeat the following 3d gcode or instructions.

Grow the picture

Above is what I have to repeat in order to have a first level of extrusion or fit. Then, I have to repeat that's part with 1) a comeback to 0.000 on the axe Z and 2) a level up on the Y axe and 3) find the right extrusion on E or the printer head of the 3d motor.

To conclude, I have to introduce the border frame on the rectangle to fit the support card into

After several unsuccessful attempts, I manage to get what's on the picture above. It remains to introduce the border frame. I am not going to explain this step.

Writing C program

The definitive C code generating the definitive gcode or 3d instructions for the 3d support card is below, it's a self-gen 3d printer instructions executable:

#include <stdio.h>

#define STEP_X 0.700

#define STEP_Y 0.200

#define STEP_Z 0.010

#define STEP_E 0.200

#define IMAX_E  1

#define EXTRUDE(E) do { \

                        printf("G1 E%.3f\n", E); \

                        E += STEP_E; \

                    } while(0)

static float X, Y, Z, E = 0.000;

void surface_edge_border(void) {

    int layer = 0;

    printf("; surface edge border\n");

    for(Y; Y <= 10.801; Y += STEP_Y)

        printf("G1 F200 Y%.3f\n", Y);

    

    while (layer < 21) {

        for (X; X < 37.101; X += STEP_X)

            printf("G1 F200 X%.3f\n", X);

        EXTRUDE(E);

        EXTRUDE(E);

        for (Z; Z > -0.501; Z -= STEP_Z)

            printf("G1 F200 Z%.3f\n", Z);

        EXTRUDE(E);

        EXTRUDE(E);

        for (Z; Z > -1.001; Z -= STEP_Z)

            printf("G1 F200 Z%.3f\n", Z);

        EXTRUDE(E);

        EXTRUDE(E);

        for (Z; Z > -2.001; Z -= STEP_Z)

            printf("G1 F200 Z%.3f\n", Z);

        EXTRUDE(E);

        EXTRUDE(E);

        for (Z; Z > -2.541; Z -= STEP_Z)

            printf("G1 F200 Z%.3f\n", Z);

        EXTRUDE(E);

        EXTRUDE(E);

        for (X; X > -0.001; X -= STEP_X)

            printf("G1 F200 X%.3f\n", X);

        

        EXTRUDE(E);

        EXTRUDE(E);

        EXTRUDE(E);

        EXTRUDE(E);        

        if (layer < 2) {

            EXTRUDE(E);

            EXTRUDE(E);

            EXTRUDE(E);

        }

        for (Z; Z < -2.539; Z += STEP_Z)

            printf("G1 F20 Z%.3f\n", Z);

        EXTRUDE(E);

        EXTRUDE(E);

        if (layer < 2) {

            EXTRUDE(E);

            EXTRUDE(E);

        }

        for (Z; Z < -1.001; Z += STEP_Z)

            printf("G1 F20 Z%.3f\n", Z);

        EXTRUDE(E);

        EXTRUDE(E);

        if (layer < 2) {

            EXTRUDE(E);

            EXTRUDE(E);

        }

        for (Z; Z < -0.499; Z += STEP_Z)

            printf("G1 F20 Z%.3f\n", Z);

        EXTRUDE(E);

        EXTRUDE(E);

        

        if (layer < 2) {

            EXTRUDE(E);

            EXTRUDE(E);

        }

        for (Z; Z < 0.001; Z += STEP_Z) {

            if (Z > -0.030) {

                Y += STEP_Y;

                printf("G1 F200 Y%.3f\n", Y);

            }

            printf("G1 F20 Z%.3f\n", Z);

        }

        Y += STEP_Y;

        printf("G1 F200 Y%.3f\n", Y);

        layer++;

    }

    return;

}

void base_filled_rectangle(void) {

    int layer = 0;

    int max_E = IMAX_E, cnt_E;

    for(cnt_E = 0; cnt_E < max_E; cnt_E++)

        EXTRUDE(E);

    while (layer < 7) {

        if (layer == 2)

            max_E += 4;

        

        if (layer == 6)

            max_E -= 2;

        while(Z > -2.541) {

            for (X; X < 37.101; X += STEP_X)

                printf("G1 F200 X%.3f\n", X);

            for(cnt_E = 0; cnt_E < max_E; cnt_E++)

                EXTRUDE(E);

            Z -= STEP_Z;

            printf("G1 F200 Z%.3f\n", Z);

            Z -= STEP_Z;

            printf("G1 F200 Z%.3f\n", Z);

        

            for(cnt_E = 0; cnt_E < max_E; cnt_E++)

                EXTRUDE(E);

            for (X; X > -0.001; X -= STEP_X)

                printf("G1 F200 X%.3f\n", X);

            for(cnt_E = 0; cnt_E < max_E; cnt_E++)

                EXTRUDE(E);

            Z -= STEP_Z;

            printf("G1 F200 Z%.3f\n", Z);

            Z -= STEP_Z;

            printf("G1 F200 Z%.3f\n", Z);

        

        }

        for (Z; Z < -2.539; Z += STEP_Z)

            printf("G1 F200 Z%.3f\n", Z);

        for(cnt_E = 0; cnt_E < max_E; cnt_E++)

            EXTRUDE(E);

        for (Z; Z < -1.001; Z += STEP_Z)

            printf("G1 F200 Z%.3f\n", Z);

        for(cnt_E = 0; cnt_E < max_E; cnt_E++)

            EXTRUDE(E);

        

        for (Z; Z < -0.499; Z += STEP_Z)

            printf("G1 F200 Z%.3f\n", Z);

        

        for(cnt_E = 0; cnt_E < max_E; cnt_E++)

            EXTRUDE(E);

        for (Z; Z < 0.001; Z += STEP_Z)

            printf("G1 F200 Z%.3f\n", Z);

        

        for(cnt_E = 0; cnt_E < max_E; cnt_E++)

            EXTRUDE(E);

        Y += STEP_Y;

        printf("G1 F200 Y%.3f\n", Y);

        Y += STEP_Y;

        printf("G1 F200 Y%.3f\n", Y);

        Y += STEP_Y;

        printf("G1 F200 Y%.3f\n", Y);

        Y += STEP_Y;

        printf("G1 F200 Y%.3f\n", Y);

        Y += STEP_Y;

        printf("G1 F200 Y%.3f\n", Y);

        Y += STEP_Y;

        printf("G1 F200 Y%.3f\n", Y);

        

        layer++;

    }

}

void marlin_init(void) {

    printf("G90\n");

    printf("M106 S225\n");

    printf("M109 S225\n");

    return;

}

void marlin_finish(void) {

    printf("M106 S0\n");

    printf("M109 S0\n");

   

    for (Z; Z < 0.777; Z += STEP_Z)

        printf("G1 F200 Z%.3f\n", Z);

    

    return;

}

int main(int argc, char **argv) {    

    marlin_init();

    base_filled_rectangle();

    surface_edge_border();

    marlin_finish();

    return 1;

}

Printed piece

The definitive work production is below in three pictures

Files to download support_card.c et support_card.g

I copy support_card.g in an SD card that I insert into the 3d printer SD module and ...

the printer start to print the support card.

Difficulties I met

One of the severe drawbacks is that we can't compare floating point number. For example, to test the number 0.444 we have to tester whether 0.444 is less than 0.4441 or more than 0.4439. An another drawback is that to print the border frame we have to level up very right. It needs a kind of patience to get the combo.

 

Top
contact