The SCurveMotion library provides an easy way to control motion with an S-curve acceleration profile. This is particularly useful for applications like robotic motion, CNC machines, or other projects where smooth acceleration and deceleration are desired. It implements a motion profile that transitions smoothly between acceleration, constant speed (cruise), and deceleration phases.
- Smooth motion: The library generates smooth motion profiles with adjustable acceleration, deceleration, and jerk time.
- Configurable: You can customize the acceleration, deceleration, jerk time, and maximum speed to suit your needs.
- Simple API: Provides an easy-to-use interface for controlling motion.
You can install the SCurveMotion library directly into the Arduino IDE by following these steps:
- Download the library
.zipfile. - Open the Arduino IDE.
- Go to Sketch → Include Library → Add .ZIP Library....
- Select the downloaded
.zipfile. - The library is now installed and ready to use.
Alternatively, you can clone the repository using Git and place the folder in your Arduino libraries directory.
To visualize the motion parameters in real-time using the Arduino Serial Plotter, follow these steps:
-
Install Better Serial Plotter:
- Follow the instructions on Better Serial Plotter GitHub.
-
Upload the Sketch:
- Upload the example code "plot_all" to your Arduino board.
-
Open the Serial Plotter:
- The plotter will display graphs of position, velocity, acceleration, and jerk.
In your Arduino sketch, include the SCurveMotion library:
#include <SCurveMotion.h>
SCurveMotion motion;
void setup() {
Serial.begin(9600);
motion.init(2.0, 2.0, 0.5, 100.0); // Initialize motion parameters
motion.start(1000.0); // Start motion towards position 1000
}
void loop() {
motion.update(); // Update motion state
// get motion parameters
float pos = sCurve.getPos();
float speed = sCurve.getVel();
float acc = sCurve.getAcc();
float jerk = sCurve.getJerk();
// your code
}
