Welcome! Log In Create A New Profile

Advanced

Electronics - L298N Stepper Motor Driver

Posted by isolt 
Electronics - L298N Stepper Motor Driver
December 02, 2012 09:54PM
Hi I'm planning on building a reprap.
I want to learn more about audrino's so I two birds with one stone if I do that.
Pololu drivers and Ramps seems the popular way to go.
I was wondering if there was any downside to using these L298N drivers instead?
[dx.com]

Obviously the electronics would be larger, and I'd have to make my own heating circuits that are included on the RAMPS.
Any other downsides?
I can get a mega clone and 4 steppers shipped here for about $56, that seems like a very cheap solution.
Re: Electronics - L298N Stepper Motor Driver
December 03, 2012 01:28AM
That a very simple device. It doesn't provide the standard enable, step and direction interface so will not work with normal firmware (with out additional hardware) and it only does half stepping so It will be noisy and jerky.

reprap used to use them before everyone moved to pololu see [reprap.org]

Edited 2 time(s). Last edit at 12/03/2012 01:34AM by Dust.
Re: Electronics - L298N Stepper Motor Driver
December 03, 2012 03:49PM
Thanks Dust, that's just the sort of info I was looking for!
Re: Electronics - L298N Stepper Motor Driver
August 25, 2013 06:37AM
I agree with some of the above, but you most certainly CAN do microstepping with them. It needs some different hardware though.... like my design that runs sine wave PWM via a 64 byt look up table to generate the top half of a sine wave. The drawback is that you need a fast microcontroller to schedule all the look up table entries, correlate them to the correct enable pin, synchronise them with the individual direction pin polarities to each pin and still get all the other stuff done.

I'm using an ARM Cortex-M3 to make all that happen, plenty of time for it. It's the delta calculations that have taken it from zippy to just fast.smileys with beer
Re: Electronics - L298N Stepper Motor Driver
August 27, 2013 03:18AM
Rather an old thread to dig up, but...
The L298N uses BJTs on the outputs as opposed to the DMOS based A498x / DRV88xx chips. Therefore, these suckers would get rather 'warm' by comparison if they were driving something like our 1.7A or so steppers in a RepRap...
While they are 'rated' to 2A continuous, they'd need a fairly decent heatsink on each one to achieve anything close to that!

Sure, the DMOS devices might be a little more expensive to begin with, but once you factor in all the effort to make an L298N do what we want, I suspect the price difference will be negligible.
Re: Electronics - L298N Stepper Motor Driver
August 28, 2013 04:16AM
Cost is actually pretty similar.
Mosfet highly integrated stepper devices such as the Allegro chips give a tidier PCB solution using less real estate, but I've already solved the "all the effort to make an L298N do what we want" issuesmiling smiley It's nice to be able to choose the degree of microstepping myself !

As for the age of the thread... Not nearly as old as the 4 year old Arm circuit board I'm only now finishing the firmware for!spinning smiley sticking its tongue out
Re: Electronics - L298N Stepper Motor Driver
August 28, 2013 06:34AM
Arm firmware?? link please smiling smiley
Re: Electronics - L298N Stepper Motor Driver
September 03, 2013 05:41AM
I think it attaches if I tick for my signature... Only recently back in this forum.

My board is completely custom, I designed it myself.
Here's my sys_tick code:
(uStep64 is a 64 byte top half sinewave table.)

