Greetings,
I am using a NodeMCU(12-E) V2.0 micro-controller to control a Stepper Motor.
Important Motor Specs:
- Steps per Rev: 200
- (The power from the GPIO pins are sufficient)
- Bipolar (4 wires)
I have the datasheet here: https://www.omc-stepperonline.com/download/24HR04-1004S.pdf
which shows which wires are A, A/, B, and B/
I connected A to GPIO pin 4, A/ to 0, B to 5, and B/ to 16
There is no driver, the motor pins are connected directly to the gpio pins, which all provide sufficient power.
The issue I am encountering is that the motor simply vibrates, but does not turn in full revolutions. By setting the delay speed to a high number (super slow) I could feel that individual steps are being made, however I believe that one of the steps brings it back to the original position, and does not continue to rotate in the same direction. The steps are far too subtle for me do figure out which step this is occurring on, but I know there is motion because I can feel steps at low speeds, and vibration at high speeds.
Here is the code:
#define in_B_1 5
#define in_B_2 16
#define in_A_1 4
#define in_A_2 0
int currentStep = 0;
void setup()
{
pinMode(in_A_1, OUTPUT);
pinMode(in_A_2, OUTPUT);
pinMode(in_B_1, OUTPUT);
pinMode(in_B_2, OUTPUT);
}
unsigned int time_delay = 20;
void step1(){
//A+,B+
digitalWrite(in_A_1, 1);
digitalWrite(in_A_2, 0);
digitalWrite(in_B_1, 1);
digitalWrite(in_B_2, 0);
delay(time_delay);
}
void step2(){
//A+,B-
digitalWrite(in_A_1, 0);
digitalWrite(in_A_2, 1);
digitalWrite(in_B_1, 1);
digitalWrite(in_B_2, 0);
delay(time_delay);
}
void step3(){
//A-,B-
digitalWrite(in_A_1, 0);
digitalWrite(in_A_2, 1);
digitalWrite(in_B_1, 0);
digitalWrite(in_B_2, 1);
delay(time_delay);
}
void step4(){
//A-,B+
digitalWrite(in_A_1, 1);
digitalWrite(in_A_2, 0);
digitalWrite(in_B_1, 0);
digitalWrite(in_B_2, 1);
delay(time_delay);
}
void loop()
{
CW();
}
void CW(){
step1();
step2();
step3();
step4();
}
I have also tried:
#define in_B_1 5
#define in_B_2 16
#define in_A_1 4
#define in_A_2 0
int currentStep = 0;
void setup()
{
pinMode(in_A_1, OUTPUT);
pinMode(in_A_2, OUTPUT);
pinMode(in_B_1, OUTPUT);
pinMode(in_B_2, OUTPUT);
}
unsigned int time_delay = 20;
void step1(){
//A+
digitalWrite(in_A_1, 1);
digitalWrite(in_A_2, 0);
digitalWrite(in_B_1, 0);
digitalWrite(in_B_2, 0);
delay(time_delay);
}
void step2(){
//B+
digitalWrite(in_A_1, 0);
digitalWrite(in_A_2, 0);
digitalWrite(in_B_1, 1);
digitalWrite(in_B_2, 0);
delay(time_delay);
}
void step3(){
//A-
digitalWrite(in_A_1, 0);
digitalWrite(in_A_2, 1);
digitalWrite(in_B_1, 0);
digitalWrite(in_B_2, 0);
delay(time_delay);
}
void step4(){
//B-
digitalWrite(in_A_1, 0);
digitalWrite(in_A_2, 0);
digitalWrite(in_B_1, 0);
digitalWrite(in_B_2, 1);
delay(time_delay);
}
void loop()
{
CW();
}
void CW(){
step1();
step2();
step3();
step4();
}
Same issue, but now the vibrations are more subtle