Hi !
Im trying to control a ‘hybrid’ closed loop stepper motor the HB860H specifically this one:
http://www.sah.co.rs/media/sah/techdocs/hb860h_manual.pdf
This hybrid stepper motor has feedback control to read how many steps it took thus to know the position.
I ran this demo code which worked fine:
// for stepper motor 1
const int stepPin = 5;
const int dirPin = 2;
const int enPin = 9;
char data;
#define potmeterPin A0
int p;
float delay_time=500;
void setup() {
pinMode(stepPin,OUTPUT);
pinMode(dirPin,OUTPUT);
pinMode(enPin,OUTPUT);
digitalWrite(enPin,LOW); //motor1 is enabled
Serial.begin(9600);
}
void loop() {
if(Serial.available()>0) // we give commands through serial monitor
{
data=Serial.read(); //command from monitor
if(data=='a') //stepper 1 right
{
digitalWrite(enPin,LOW);
digitalWrite(dirPin,HIGH); //motor will rotate write
for(int x = 0; x < 48000; x++)
{
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
Serial.print("*");
if(Serial.read()=='e') //to stop
{
digitalWrite(enPin,HIGH);
Serial.print("stop");
break;
}
}
}
if(data=='b') //stepper motor1 left
{
digitalWrite(enPin,LOW);
digitalWrite(dirPin,LOW);
for(int x = 0; x < 48000; x++)
{
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
Serial.print("$");
if(Serial.read()=='e') //to stop
{ digitalWrite(enPin,HIGH);
Serial.print("stop");
break;
}
}
}
}
}
I though I could control the speed of the motor by varying the delay time between stepPin(HIGH) and stepPin(LOW). However this doesn’t seem to affect the speed. The only thing that did effect the speed was the Pulse/rev setting of the driver itself.
Surely it much be possible to make the speed variable with a potmeter as in this example, but how?:
http://www.arduinotutorialonline.com/2017/12/stepper-motor-speed-control-with.html