Linear motion with 2 stepper motors using AccelStepper

I am trying to make an AGV (Automated Guided Vehicle). I am using 2 industrial grade stepper motors (NEMA23; Model ID - 23H2100-019S) with an industrial grade motor driver (ST3986).

Since Arduino can run only single threaded processes, i.e, cannot exactly signal both the motors at the same time, and other mechanical & electrical errors, the vehicle may go off path.

If I use AccelStepper library to make the vehicle go on a linear path for a predetermined distance (say 1m) would the error be so significant that the vehicle moves away from the path and reaches some other destination?

I want to know if attaching an accelerometer to the vehicle is necessary to correct the errors. If so, are there any objects in the library to make corrections?

I tried searching online for similar example even with smaller motors and drivers, but I wasn't able to find any.

An accelerometer would not work.

You should study the AccelStepper library some more. You can tell 2 (or 3 or 4 or more) motors to go a number of steps and as long as you call the run() function often enough the motors will move there while you do other stuff.

Use the MultStepper class to make the motors do coordinated movements.

I have tested the Multistepper class, though not on ground with wheels attached. But, even that is not a multithreaded process... there will be a difference in when signals reach both the motors...

Please explain further. As I understand an accelerometer is usually used in these kind of use cases to detect a change in direction of movement.

It detects acceleration not movement . If the movement is at a constant speed then there is no acceleration.
The data from an accelerometer is too noisy and will drift. You are mistaken if you thing people use this for correcting robots, they don’t.

Okay, I understand your point. Do you know what sensors can be used to detect robot drift from path?

You need to use an rotary encoder attached to the motor’s to measure that the required number of steps has been mage by each motor. But the wheels could slip on the floor maki g this not work.

There is no simple way to do what you want.

Do you think a gyroscope, perhaps as part of an IMU chip like MPU9250, would do a good job?

I don’t know, they are subject to drift and noise so that will very well be the limiting factor.

The time difference would be in microseconds if written properly. I do not see how that would have enough of an effect.

Hi,

Why not, how are you going to see if it doesn't work if you don't try it in the real world, wheels attached.

Can you post your code please?
To add code please click this link;

Tom.... :grinning: :+1: :coffee: :australia:

After calibration, you might be able to use a magnetic compass (magnetometer) or a rate gyroscope to keep your robot pointed in the desired direction. Neither will do anything for measuring distance traveled. For that, your best bet might be to count steps to the wheels. That assumes the wheels never slip.

I have not written the code yet. I have only tried the example programs, manipulating the configuration. It's an industrial prototype project, and they also need to construct the body. But I will update as soon as I am able to try it out with wheels attached. Thanks!

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