Go Down

### Topic: tryiing to get a stepper motor to work on ardiuno (Read 4063 times)previous topic - next topic

#### Joes

##### Mar 26, 2010, 10:58 pm
hi
i have a bipolar stepper motor what i need to controlon my ardiuno im trying to control it with a 10k temperaturometer so basically the stepper motor reanacts what the pot is doing but i need to be able to set a amount of degrees the motor will rotate eg 180 degrees
i have no idea how to program this so any help would be appreciated

thanks Joe

#### PaulS

#1
##### Mar 27, 2010, 12:21 am
What don't you know how to do?

How to read the temperature sensor? How to convert the temperature sensor value to a stepper position? How to make the stepper motor step the required number of steps? All of the above?

#### Joes

#2
##### Mar 27, 2010, 10:54 am
sorry my bad spelling i meant potentiomenter theres no temperature sensor
basically how to do the programming for all of it i find it hard to get the programming round my head lol

thanks Joe

#### PaulS

#3
##### Mar 27, 2010, 01:34 pm
Code: [Select]
`#define potPin 1 // Change to whatever pin the // potentiometer is connected tovoid setup(){}void loop(){    int potVal = analogRead(potPin);    int stpPos = map(potVal, 0, 1023, 0 180);}`

This code will read the potentiometer setting, and map that value from a range of 0 to 1023 to a range of 0 to 180.

Without knowing anything about your stepper motor, and how it is connected, I can't help you with any more code.

The range that you are talking about (0 to 180) makes me think that you are talking about a servo, rather than a stepper motor.

Tell us more about the actual hardware, and we can move on.

#### Joes

#4
##### Mar 27, 2010, 02:37 pm
her is a picture of my setup
digital pins 8,9,10, 11 are connected to the motor
and analog pin 0 is connected to the centre of the potentiomenter

hope this is some help

thanks Joe

#### PaulS

#5
##### Mar 28, 2010, 03:41 pm
Still not quite enough information...

How many steps per revolution?

There is a Stepper library that can easily be use to drive the stepper motor. You tell it haw many steps in a complete revolution. Then, tell it to step the motor.

Since you want the stepper motor to act like a servo, you will need to keep track of where it is, and whether the motor should step forwards or backwards to get from the old position to the new position.

#### Joes

#6
##### Mar 28, 2010, 04:26 pm
soz if im being a bit thick how do you count the steps is it as simple as counting the clicks at you rotate the shaft?

#### PaulS

#7
##### Mar 28, 2010, 04:35 pmLast Edit: Mar 28, 2010, 04:36 pm by PaulS Reason: 1
Quote
how do you count the steps

You look at the data sheet for your stepper motor. It will tell you that.

Also, the design of the driver will determine whether half steps, quarter steps, or eighth steps are possible.

Or, you experiment...

#### Joes

#8
##### Mar 28, 2010, 04:37 pm
i have no info for it unfortunatly

#### Chris Parish

#9
##### Mar 30, 2010, 04:54 pm
Ok, so we have no information; lets try and get some.

1) What is the chip in the picture?

2) Can you make the motor do anything?

3) are there any numbers on the motor?

If you can give me the chip number and/or the numbers on the motor I might be able to help you.

Chris

#### Chris Parish

#10
##### Mar 30, 2010, 05:12 pm
Closer inspection of your picture leads me to think that you have a L239D H bridge chip.
Assuming you have then try running the MotorKnob example bundled with the Arduino IDE, you might need to change some of the pin bindings. If this works then replace the code in setup() and loop() with this:

Code: [Select]
`void setup(){    stepper.setSpeed(30);}loop(){    stepper.step(100);}`

watch your motor turn, if it goes more than one turn, then reduce the number of steps set by #define STEPS on line 13. If it goes less then a turn then increase the number of steps. Once you have found the number of steps per turn then you can follow the code suggested by PaulS

Chris

#### AlphaZeta

#11
##### Mar 30, 2010, 07:02 pm
I just recently built a controller to work with bi-polar stepper motors myself. You can find more details here: http://www.kerrywong.com/2010/03/22/a-simple-dual-h-bridge/

Hope it helps!

#### Joes

#12
##### Mar 30, 2010, 10:57 pm
the chip in the picture is H-bridge sn764410NE
Can you make the motor do anything?
yes I have had it working on the arduino with the coding on the arduino software under stepper what makes the motor rotate  backwards and forwards but cannot control it. It does what it wants to do
are there any numbers on the motor?
16hy0417n
Date 03 01 23

hope that is some help

#### PaulS

#13
##### Mar 30, 2010, 11:49 pm
Quote
Can you make the motor do anything?

yes I have had it working on the arduino with the coding on the arduino software under stepper what makes the motor rotate  backwards and forwards but cannot control it. It does what it wants to do

It does not do what it wants to do. It does what you told it to do.

Apparently, what you told it to do, and what you wanted it to do, are not the same thing.

Post that code that does something, and describe what it does, and what you want it to do instead.

#### cr0sh

#14
##### Mar 31, 2010, 12:24 am
Something else to keep in mind, which PaulS hinted about...

Even if you are counting steps to get to the angle you want, those will ONLY be referenced to the starting position of the motor. Should the motor slip or mis-step, or should something force the shaft to rotate (or stop it from rotating), the count the system has for the position will not be the same as the rotational position of the shaft.

In order to obtain the positional information of the shaft, you need to implement an absolute position encoder scheme; if you are limited to only a certain set of angles less than 360 degrees, you can use a potentiometer (multi-turn if you can get by with a few full rotations or need 360 degrees). If you need full and continuous rotation, then you will need a binary encoder of some sort (works like any optical encoder, except that it outputs a binary number indicating its position - and typically does not have rotational limits - but they don't tend to be cheap, either, depending on the required resolution).

Either of these options will give you the ability to monitor the shaft of the motor for positional information to a fixed angle.
I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

Go Up

Please enter a valid email to subscribe