Giter Club home page Giter Club logo

pico-accelstepper's Introduction

Pico-AccelStepper

This fork of the AccelStepper library is a port of the library to make it work with the Raspberry Pi Pico board (and variants) using the Pico SDK.

List of features:

  • Supports acceleration and deceleration
  • Supports multiple simultaneous steppers, with independent concurrent stepping on each stepper
  • API functions never delay() or block
  • Supports 2, 3 and 4 wire steppers, plus 3 and 4 wire half steppers.
  • Supports alternate stepping functions to enable support of AFMotor (https://github.com/adafruit/Adafruit-Motor-Shield-library)
  • Supports stepper drivers such as the Sparkfun EasyDriver (based on 3967 driver chip)
  • Very slow speeds are supported
  • Extensive API
  • Subclass support

All the examples (except 2) have been modified to reflect program structure for the Pico using the Pico SDK. The original examples are the original work of Mike McCauley.

Using

I’ll assume that you, the breathtaking reader, have successfully compiled, and loaded a program onto your Pico board. Here’s a great getting started guide if you haven’t, yet: getting-started-with-pico.pdf.

Essentially, it’s “Clone this repo under your project, and use add_subdirectory to your CMakeLists.txt and then link the library”. Here’s an example:

The structure is like this:

|- CMakeLists.txt
|- main.cpp
|- pico-accelstepper # this repo!

Here’s the CMakeLists.txt file:

cmake_minimum_required(VERSION 3.14)
set(PROJECT test)

include($ENV{PICO_SDK_PATH}/pico_sdk_init.cmake)

project(${PROJECT} C CXX ASM)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

pico_sdk_init()

add_executable(test main.cpp)

add_subdirectory(pico-accelstepper) # or what you've named it as

target_link_libraries(test accelstepper) # yes the library name is different 

# create all those bin/hex files
pico_add_extra_outputs(test) 

Here’s main.cpp:

#include <AccelStepper.h>

int main()
{
    AccelStepper stepper;

    stepper.setMaxSpeed(100);
    stepper.setAcceleration(200);
    stepper.moveTo(1000);

    while (true)
        stepper.run();
  
}

Now configuring and building it:

# make sure to set PICO_SDK_PATH before this
cmake -S . -B build
cmake --build build
picotool load build/main.uf2 # or just move it using cp or something 

See picotool for more information on that tool.

Examples

The AFMotor examples (AFMotor_ConstantSpeed and AFMotor_MultiStepper) have not been ported because the library used in it Adafruit-Motor-Shield-Library has been deprecated.

The examples can be built by setting the BUILD_EXAMPLES option:

# from the project root directory
cmake -S . -B build -DBUILD_EXAMPLES=ON # out of source build ftw
cmake --build build

Contributing

PRs are welcome, just be respectful!

pico-accelstepper's People

Contributors

ru2saig avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.