Gcode - not in order line execution

Hi
i  am using repetier firmware 1.0 , Ramps1.4 , Arduino Mega   to control  a prototype robotic arm i build

i have setup the firmware in order to have a servo enable and one  stepper motor extra

the problem that i am having is that in a small Gcode  command line  i wrote to test the arm  some of the  commands are executing before the  order i have placed them 

the code is this one :
------------------------------------------------------------------------------
G28
G205 E0 P1
G201 X30 P1
G90
M340 P0 S500
M340 R1000 P0 S1500
G204 P1 S0
G1 X400 Y400 Z400 F2400
G1 Y600 Z600
G1 X10 Z740
M340 P0 S2500
G1 X10 Y500
G1 X400 Y100 f1500
G201 X5 P1
M340 R1000 P0 S500
G201 X30 P1
G90
M84
M104 T0 S0
M140 S0
M84
M104 T0 S0
M140 S0
M84
------------------------------------------------------------------------

the problem is  that  the  commands :
M340 P0 S2500  (line 11)
M340 P0 S2500 (line 12)
M340 R1000 P0 S500 (line 15)
G201 X5 P1 (line 14)
G201 X30 P1  (line 16)


became active at the same time as the :

G1 X400 Y400 Z400 F2400 (line 8 )

What i am doing wrong ?

how should i write these commands in order to be executed  in  the line order i choose?


Thanks in advance









Comments

  • Ok i found in one forum something similar and the solution is to use  M400  command  before each of the commands that were executing earlier than they should  .

    ( M400: Wait for current moves to finish )

    So with this code everything worked fine :

    G21
    G28
    G205 E0 P1
    G201 X30 P1
    G90
    M340 P0 S500
    M340 R1000 P0 S1500
    G204 P1 S0
    G1 X400 Y400 Z400 F2400
    G1 Y600 Z600
    G1 X10 Z740
    M400
    M340 P0 S2100
    G1 X10 Y500
    G1 X400 Y100
    M400
    G201 X5 P1
    M400
    M340 R1000 P0 S500
    G201 X30 P1
    G90
    M84
    M104 T0 S0
    M140 S0
    M84
    M104 T0 S0
    M140 S0
    M84
    M104 T0 S0
    M140 S0
    M84
    M104 T0 S0
    M140 S0
    M84



    i dont know if it the right solution but for the moment works

    if there is any other solution i would be glad  learn it


  • G0/G1 moves are buffered and executed in background for print quality, so yes M400 is the way to sync these moves so following moves execute when they are finished.

    Also be awayre about G340 being similar. They only set position and timeout but do NOT wait for the servo to reach it. In fact there is no feedback to measure this anyway. So add a G4 afterwards if you want to start moving only after servo is positioned.
  • Thanks :)
Sign In or Register to comment.