Quantcast
Channel: Reprap Forum - Firmware - Marlin
Viewing all articles
Browse latest Browse all 2838

SOLVED Marlin and GCODE processing sequence v1.1.8 (2 replies)

$
0
0
I am having a bit of difficulty with something new I am working on. I am trying to add some new functionality for a robot and I am sure there are things I do not understand about Marlin. I have literally been up every night this week til early morning trying to get this to work and just need a bit of assistance please.

Here is a sample of a series of gcodes I execute from pronterface
where it says switch would be hit that is an endstop I have set up as E (i added new gcode to steppers.cpp to check this, that code is below as well, the code works fine when running from pronterface)
Anyway, I want to home E thus the G1 e-300 f100
then it hits the switch, then I disable endstops, set the home position for E to zero, reverse E just a bit to back off the endstop, enable the endstops, and reset the new position as E0 - this all works perfectly in pronterface when I type commands one at a time.

However, I then put the code in a gcode file and run from an SD card and BAM it does not work at all. The endstop no longer stops the motor at home. I am pretty sure this is due to queuing and processing commands out of order/or at least 2nd, 3rd,4th, etc before the 1st is completed.

G21			;METRIC
G90		     ;ABSOLUTE POS
M82			;M82 EXTRUDER ABSOLUTE

G1 E-300 F100	;HOME E
;SWITCH WOULD BE HIT
M121			;DISABLE ENDSTOPS TO MOVE AWAY
G92 E0		;SET POSITION TO ZERO
G1 E2 F50
M120			;ENABLE ENDSTOPS
G92 E0			;RESET POSITION AWAY FROM ENDSTOP AS ZERO

So I tried to deal with this in marlinmain.cpp. I wrote a new MCODE routine(below). I then had a gcode file with just a single M442 in it. It still does not process the way I want. I thought that my enqueuing a command and issuing a stepper.synchronize, it would do that command and wait for completion before the next.

So if you have ideas for how to process the original gcodes above, sequentially, I would be much appreciative. Or perhaps my M442 coding is missing something else to make it process properly.

inline void gcode_M442() {
  
  safe_delay(100);
    SERIAL_ECHO_START();
    SERIAL_ECHOLNPAIR("M442 START ", parser.value_byte());
    lcd_setstatus("M442 START");
enqueue_and_echo_commands_P(PSTR("G21"));
stepper.synchronize();
enqueue_and_echo_commands_P(PSTR("G90"));
stepper.synchronize();
enqueue_and_echo_commands_P(PSTR("M82"));
stepper.synchronize();
enqueue_and_echo_commands_P(PSTR("G1 E-300 F100"));
stepper.synchronize();
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR("AFTER G1 300 ", parser.value_byte());
lcd_setstatus("AFTER G1 300 ");
enqueue_and_echo_commands_P(PSTR("M121"));
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR("AFTER M121 ", parser.value_byte());
lcd_setstatus("AFTER M121 ");
stepper.synchronize();
enqueue_and_echo_commands_P(PSTR("G92 E0"));
stepper.synchronize();
enqueue_and_echo_commands_P(PSTR("G1 E2 F50"));
stepper.synchronize();
enqueue_and_echo_commands_P(PSTR("M120"));
stepper.synchronize();
enqueue_and_echo_commands_P(PSTR("G92 E0"));
stepper.synchronize();
}

Pronterface output from m442 command
echo:enqueueing "M23 test9~1.gco"
echo:enqueueing "M24"
echo:Now fresh file: test9~1.gco
File opened: test9~1.gco Size: 156
File selected
Done printing fiecho:enqueueing "M84 X Y Z E"
le
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing

gcode from steppers.cpp
  if((READ(E_MIN_PIN) == 0) && (ENDSTOPS_ENABLED))
        {SERIAL_PROTOCOLPGM("reademin");
          stepper.endstop_triggered(E_AXIS);
          all_steps_done = true;
          current_block = NULL;
          planner.discard_current_block();
                 }

Viewing all articles
Browse latest Browse all 2838

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>