Alternative pins for NEMA 17

I'm making a project using an Arduino MEGA, and have run out of PWM pins for a stepper motor.
The NEMA 17 motor is going to be controlled with a L298N Dual Bridge controller

However, I have run out of PWM pins, but then I saw the pinout diagram for the Arduino MEGA, and noticed, that four of the pins in the end of the board, are marked as PWM, pins 44, 45, 46 and 52.

Will I be able to use pins 44, 45, 46 and 52 as PWM outputs for the L298N Dual Bridge controller?

1 Like

There is no need for PWM pins to run a stepper.

The ancient and inefficient L298 is just about the worst driver that one could pick for a bipolar stepper driver. Those are terrible DC motor drivers and even worse stepper drivers.

Pololu has a good selection of modern stepper drivers. Pololu - Stepper Motor Drivers

I suggest the DRV8825 driver for a bipolar stepper under 2A coil current and 45V motor supply current. Be sure to properly set the coil current limit.

1 Like

Can you please tell us a little bit more about your project? As @groundFungus already suggested, steppers are not controlled by a PWM signal.
And as already stated, the ancient L298 driver is a really bad driver for some steppers. But it is completely unsuitable for modern low impedance steppes. You can burn your stepper and/or the driver if you try to combine them.
Please show a datasheet of your stepper. NEMA17 tells nothing about the electrical characteristics, it tells only about the size of the mounting plate.

Thanks for the answers. Ok, PWM pins not needed, just regular digital pins then?

The motors are from STEPPERONLINE;
2 x Nema 17 Bipolar 59Ncm(83.55oz.in) 2A 42x48mm 4 Wires w/ 1m Cable &
Connector, Model 17HS19-2004S1
https://www.omc-stepperonline.com/de/nema-17-bipolar-59ncm-84oz-in-2a-42x48mm-4draehte-w-1m-kabel-verbinder-17hs19-2004s1

The project is for controling an Alt/Az telescope mount.
Page with a little more info on the project (danish translated into english)
https://www-astronet-dk.translate.goog/forum/viewtopic.php?f=42&t=7739&p=62819&_x_tr_sl=da&_x_tr_tl=en&_x_tr_hl=da&_x_tr_pto=wapp#p62819

This is a low impedance stepper that cannot be driven by the L298.
The DRV8825 suggested by @groundFungus is a suitable driver, but you will need a heatsink if you want the full tourqe of the motor.

Yes, You need 2 pins per motor, step and direction.

1 Like

If interested you can go back to a UNO/NANO and use the analog pins as digital. In setup() use pinMode to set them to outputs. There will be no pull up/down options. Have fun!

Thanks for the answer guys, I really appreciate it!
If I hadn't asked the dumb PWM question here, I most likly would have fried two L298N controllers and two steppermotors... And wastet presious time frustrated over misbehaving motors.

I have been in contact with a guy, who build the OnStep project, to control a telescope.
OnStep project
It's from there, that I got the specific NEMA 17 motor recomendation.
He recomend using this driver for the motors: TMC5160 with heatsink.
He also recomended a 100 uf capacitor on the supply pins, from GND to VM.

This is the pin layout
TMC5160_s

I have 12V PSU, that can deliver 5A.

So, back to pin connections, the "bottom" digital pins, D22 to D53 are all free:

Ardo ==> TMC5160
D22 ==> DIR/REFR
D23 ==> STEP/REFL

12V++ to VM on TMC5160
GDN to GND on TMC5160

A1, A2, B1 and B1 on TMC5160 to the NEMA 17 motor

Is that the way to go?

I do not plan on driving the steppermotor myself, but have looked at the AccelStepper library, which has all the functionality I need for the project. There's a lot of mass inertia in a telescope mount, so I will need to accelerate the motors when slewing.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.