Menu
Microbots
0
  • Learn
  • Shop
    • Maker-Modules
    • Maker-Packs
    • Tools & Gears
    • Robots & Displays
    • All Products
  • Community
    • Education
    • Software
  • About
    • Our Story
    • Reach Out
    • FAQs
  • English
  • Your Cart is Empty
Microbots
  • Learn
  • Shop
    • Maker-Modules
    • Maker-Packs
    • Tools & Gears
    • Robots & Displays
    • All Products
  • Community
    • Education
    • Software
  • About
    • Our Story
    • Reach Out
    • FAQs
  • Language

  • 0 0

Using DriveCell to Control Magnetic Actuators

Magnetic actuators, like the CoilPad and FlatFlap, use planar PCB coils to generate a small magnetic field to interact with magnets, converting electrical into mechanical energy. DriveCell is perfect for driving these actuators, because of its small size and easy to use library.

Understanding Magnetic Actuators & Why They Need DriveCell

What Are Magnetic Actuators?

Magnetic actuators work by passing current through a coil, which creates a magnetic field that interacts with nearby magnets. This allows them to vibrate or oscillate.

Unlike traditional DC motors, magnetic actuators require rapid polarity switching and precise control to function effectively, which is why H-Bridge drivers like DriveCell are required.

Why Use an H-Bridge Driver Like DriveCell?

Since magnetic actuators rely on alternating current directions, a standard transistor circuit won’t be enough. The DRV8837 H-Bridge in DriveCell allows current to flow in both directions, enabling full control over the polarity and intensity of the magnetic field.

DriveCell Specifications for Magnetic Actuators

Before connecting your actuators, it's essential to understand DriveCell’s electrical limitations:

  • Operating Voltage: 1.8V to 5V 
  • Maximum Continuous Current: 1.8A 
  • H-Bridge Chip: DRV8837, allowing polarity switching & PWM control
  • Built-in Protections: Overcurrent, undervoltage lockout, and thermal shutdown

Note: Both the CoilPad and the FlatFlap consume around 200mA - this means you can connect up 8 actuators in parallel, driving them using a single DriveCell.

Wiring a Magnetic Actuator to DriveCell

Basic Connection for One Actuator

Here’s how to solder/wire a single CoilPad or FlatFlap actuator to DriveCell:

  1. Connect DriveCell Output Pins to the Actuator:
    • OUT1 → Actuator Terminal 1
    • OUT2 → Actuator Terminal 2
  2. Connect DriveCell Input Pins to the Microcontroller:
    • IN1 → Any digital PWM-capable pin
    • IN2 → Another digital PWM-capable pin
  3. Power Connections:
    • VCC → 5V (or up to 11V based on your actuator requirements)
    • GND → Common ground with the microcontroller

Parallel Connection for Multiple Actuators

You can connect multiple actuators in parallel:

  • OUT1 → Both Actuator 1 and Actuator 2 terminal-1
  • OUT2 → Both Actuator 1 and Actuator 2 terminal-2

This setup will drive both actuators in sync, making them activate simultaneously.

Controlling Magnetic Actuators with DriveCell Library

To simplify actuator control, DriveCell provides a software library. Below are the key functions you’ll need:

1. Installing the Library

  1. Open Arduino IDE
  2. Go to Library Manager
  3. Search for DriveCell and install it

2. Code Example

The following example demonstrates how to control two actuators with different intensities:

#include <DriveCell.h>

#define IN1_pin1 2
#define IN1_pin2 3
#define IN2_pin1 5
#define IN2_pin2 6

DriveCell Actuator1(IN1_pin1, IN1_pin2);
DriveCell Actuator2(IN2_pin1, IN2_pin2);

void setup() {
  Actuator1.Init();
  Actuator2.Init();
}

