Welcome! Log In Create A New Profile

Advanced

Marlin Pulse Width Lengthening

Posted by Blairm 
Marlin Pulse Width Lengthening
December 24, 2012 02:35AM
Hello Guys,

My friend is helping me build a Mendel Max variant (ballscrews on the Z with no supports). After he built 2 previous machines using Printerboards and having some issues with burning plugs on the stepper drivers etc, he has redone the boards with remote stepper drivers. Opto's were included for isolation, but what was not realized at the time was very short length of the pulse from the Marlin firmware. Keen to retain Marlin (I believe teacup will work?) as we have LCD, SD etc but I am struggling to find a current solution to lengthen the pulse. Currently we are measuring just under 3 uS whick looks longer than an earlier version we measured at about 1.4 uS.

I found [github.com] but it looks like it is not longer able to be used in the current version.

Can someone please point me in the correct direction. Everything looks like the leaning tower of Pisa at present as it seems to be missing steps regularly.

Regards Blair
Re: Marlin Pulse Width Lengthening
December 25, 2012 02:51PM
Hi Guys,

I have been trying to work my way through this issue. My code skills are basic, but I have identified the following:

April version (1.4 uS pulse Width):

counter_y += current_block->steps_y;
if (counter_y > 0) {
WRITE(Y_STEP_PIN, HIGH);
counter_y -= current_block->step_event_count;
WRITE(Y_STEP_PIN, LOW);
count_position[Y_AXIS]+=count_direction[Y_AXIS];
}


Latest version (Around 3 uS pulse width):

counter_y += current_block->steps_y;

if (counter_y > 0) {

WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN);

counter_y -= current_block->step_event_count;

count_position[Y_AXIS]+=count_direction[Y_AXIS];

WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);



So the addition (move) of the single line between line between pin inverts seems to have added 1.6 uS approx to the pulse. They have obviously done some other changes for flexibility or something. Guess allow inversion of lines more easily?


So I am wondering if we try something like adding a function as below:

void Pulse_Lengthen(){
// Alter i to increase wait length
for(int8_t i=0; i < 2; i++){
}
}

Should take maybe 3 uS to execute based on the above? Looks like we need about 5uS to get reliable stepping with the opto's we are using.

I have called this function between the pin toggle lines in the code that I can identify. Not able to test for a few days as out of town over the holidays, but I am wondering if this is likely to invoke the "Law of Unintended Consequences". Could I muck the whole program up and see time over run issues etc in other parts of the code? I would hate to introduce some other issues that may not manifest themselves in easily identifiable ways.

Anyway, Season Greeting and thanks from Down Under in New Zealand.


Regards Blair
Re: Marlin Pulse Width Lengthening
February 06, 2013 01:52PM
I know this is old, but CNCDudez in the UK just add delayMicroseconds(1) after every WRITE.
So it sends a pulse, waits, then continues.
I've successfully added delay in Marlin.

I have an Azteeg X3 with external box stepper drivers, 542 and 420 size.

it works well, but I am struggling to solve a buffer underrun issue.
Small curves stutter and jitter at any speed.

Even with low polygon count, radii cause missed steps and an alignment issue.
I can move straight line (infill) very nicely.
Re: Marlin Pulse Width Lengthening
February 07, 2013 03:24AM
Thanks Dave,

We tried a couple of things and finally managed to fool the compiler to actually include the lengthening. I have not got access to the code tonight, but will certainly look at trying your solution at the weekend.

Regards Blair
Re: Marlin Pulse Width Lengthening
February 07, 2013 06:18PM
I've concluded the 420 box drivers are to blame and am going to install Gecko 251x on my X and Y.

I was reviewing the latest Marlin and in the stepper.cpp, the HIGH and LOW write sections are a bit different now.

attached is what I feel is the Marlin V1 stepper.cpp changes to introduce a 1microsecond delay after each STEP pin high instruction.
for X,Y,Z and E, and not added to the CoreXY section.

Here is the CNCdudez forum that has their marlin code in a zip file.
[www.ukcnc.info]
He also describes the HIGH/LOW delay area.

Dave
Attachments:
open | download - stepper.cpp (32.9 KB)
Re: Marlin Pulse Width Lengthening
November 27, 2013 09:45AM
Has anyone been able to figure out of to get the pulses longer. I need to get my pulses to about 10us. I have been able to do this inside teacup but marlin has so features built in that I like.
Thanks,
Ryan
Re: Marlin Pulse Width Lengthening
November 14, 2014 12:17AM
I have successfully achieved pulse width of 12.6us using Marlin. If you have done Microcontroller programming before all you need to do is check out the ISR and make necessary changes der.
Sorry, only registered users may post in this forum.

Click here to login