About | Features | Usage/Functionality | Demo
An Mbed library to control cartesian robot stepper motors. The library features a thread-safe movement buffer and limit configuration methods. It can be used to control three-axis linear motion systems with a single function.
✔️ Step/Direction/Enable motor driver compatability
✔️ Limit configuration
✔️ Stepper state maintenance
✔️ Configurable acceleration/deceleration
✔️ Single function control
✔️ Thread-safe motion buffer management
The library itself and the complete demo program can be found and imported into an Mbed Compiler on the official Mbed website here:
A block diagram of the demo hardware configuration has been included in this repository for reference:
This library requires that the official Mbed 2 C/C++ SDK and the Mbed Real Time Operating System be included in your project. They can be found on the official Mbed website. The revisions listed here have been validated to work:
To support the 4DGL-uLCD used in the demo an additional library was included:
- 4DGL-uLCD-SE - 7:e39a44d
The CartesianRobot constructor requires 9 GPIOs
CartesianRobot robot(p22,p23,p24, p25,p26,p27, p28,p29,p30);DigitalIn enable(p13);
void enable_switch(void const *args){
while(1){
if (!enable && robot.enabled())
robot.disable();
else if (enable && !robot.enabled())
robot.enable();
}
}
int main()
{
...
enable.mode(PullDown);
Thread t1(enable_switch);
...
}void position_monitor(void const *args){
int x_pos, y_pos, z_pos;
while(1){
x_pos = robot.getXPosition()/8;
y_pos = robot.getYPosition()/8;
z_pos = robot.getZPosition()/8;
// Report to Serial, uLCD, etc.
}
}
int main()
{
...
Thread t2(position_monitor);
...
}int main()
{
...
robot.setXSpeed(1200);
robot.setYSpeed(1200);
robot.setZSpeed(2400);
robot.setXAcc(0);
robot.setYAcc(0);
robot.setZAcc(0);
robot.setXDec(0);
robot.setYDec(0);
robot.setZDec(0);
robot.startManager(); // Buffer Manager
...
}DigitalIn set(p14);
DigitalIn controlX(p15);
DigitalIn controlY(p16);
DigitalIn controlZ(p17);
int main()
{
...
set.mode(PullDown);
controlX.mode(PullDown);
controlY.mode(PullDown);
controlZ.mode(PullDown);
while(!set);
robot.setOrigin();
while(!set){
if (robot.stopped() && controlX)
robot.moveX(80); // 10 steps
if (robot.stopped() && controlY)
robot.moveY(80); // 10 steps
if (robot.stopped() && controlZ)
robot.moveZ(80); // 10 steps
}
robot.setLimits();
...
}Serial pc(USBTX,USBRX);
int main()
{
int x, y, z;
int x_s = 600;
int y_s = 600;
int z_s = 1000;
while(1){
if (pc.readable()){
pc.scanf("%d,%d,%d", &x, &y, &z);
pc.printf("Position Buffered\n");
pc.printf("x=%d, y=%d, z=%d\n", x, y, z);
// 1/8 microstepping
robot.moveToXYZ(x*8,y*8,z*8,(float)x_s,(float)y_s,(float)z_s);
}
}
}Made with ❤️ by Marco Newman

