Arduino Uno CNC shield (software PWM) ???

Hi Forum,

I just got a new Uno CNC Shield from PROTONEER. When I checked the datasheet for this board, I found out they use digital pin 2, 3, 4 (Please see attachment) as a4988 driver step input. But according to the pinout of UNO, only pin 3 (OC2B) can generate timer PWM (Please see attachment).

So I was wondering: if I want to use this shield to build a robot arm, Does it mean I have to use "delay" (software) function to generate PWM instead of using timer (hardware)?

I'm really confused right now and hope someone can give me some guidance.

Any help is truly appreciated!!

G

Arduino-Uno-Pinout-Digital-Pins.jpg

You don't need PWM with a stepper motor driver. PWM is normally used to control the speed of a DC motor or the brightness of an LED.

...R

In addition to Robin.

PWM is also used to control a LASER if you use one with your CNC.

It's pin usage depends on which version of GRBL you would have installed.

Bob.

Thanks for the help

Sorry for the misleading. let me make my question more straightforward.

On the CNC shield, the "step" pin of X axis is connected to the UNO pin 2 ,which cannot generate hardware PWM. So based on my knowledge, we have to use the "delay" function to generate the software PWM to tell the a4988 driver how many steps and how fast we want the motor go.

I cannot find the reason for that. Does it mean this shield can only work with software PWM?? or if not, how can I edit my code to control 3 motors together?

Thanks

Robin2:
You don't need PWM with a stepper motor driver. PWM is normally used to control the speed of a DC motor or the brightness of an LED.

...R

'

Hi Robin,

I forgot to mention my step motor driver. The driver I used is A4988, which need 2 signals from the MCU. One is the "direction" (digital high CW, digital low CCW), the other is "step". The "step" pin need a PWM signal to tell the driver board how many steps and how fast we want the motor go. So I do need a PWM signal for A4988 driver.

My question is, if the "step" pin of X axis in this CNC shield is connected to UNO pin 2, which cannot generate hardware PWM signal, does it mean I have to use software PWM ("delay" function) to drive the motor? if yes, then how can I drive 3 motors at the same time?

Thanks~

G

Simple - Don't use delay. Use millis() or micros() to determine when you want the next edge to occur for each motor.

Here's an extreme example, using micros() and arrays, to create 13 tones with a '1284P - when a button is pressed, a tone is played. I used a '1284P as it has 32 IO, and I wanted 13 buttons and 13 tones.
https://forum.arduino.cc/index.php?topic=179761.0

Instead of waiting for a button press, do that under software control. And make the frequency whatever you want, mine are mathematically calculated to be close to piano notes, and sounded very in tune with my wife's piano.

geraffe:
My question is, if the "step" pin of X axis in this CNC shield is connected to UNO pin 2, which cannot generate hardware PWM signal, does it mean I have to use software PWM ("delay" function) to drive the motor? if yes, then how can I drive 3 motors at the same time?

Like I said earlier there is no need for PWM with a stepper motor. Have a look at this Simple Stepper Code - especially the second example. It will work with any Arduino I/O pins.

Note that PWM varies the duty cycle of the pulses whereas the speed of a stepper motor is controlled by changing the frequency of the pulses - the number of millisecs (or microsecs) between steps.

...R