Welcome! Log In Create A New Profile

Advanced

Marlin successive home issue

Posted by Sodombar 
Marlin successive home issue
June 17, 2015 08:56AM
Aye all,

I'm new here. I work on a 3D printer (based on ramps 1.4 + Marlin) which prints drawings. So it's more like a pseudo-3D printer because drawing doesn't have thickness.

For bring back on top the Z motor, I use the command G28 Z0 to home it because I don't have enought skill to write my own command to do something like that.

My issue is between two calls of G28, sometimes the gcode inside is not executed. The Gcode is well executed untill we reach these lines :

G28 Z0
G0 X-9.253807106598984 Y26.3502538071066
M12
M3
G1 X-0.5939086294416244 Y21.3502538071066 F250
G1 X-0.5939086294416244 Y11.350253807106599
G1 X-9.253807106598984 Y6.3502538071066
G1 X-17.913705583756347 Y11.350253807106599
G1 X-17.913705583756347 Y21.3502538071066
G1 X-9.253807106598984 Y26.3502538071066
M5
M13
G28 Z0
G0 X-7.894670050761421 Y-6.361167512690355
M12
M3
G1 X0.766497461928934 Y-11.360406091370558 F250
G1 X0.766497461928934 Y-21.360406091370557
G1 X-7.895939086294417 Y-26.360406091370557
G1 X-16.555837563451774 Y-21.360406091370557
G1 X-16.555837563451774 Y-11.360406091370558
G1 X-7.895939086294417 Y-6.3604060913705585
M5
M13
G28 Z0


There is approximately 10 lines between two calls. These lines are not executed. They are just ignored so we have a succession of home command.

I noticed that the Gcode is well exectued when there is enought command between two calls (around 20 lines).

When there is enought command line between two calls, it works well again. It appears that there is a kind of delay between two calls.

If I have a question, it would be : is it a mistake to use the home command so many times ?

PS : sorry for my approximate english ^^"

Edited 1 time(s). Last edit at 06/17/2015 08:57AM by Sodombar.
Attachments:
open | download - fat.gcode (16.6 KB)
Re: Marlin successive home issue
June 17, 2015 09:12AM
I dont see why you need to home it so often? after you have homed it once it should be fine.

You can instruct the printer to go back to the same position it was homed to by giving it the command G0 Z0

What does M3 M5 M12 and M13 control?
Re: Marlin successive home issue
June 17, 2015 09:13AM
Quote
Sodombar
For bring back on top the Z motor, I use the command G28 Z0 to home it because I don't have enought skill to write my own command to do something like that.

I don't know about the multiple homing issue you describe but the idea is that you home once at the start of the program and from that point on the machine knows exactly where it is (and can move around as instructed).

Instead of homing multiple times (you have to home it once at the start of the program though), try the following to make the head go back to z=0:
G0 Z0
Re: Marlin successive home issue
June 17, 2015 09:35AM
@wes1007 : I forgot to mention my personal commands. M3 active/ M5 deactive a tool which draws and M12 activate/ M13 deactivate an other tool which determine when we reach the platform. This tool is attached to the Z motor and drive it towards the platform. Unfortunatelly, the tool moves the motors but for the firmware, the motor doesn't move so it still at the position Z0.

@mandrav : The reason why I don't use this command is because for the software, the motor stay at the same position, Z0 so G0 Z0 won't bring back to the top the motor.

The first option I thought is to write a custom command which do a similar thing as G28. I want the Z motor move to the top until it hits a endstop. That's why I use the home command but it is not really appropriate.
Re: Marlin successive home issue
June 17, 2015 10:35AM
Both segments that doesn´t get printed/painted have negative ccordinates.

Usually the firmware ignores all commands with values below "0" unless you allow it.

Lines 339ff from marlins configuration.h:
#define min_software_endstops true // If true, axis won't move to coordinates less than HOME_POS.
#define max_software_endstops true  // If true, axis won't move to coordinates greater than the defined lengths below.

Another point, maybe Marlin resets the code-buffer after homing?

-Olaf

