Controlling stepper motor using TB6612 Stepper Motor Driver Breakout Board

Thread Starter

zainiii

Joined Jul 26, 2024
39
Hi everyone.

I have been facing the issue to run the Bipolar stepper motor using the TB6612 Stepper Motor Driver Breakout Board. On the internet there are many codes available regarding controlling the stepper motor by changing the RPM ,but my motor is working on PPS (Pulse per seconds). i took the code from the ad fruit website to run the motor.

https://learn.adafruit.com/adafruit...er-motor-driver-breakout/using-stepper-motors

the code is

Arduino Code:
#include <Stepper.h>

// change this to the number of steps on your motor
#define STEPS 200

// create an instance of the stepper class, specifying
// the number of steps of the motor and the pins it's
// attached to
Stepper stepper(STEPS, 4, 5, 6, 7);


void setup()
{
  Serial.begin(9600);
  Serial.println("Stepper test!");
  // set the speed of the motor to 30 RPMs
  stepper.setSpeed(60);
}

void loop()
{
  Serial.println("Forward");
  stepper.step(STEPS);
  Serial.println("Backward");
  stepper.step(-STEPS);
}
but this code didn't work, the company from where i bought the pump having stepper motor provide me one page regarding the flow rate controlling of pump and they also provide me the method how to control the flow rate.

**the method is**

" How It Works:
・The stepper motor has two sets of wires connected to two coils inside the motor.
・We call these coils "Coil A" and "Coil B".
Coil A is controlled by two wires (Black and Brown).
Coil B is controlled by another two wires (Orange and Yellow).
Operating the Motor:
The motor works by turning on these coils in a specific sequence.
First, Coil A is turned on, which moves the motor a little bit.
Then Coil B is turned on, which moves the motor a bit more.

By continuing to switch between these coils in a pattern, the motor rotates smoothly.
Controlling the Speed (and Flow Rate):

・Faster Pulses = Faster Motor = Higher Flow Rate: If we send pulses quickly, the motor turns faster, which pumps the fluid faster.
・Slower Pulses = Slower Motor = Lower Flow Rate: If we send pulses more slowly, the motor turns slower, reducing the flow rate."
the Flow rate related file is attached in the picture. Also, the pin configuration is correct as per my understanding, and pin configuration is also attached in the picture as well.
the motor worked on 10V DC which i applied on Vm pin of the module and the current draw by it is 350mA. With different codes the pump even didn't turn ON and i didn't listen or see any voice of the pump :(

few things i observed.
when i gave the 10vDC to Vm pin of the TB6612 Stepper Motor Driver Breakout Board, without connecting it with Arduino, the multimeter shows the 10V DC across , but when i connected the Arduino to Vcc of this board the voltage drop down to 1.14, Also the pins of the board used to connect with the coil of the motor shows the DC voltage 0, the board picture is also attached below, Motor A two pins used for one pair of motor coil and Motor B 2 pins used for second coil of stepper motor

my questions are.
1) can someone provide me the code to control the flow rate using the PPS method, i saw few codes using the AI tool but no one is working.

2) does in case of controlling the flow rate using the PPS does we need to change the pins configuration or not.

3) does this pump will work by changing the RPM or we have to control the flow rate using the PPS method
 

Attachments

Last edited by a moderator:

Jerry-Hat-Trick

Joined Aug 31, 2022
775
The Adafruit instructions are really clear so if you have followed them correctly I’m surprised it’s not working. Instead of using the Arduino stepper library how about writing a simple program which energizes the coils in the sequence you describe - turn on coil A, turn on coil B, turn off coil A, turn off coil B - with delay(100); between each instruction. Just let this loop, and the delay value will determine the speed. You may find this is all you need. If this doesn’t work, make the delay 1000 and instead of connecting motor coils connect LEDs in series with 1K resistors and watch if the on/off sequence is what you expect it to be.

Hope this helps….
 

Thread Starter

zainiii

Joined Jul 26, 2024
39
The Adafruit instructions are really clear so if you have followed them correctly I’m surprised it’s not working. Instead of using the Arduino stepper library how about writing a simple program which energizes the coils in the sequence you describe - turn on coil A, turn on coil B, turn off coil A, turn off coil B - with delay(100); between each instruction. Just let this loop, and the delay value will determine the speed. You may find this is all you need. If this doesn’t work, make the delay 1000 and instead of connecting motor coils connect LEDs in series with 1K resistors and watch if the on/off sequence is what you expect it to be.

Hope this helps….
Dear Sir, this code is working fine, but there is no movement of the stepper motor coil, how i verified that this code is working, there is LED built on the Arduino, which was ON and OFF accordingly
 

Thread Starter

zainiii

Joined Jul 26, 2024
39
The Adafruit instructions are really clear so if you have followed them correctly I’m surprised it’s not working. Instead of using the Arduino stepper library how about writing a simple program which energizes the coils in the sequence you describe - turn on coil A, turn on coil B, turn off coil A, turn off coil B - with delay(100); between each instruction. Just let this loop, and the delay value will determine the speed. You may find this is all you need. If this doesn’t work, make the delay 1000 and instead of connecting motor coils connect LEDs in series with 1K resistors and watch if the on/off sequence is what you expect it to be.

Hope this helps….
pic 0003 adafruit blue color
 

Jerry-Hat-Trick

Joined Aug 31, 2022
775
this code is working fine, but there is no movement of the stepper motor coil, how i verified that this code is working, there is LED built on the Arduino, which was ON and OFF accordingly
Just because code compiles and works, doesn’t necessarily mean it does what you want it to do. You need to adopt a systematic approach to troubleshoot the issue. My suggestions were meant to help you do this. Maybe your hardware connections are not correct? You could try driving the motor by connecting and disconnecting the coils directly to the 10V supply in the correct sequence to check the motor actually works. Connecting LEDs in place of the coils is a real way to check if your connections are correct.
pic 0003 adafruit blue color
I think you have answered part of sarahMCML’s question, she also asked for details of the motor.
 
Top