Pages: [1] 2   Go Down
Author Topic: tryiing to get a stepper motor to work on ardiuno  (Read 2368 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 296
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 613
Posts: 49270
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 296
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 613
Posts: 49270
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
#define potPin 1 // Change to whatever pin the
// potentiometer is connected to

void 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.
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 296
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 613
Posts: 49270
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 296
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 613
Posts: 49270
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
« Last Edit: March 28, 2010, 09:36:13 am by PaulS » Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 296
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i have no info for it unfortunatly
Logged

Poole
Offline Offline
Jr. Member
**
Karma: 0
Posts: 89
I'm not a complete idiot. Some bits are missing
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Poole
Offline Offline
Jr. Member
**
Karma: 0
Posts: 89
I'm not a complete idiot. Some bits are missing
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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
Logged

CT, USA
Offline Offline
Sr. Member
****
Karma: 3
Posts: 446
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 296
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 613
Posts: 49270
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Phoenix, Arizona USA
Offline Offline
Faraday Member
**
Karma: 40
Posts: 5575
Where's the beer?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

Pages: [1] 2   Go Up
Jump to: