Newbie wants to control stepper motors

A project requires 4 stepper motors to run, one after another with some waiting in between. The basic code to run the stepper is not working correctly.

Can someone help with this?

The project requires smooth stepper operation, that is to say, with plenty of microstepping.

It also requires setting the exact rotation of the different motors: for example, the first one turns 4.65 turns at low speed, the next one turns 95 turns at higher speed, and so on.

But the basic code is not effective. The stepper motor is too weak. It is too slow. Here is the code. Int wait is intended to increase the speed, but it does not seem to have effect except if it is too low the stepper does not rotate:

const int A1A = 5;
const int A1B = 6;
const int B1A = 9;
const int B1B = 10;
int stepnumber = 0;
int Pa; int Pb;

void setup()
{
pinMode(A1A, OUTPUT);
pinMode(A1B, OUTPUT);
pinMode(B1A, OUTPUT);
pinMode(B1B, OUTPUT);
Serial.begin(9600);
}

void loop() {{
for (int i=0; i<24000; i++)
{
stepnumber++;
move(stepnumber,200, 2);
}
delay(250);
for (int i=0; i>-12000; i–)
{
stepnumber–;
move(stepnumber, 200, 5);
}
delay(1000);
}
}

void move(int stepnumber, int MAXpower, int wait) {
Pa = (sin(stepnumber*.098174)MAXpower);
Pb = (cos(stepnumber
.098174)*MAXpower);
if (Pa > 0)
{
analogWrite(A1A,Pa);
analogWrite(A1B,0);
}
else
{
analogWrite(A1A,0);
analogWrite(A1B,abs¶);
}
if (Pb > 0)
{
analogWrite(B1A,Pb);
analogWrite(B1B,0);
}
else
{
analogWrite(B1A,0);
analogWrite(B1B,abs(Pb));
}
delayMicroseconds(wait);
}

I have tried it with a few stepper motors, I do not have their documentation, they are 42 mm square and 30 or 40 mm long, should be plenty of power.

The total power required is very low, to push a 1 kilo weight on a horizontal guide.

If anyone can help it would be much appreciated.

The main work of the project is not in the area of electronics, we are newbies at this.

Thanks

You have not given us much information.

What stepper motor drivers are you using? What stepper motor power supply are you using (volts and amps)? If you don't have specifications for the motors, where did you get them and what do they look like? Have you measured how much force is required to move your 1kg mass? What is the mechanical arrangement between the motors and the mass that is to be moved?

What is the project you are trying to create? It is very much easier to offer useful advice when we can understand the context of your questions.

...R Stepper Motor Basics Simple Stepper Code

What stepper motor drivers are you using? an L9110 What stepper motor power supply are you using (volts and amps)? adjustable power supply, it works "OK" but not great at 6 V (DC) 2 amps. Increase the voltage and it goes faster, but by 7 or 8 volts it stops and just wiggles. If you don't have specifications for the motors, where did you get them and what do they look like? I took the motor off a 3D printer. Another one I bought 3 years ago. They are 42 mm square, and 35 or 43 mm long. Have you measured how much force is required to move your 1kg mass? I did not measure it, there is another part that will have to lift 800 grams on a 18% slope. Linear bearings. What is the mechanical arrangement between the motors and the mass that is to be moved? The motors turn lead screws, or in one case turn a belt.

What is the project you are trying to create? A machine to go through steps. L9110

testitout: What stepper motor drivers are you using? an L9110

What stepper motor power supply are you using (volts and amps)? adjustable power supply, it works "OK" but not great at 6 V (DC) 2 amps. Increase the voltage and it goes faster, but by 7 or 8 volts it stops and just wiggle

If you don't have specifications for the motors, where did you get them and what do they look like? I took the motor off a 3D printer. Another one I bought 3 years ago. They are 42 mm square, and 35 or 43 mm long.

Have you measured how much force is required to move your 1kg mass? I did not measure it, there is another part that will have to lift 800 grams on a 18% slope. Linear bearings

What is the mechanical arrangement between the motors and the mass that is to be moved? The motors turn lead screws, or in one case turn a belt.

What is the project you are trying to create? A machine to go through steps. L9110

Your Reply #2 is very difficult to read. I have tried to set it out more clearly above.

If you got the motors from a 3D printer they are probably Nema17 motors (1.7 inches is 43mm). Those motors should almost certainly be driven with a specialised stepper motor driver such as a DRV8825 and powered by at least 12v. What motor drivers and what power supply did the 3D printer have. Have you read the links I gave you?

"A machine to go through steps" is the sort of answer that makes me not want to bother trying to help. Provide a proper project description.

...R

Sorry for the lack of clarity.

The machine is a special purpose plastic extrusion machine, like a 3-d printer, except it has a longer path, close to a meter. It also has a machining part that gets carried across the same path.

The stepper motors exhibited plenty of power working off a pololu driver working off the usb, except they vibrated much too much. Perhaps this means that my L9110 was actually the problem!

I thought the buzzing came from too little microstepping. So to get more microstepping I tried this sketch. I switched from the Pololu because I needed 4 drivers and I had only 2 Pololu's.

A side issue, I have another application that would require control of every step of the stepper, so I would like to do the microstepping in the sketch so I can learn how to control it. That's why I did not want to just call some library.

An L9110 is just ok for tiny brushed DC motors, not for (most) stepper motors.

What is the resistance of the coils of the stepper you trying to abuse the chip with.
Leo…

testitout: The stepper motors exhibited plenty of power working off a pololu driver working off the usb, except they vibrated much too

What Pololu driver?

What do you mean by "working off the USB"?

Please always provide the details.

If the driver was an A4988 then it can operate at 16x microstepping. If that gives too much vibration then a DC motor driver is not the answer. You need a stepper driver that can apply an even greater level of microstepping.

And, for the project you describe, it would make a lot of sense to use the GRBL software control system.

...R

PS ... just out of curiosity, why are you not using the complete control system from the 3D printer?