I am at the moment trying to make a bipolar stepper motor move.
I am interfacing it through a control board, which takes the input Step
, Dir
, En
, and 5V.
I am providing those input signal via an Arduino, but can't get the damn thing to move. all it does it move a step forward and backwards, like it being stuck or and tries to wiggle out of something.. What could the reason be..
Here is the Code:
#include "stepper_motor.h"
int max_step = 200;
stepper_motor::stepper_motor()
{
pinMode(BUILTIN_LED,OUTPUT);
pinMode(step_pin,OUTPUT);
pinMode(dir_pin,OUTPUT);
pinMode(en_pin,OUTPUT);
alive_bool = true;
position_bool = false;
step_count = 0;
}
void stepper_motor::step_pwm()
{
if(position_bool==true)
{
//Dir pin low
digitalWrite(step_pin, LOW);
digitalWrite(dir_pin,LOW);
digitalWrite(en_pin,LOW);
delay(0.005);
digitalWrite(step_pin, LOW);
digitalWrite(dir_pin,LOW);
digitalWrite(en_pin,HIGH);
delay(0.005);
int step = 0;
while(step < max_step)
{
digitalWrite(step_pin,HIGH);
delay(1);
digitalWrite(step_pin,LOW);
delay(1);
}
//digitalWrite(en_pin,LOW);
//position_bool = false;
}
else
{
//Dir pin high
delay(1000);
digitalWrite(step_pin, LOW);
digitalWrite(dir_pin,LOW);
digitalWrite(en_pin,LOW);
delay(0.005);
digitalWrite(step_pin, LOW);
digitalWrite(dir_pin,LOW);
digitalWrite(en_pin,HIGH);
delay(0.005);
digitalWrite(step_pin, LOW);
digitalWrite(dir_pin,HIGH);
digitalWrite(en_pin,HIGH);
int step = 0;
while(step < max_step)
{
digitalWrite(step_pin,HIGH);
delay(1);
digitalWrite(step_pin,LOW);
delay(1);
}
//digitalWrite(en_pin,LOW);
//position_bool = true;
}
}
Updated step_pwm():
void stepper_motor::step_pwm()
{
//Start - En Low , DIR HIGH, STEP high
//init configuration!
digitalWrite(step_pin, HIGH);
digitalWrite(dir_pin,HIGH);
digitalWrite(en_pin,LOW); // Previous LOW
delay(0.005);
//T1- En HIGH , DIR HIGH, STEP HIGH
//Enable high
//digitalWrite(step_pin, HIGH);
//digitalWrite(dir_pin,HIGH);
digitalWrite(en_pin,HIGH);
delay(0.005);
//T2- En HIGH , DIR low, STEP HIGH
//Direction choosen
//digitalWrite(step_pin, HIGH);
digitalWrite(dir_pin,LOW);
//digitalWrite(en_pin,HIGH);
delay(0.005);
//T2- En HIGH , DIR low, STEP HIGH
//STEP step between low and high with 2.5µs between
while(1)
{
digitalWrite(step_pin,LOW);
delay(2.5);
digitalWrite(step_pin,HIGH);
delay(2.5);
}
}
The control board i am using is a ST330-v3 The motor i am using is this one here is a little block diagram of how things are connected.