Makeblock-library-for-Arduino  V3.2.4
It's a library for arduino application developers
MeStepper.h
Go to the documentation of this file.
1 
57 #ifndef MeStepper_h
58 #define MeStepper_h
59 #include "MePort.h"
60 
61 #if ARDUINO >= 100
62  #include "Arduino.h"
63 #else
64  #include "WProgram.h"
65  #include "stdlib.h"
66  #include "wiring.h"
67 #endif
68 
69 
70 // These defs cause trouble on some versions of Arduino
71 #undef round
72 
78 class MeStepper:public MePort
79 {
80 public:
87  MeStepper();
88 
95  MeStepper(uint8_t port);
96 
113  void setpin(uint8_t dir_data, uint8_t step_data);
114 
129  void moveTo(long absolute);
130 
145  void move(long relative);
146 
161  boolean run();
162 
177  boolean runSpeed();
178 
193  void setMaxSpeed(float speed);
194 
209  void setAcceleration(float acceleration);
210 
225  void setSpeed(float speed);
226 
241  float speed();
242 
257  long distanceToGo();
258 
273  long targetPosition();
274 
289  long currentPosition();
290 
305  void setCurrentPosition(long position);
306 
321  void runToPosition();
322 
337  boolean runSpeedToPosition();
338 
353  void runToNewPosition(long position);
354 
355  void disableOutputs();
356  void enableOutputs();
357 
358 protected:
373  void computeNewSpeed();
374 
389  virtual void step();
390 private:
391  static volatile uint8_t _dir_data;
392  static volatile uint8_t _step_data;
393  uint8_t _dir; // 2 or 4
394  long _currentPos; // Steps
395  long _targetPos; // Steps
396  float _speed; // Steps per second
397  float _maxSpeed;
398  float _acceleration;
399  unsigned long _stepInterval;
400  unsigned long _lastStepTime;
402  long _n;
403 
405  float _c0;
406 
408  float _cn;
409 
411  float _cmin; // at max speed
412  uint8_t _dirPin, _stpPin;
413 };
414 
415 #endif
void setSpeed(float speed)
Definition: MeStepper.cpp:482
boolean run()
Definition: MeStepper.cpp:394
Port Mapping for RJ25.
Definition: MePort.h:118
void setMaxSpeed(float speed)
Definition: MeStepper.cpp:422
float speed()
Definition: MeStepper.cpp:516
void runToPosition()
Definition: MeStepper.cpp:564
void setAcceleration(float acceleration)
Definition: MeStepper.cpp:451
long targetPosition()
Definition: MeStepper.cpp:243
void move(long relative)
Definition: MeStepper.cpp:161
void setCurrentPosition(long position)
Definition: MeStepper.cpp:281
MeStepper()
Definition: MeStepper.cpp:71
boolean runSpeed()
Definition: MeStepper.cpp:180
Driver for Me Stepper device.
Definition: MeStepper.h:78
void computeNewSpeed()
Definition: MeStepper.cpp:302
Header for MePort.cpp module.
void setpin(uint8_t dir_data, uint8_t step_data)
Definition: MeStepper.cpp:111
boolean runSpeedToPosition()
Definition: MeStepper.cpp:586
long currentPosition()
Definition: MeStepper.cpp:262
virtual void step()
Definition: MeStepper.cpp:535
long distanceToGo()
Definition: MeStepper.cpp:224
void moveTo(long absolute)
Definition: MeStepper.cpp:138
void runToNewPosition(long position)
Definition: MeStepper.cpp:617
void enableOutputs()
void disableOutputs()