Stepper Motor Variable Speed Not Functioning

Hey, everybody!

So I had this wireless motorized tripod head, but I didn't have a infrared remote.
And of course I thought I could get one on eBay, but after hours of searching the internet for one,
I decided I would have to just take out the micro-processor and hook up an Arduino.
And I also decided to swap the IR sensor with Bluetooth for the purpose of using a smartphone.
So I through some code together, and tested it with an old stepper and an Arduino uno, and it worked perfectly.
Then I opened the case of the tripod head, hooked up the stepper, and everything worked just fine except changing speed, I've gone over the code multiple times checking for errors, with no result.
Any help would be appreciated, thanks.

The stepper is a Limit Ming Jong ST30. Picture attaches.
I will be using a Arduino pro mini(which hasn't come in the mail yet.)

Attached is the code(which is somewhat complicated) and a picture of the stepper.
I will be using an optoisolator instead of a relay.

Motorized_tripod_bluetooth.ino (1.99 KB)

Image from Original Post Reply so we don't have to download it. See this Image Guide

Code from Original Reply so others don't have to downoad it

#include <Stepper.h>
const int stepsPerRevolution = 400;
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11); 
int doing = 0; // 1=left, 0=right.
int button1 = 2;
int button2 = 3;
int rpm = 10;
int start_stop = 0; // 0=stop, 1= start.
int relay1 = A0;
int relay2 = A1;
int results;
int shots;
int interval;
void setup() {
myStepper.setSpeed(10);
Serial.begin(9600);
pinMode(13,OUTPUT);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
 digitalWrite(13,HIGH);
pinMode(relay1,OUTPUT);
pinMode(relay2,OUTPUT);
digitalWrite(relay1,HIGH);
digitalWrite(relay2,HIGH);
}

void loop() {
  

    
  if(digitalRead(button1) == LOW) {
 if(doing == 1){
 doing = 0; 
}else{
 doing = 1; 
}   
  }
  
  if(digitalRead(button2) == LOW) {
 if(doing == 1){
 doing = 0; 
}else{
doing = 1; 
}   
  }
  
  
  if (Serial.available()) {
results = Serial.read();
  switch(results){
  
    case 49:
if(doing == 1){
 doing = 0; 
}else{
 doing = 1; 
 
digitalWrite(13,HIGH);
delay(75);
digitalWrite(13,LOW);
}
  break;
  
case 50:
if(start_stop == 1){
 start_stop=0; 
}else{
 start_stop=1; 

digitalWrite(13,HIGH);
delay(75);
digitalWrite(13,LOW);
}
break;


case 51:
    if(rpm < 75){
      rpm++;
  myStepper.setSpeed(rpm);
  } 
digitalWrite(13,HIGH);
delay(75);
digitalWrite(13,LOW);
break;


case 52:
    if(rpm > 1){
      rpm--;
  myStepper.setSpeed(rpm);
  } 
digitalWrite(13,HIGH);
delay(75);
digitalWrite(13,LOW);
break;

case 53:
digitalWrite(relay1,LOW);
delay(100);
digitalWrite(relay1,HIGH);
digitalWrite(13,HIGH);
delay(75);
digitalWrite(13,LOW);
break;

case 54:
digitalWrite(relay2,LOW);
delay(100);
digitalWrite(relay2,HIGH);
digitalWrite(13,HIGH);
delay(75);
digitalWrite(13,LOW);
break;


default:
digitalWrite(13,HIGH);
delay(75);
digitalWrite(13,LOW);

digitalWrite(relay1,LOW);
delay(results);
digitalWrite(relay1,HIGH);

digitalWrite(13,LOW);
delay(75);
digitalWrite(13,HIGH);
break;

}
    }

if(start_stop == 1){  
  if(doing == 1){   
   myStepper.step(1);
delay(2);

}

  if(doing == 0){   
   myStepper.step(-1);
delay(2);

}
}
}

...R

A picture of a motor is no help. Please post a link to its datasheet.

What stepper motor driver are you using?

I don't see any evidence of speed change in your code.

How is the code intended to work - I'm not going to waste time trying to figure that out when you can tell me.
What does it actually do?

...R
Stepper Motor Basics
Simple Stepper Code

I don't see any evidence of speed change in your code

Seems the code is using serial input to modify the parameters (left, right, stop, RPM).
And: if I am not mistaken, he has to key in 51 to increase the speed; but case 52 is very dubious ...

But the OP should tell us exactly what he intends to do or what he thinks the code should do and what it does / doesn't.

rpt007:
Seems the code is using serial input to modify the parameters (left, right, stop, RPM).

I guess I missed that.

However the motor is only doing 1 step at a time and I assumed the delay(2) was intended to manage the step rate.

...R

Robin2:

It clearly is of help, it shows 6V 50 ohm as the rating. Its a high impedance stepper therefore.

Sorry for the late reply. Email Problems.

Anyway,

the code works like this:

A Bluetooth smartphone will connect to an HC-05 Bluetooth module,
using that as my serial input,

the doing variable is used to tell the stepper which direction to go,
and is changed by two input buttons (so as to not allow the stepper to turn to far) and a serial reading of 49.

The rpm variable is set to the desired rpm of the motor, and will change with the serial read of 51/52.
The maximum rmp value of 75 and the max stepsPerRevolution value of 400 was determined by testing an old stepper for it's max speed, and would be changed to fit the max speed of the one I will be using.

The start_stop variable is used to determine if the stepper should be moving, and will be changed by a serial reading of 50.

The two relays (which willl be switched out for optoisolators) are used to control the camera's shutter through a cable attached to the case, and will be controlled by a serial reading of 53/54.

The default serial reading is for multi-shot and/or bulb mode on the camera.

The reappearing flashing of pin 13 is for alerting when something happens and is useful for debugging any potential Bluetooth connectivity issues.

I have tested the code with an old stepper and worked perfectly.

Thanks.

Arduino_Geeko:
I have tested the code with an old stepper and worked perfectly.

Then what exactly is the problem you want help with?

And what are the precise differences between the system that works and the system that does not?

...R

The problem is that the stepper being used will not change speed.

Arduino_Geeko:
The problem is that the stepper being used will not change speed.

That is only a response to one of the questions in Reply #7.

If I am to help I also need an answer to the other question. And my willingness to help is not improved by having to ask twice.

...R

Robin2:
Then what exactly is the problem you want help with?

And what are the precise differences between the system that works and the system that does not?

...R

The only difference is I'm using a different stepper.

If you really want help then pls give us a complete picture of your project/configuration/problem.
Otherwise nobody would be interested in wasting more time in here.