Pages: 1 [2] 3   Go Down
Author Topic: 6 Wire Stepper and ULN2803A  (Read 4067 times)
0 Members and 1 Guest are viewing this topic.
Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 603
Posts: 33387
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well you have mapped the reading to 0 - 100, so if it is over 50 then set the direction the other way.
Use the if statement for this.

For the speed:-
When it is around 50 you want it slow so for the speed subtract the reading from 50 and take the absolute value abs() function to always get a positive value.
Logged

Toronto Canada
Offline Offline
Jr. Member
**
Karma: 0
Posts: 70
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Wicked thanks smiley

I got it working - sort of with this

Code:
#include <Stepper.h>

const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution
// for your motor


// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8,9,10,11);           

int stepCount = 0;         // number of steps the motor has taken

void setup() {
  // initialize the serial port:
  Serial.begin(9600);
}

void loop() {
  // read the sensor value:
  int sensorReading = analogRead(A0);
  // map it to a range from 0 to 100:
  int motorSpeed = map(sensorReading, 0, 1023, 0, 100);
  // set the motor speed:
   
  if (motorSpeed > 50) {
    myStepper.setSpeed(motorSpeed);
    // step 1/100 of a revolution:
    myStepper.step(stepsPerRevolution/50);
    Serial.print("Forward steps:" );
    Serial.println(stepCount);
    stepCount++;
  } else {
       if (motorSpeed < 50){
        myStepper.setSpeed(motorSpeed);
        // step 1/100 of a revolution:
        myStepper.step(-stepsPerRevolution/50);
        Serial.print(" Reverse steps:" );
        Serial.println(stepCount);
        stepCount++;
          }
  }
}

It seems though that the speed varience is off
For example if the POT is at between 49 and 51 the speed should be the same, just in different directions - right?
And when at 23 and 1000 - same speed just differernt directions

What is in fact happening is the the direction is changing now, but the speed variates from 0-100 not from 0 to 50 and 50 to 0.

Thoughts? Does this make sense?
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 603
Posts: 33387
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well you didn't do all I said did you. Here is your code corrected:-
Code:
#include <Stepper.h>

const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution
// for your motor


// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8,9,10,11);           

int stepCount = 0;         // number of steps the motor has taken

void setup() {
  // initialize the serial port:
  Serial.begin(9600);
}

void loop() {
  // read the sensor value:
  int sensorReading = analogRead(A0);
  // map it to a range from 0 to 100:
  int knobReading = map(sensorReading, 0, 1023, 0, 100);
  // set the motor speed:
   
  if (knobReading > 50) {
    myStepper.setSpeed((knobReading-50) * 2);
    // step 1/100 of a revolution:
    myStepper.step(stepsPerRevolution/50);
    Serial.print("Forward steps:" );
    Serial.println(stepCount);
    stepCount++;
  } else {
       if (knobReading < 50){
        myStepper.setSpeed((50 - knobReading) * 2);
        // step 1/100 of a revolution:
        myStepper.step(-stepsPerRevolution/50);
        Serial.print(" Reverse steps:" );
        Serial.println(stepCount);
        stepCount++;
          }
  }
}
Logged

Toronto Canada
Offline Offline
Jr. Member
**
Karma: 0
Posts: 70
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks so very much for this help smiley

It is working quite well.

2 Things though

1: Proir to adding the direction change, the stepper stepped very smoothly, now it seems to vibrate a lot more, almost like it is labouring to step.

2: When I max the knob out to either 0 or 100 the stepper stutters and does not rotate, it just steps in place (you can feel it stepping with no rotation).

I should probably add the I have added a 16x2 LCD and change the stepper pins from;
8, 9 , 10, 11
to
3, 4, 5, 6

I just loaded the previous Sketch to eliminate the LCD as a factor using the new pins, with the same choppy step results as mentioned above


Any thoughts on this?
« Last Edit: January 25, 2012, 12:26:02 pm by graphections » Logged

Toronto Canada
Offline Offline
Jr. Member
**
Karma: 0
Posts: 70
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok i seem to be the Knob here - In reguards to the post above, this issue was that the Batteries running the stepper were running low.

smiley But at least we know now!
Logged

Toronto Canada
Offline Offline
Jr. Member
**
Karma: 0
Posts: 70
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Now the next issue is that the ULN2803a just got extremely HOT, I added a new battery pack with 8aas (previously it was 4).

Would a heat synch solve this or do you think I am running too much current through it now?

I need a battery source that will last for at least 5 hours running the stepper - with as much torque as possible.

Thoughts anyone?
Logged

Offline Offline
God Member
*****
Karma: 1
Posts: 547
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The ULN2803A has a current limit of 500mA per output device.
Logged

Toronto Canada
Offline Offline
Jr. Member
**
Karma: 0
Posts: 70
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@ ajofscott

I have it all working now, what battery source would you suggest to retain as much torque as possible?

Currently (no pun) with 4 1.5v aa's I am getting a total of 6volts, and the stepper seems to stutter at its max speed. ULNs temp is fine

I tried running it with 8 1.2v aa's and motor control is much better (no stuttering of stepper) but ULN gets very hot - The batteries are 2200 mah recharables.

SO i suppose my questions is, can I increase the voltage as long as I keep the mah to 500 or so? Keeping in mind I need torque and long run times.

thoughts?
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 603
Posts: 33387
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The ULN2803A has a current limit of 500mA per output device.
But only about 650mA can be switched on in any chip at any time:-
http://www.thebox.myzen.co.uk/Tutorial/Power_Examples.html

Nowhere have you said what CURRENT the motor coils are pulling. Either measure the current or measure the coil resistance. It is the only way to know what you are doing.
Logged

Toronto Canada
Offline Offline
Jr. Member
**
Karma: 0
Posts: 70
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey Mike, how would I measure the coils current resistance?
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 603
Posts: 33387
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Put a current meter in series with the motor coil.
Meters are only $10 or so, so you should have one.
Logged

Toronto Canada
Offline Offline
Jr. Member
**
Karma: 0
Posts: 70
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ah ok, or would looking up the specs on the Motors Coil Resistance work too?

So the current meter should tell me what the levels are on the stepper, and then I match a power source to those level to get the optimal performance from the motor?

Edit:

Ok i found the spec sheet for my Stepper here
http://www.slidesandballscrews.com/pdf/steppermotors/SY42STH47-1206A.pdf

The Current rating is (A) 1.2 so does this mean anything over 1.2 amps will damage the motor and over heat the ULN?
And the Voltage rating is (V) 4 - So using 4 rechargable 1.2 volt aas is an overload?

How do I figure out what the combined Amperage is with the 4 AA's?

Would Sparkfuns Easy Driver be easier to work with in this project?
« Last Edit: February 23, 2012, 11:49:44 am by graphections » Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 603
Posts: 33387
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You need a regulating stepper driver to limit the current to a fixed ammount while allowing you to feed it with a higher voltage than 4V.
Logged

Toronto Canada
Offline Offline
Jr. Member
**
Karma: 0
Posts: 70
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Makes sense, I was tryint to keep it simple.

I have used the Pololu driver chio and I fried it, ill go with the SparkFun easy driver this time smiley-wink
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 603
Posts: 33387
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I have used the Pololu driver chio and I fried it,
Only because you set it to deliver too much current.
Logged

Pages: 1 [2] 3   Go Up
Jump to: