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). Also the drop-in features missed step detection and correction is done in this timer.

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

Warning
MAC users should be aware, that OSX does NOT include FTDI VCP drivers, needed to upload sketches to the uStepper, by default. This driver should be downloaded and installed from FTDI's website:
http://www.ftdichip.com/Drivers/VCP.htm
The uStepper should NOT be connected to the USB port while installing this driver !
This is not a problem for windows/linux users, as these drivers come with the arduino installation.
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
  • Clean out in unused variables
  • Update comments
  • Implement PID-controller into dropin feature
  • Implement multiaxis feature between multiple uSteppers
  • Add support for limit switches
  • Split the library into multiple files
Known Bugs
  • No known bugs
Author
Thomas Hørring Olsen (thoma.nosp@m.s@us.nosp@m.teppe.nosp@m.r.co.nosp@m.m)
Change Log
Version
0.4.1:
  • Fixed bug with getAngleMoved() returning alternating values (offset by exactly 180 degrees) between resets.
  • Added keywords
  • Updated pin connection description for Drop-in example
0.4.0:
  • Added Drop-in feature to replace stepsticks with uStepper for error correction
  • Fixed bug in stepper acceleration algorithm, making the motor spin extremely slow at certain accelerations. Also this fix reduced the motor resonance
  • Implemented an IIR filter on the speed measurement, to smooth this out a bit.
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