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.
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.
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.
Before connecting your actuators, it's essential to understand DriveCell’s electrical limitations:
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.
Here’s how to solder/wire a single CoilPad or FlatFlap actuator to DriveCell:
You can connect multiple actuators in parallel:
This setup will drive both actuators in sync, making them activate simultaneously.
To simplify actuator control, DriveCell provides a software library. Below are the key functions you’ll need:
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 pinsDrive(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.
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!
Soyez le premier informé des nouveaux projets et bénéficiez d'offres intéressantes !
© 2025 Microbots.