0
Offline
Full Member
Karma: 0
Posts: 236
Arduino rocks
|
 |
« on: March 26, 2010, 04:58:11 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
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Online
Brattain Member
Karma: 316
Posts: 35532
Seattle, WA USA
|
 |
« Reply #1 on: March 26, 2010, 06:21:41 pm » |
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
Full Member
Karma: 0
Posts: 236
Arduino rocks
|
 |
« Reply #2 on: March 27, 2010, 04:54:42 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
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Online
Brattain Member
Karma: 316
Posts: 35532
Seattle, WA USA
|
 |
« Reply #3 on: March 27, 2010, 07:34:50 am » |
#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
Full Member
Karma: 0
Posts: 236
Arduino rocks
|
 |
« Reply #4 on: March 27, 2010, 08:37:15 am » |
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
Online
Brattain Member
Karma: 316
Posts: 35532
Seattle, WA USA
|
 |
« Reply #5 on: March 28, 2010, 08:41:20 am » |
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
Full Member
Karma: 0
Posts: 236
Arduino rocks
|
 |
« Reply #6 on: March 28, 2010, 09:26:16 am » |
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
Online
Brattain Member
Karma: 316
Posts: 35532
Seattle, WA USA
|
 |
« Reply #7 on: March 28, 2010, 09:35:30 am » |
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
Full Member
Karma: 0
Posts: 236
Arduino rocks
|
 |
« Reply #8 on: March 28, 2010, 09:37:44 am » |
i have no info for it unfortunatly
|
|
|
|
|
Logged
|
|
|
|
|
Poole
Offline
Jr. Member
Karma: 0
Posts: 83
I'm not a complete idiot. Some bits are missing
|
 |
« Reply #9 on: March 30, 2010, 09:54:27 am » |
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
Jr. Member
Karma: 0
Posts: 83
I'm not a complete idiot. Some bits are missing
|
 |
« Reply #10 on: March 30, 2010, 10:12:58 am » |
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: 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
Sr. Member
Karma: 2
Posts: 446
Arduino rocks
|
 |
« Reply #11 on: March 30, 2010, 12:02:33 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!
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Full Member
Karma: 0
Posts: 236
Arduino rocks
|
 |
« Reply #12 on: March 30, 2010, 03:57:02 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
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Online
Brattain Member
Karma: 316
Posts: 35532
Seattle, WA USA
|
 |
« Reply #13 on: March 30, 2010, 04:49:02 pm » |
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
Faraday Member
Karma: 27
Posts: 5082
Where's the beer?
|
 |
« Reply #14 on: March 30, 2010, 05:24:26 pm » |
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
|
|
|
|
|
|