L293D shield (driver board) with Arduino UNO - Attempt to understand CNC.

I am mechanical engineering graduate (zero experience in Arduino, programming etc.) I want to make a bigger CNC at some point in future which can have some practical use too. However, I am not very confident that I can actually make it, so to not waste a lot of money, :slight_smile: I am trying to understand basics first and making small CNC toy sort thing and plan to use that knowledge in future.

I am using two stepper motors (salvaged from DVD / CD players, both have 4 wires, so I suppose they are bipolar) and L293D driver board (shield). I would be powering the shield from separate power source (5V 1A DC - will it work?, I have not tried, scared it will burn the board) and Arduino from USB. I would only be connecting both the motors to see if I am successfully able to make require X - Y motion. At this point, I am not using servo that can lift the pen, so I will only be trying to make square, spiral, and things of that type. In future, I understand that a signal from Arduino board can be used to trigger a relay and spindle can be turned on using this etc.

I understand that L293D is a very old board and I can use new boards which are more efficient etc. However, I want to understand if I can use L293D board for the purpose I mentioned above. Also, if needed, can I do microstepping too with this? (I have uploaded the two libraries (1) and (2) in Arduino that the driver board recommended and also the GRBL library), let me know if both are required for making the motors move as per CNC code or only GRBL is sufficient.

I know how to generate CNC code in softwares like Catia etc. or for 2D drawings. However, I am not sure how to do the programming for stepper motors so that they move according to the CNC code. Also, can I use GRBL CNC code directly without programming? and how? I am stuck after making connections. Also, if I need to change parameters like how much steps of revolution the motor should make, how can I do that? Do I need to write the complete code? Can someone help me with it?

Some of the questions may be lame, but I have tried and researched as much as I could and then purchased these couple of things and basic electronics kit to get me started. Please let me know if understanding is correct and how can I move forward.

PS: I have practiced a few programming examples in Arduino like blink LED etc.

Regards.
Pankaj

Grbl is an awesome program for interpreting gcode and controlling steppers. However, grbl will not work with drivers like the L293, L298. Grbl is written to use proper stepper driver that use the step/dir interface (like the A4988 or DRV8825, and the like, drivers). Grbl has the stepper driver software in the firmware, no additional libraries needed. All of my DIY 2 and 3 axis machines (plotters, router) are running grbl.

All that you need to do to use grbl is to upload it to an Uno and set some configuration values like steps per millimeter, max stepper speeds, axis limits, homing setup, etc. No other programming required.

Here is the grbl Wiki with more information.

@gF. Nice to see You here.
@vigisbig. You are graduated and probably professional in using CNCs. Consider the torque needed for the axis. That will point out what size of steppers You need. The need of current for the steppers then tells what drivers, powerstages, You need. The 4998 has a current limit of 1,5 - 2 Amps and then needs fan cooling. 6650 drivers supply up to 3,5 Amps per winding. Air cooling dependant of supply voltage probably. Both are of the type suggested by gF, step/dir/enable and qiute easy to connect to an Arduino.

Thanks, Ground Fungus and Rail Roader. I have wired the shield at this point of time with one stepper motor. I am powering the shield with 9v 1amp and Arduino using USB.

Also, I am using the following code in Arduino to check if stepper motor is working. The stepper motor moves in a kind of jerky fashion but not straight as the code should do. (Please check if code is correct).

I have removed the follower too to make sure that it's not stopping the stepper shaft from rotating and to prevent chip heatup. Also, I have confirmed the continuity in coils and connection etc.

Here is a small video: https://photos.app.goo.gl/HsdJANbuSQs1hJFr9

=====================

#include <AFMotor.h>
AF_Stepper motor(200, 1);
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Stepper test!");
motor.setSpeed(50); // 10 rpm
motor.step(400, FORWARD, SINGLE);
motor.release();
delay(10000);
}
void loop() {
motor.step(200, FORWARD, SINGLE);
motor.step(200, BACKWARD, SINGLE);
motor.step(200, FORWARD, DOUBLE);
motor.step(200, BACKWARD, DOUBLE);
motor.step(200, FORWARD, INTERLEAVE);
motor.step(200, BACKWARD, INTERLEAVE);
motor.step(200, FORWARD, MICROSTEP);
motor.step(200, BACKWARD, MICROSTEP);
}

==============================

Can someone tell where am I going wrong or suggest what could be wrong?

Thanks
Pankaj

The power supplying ought to be good. Is there any Amp. setting in the stepper driver board? That should be set to max 1 Amp in order to not owerload the 9V. Are the stepper windings healthy all the way? You can check that by connecting one coil at the time and then trying to manually turn the stepper. Compare to a totaly disconnected stepper You should feel an increased resistance when power is fed to one or more coils. Can one winding be polarized the wrong way?
I don't know that stepper lib. Could You start testing using the most simple stepping technic? Issuing a 2 - 5 second delay between stepper commands in loop() could make observatiions easier.

In my understanding the L293D has no adjustable current limit, thus is not usable for current driven steppers nor microstepping.

all stepper driver boards are set with a sense circuit to detect the power at the coils.
be careful to not pick an arbitray number for a motor that is higher than the motor rating.
many diriver requires that a coil be connected or they can blow out the power side of the driver.
if you pump too many amps and burn a motor, then you might blow the driver as well.

your tiny motor seems to be fractions of an amp.

the jerky motion appears to be wrong wiring. bipolar stepper motors have two coils you if you think of the coils as A and B and the leads as A1 and A2 and B1 and B2
the step sequence is like walking, one step in front of the other. Wired wrong and the motor does not rotate properly.

most of the time, you double check that both A leads go to the same coil
once you verify that, you can swap A1 and A2, then try again.

if you are pulling and pushing in the wrong direction, the motor dithers and goes nowhere.

it is safest to start testing by using the motor voltage and make it spin on a bench.

Once you have all the pieces in place, the amp setting (sense resistor) become vitally important and power increases proportional to the voltage, divided by the sqrt of the inductance. this is why people want to put at least 4 times more voltage into a coil than the motor namplate.

a proper steper driver , like the L298 has the current sense circuit as part of the chip.
However. the L298 is old technology and the new drivers are much-MUCH preferred.
as GroundFungus mentioned, you have to driver each coil from your Arduino, that is 4 pins, and the step values have to be in the correct sequence.

the new crop of drivers use just 1 pin to driver the motor, a pulse pin. then, there is a second pin for motor direction. So 2 pins can make the motor do what you want. generating the pulse train is easier than outputting the wave for steps.

DrDiettrich:
In my understanding the L293D has no adjustable current limit, thus is not usable for current driven steppers nor microstepping.

This is correct. this makes the L293 a poor choice for a stepper driver.
The microsteping is usually often desired, but not required. also since they are not true steps, they are much weaker in power and should not be considdered for high accuracy or high power (machine tool) work. great for camera positioning or telescope tracking, but poor for machine tools.
if you are using a stepper at the motor namplate voltage, there is no need for current sense circuits. the L293 could work.

Once you move up to a proper driver, like aL298 that has current sense resistors you can use a higher voltage. the chopper style drivers can drive the motors with a LOT more power.
But as GroundFungus mentions, the new crop of drivers with both current sensing and microstepping are the better choice.
Also, the L298 does not use FET's so gets hotter, another reason it is not preferred or recommended.

These links may be of interest.

Stepper Motor Basics
Simple Stepper Code

...R