The CoilPad is an incredibly thin and innovative actuator that brings motion to your projects in a compact form factor. To understand how it works, let's dive into its unique design and the principles behind its operation.
In this tutorial we will explain:
What is a CoilPad?
The CoilPad is an actuator made from a flexible planar coil that adheres seamlessly to any smooth surface. By adding a magnet, it transforms into a device capable of magnetic movement, buzzing, or even heating. It’s designed to convert electrical energy into mechanical movement with ease.
How Does It Work?
The CoilPad features a flat, ultra-thin coil that interacts with external magnets. When an electric current passes through the coil, it generates a magnetic field that either attracts or repels the magnet, causing movement. By alternating the direction of the current, you can control the motion of the CoilPad. Applying a square wave signal makes the CoilPad oscillate continuously, with adjustable speed and intensity. For smooth organic motions, we will explore the DriveCell PWM library.
Installing CoilPad
The CoilPad design makes it easy to install. It comes with a peelable adhesive back, ensuring that it stays firmly attached to any smooth surface.
Getting Your CoilPad Moving
You can start testing it, by pulling one of its pins to 5V and the other to ground, then switch them around. In one instance, the magnet will be repelled, and in the other, it will be attracted. You can connect it to your own transistors or H-bridge module to switch these pins automatically. However, to make it even easier, you can purchase our tiny DriveCell module. The DriveCell is a compact, pin-to-pin compatible H-bridge driver that simplifies the process of controlling actuators like the CoilPad. Its open-source Arduino software library makes actuator control easy, especially for beginners, by providing straightforward software functions and easy-to-follow examples.
For an in-depth guide on the DriveCell Software Library, check out this article. But here’s a quick recap of how you can use its functions to enhance the CoilPad actuation. Don’t worry, it’s quite simple! Start by downloading the "DriveCell" library from Arduino's Library Manager. Once installed, you’ll be ready to control your device. Before we start, make sure you connect the DriveCell to your microcontroller. We recommend using a CodeCell, which is pin-to-pin compatible, supports all the library functions, and can add wireless control and interactive sensing to your CoilPad.
1. Init()
First, we need a basic setup code to get you started:
#include <DriveCell.h> // This line includes the DriveCell library
DriveCell myCoilPad(IN1, IN2); // Replace IN1 and IN2 with your specific pins
void setup() {
myCoilPad.Init(); // Initializes your DriveCell connected to a CoilPad
}
This code gives the name 'myCoilPad' to your DriveCell and tells it to start up and initialize all the necessary peripherals.
2. Pulse(bool direction, uint8_t ms_duration)
This function sends a brief burst of power to the CoilPad in a specified polarity. This quick energizing and de-energizing can cause a short, sharp movement of the CoilPad, depending on the polarity.
myCoilPad.Pulse(1, 10); // Sends a short burst for 10 milliseconds in the specified direction
3. Buzz(uint16_t us_buzz)
This function makes the CoilPad vibrate like a buzzer, which is useful for creating audible feedback.
myCoilPad.Buzz(100); // Makes the CoilPad buzz with a 100 microsecond pulses
4. Tone()
The Tone
function makes the CoilPad play a tone. This can be used for audible feedback or creative applications where sound is part of the interaction.
myCoilPad.Tone(); // Plays a tone by varying the frequency
5. Toggle(uint8_t power_percent)
This function toggles the CoilPad polarity, which can be useful for creating a rapid flapping movement or reversing direction quickly in your code.
myCoilPad.Toggle(100); // Toggles direction at 100% power
6. Run(bool smooth, uint8_t power_percent, uint16_t flip_speed_ms)
This function allows you to continuously flip the polarity of the CoilPad and control its motion speed and smoothness. If smooth
is set to true
, the actuation will be less sharp and smoothed, which is ideal for slower, controlled movements.
myCoilPad.Run(true, 50, 1000); // Runs the CoilPad smoothly at 50% power, flipping every 1000 milliseconds
7. Drive(bool direction, uint8_t power_percent)
This function lets you control the CoilPad polarity and its magnetic field strength by adjusting the power level.
myCoilPad.Drive(true, 75); // Moves the CoilPad forward at 75% power
Here's an example where we configure two CoilPads and actuate them at two different speeds:
#include <DriveCell.h>
#define IN1_pin1 2
#define IN1_pin2 3
#define IN2_pin1 5
#define IN2_pin2 6
DriveCell CoilPad1(IN1_pin1, IN1_pin2);
DriveCell CoilPad2(IN2_pin1, IN2_pin2);
uint16_t c_counter = 0;
void setup() {
CoilPad1.Init();
CoilPad2.Init();
CoilPad1.Tone();
CoilPad2.Tone();
}
void loop() {
delay(1);
c_counter++;
if (c_counter < 2000U) {
CoilPad1.Run(0, 100, 100);
CoilPad2.Run(0, 100, 100);
}
else if (c_counter < 8000U) {
CoilPad1.Run(1, 100, 1000);
CoilPad2.Run(1, 100, 1000);
} else {
c_counter = 0U;
}
}
Combining with CodeCell Sensors
To make it even more interactive you can combine the CoilPad and DriveCell with the tiny CodeCell Sensor Module. CodeCell is pin-to-pin compatible with DriveCell, supports all library functions, and can adds wireless control and interactive sensing to your project. This allows you to create more advanced, responsive elements with your CoilPad actuators.
With this next example the CodeCell controls two CoilPad that stops flapping when proximity is detected. Their magnetic field gets adjusted dynamically based on how close your hands gets. If no hand is detected it flips the CoilPad polarity every 400 milliseconds.
#include <CodeCell.h>
#include <DriveCell.h>
#define IN1_pin1 2
#define IN1_pin2 3
#define IN2_pin1 5
#define IN2_pin2 6
DriveCell CoilPad1(IN1_pin1, IN1_pin2);
DriveCell CoilPad2(IN2_pin1, IN2_pin2);
CodeCell myCodeCell;
void setup() {
Serial.begin(115200);
/* Set Serial baud rate to 115200. Ensure Tools/USB_CDC_On_Boot is enabled if using Serial. */
myCodeCell.Init(LIGHT); /*Initializes Light Sensing*/
CoilPad1.Init();
CoilPad2.Init();
CoilPad1.Tone();
CoilPad2.Tone();
}
void loop() {
if (myCodeCell.Run()) {
/*Runs every 100ms*/
uint16_t proximity = myCodeCell.Light_ProximityRead();
Serial.println(proximity);
if (proximity < 100) {
CoilPad1.Run(1, 100, 400);
CoilPad2.Run(1, 100, 400);
} else {
proximity = proximity - 100;
proximity = proximity / 10;
if (proximity > 100) {
proximity = 100;
}
CoilPad1.Drive(0, (proximity));
CoilPad2.Drive(0, (proximity));
}
}
}
Feel free to tweak the code with your own creative ideas, or add motion sensing for a new reaction! Get started today with our Arduino libraries! If you have any more question about the CoilPad feel free to email us and we will gladly help out!
Be the first to know about new projects and get exciting deals!
© 2024 Microbots.