Menu
Microbots
0
  • Apprendre
  • Boutique
    • Modules et technologies
    • Maker-Packs
    • Outils et engrenages
    • Robots & Displays
    • Tous les produits
  • Communauté
    • Education
    • Software
  • À propos
    • Notre histoire
    • Tendez la main
    • FAQ
  • français
  • Votre panier est vide
Microbots
  • Apprendre
  • Boutique
    • Modules et technologies
    • Maker-Packs
    • Outils et engrenages
    • Robots & Displays
    • Tous les produits
  • Communauté
    • Education
    • Software
  • À propos
    • Notre histoire
    • Tendez la main
    • FAQ
  • Langue

  • 0 0

MotorCell - Controlling High Speed RPM

MotorCell utilizes the BD67173NUX three-phase back-EMF controller with a sensorless drive system, allowing speed control via a PWM input signal duty cycle. The IN pin defaults to low, running the motor at full speed when pulled high (2.5V–5V). You can adjust the speed in 1,000 RPM increments via the duty cycle, or directly use the MotorCell library functions.

Important Notes & Safety Information

  • Load: MotorCell is designed to drive small loads. The speed will decrease as the load/drag increases. The maximum spinning load is 12g at a radius of 18mm. For larger radius check the specifications for the full torque vs speed graph.
  • High-Speed Caution: Keep hands away from moving parts and wear protective eyewear.
  • OUT Pin Pull-Up Resistor: The MotorCell library automatically enables an internal pull-up on the OUT pin for speed readings. If using custum software, ensure the pull-up remains enabled or add an external one.
  • Stall Detection: If the motor is forced to stop, it enters a 5-second lock protection mode. This can be reset by setting the PWM input to 0% and back on, a process automatically handled by the MotorCell library’s Spin function.

Setting Up Your MotorCell 


Connecting Your MotorCell

  • IN: 10kHz-50kHz PWM input for speed control (or connect to VDD for full speed)
  • OUT: Speed frequency feedback (requires a pull-up resistor if not implemented through software)
  • FR: Optional direction control (connect to VDD, GND, or control with GPIO)
  • GND: Ground connection
  • VDD: Power input (2.5V–5V)

Installing the MotorCell Library 

To get started, install the MotorCell library from the Arduino Library Manager:

  1. Open the Arduino IDE.
  2. Navigate to Sketch > Include Library > Manage Libraries.
  3. Search for “MotorCell” and install it.

The library includes examples to help you quickly get started with MotorCell control.

Speed Control Example

We going to start with control the speed level using the Spin function. This function adjusts the motor’s speed to the desired percentage of its maximum capability and returns the current RPM value. This value is also automatically printed on the Serial Monitor, for easy debugging.  If the motor stalls, it will automatically attempt to restart.

#include <MotorCell.h>

#define IN_pin1 2
#define OUT_pin2 3
#define FR_pin2 1

MotorCell myMotorCell(IN_pin1, OUT_pin2, FR_pin2); /* Configure the MotorCell pins */

void setup() {
  Serial.begin(115200); /* Set up serial - Ensure Tools/USB_CDC_On_Boot is enabled */

  myMotorCell.Init(); /* Initialize the MotorCell */
}

void loop() {
  uint16_t MotorRPM = myMotorCell.Spin(25); /* Set speed to 25% of maximum speed */
}

⚠ Note: For this function we recommend using an ESP32 device like the CodeCell to avoid delays when reading the RPM

Reversing Motor Direction Example

This next example demonstrates how to reverse the motor’s direction every 5 seconds while running it at full speed. The MaxSpin function sets the motor to its maximum speed, while the ReverseSpin function changes its rotation direction. This alternates between clockwise and counterclockwise rotation with a 5-second delay between each direction change.

#include <MotorCell.h>

#define IN_pin1 2
#define OUT_pin2 3
#define FR_pin2 1

MotorCell myMotorCell(IN_pin1, OUT_pin2, FR_pin2); /* Configure the MotorCell pins */

void setup() {
  Serial.begin(115200); /* Set up serial - Ensure Tools/USB_CDC_On_Boot is enabled */

  myMotorCell.Init(); /* Initialize the MotorCell */
}

void loop() {
  myMotorCell.MaxSpin(); /* Set motor to maximum speed */
  myMotorCell.ReverseSpin(); /* Reverse the motor's rotation direction */
  delay(5000); /* Wait for 5 seconds */
  
  myMotorCell.MaxSpin(); /* Maintain maximum speed */
  myMotorCell.ReverseSpin(); /* Reverse direction again */
  delay(5000); /* Wait for another 5 seconds */
}

PID Speed Control Example

This final example implements a PID controller to regulate the motor speed to the desired RPM using the SpinPID function. The PID controller dynamically compensates for disturbances and load variations, ensuring smooth operation. If the motor stalls, the function will automatically restart it and notify you if the target speed cannot be reached. This is also automatically printed on the Serial Monitor, for easy debugging.

#include <MotorCell.h>

#define IN_pin1 2
#define OUT_pin2 3
#define FR_pin2 1

MotorCell myMotorCell(IN_pin1, OUT_pin2, FR_pin2); /* Configure the MotorCell pins */

void setup() {
  Serial.begin(115200); /* Set up serial - Ensure Tools/USB_CDC_On_Boot is enabled */

  myMotorCell.Init(); /* Initialize the MotorCell */
}

void loop() {
  uint16_t MotorRPM = myMotorCell.SpinPID(15000); /* Set target RPM to 15,000 using PID */
}

⚠ Note: The SpinPID() function uses a high-speed PWM timer, making it compatible only with CodeCell and ESP32-based devices.

Conclusion 

With the MotorCell library installed, you can easily control speed, direction, and monitor its RPM!

Ready to start experimenting? Grab a MotorCell today and check out the MotorCell GitHub Repository for more code examples and technical documentation!

 

  • Partager:

Partage

Github

  • À propos
  • Software
  • Education
  • Contact
  • FAQ
  • Termes
  • Politique de remboursement
  • politique de confidentialité

Soyez le premier informé des nouveaux projets et bénéficiez d'offres intéressantes !

© 2025 Microbots.