Go Down

### Topic: Accelerometer - Stepper Motor Speed Control (Read 5000 times)previous topic - next topic

#### Bharath_Inti

##### Sep 21, 2011, 08:33 pm
Hey guys, can anyone suggest me how can I control the speed of a stepper motor by using an accelerometer ?
The stepper motors that I use are of these kind -
http://www.nex-robotics.com/products/micromouse/high-torque-bipolar-stepper-motor.html

And the driver suggested is L293D, A3982 35V, 2A Stepper Motor Driver . . . are there any more suitable drivers such that i can obtain a high speed and as well as regulate it  . . ..   And how can I control it using an Accelerometer ?

#### PaulS

#1
##### Sep 22, 2011, 01:39 pm
Quote
Hey guys, can anyone suggest me how can I control the speed of a stepper motor by using an accelerometer ?

What, exactly, should the relationship between speed and acceleration along some axis be?

Quote
And the driver suggested is L293D, A3982 35V, 2A Stepper Motor Driver . . . are there any more suitable drivers

There must be some reason that the seller suggested that motor driver. Perhaps because they have tested the combination, and know that the two work together. What's "more suitable" than that?

#### Bharath_Inti

#2
##### Sep 23, 2011, 06:10 am
Hi Paul, I will be attaching the accelerometer to my hand and will be moving it up and down -
-
The flexion and extension movements in the picture. Now as hand goes up the motor speed should increase and as it goes down the speed should decrease. This is the basic concept how i need to work out.
I've found many tutorials to control the stepper motor speed using variable resistors (through the motor driver circuit) but haven't found much clearly specifying the speed controlling using accelerometer.
And what I think is that I must map the acceleration values in a particular axis (say y-axis) i.e the range of acceleration from the upper most tip of 'extension' to the lower most tip of 'flexion' (in the image).. . These values must be mapped to the speed of stepper motor (say a range of 200rpm - 1200 rpm). This is what I think that should be done .., but I exactly don't know how it can be done. And if Im wrong anywhere... plz correct it ?

#3
##### Sep 23, 2011, 07:30 pm
Just for clarification, do you want to control the speed of the motor based on hand orientation, or the position of the motor based on hand orientation?

If the former really is what you want, then what you think is the gist of it.

#### Bharath_Inti

#4
##### Sep 25, 2011, 05:10 am
Hey, I exactly need to control the speed of the motor based on hand movement. Please tell me how to code it for a stepper as well as geared dc motor

#### PaulS

#5
##### Sep 25, 2011, 04:29 pm
Quote
Hey, I exactly need to control the speed of the motor based on hand movement. Please tell me how to code it for a stepper as well as geared dc motor

Controlling a geared DC motor is pretty simple. Set the direction pin HIGH or LOW, based on the direction you want to go. Set the PWM pin's value to the speed you want the motor to run.

Controlling a stepper motor is similar. If you are using the Stepper library, set the direction, the speed, and the number of steps.

Of course, none of this is practical, since you have not defined what the speed should be based on the POSITION of the hand, and an accelerometer won't give you position, anyway, without a lot of effort.

If it is the VELOCITY of the hand at any given time that should define the speed of the motor, you still have a long ways to go before an accelerometer will give you VELOCITY.

If it is the ACCELERATION of the hand at any given time that should define the speed of the motor, then your job is just about done.

Although using acceleration (a non-linear attribute) to control speed does not make a lot of sense.

So, we are back to the original question. How exactly should the output of the accelerometer (acceleration at a given point in time) be used to control the motor - speed? direction? amount to turn?

#### Bharath_Inti

#6
##### Sep 26, 2011, 02:23 pm
Hi Paul, that was a cool explanation.

>> Now, my first doubt is that in controlling a dc motor you've said that we can set the speed while coding,... what is the maximum value of speed that we can set.. is it the rated no load speed ?

>> I thought that we can control the speed of the motor by the position of the accelerometer., but u cleared that we cannot do that.
Now in coding, can't we map the 'acceleration in y axis' to a set of 'motor speed values' ? I don't know whether this works or it doesn't make    any sense !    But there are some videos in 'youtube' where an rc toy car is hacked and controlled by an accelerometer. But over there I think that keeping the accelerometer constantly in some direction increases the cars speed, can't we do something similar like this !

#### Bharath_Inti

#7
##### Sep 26, 2011, 02:27 pm
Hey, watch this. Here the motors speed changes as the  accelerometer position changes.

#### PaulS

#8
##### Sep 26, 2011, 03:11 pm
Quote
what is the maximum value of speed that we can set.. is it the rated no load speed ?

The rated no load speed is the maximum speed that the motor can turn with nothing attached to it. Adding wheels or tracks will reduce that speed. Setting the wheel/track on the ground will reduce the speed some more.

Typically, though, the speed is set to some value between 0 and 255 which corresponds to stopped to maximum possible, with no real relationship between speed value and actual speed.

Quote
But there are some videos in 'youtube' where an rc toy car is hacked and controlled by an accelerometer.

The accelerometer will output a value that represents acceleration along an axis at an instant in time. If you want to map that value to a motor speed PWM value, as is done in those videos, feel free.

Understand, though, that there will be no plot-able relationship between acceleration, velocity, or position of the accelerometer and the speed of the car.