uStepper
 All Classes Files Functions Variables Macros Pages
Arduino library for the uStepper Board

This is the uStepper Arduino library, providing software functions for the different features of the uStepper board.

Features
The uStepper library contains the following features:

The library uses both timer one and timer two in order to function properly, meaning that unless the user of this library can accept the loss of some functionality, these two timers are unavailable and the registers associated with these timers should not be reconfigured.

Timer one is used for sampling the encoder in order to provide the ability to keep track of both the current speed and the angle moved since the board was reset (or a new home position was configured).

Timer two is used to calculate the stepper acceleration algorithm.

Warning
In order to get some features working, it was necessary to write functions to control the I2C hardware in the MCU, since the build in wire library of Arduino uses interrupt which doesn't play well when used inside a timer interrupt routine. Therefore if the user of this library needs to use the I2C bus, the user should use the functions defined in this library instead of wire library !
Installation
To install the uStepper library into the Arduino IDE, perform the following steps:

The library is tested with Arduino IDE 1.6.8

Theory

The acceleration profile implemented in this library is a second order profile, meaning that the stepper will accelerate with a constant acceleration, the velocity will follow a linear function and the position will look like an S-curve (it will follow a linear function at top speed and a second order function during acceleration and deceleration). As a result, the position of the stepper motor will have continous and differentiable first and second derivatives.

The second order acceleration profile can be illustrated as follows (Source):

dva.gif

From the above picture it can be seen how the motor moves with this second order acceleration profile. The postion is depicted as orange, velocity as red and the acceleration as green.

The algorithm used is NOT designed by me, I ONLY implemented the algorithm! credit is therefore given to the appropriate author: Aryeh Eiderman.

for those interested, the deriviation of the algorithm used can be found at the following webpage (Which is neither owned nor affiliated with ON Development IVS in any way): Real Time Stepper Motor Linear Ramping Just by Addition and Multiplication

Copyright

(C)2016 ON Development IVS

www.on-development.com

admin.nosp@m.istr.nosp@m.ation.nosp@m.@on-.nosp@m.devel.nosp@m.opme.nosp@m.nt.co.nosp@m.m

Creative Commons License

The code contained in this file is released under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License

The code in this library is provided without warranty of any kind - use at own risk! neither ON Development IVS nor the author, can be held responsible for any damage caused by the use of the code contained in this library !

To do list
  • Fix bug in stepper algorithm
  • Clean out in unused variables
  • Update comments
  • Implement multiaxis feature between multiple uSteppers
  • Add support for limit switches
Known Bugs
Bug:
Stepper algorithm still has a bug, which makes the deceleration part perform strange under a small subset of max velocity/acceleration settings. This bug is due to lack of precision in the variables used for the algorithm, and will be fixed in a later version. However, the subset of settings is small, and therefore other tasks has been prioritized.
Author
Thomas Hørring Olsen (thoma.nosp@m.s@us.nosp@m.teppe.nosp@m.r.co.nosp@m.m)
Change Log
Version
0.3.0:
  • Added support for speed readout
  • Added support for measuring the shaft position with respect to a zero reference. (absolute within multiple revolutions)
0.2.0:
  • Complete rewrite of the stepper algorithm in assembler
  • Changed from fixed point to floating point variables, due to the need for more precision
  • Removed the getSpeed() method, as it didn't work, and therefore it would make more sense to remove it and re-add it when i get the time to fix it
  • Added a few doxygen comments
  • Added a new method (getStepsSinceReset()), which returns all steps performed since reset of the uStepper. positive values corresponds to steps in clockwise direction, while negative values corresponds to steps in counterclockwise direction.
0.1.0:
  • Initial release