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?
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.
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.
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.
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
I have 12V PSU, that can deliver 5A.
So, back to pin connections, the "bottom" digital pins, D22 to D53 are all free:
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.