Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/alex-stone-github/pepstep

Arduino Library for concurrent stepper control
https://github.com/alex-stone-github/pepstep

arduino arduino-ide arduino-library scheduler scheduling-algorithms stepper-library stepper-motor steppers

Last synced: 14 days ago
JSON representation

Arduino Library for concurrent stepper control

Awesome Lists containing this project

README

        

# Pepstep
_For stepper motors with pep to their step_

![Library Cover Image](docs/cover.png)

## Functionality

This library allows the control of multiple stepper motors concurrently through "ScheduleEntrys."

# Compatability
It supports stepper motors from the Arduino library. The CNCShield wrapper API, "CNCShieldMotor," looks like this:
```cpp
auto get(double steps_per_unit) -> double;
auto set(ScheduleEntry& scheduler, double speed) -> void;
auto stop(ScheduleEntry& scheduler) -> void;
auto reset() -> void;
```

# Examples with
## Simple Example
```cpp
#include
#include

CNCShield arduino_shield;
pep::CNCShieldMotor rotation(arduino_shield.get_motor(0));
pep::CNCShieldMotor linear(arduino_shield.get_motor(1));

void printhi(void*) {
Serial.println("Hello, World");
Serial.println(linear.get(1.0));
}

pep::ScheduleEntry schedule[] = {
CNCSMEntry(rotation),
CNCSMEntry(linear),
pep::ScheduleEntry(1000,(void(*)(void*))(&printhi),NULL),
};

void setup() {
Serial.begin(9600);
while (!Serial);
arduino_shield.begin();
arduino_shield.enable();

rotation.set(schedule[0], 0.1);
linear.set(schedule[1],0.2);
}
void loop() {
POLL(schedule);
}
```

## Scheduling Example
```cpp
#include
#include

CNCShield arduino_shield;
pep::CNCShieldMotor rotation(arduino_shield.get_motor(0));
pep::CNCShieldMotor linear(arduino_shield.get_motor(1));

void printhi(void*) {
Serial.println("Hello, World");
rotation.reset(); // Reset Internal Step Counter, "Encoder"
}

pep::ScheduleEntry schedule[] = {
pep::ScheduleEntry(10000, (void(*)(void*))(&pep::CNCShieldMotor::step), (void*)&rotation),
pep::ScheduleEntry(10000, (void(*)(void*))(&pep::CNCShieldMotor::step), (void*)&linear ),
pep::ScheduleEntry(1000, (void(*)(void*))(&printhi), NULL ),
};
void setup() {
Serial.begin(9600);
while (!Serial);
arduino_shield.begin();
arduino_shield.enable();

rotation.set(schedule[0], 0.1);
linear.set(schedule[1],0.2);
}
void loop() {
for (auto& entry : schedule)
entry.poll(millis());
}
```