uStepper S
uStepperEncoder.h
Go to the documentation of this file.
1 /********************************************************************************************
2 * File: uStepperEncoder.h *
3 * Version: 1.0.1 *
4 * Date: May 14th, 2019 *
5 * Author: Thomas Hørring Olsen *
6 * *
7 *********************************************************************************************
8 * (C) 2019 *
9 * *
10 * uStepper ApS *
11 * www.ustepper.com *
12 * administration@ustepper.com *
13 * *
14 * The code contained in this file is released under the following open source license: *
15 * *
16 * Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International *
17 * *
18 * The code in this file is provided without warranty of any kind - use at own risk! *
19 * neither uStepper ApS nor the author, can be held responsible for any damage *
20 * caused by the use of the code contained in this file ! *
21 * *
22 ********************************************************************************************/
33 #include <Arduino.h>
35 #define CS PB2
36 
38 #define DIN PB3
39 
41 #define DO PB4
42 
44 #define CLK PB5
45 
47 #define ENCODERDATATOSTEP 51200.0/65536.0
48 
50 #define ENCODERDATATOREVOLUTIONS 60.0/65536.0
51 
59 {
60  public:
61 
65  uStepperEncoder(void);
66 
74  void init( uStepperS * _pointer );
75 
82  void setHome( void );
83 
94  float getAngle( void );
95 
107  uint16_t getAngleRaw( void );
108 
125  float getAngleMoved( void );
126 
143  int32_t getAngleMovedRaw( void );
144 
155  float getSpeed(void);
156 
167  float getRPM(void);
168 
177  uint16_t captureAngle( void );
178 
186  uint8_t getStatus( void );
187 
198  bool detectMagnet(void);
199 
200 
202  uint16_t encoderOffset;
203 
206  volatile uint16_t angle;
207 
210  volatile int32_t angleMoved;
211 
212 
216  volatile uint16_t oldAngle;
217 
218 
222  volatile int16_t revolutions;
223 
224 
227  volatile float curSpeed;
228 
231 
232  private:
233 
236 
242  void chipSelect(bool state);
243 
245  uint8_t status;
246 
247 
248 
249 };
250 
uStepperEncoder(void)
Constructor of uStepperEncoder class.
volatile posFilter_t encoderFilter
float getSpeed(void)
Measure the current speed of the motor.
int32_t getAngleMovedRaw(void)
Returns the angle moved from reference position in raw encoder readings.
volatile float curSpeed
Prototype of class for accessing all features of the uStepper S in a single object.
Definition: uStepperS.h:252
float getAngleMoved(void)
Returns the angle moved from reference position in degrees.
Struct for encoder velocity estimator.
Definition: uStepperS.h:173
volatile int32_t angleMoved
uint16_t captureAngle(void)
Capture the current shaft angle.
volatile uint16_t oldAngle
uint16_t getAngleRaw(void)
Return the current shaft angle in raw encoder readings.
Prototype of class for the AEAT8800-Q24 encoder.
void setHome(void)
Define new reference(home) position.
volatile uint16_t angle
volatile int16_t revolutions
float getAngle(void)
Return the current shaft angle in degrees.
void init(uStepperS *_pointer)
Initiation of the encoder.
uStepperS * pointer
uint16_t encoderOffset
void chipSelect(bool state)
Set the output level of the chip select pin.
float getRPM(void)
Measure the current speed of the motor.
bool detectMagnet(void)
detect magnet
uint8_t getStatus(void)
Get encoder status.