void SysTickHandler(void)
{
//toggle the Piezo pin:
if (pzoState==1)
{
pzoCounter=(pzoCounter+1)%pzoPeriod;
if (pzoCounter==1)
{
GPIO_WriteBit(GPIOB,GPIO_Pin_11,(BitAction)(1-GPIO_ReadOutputDataBit(GPIOB, GPIO_Pin_11)));
}
}

//Set RC type Servo motor pulses:
GPIO_WriteBit(GPIOC,GPIO_Pin_14,PWMpower1>servo.count);
GPIO_WriteBit(GPIOC,GPIO_Pin_15,PWMpower2>servo.count);
GPIO_WriteBit(GPIOB,GPIO_Pin_10,PWMpower3>servo.count);
GPIO_WriteBit(GPIOB,GPIO_Pin_4,PWMpower4>servo.count);
GPIO_WriteBit(GPIOB,GPIO_Pin_3,PWMpower5>servo.count);

//Set Transistor drivers:
GPIO_WriteBit(GPIOA,GPIO_Pin_8,(servo.req1>servo.count));
GPIO_WriteBit(GPIOA,GPIO_Pin_13,(servo.req2>servo.count));
GPIO_WriteBit(GPIOA,GPIO_Pin_14,(servo.req3>servo.count));
GPIO_WriteBit(GPIOA,GPIO_Pin_15,(servo.req4>servo.count));
GPIO_WriteBit(GPIOE,GPIO_Pin_7,(servo.req5>servo.count));
servo.count=(servo.count+1)%400; // 18-25 mS control pulse active high for 1mS to 2mS

// Sequence step calculations between motors per permitted interrupt to reduce service period:
StepDithercount-=1;
if (StepDithercount < 1)
{
StepDithercount = StepDither;
TaskCounter=(TaskCounter+1)%4;
switch(TaskCounter) // Stepper motor rotations:

{
case 0:
// if (GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_5)&&(limitOverride==1)) w.actual=0; //zero axis on end detection

if (w.req != w.actual)
{
w.actual+=(((w.req-w.actual)>0)-((w.req-w.actual)<0)); // Move ONE and one step only, if required! (boolean)
MotorSteplock(1,(w.actual&96)>>5); //Drive the coil direction off bits 64 and 32
PWMStepperCoilPair(1,uStep64[(w.actual)&63],uStep64[(w.actual+32)&63]); // set PWMs off bits 0-5
}
break;
case 1:
if (x.req!=x.actual)
// bzst=(x.req-x.actual);//if (bzst!=0)
{
x.actual+=(((x.req-x.actual)>0)-((x.req-x.actual)<0));
MotorSteplock(2,(x.actual&96)>>5);
PWMStepperCoilPair(2,uStep64[(x.actual+32)&63],uStep64[(x.actual)&63]);
}
break;
case 2:
if (y.req!=y.actual)
{
y.actual+=(((y.req-y.actual)>0)-((y.req-y.actual)<0));
MotorSteplock(3,(y.actual&96)>>5);
PWMStepperCoilPair(3,uStep64[(y.actual)&63],uStep64[(y.actual+32)&63]);
}
break;
case 3:
if (z.req!=z.actual)
{
z.actual+=(((z.req-z.actual)>0)-((z.req-z.actual)<0)); // (the sign of z.actual)
MotorSteplock(4,(z.actual&96)>>5);
PWMStepperCoilPair(4,uStep64[(z.actual+32)&63],uStep64[(z.actual)&63]);
}
break;
}

//show green LED if all W,X,Y,Z targets achieved:
GPIO_WriteBit(GPIOE,Green_LED,(((w.req==w.actual)&(x.req==x.actual)&(y.req==y.actual)&(y.req==y.actual))));
}
}



Here's some stuff I adapted from others:
void line(int x1, int y1)
{
int x0=LastX;
int y0=LastY;
int dx = abs(x1-x0), sx = x0dy ? dx : -dy)/2, e2;

for(;winking smiley{
GoDelta(x0,y0,Z);
if (x0==x1 && y0==y1) break;
e2 = err;
if (e2 >-dx) { err -= dy; x0 += sx; }
if (e2 < dy) { err += dx; y0 += sy; }
}
}

void plotCircle(vs32 i_xm, vs32 i_ym, vs32 i_r)
{
//plotLine(i_xm,i_xy); //Flat line plotted move to circle beginning
int xm=i_xm;
int ym=i_ym;
int r=i_r;
int x = -r, y = 0, err = 2-2*r; /* II. Quadrant */
do {
GoDelta(xm-x, ym+y,Z); /* I. Quadrant */
r = err;
if (r <= y) err += ++y*2+1; /* e_xy+e_y < 0 */
if (r > x || err > y) err += ++x*2+1; /* e_xy+e_x > 0 or no 2nd y-step */
} while (x < 0);

xm=i_xm;
ym=i_ym;
r=i_r;
x = -r, y = 0, err = 2-2*r; /* II. Quadrant */
do {
GoDelta(xm-y, ym-x,Z); /* II. Quadrant */
r = err;
if (r <= y) err += ++y*2+1; /* e_xy+e_y < 0 */
if (r > x || err > y) err += ++x*2+1; /* e_xy+e_x > 0 or no 2nd y-step */
} while (x < 0);

xm=i_xm;
ym=i_ym;
r=i_r;
x = -r, y = 0, err = 2-2*r; /* II. Quadrant */
do {
GoDelta(xm+x, ym-y,Z); /* III. Quadrant */
r = err;
if (r <= y) err += ++y*2+1; /* e_xy+e_y < 0 */
if (r > x || err > y) err += ++x*2+1; /* e_xy+e_x > 0 or no 2nd y-step */
} while (x < 0);

xm=i_xm;
ym=i_ym;
r=i_r;
x = -r, y = 0, err = 2-2*r; /* II. Quadrant */
do {
GoDelta(xm+y, ym+x,Z); /* IV. Quadrant */
r = err;
if (r <= y) err += ++y*2+1; /* e_xy+e_y < 0 */
if (r > x || err > y) err += ++x*2+1; /* e_xy+e_x > 0 or no 2nd y-step */
} while (x < 0);
}


My CNC/extruder creation: [grael-minifactory.blogspot.com]
Sorry, only registered users may post in this forum.

Click here to login