Edited 1 time(s). Last edit at 06/17/2015 10:39AM by o_lampe.
Re: Marlin successive home issue
June 17, 2015 11:04AM
@o_lampe : Here is the beginning of the Gcode file :
G28 Z0
M12
M3
G0 X-63.569035532994924 Y0.2878172588832487
G2 X-63.21065989847716 Y2.230964467005076 I5.449238578680204 J0 F250
G2 X-62.10406091370558 Y4.126903553299492 I6.2944162436548226 J-2.4010152284263957
G2 X-60.464467005076145 Y5.675126903553299 I7.114213197969543 J-5.893401015228426
G2 X-57.71065989847716 Y7.3578680203045685 I11.225888324873097 J-15.258883248730966
G2 X-51.65736040609137 Y9.459390862944163 I11.076142131979696 J-22.15228426395939
G2 X-43.568527918781726 Y10.286802030456851 I8.088832487309645 J-39.055837563451774
G2 X-35.47969543147208 Y9.459390862944163 I0 J-39.88324873096447
G2 X-29.426395939086298 Y7.3578680203045685 I-5.022842639593908 J-24.253807106598984
G2 X-26.67258883248731 Y5.675126903553299 I-8.472081218274111 J-16.941624365482234
G2 X-25.03299492385787 Y4.126903553299492 I-5.474619289340101 J-7.441624365482234
G2 X-23.926395939086294 Y2.230964467005076 I-5.187817258883248 J-4.2969543147208125
G2 X-23.568527918781726 Y0.2868020304568528 I-5.091370558375634 J-1.9416243654822334
G2 X-23.926395939086294 Y-1.6548223350253808 I-5.449238578680204 J0
G2 X-25.03299492385787 Y-3.550761421319797 I-6.2944162436548226 J2.4010152284263957
G2 X-26.67258883248731 Y-5.098984771573604 I-7.114213197969543 J5.893401015228426
G2 X-29.426395939086298 Y-6.784263959390863 I-11.225888324873097 J15.258883248730966
G2 X-35.47969543147208 Y-8.883248730964468 I-11.076142131979696 J22.15228426395939
G2 X-43.568527918781726 Y-9.713197969543147 I-8.088832487309645 J39.055837563451774
G2 X-51.65736040609137 Y-8.883248730964468 I0 J39.88324873096447
G2 X-57.71065989847716 Y-6.784263959390863 I5.022842639593908 J24.253807106598984
G2 X-60.464467005076145 Y-5.098984771573604 I8.472081218274111 J16.941624365482234
G2 X-62.10406091370558 Y-3.550761421319797 I5.474619289340101 J7.441624365482234
G2 X-63.21065989847716 Y-1.6548223350253808 I5.187817258883248 J4.2969543147208125
G2 X-63.568527918781726 Y0.2868020304568528 I5.091370558375634 J1.9416243654822334
M5
M13
G28 Z0


Negative coordinates don't seem to be a problem for the execution.
Re: Marlin successive home issue
June 17, 2015 11:59AM
So how does this tool determine when it is on the surface? How does it drive the stepper motor? What is the tool?
Re: Marlin successive home issue
June 17, 2015 12:38PM
The tool is a kind of sensor.

I use this function to drive the motor :

// Takes a single step
void takeSingleStep() {
Z_STEP_WRITE(LOW);
delayMicroseconds(stepPulseWidthInMicroSec);
Z_STEP_WRITE(HIGH);
delayMicroseconds(timeBetweenStepsInMicroSec);
}

In relation to the state of the sensor :

// GO UP
if (state1 < threshold && state2 >= threshold) {
Z_DIR_WRITE(HIGH);
takeSingleStep();

// GO DOWN
if (state2 < threshold && state1 >= threshold) {
Z_DIR_WRITE(LOW);
takeSingleStep();


In fact, the motor moves but return no information about its motion. Because, if it could return some informations about its position then it would be possible to use G0 Z0 as the motor is no longer at the position Z0.

Edited 1 time(s). Last edit at 06/17/2015 12:39PM by Sodombar.
Re: Marlin successive home issue
June 17, 2015 12:47PM
Quote
Sodombar
The tool is a kind of sensor.

I use this function to drive the motor :

// Takes a single step
void takeSingleStep() {
Z_STEP_WRITE(LOW);
delayMicroseconds(stepPulseWidthInMicroSec);
Z_STEP_WRITE(HIGH);
delayMicroseconds(timeBetweenStepsInMicroSec);
}

In relation to the state of the sensor :

// GO UP
if (state1 < threshold && state2 >= threshold) {
Z_DIR_WRITE(HIGH);
takeSingleStep();

// GO DOWN
if (state2 < threshold && state1 >= threshold) {
Z_DIR_WRITE(LOW);
takeSingleStep();


In fact, the motor moves but return no information about its motion. Because, if it could return some informations about its position then it would be possible to use G0 Z0 as the motor is no longer at the position Z0.

Okay so why not add a variable in that counts the number of steps from the M12 command till it reaches the platform. Then when an M13 is issued it will go back up the same amount. and reset the counter back to 0. Im not brilliant with code (else id have put all the bits in for you) and i dont have all your code to play with.

Edited 1 time(s). Last edit at 06/17/2015 12:48PM by wes1007.
Re: Marlin successive home issue
June 17, 2015 01:38PM
If you implemented this code snip into Marlin, IMHO it is a bad idea to use the delay command.
Because it freezes the cpu and it is not able to answer interrupts and other stuff during the delay.
It is better to use a timer, but I´m not familiar with Marlin to say, which timer is not occupied already..
-Olaf
Re: Marlin successive home issue
June 18, 2015 06:10AM
@wes1007 : initially I had a variable which counted the number of steps but, the problem is, unlikely to home command, the program doesn't wait for the counter to reach 0. Typically, it just had time to make one step back before the next command is executed. That's why I use the home command for that.

If I use this counter again, I would like to find a way to interrupt the program while a condition is not verified, and in that case, the counter equal 0.

But, because there is always a but, even the tool drive the motor up and down, the firmware can do it too and in the same time. I explain, even we count the number of steps in order to come back to the initial position, nothing prevent the firmware (for any reason) to move the same motor. So the firmware will translate the original position and when the M13 command is executed, the motor won't step back at its original position.

Using home command with an endstop provides a fixed point in the space.

@Olaf : you are certainly right but for now it works so I'll see this later.
Sorry, only registered users may post in this forum.

Click here to login