资源简介
有关arduino所需要的所有库文件几乎都涵盖在这里了,有需要的朋友可以进行下载,不用再网上一点一点的寻找了
代码片段和文件信息
// AccelStepper.cpp
//
// Copyright (C) 2009 Mike McCauley
// $Id: AccelStepper.cppv 1.13 2012/11/28 09:28:24 mikem Exp mikem $
#include “AccelStepper.h“
#if 0
// Some debugging assistance
void dump(uint8_t* p int l)
{
int i;
for (i = 0; i < l; i++)
{
Serial.print(p[i] HEX);
Serial.print(“ “);
}
Serial.println(““);
}
#endif
void AccelStepper::moveTo(long absolute)
{
if (_targetPos != absolute)
{
_targetPos = absolute;
computeNewSpeed();
// compute new n?
}
}
void AccelStepper::move(long relative)
{
moveTo(_currentPos + relative);
}
// Implements steps according to the current step interval
// You must call this at least once per step
// returns true if a step occurred
boolean AccelStepper::runSpeed()
{
// Dont do anything unless we actually have a step interval
if (!_stepInterval)
return false;
unsigned long time = micros();
// Gymnastics to detect wrapping of either the nextStepTime and/or the current time
unsigned long nextStepTime = _lastStepTime + _stepInterval;
if ( ((nextStepTime >= _lastStepTime) && ((time >= nextStepTime) || (time < _lastStepTime)))
|| ((nextStepTime < _lastStepTime) && ((time >= nextStepTime) && (time < _lastStepTime))))
{
if (_direction == DIRECTION_CW)
{
// Clockwise
_currentPos += 1;
}
else
{
// Anticlockwise
_currentPos -= 1;
}
step(_currentPos & 0x7); // Bottom 3 bits (same as mod 8 but works with + and - numbers)
_lastStepTime = time;
return true;
}
else
{
return false;
}
}
long AccelStepper::distanceToGo()
{
return _targetPos - _currentPos;
}
long AccelStepper::targetPosition()
{
return _targetPos;
}
long AccelStepper::currentPosition()
{
return _currentPos;
}
// Useful during initialisations or after initial positioning
// Sets speed to 0
void AccelStepper::setCurrentPosition(long position)
{
_targetPos = _currentPos = position;
_n = 0;
_stepInterval = 0;
}
void AccelStepper::computeNewSpeed()
{
long distanceTo = distanceToGo(); // +ve is clockwise from curent location
long stepsToStop = (long)((_speed * _speed) / (2.0 * _acceleration)) + 1; // Equation 16 (+integer rounding)
if (distanceTo == 0 && _n == 0)
{
// We are at the target and not moving. Stop here
_stepInterval = 0;
_speed = 0.0;
return;
}
if (distanceTo > 0)
{
// We are anticlockwise from the target
// Need to go clockwise from here maybe decelerate now
if (_n > 0)
{
// Currently accelerating need to decel now? Or maybe going the wrong way?
if ((stepsToStop >= distanceTo) || _direction == DIRECTION_CCW)
_n = -stepsToStop; // Start deceleration
}
else if (_n < 0)
{
// Currently decelerating need to accel again?
if ((stepsToStop < distanceTo) && _direction == DIRECTION_CW)
_n = -_n; // Start accceleration
}
}
else if (distanceTo < 0)
{
// We are clockwise from the target
// Need to go anticlockwise from here
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2016-03-11 21:48 AccelStepper\
文件 11896 2012-11-29 05:28 AccelStepper\AccelStepper.cpp
文件 27701 2012-11-29 05:37 AccelStepper\AccelStepper.h
目录 0 2016-03-11 21:48 AccelStepper\doc\
文件 47718 2012-01-08 15:27 AccelStepper\doc\AccelStepper_8h-source.html
文件 2468 2012-11-29 05:37 AccelStepper\doc\annotated.html
文件 13175 2012-11-29 05:37 AccelStepper\doc\classAccelStepper-members.html
文件 66539 2012-11-29 05:37 AccelStepper\doc\classAccelStepper.html
文件 19165 2012-11-29 05:37 AccelStepper\doc\doxygen.css
文件 3779 2012-11-29 05:37 AccelStepper\doc\doxygen.png
文件 2312 2012-11-29 05:37 AccelStepper\doc\files.html
文件 8489 2012-11-29 05:37 AccelStepper\doc\functions.html
文件 6851 2012-11-29 05:37 AccelStepper\doc\functions_func.html
文件 11498 2012-11-29 05:37 AccelStepper\doc\index.html
文件 1095 2012-11-29 05:37 AccelStepper\doc\tabs.css
文件 35 2012-01-08 15:27 AccelStepper\doc\tab_b.gif
文件 706 2012-01-08 15:27 AccelStepper\doc\tab_l.gif
文件 2585 2012-01-08 15:27 AccelStepper\doc\tab_r.gif
目录 0 2016-03-11 21:48 AccelStepper\examples\
目录 0 2016-03-11 21:48 AccelStepper\examples\AFMotor_ConstantSpeed\
文件 771 2012-03-13 05:42 AccelStepper\examples\AFMotor_ConstantSpeed\AFMotor_ConstantSpeed.pde
目录 0 2016-03-11 21:48 AccelStepper\examples\AFMotor_MultiStepper\
文件 1350 2012-03-12 19:14 AccelStepper\examples\AFMotor_MultiStepper\AFMotor_MultiStepper.pde
目录 0 2016-03-11 21:48 AccelStepper\examples\Blocking\
文件 693 2012-09-24 04:59 AccelStepper\examples\Blocking\Blocking.pde
目录 0 2016-03-11 21:48 AccelStepper\examples\Bounce\
文件 683 2012-10-06 13:48 AccelStepper\examples\Bounce\Bounce.pde
目录 0 2016-03-11 21:48 AccelStepper\examples\ConstantSpeed\
文件 520 2012-09-24 04:59 AccelStepper\examples\ConstantSpeed\ConstantSpeed.pde
目录 0 2016-03-11 21:48 AccelStepper\examples\MultiStepper\
文件 1133 2012-09-24 05:00 AccelStepper\examples\MultiStepper\MultiStepper.pde
............此处省略2015个文件信息
评论
共有 条评论