MakeBlock Drive Updated Updated library for MakeBlock Ranger

Loading...
Searching...
No Matches
MeStepper.h
Go to the documentation of this file.
1
63#ifndef MeStepper_h
64#define MeStepper_h
65#include "MePort.h"
66
67#if ARDUINO >= 100
68 #include "Arduino.h"
69#else
70 #include "WProgram.h"
71 #include "stdlib.h"
72 #include "wiring.h"
73#endif
74
75
76// These defs cause trouble on some versions of Arduino
77#undef round
78
84 class MeStepper:public MePort
85{
86 public:
93 MeStepper();
94
101 MeStepper(uint8_t port);
102
119 void setpin(uint8_t dir_data, uint8_t step_data);
120
135 void moveTo(long absolute);
136
151 void move(long relative);
152
167 boolean run();
168
183 boolean runSpeed();
184
199 void setMaxSpeed(float speed);
200
215 void setAcceleration(float acceleration);
216
231 void setSpeed(float speed);
232
247 float speed();
248
263 long distanceToGo();
264
279 long targetPosition();
280
295 long currentPosition();
296
311 void setCurrentPosition(long position);
312
327 void runToPosition();
328
343 boolean runSpeedToPosition();
344
359 void runToNewPosition(long position);
360
361 void disableOutputs();
362 void enableOutputs();
363
364 protected:
379 void computeNewSpeed();
380
395 virtual void step();
396 private:
397 static volatile uint8_t _dir_data;
398 static volatile uint8_t _step_data;
399 uint8_t _dir; // 2 or 4
400 long _currentPos; // Steps
401 long _targetPos; // Steps
402 float _speed; // Steps per second
403 float _maxSpeed;
404 float _acceleration;
405 unsigned long _stepInterval;
406 unsigned long _lastStepTime;
408 long _n;
409
411 float _c0;
412
414 float _cn;
415
417 float _cmin; // at max speed
418 uint8_t _dirPin, _stpPin;
419};
420
421#endif
MePort.h
Header for MePort.cpp module.
MePort
Port Mapping for RJ25.
Definition MePort.h:128
MeStepper
Driver for Me Stepper device.
Definition MeStepper.h:85
MeStepper::computeNewSpeed
void computeNewSpeed()
Definition MeStepper.cpp:308
MeStepper::moveTo
void moveTo(long absolute)
Definition MeStepper.cpp:144
MeStepper::MeStepper
MeStepper()
Definition MeStepper.cpp:77
MeStepper::setCurrentPosition
void setCurrentPosition(long position)
Definition MeStepper.cpp:287
MeStepper::targetPosition
long targetPosition()
Definition MeStepper.cpp:249
MeStepper::setpin
void setpin(uint8_t dir_data, uint8_t step_data)
Definition MeStepper.cpp:117
MeStepper::runToNewPosition
void runToNewPosition(long position)
Definition MeStepper.cpp:623
MeStepper::setMaxSpeed
void setMaxSpeed(float speed)
Definition MeStepper.cpp:428
MeStepper::step
virtual void step()
Definition MeStepper.cpp:541
MeStepper::runToPosition
void runToPosition()
Definition MeStepper.cpp:570
MeStepper::runSpeedToPosition
boolean runSpeedToPosition()
Definition MeStepper.cpp:592
MeStepper::currentPosition
long currentPosition()
Definition MeStepper.cpp:268
MeStepper::move
void move(long relative)
Definition MeStepper.cpp:167
MeStepper::setSpeed
void setSpeed(float speed)
Definition MeStepper.cpp:488
MeStepper::run
boolean run()
Definition MeStepper.cpp:400
MeStepper::setAcceleration
void setAcceleration(float acceleration)
Definition MeStepper.cpp:457
MeStepper::distanceToGo
long distanceToGo()
Definition MeStepper.cpp:230
MeStepper::runSpeed
boolean runSpeed()
Definition MeStepper.cpp:186
MeStepper::speed
float speed()
Definition MeStepper.cpp:522