void loop() {
  delay(3000);
      Actuator1.Drive(1, 40); // Activate Actuator1 North-Polarity at 40% power
      Actuator2.Drive(1, 80); // Activate Actuator2 North-Polarity at 80% power
  delay(3000);
      Actuator1.Drive(0, 50); // Activate Actuator1 South-Polarity at 50% power
      Actuator2.Drive(1, 50); // Activate Actuator2 North-Polarity at 50% power
  delay(3000);
      Actuator1.Drive(0, 0); // Deactivate Actuator1
      Actuator2.Drive(0, 100); // Activate Actuator2 South-Polarity at 100% power
}

Understanding the Functions:

  • Init() → Initializes DriveCell and sets up the input pins
  • Drive(direction, power) → Controls actuator:
    • direction → 1 (north) / 0 (south)
    • power → Magnetic-field strength (0 to 100%)

Here's another example where we configure two FlatFlaps and flap them at different speeds:

#include <DriveCell.h>

#define IN1_pin1 2
#define IN1_pin2 3
#define IN2_pin1 5
#define IN2_pin2 6

DriveCell FlatFlap1(IN1_pin1, IN1_pin2);
DriveCell FlatFlap2(IN2_pin1, IN2_pin2);

uint16_t flap_counter = 0;

void setup() {
  FlatFlap1.Init();
  FlatFlap2.Init();

  FlatFlap1.Tone();
  FlatFlap2.Tone();
}

void loop() {
  delay(1);
  flap_counter++;
  if (flap_counter < 2000U) {
    FlatFlap1.Run(0, 100, 100);
    FlatFlap2.Run(0, 100, 100);
  }
  else if (flap_counter < 8000U) {
    FlatFlap1.Run(1, 100, 1000);
    FlatFlap2.Run(1, 100, 1000);
  } else {
    flap_counter = 0U;
    FlatFlap1.Drive(0, 100);
    FlatFlap2.Drive(1, 100);
    delay(500);
    FlatFlap1.Drive(1, 100);
    FlatFlap2.Drive(1, 100);
    delay(500);
    FlatFlap1.Drive(1, 100);
    FlatFlap2.Drive(0, 100);
    delay(500);
    FlatFlap1.Drive(1, 100);
    FlatFlap2.Drive(1, 100);
    delay(500);
    FlatFlap1.Drive(0, 100);
    FlatFlap2.Drive(0, 100);
    delay(500);
    FlatFlap1.Drive(1, 100);
    FlatFlap2.Drive(1, 100);
    delay(500);
    FlatFlap1.Tone();
    FlatFlap2.Tone();
  }
}

Understanding the Functions:

  • Run(smooth, power, speed_ms) → Oscillate the FlatFlap in either a square wave or a smoother PWM wave.
    • smooth → 1 (pwm wave) / 0 (square wave)
    • power → Magnetic-field strength (0 to 100%)
    • power → Flipping speed in milliseconds

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

Below is another example that can be used with other microcontrollers like the Arduino Uno:

#include <DriveCell.h>

#define IN1_pin1 2
#define IN1_pin2 3

DriveCell myActuator(IN1_pin1, IN1_pin2);

void setup() {
  myActuator.Init();
}

void loop() {
    myActuator.Run(1000); // Activate actuator for 1 second, then reverse
}

This example activates the actuator in North-polarity for 1 second before reversing polarity, creating an oscillating square wave movement.

Conclusion

The tiny DriveCell module makes magnetic-actuator control simple and easy to use! Check out the DriveCell GitHub Repository for more code examples and technical documentation!

  • Share:


Also in DriveCell

Using DriveCell to Control Buzzing
Using DriveCell to Control Buzzing

Read More

Using DriveCell to Control High-Power LEDs
Using DriveCell to Control High-Power LEDs

Read More

Using DriveCell to Control DC Motors
Using DriveCell to Control DC Motors

Read More

Follow

Github

  • About
  • Software
  • Education
  • Contact
  • FAQs
  • Terms
  • Refund Policy
  • Privacy Policy

Join our Community ~ Be the first to know about new products and get exciting deals!

© 2025 Microbots.