fra589 / grbl-Mega-5X

5/6 Axis version of Grbl, the open source, embedded, high performance g-code-parser and CNC milling controller written in optimized C that will run on an Arduino Mega2560
https://github.com/fra589/grbl-Mega-5X/wiki
Other
341 stars 159 forks source link

No delay after command M3 to keep time "pen down" #362

Closed Srallie closed 6 months ago

Srallie commented 6 months ago

Hello,

is it possible to create a delay of 300ms standard after command M3 SXX so that the plotter pen has time to go down? By pen up there is no delay needed. I wanna change it in the firmware, i dont want to change the gcode every time. Do you know how? in gcode.c?

greetz

fra589 commented 6 months ago

Hi @Srallie,

It's probably possible, but in my opinion it's not a good solution. Changing this in Grbl will lose compatibility with standard GCode operation. The normal solution to do what you need is to use a G4 P0.3 (Dwell GCode: http://linuxcnc.org/docs/html/gcode/g-code.html#gcode:g4) after the M3 command. This should be able to be added automatically by the post processor of the software that generates the GCode.

If you still want to add this tempo in Grbl-Mega-5X, you may be able to do it in spindle_control.c, in the spindle_sync() function.

@++; Gauthier.

Srallie commented 6 months ago

Hello,

Thank you for your answer. I want to use lightburn for my laser project, and now also for my vinyl cutter,then i can use the same program. But lightburn didnt have the option to tweak the gcode. Thats the reason that i will implement it in the firmware.

When i still want to change spindle_control.c, but i dont know how. I am not be able to figure that out. Small changes i can,but adding lines not.

Greetz lars

Verzonden vanaf Outlook voor Androidhttps://aka.ms/AAb9ysg


From: Gauthier Brière @.> Sent: Monday, February 19, 2024 12:11:44 PM To: fra589/grbl-Mega-5X @.> Cc: Srallie @.>; Mention @.> Subject: Re: [fra589/grbl-Mega-5X] No delay after command M3 to keep time "pen down" (Issue #362)

Hi @Sralliehttps://github.com/Srallie,

It's probably possible, but in my opinion it's not a good solution. Changing this in Grbl will lose compatibility with standard GCode operation. The normal solution to do what you need is to use a G4 P0.3 (Dwell GCode: http://linuxcnc.org/docs/html/gcode/g-code.html#gcode:g4) after the M3 command. This should be able to be added automatically by the post processor of the software that generates the GCode.

If you still want to add this tempo in Grbl-Mega-5X, you may be able to do it in spindle_control.c, in the spindle_sync() function.

@++; Gauthier.

— Reply to this email directly, view it on GitHubhttps://github.com/fra589/grbl-Mega-5X/issues/362#issuecomment-1952223947, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A46U5IZFHLD6LYU6X3H24TLYUMXPBAVCNFSM6AAAAABDPDH3ZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJSGIZDGOJUG4. You are receiving this because you were mentioned.Message ID: @.***>

fra589 commented 6 months ago

Hello @Srallie,

Try to change the spindlesync() function like this:
(from line 306 in the spindlecontrol.c file)

// G-code parser entry-point for setting spindle state. Forces a planner buffer sync and bails 
// if an abort or check-mode is active.
void spindle_sync(uint8_t state, float rpm)
{
  if (sys.state == STATE_CHECK_MODE) { return; }
  protocol_buffer_synchronize(); // Empty planner buffer to ensure spindle is set when programmed.
  spindle_set_state(state,rpm);
  if (gc_state.modal.spindle != SPINDLE_DISABLE) {
    delay_ms(300); // Force delay of 300 ms.
  }
}

I'm not be sure if this will work since don't have enough time and resources to make the needed tests. Tell me if it's help you :-)

@++; Gauthier.

Srallie commented 6 months ago

Hello,

First thanks a lot for your help. I have tried this code with 1000ms to see what happens. Now the knife goes down, cut a letter,then wait for 1s , then knife up, goes further to the next letter and knife goes directly down without delay, cut the letter,wait 1s and goes further.....

The delay is on the wrong place? Near by the right place i hope.

Greetz Lars

Verzonden vanaf Outlook voor Androidhttps://aka.ms/AAb9ysg


From: Gauthier Brière @.> Sent: Monday, February 19, 2024 6:27:38 PM To: fra589/grbl-Mega-5X @.> Cc: Srallie @.>; Mention @.> Subject: Re: [fra589/grbl-Mega-5X] No delay after command M3 to keep time "pen down" (Issue #362)

Hello @Sralliehttps://github.com/Srallie,

Try to change the spindle_sync() function like this: (from line 306 in the spindle_control.c file)

// G-code parser entry-point for setting spindle state. Forces a planner buffer sync and bails // if an abort or check-mode is active. void spindle_sync(uint8_t state, float rpm) { if (sys.state == STATE_CHECK_MODE) { return; } protocol_buffer_synchronize(); // Empty planner buffer to ensure spindle is set when programmed. spindle_set_state(state,rpm); if (gc_state.modal.spindle != SPINDLE_DISABLE) { delay_ms(300); // Force delay of 300 ms. } }

I'm not be sure if this will work since don't have enough time and resources to make the needed tests. Tell me if it's help you :-)

@++; Gauthier.

— Reply to this email directly, view it on GitHubhttps://github.com/fra589/grbl-Mega-5X/issues/362#issuecomment-1952923262, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A46U5IYJD7TFMLYCNCX7EJDYUODQVAVCNFSM6AAAAABDPDH3ZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJSHEZDGMRWGI. You are receiving this because you were mentioned.Message ID: @.***>

fra589 commented 6 months ago

HI @Srallie,

Oops !... Missed! :-)

By changing the direction of the test, it should probably work ?...

   if (gc_state.modal.spindle == SPINDLE_DISABLE) {
     delay_ms(300); // Force delay of 300 ms.
   }

@++; Gauthier.

Srallie commented 6 months ago

Hello Gauthier,

Now there is no delay after going up or down. Only after going down it need a pause. (Laser mode is selected)

greetz lars

fra589 commented 6 months ago

Hummmm...

I need to check more code... Sorry, I don't have lot of time this morning,... I will see it this afternoon...

Srallie commented 6 months ago

Thank you👍i will check it today after 11pm.

Greetz Lars

Verzonden vanaf Outlook voor Androidhttps://aka.ms/AAb9ysg


From: Gauthier Brière @.> Sent: Tuesday, February 20, 2024 9:26:10 AM To: fra589/grbl-Mega-5X @.> Cc: Srallie @.>; Mention @.> Subject: Re: [fra589/grbl-Mega-5X] No delay after command M3 to keep time "pen down" (Issue #362)

Hummmm...

I need to check more code... Sorry, I don't have lot of time this morning,... I will see it this afternoon...

— Reply to this email directly, view it on GitHubhttps://github.com/fra589/grbl-Mega-5X/issues/362#issuecomment-1953697962, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A46U5IZICOFG3NYW3PFVXYLYURM2FAVCNFSM6AAAAABDPDH3ZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJTGY4TOOJWGI. You are receiving this because you were mentioned.Message ID: @.***>

fra589 commented 6 months ago

I'm sorry, I was too quick to respond yesterday and this morning. I hadn't thought enough :-) This should work now:

// G-code parser entry-point for setting spindle state. Forces a planner buffer sync and bails 
// if an abort or check-mode is active.
void spindle_sync(uint8_t state, float rpm)
{
  if (sys.state == STATE_CHECK_MODE) { return; }
  protocol_buffer_synchronize(); // Empty planner buffer to ensure spindle is set when programmed.
  spindle_set_state(state,rpm);
  if (state == SPINDLE_ENABLE_CW) {
    delay_ms(300); // Force delay of 300 ms.
  }
}

(the delay work only for M3, not for M4 or M5)

@++; Gauthier.

Srallie commented 6 months ago

Hello,

He stops 300ms everytime when the knife is back up but not when the knife is down. Maybe it helps when the pwm is set from ** to zero and then pause 300ms?

greetz lars


Van: Gauthier Brière @.> Verzonden: dinsdag 20 februari 2024 16:15 Aan: fra589/grbl-Mega-5X @.> CC: Srallie @.>; Mention @.> Onderwerp: Re: [fra589/grbl-Mega-5X] No delay after command M3 to keep time "pen down" (Issue #362)

I'm sorry, I was too quick to respond yesterday and this morning. I hadn't thought enough :-) This should work now:

// G-code parser entry-point for setting spindle state. Forces a planner buffer sync and bails // if an abort or check-mode is active. void spindle_sync(uint8_t state, float rpm) { if (sys.state == STATE_CHECK_MODE) { return; } protocol_buffer_synchronize(); // Empty planner buffer to ensure spindle is set when programmed. spindle_set_state(state,rpm); if (state == SPINDLE_ENABLE_CW) { delay_ms(300); // Force delay of 300 ms. } }

(the delay work only for M3, not for M4 or M5)

@++; Gauthier.

— Reply to this email directly, view it on GitHubhttps://github.com/fra589/grbl-Mega-5X/issues/362#issuecomment-1954435167, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A46U5IYJFPVPYNZJSFWDGP3YUS4XTAVCNFSM6AAAAABDPDH3ZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJUGQZTKMJWG4. You are receiving this because you were mentioned.Message ID: @.***>

fra589 commented 6 months ago

Hello Lars,

So, I didn't understand at what point in GCode commands you want there to be a pause. I don't know your plotter and what commands control the pen. In the last code I posted, pause is executed after every M3 command. Can you explain what are the pen orders? Can you send an example of the GCode you use to drive the pen indicating where you want to insert the pauses?

@++; Gauthier

svenhb commented 6 months ago

I want to use lightburn for my laser project, and now also for my vinyl cutter

Do you know, that a RC-servo needs a different PWM than a laser? https://grbl-plotter.de/index.php?id=quick-guide&setlang=en#pwm Do you know, that a drag knife needs a different tool path than a laser? https://grbl-plotter.de/index.php?id=drag-tool&setlang=en I don't think lightburn can create a tool path for a drag knife...

Srallie commented 6 months ago

Hello,

In the nc code:

; LightBurn 1.4.01 ; GRBL device profile, absolute coords ; Bounds: X264.71 Y71.16 to X401.29 Y80.84 G00 G17 G40 G21 G54 G90 M4 ; Cut @ 6000 mm/min, 51% power M9 G0 X265.037Y77.862 M3 ; Layer 100 G1 X264.987S51F6000 ----------> knife goes down ..... ..... ..... G0 X270.537Y75.037 -----------> knife goes up and moves to position G1 X270.438Y74.737-----------> knife goes down and moves

I see that after the M3 – G1 X264.987S51F6000 command the knife will go up after G0 and with G1 he goes down. Thats the reason why your code waits on a written M3 command but there isn't 🙁 my fault... Is it also possible to create?

Greetz Lars


Van: Gauthier Brière @.> Verzonden: woensdag 21 februari 2024 07:08 Aan: fra589/grbl-Mega-5X @.> CC: Srallie @.>; Mention @.> Onderwerp: Re: [fra589/grbl-Mega-5X] No delay after command M3 to keep time "pen down" (Issue #362)

Hello Lars,

So, I didn't understand at what point in GCode commands you want there to be a pause. I don't know your plotter and what commands control the pen. In the last code I posted, pause is executed after every M3 command. Can you explain what are the pen orders? Can you send an example of the GCode you use to drive the pen indicating where you want to insert the pauses?

@++; Gauthier

— Reply to this email directly, view it on GitHubhttps://github.com/fra589/grbl-Mega-5X/issues/362#issuecomment-1955958660, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A46U5IZABKSWH6CRGII5EOLYUWFPJAVCNFSM6AAAAABDPDH3ZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJVHE2TQNRWGA. You are receiving this because you were mentioned.Message ID: @.***>

fra589 commented 6 months ago

Oh! I'm afraid you will can't simply do this!

The pen down / pen up is not drived by the spindle M3 / M4 / M5 command. It's driven by the G0 / G1 command: G0 => move with pen up => no cut G1 => move with pen down => cut

With a laser, cutting id driven by the spindle status: M5 => laser is off => next moves will no cut M3/M4 => laser is on => next move will cut

It may be very very difficult to insert pause between no cutting moves and cutting moves. All moves are buffered (planned) with a timer info which define when they must be executed. This moment is calculated according to the programed speed and depending of acceleration property of the machine (very complex calculation depending of multi-axis moves, speed and acceleration).

Modify this planner algorithm seams to me very too complicated. I have neither the time nor the means to do it for you.

As @svenhb said, I don't think Lightburn is the good software for your need... Perhaps you should find a specific drag knife software.

@++;
Gauthier.

Srallie commented 6 months ago

Hello,

I use inkscape to create a hpgl file with knife offset included. Then i import the hpgl file in lightburn. settings: $30=100 $31=0

When i set the laser power for example to 50% my solenoid will reduce the knife pressure on the vinyl.

This works perfect,accept when i reduce the power,the solenoid will be take longer to go down en misses a piece of the path....

I will looking for an other program they works with M3 commands,or where i can put the G4 P## parameter. Then i will try your piece of code again. I will report my outcomes.

greetz lars


Van: Gauthier Brière @.> Verzonden: woensdag 21 februari 2024 08:44 Aan: fra589/grbl-Mega-5X @.> CC: Srallie @.>; Mention @.> Onderwerp: Re: [fra589/grbl-Mega-5X] No delay after command M3 to keep time "pen down" (Issue #362)

Oh! I'm afraid you will can't simply do this!

The pen down / pen up is not drived by the spindle M3 / M4 / M5 command. It's driven by the G0 / G1 command: G0 => move with pen up => no cut G1 => move with pen down => cut

With a laser, cutting id driven by the spindle status: M5 => laser is off => next moves will no cut M3/M4 => laser is on => next move will cut

It may be very very difficult to insert pause between no cutting moves and cutting moves. All moves are buffered (planned) with a timer info which define when they must be executed. This moment is calculated according to the programed speed and depending of acceleration property of the machine (very complex calculation depending of multi-axis moves, speed and acceleration).

Modify this planner algorithm seams to me very too complicated. I have neither the time nor the means to do it for you.

As @svenhbhttps://github.com/svenhb said, I don't think Lightburn is the good software for your need... Perhaps you should find a specific drag knife software.

@++; Gauthier.

— Reply to this email directly, view it on GitHubhttps://github.com/fra589/grbl-Mega-5X/issues/362#issuecomment-1956060966, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A46U5I4VN4CXXAPP34DG5SDYUWQUDAVCNFSM6AAAAABDPDH3ZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJWGA3DAOJWGY. You are receiving this because you were mentioned.Message ID: @.***>

svenhb commented 6 months ago

I will looking for an other program they works with M3 commands,or where i can put the G4 P## parameter.

GRBL-Plotter can do: PWM setup with delay: https://grbl-plotter.de/index.php?id=form-setup-3#pen-up-down Drag tool compensation: https://grbl-plotter.de/index.php?id=form-setup-1#path-modifications

https://github.com/svenhb/GRBL-Plotter

Srallie commented 6 months ago

I will give it a try. Thank you.

Greetz lars

Verzonden vanaf Outlook voor Androidhttps://aka.ms/AAb9ysg


From: Sven @.> Sent: Wednesday, February 21, 2024 10:55:25 AM To: fra589/grbl-Mega-5X @.> Cc: Srallie @.>; Mention @.> Subject: Re: [fra589/grbl-Mega-5X] No delay after command M3 to keep time "pen down" (Issue #362)

I will looking for an other program they works with M3 commands,or where i can put the G4 P## parameter.

GRBL-Plotter can do: PWM setup with delay: https://grbl-plotter.de/index.php?id=form-setup-3#pen-up-down Drag tool compensation: https://grbl-plotter.de/index.php?id=form-setup-1#path-modifications

— Reply to this email directly, view it on GitHubhttps://github.com/fra589/grbl-Mega-5X/issues/362#issuecomment-1956278296, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A46U5I274RYINEOASWHRBIDYUXAA3AVCNFSM6AAAAABDPDH3ZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJWGI3TQMRZGY. You are receiving this because you were mentioned.Message ID: @.***>

Srallie commented 6 months ago

Hello Sven,

When i select in grbl-plotter the drag knife compensation then the program will hang. And the problem to get connected with bluetooth is still there, it didnt connect only in your program, with cable it still works

Verzonden vanaf Outlook voor Androidhttps://aka.ms/AAb9ysg


From: Lars Senden @.> Sent: Wednesday, February 21, 2024 11:10:56 AM To: fra589/grbl-Mega-5X @.>; fra589/grbl-Mega-5X @.> Cc: Mention @.> Subject: Re: [fra589/grbl-Mega-5X] No delay after command M3 to keep time "pen down" (Issue #362)

I will give it a try. Thank you.

Greetz lars

Verzonden vanaf Outlook voor Androidhttps://aka.ms/AAb9ysg


From: Sven @.> Sent: Wednesday, February 21, 2024 10:55:25 AM To: fra589/grbl-Mega-5X @.> Cc: Srallie @.>; Mention @.> Subject: Re: [fra589/grbl-Mega-5X] No delay after command M3 to keep time "pen down" (Issue #362)

I will looking for an other program they works with M3 commands,or where i can put the G4 P## parameter.

GRBL-Plotter can do: PWM setup with delay: https://grbl-plotter.de/index.php?id=form-setup-3#pen-up-down Drag tool compensation: https://grbl-plotter.de/index.php?id=form-setup-1#path-modifications

— Reply to this email directly, view it on GitHubhttps://github.com/fra589/grbl-Mega-5X/issues/362#issuecomment-1956278296, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A46U5I274RYINEOASWHRBIDYUXAA3AVCNFSM6AAAAABDPDH3ZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJWGI3TQMRZGY. You are receiving this because you were mentioned.Message ID: @.***>

fra589 commented 6 months ago

Hello,

Hello Sven, When i select in grbl-plotter the drag knife compensation then the program will hang.

It's not a grbl-Mega-5X issue... You must open a new issue to grbl-plotter: https://github.com/svenhb/GRBL-Plotter/issues

And the problem to get connected with bluetooth is still there, it didnt connect only in your program, with cable it still works

grbl-Mega-5X doesn't have Bluetooth support... Can't be a grbl-Mega-5X issue.

@++; Gauthier.