uStepper S
uStepperEncoder.h
Go to the documentation of this file.
1/********************************************************************************************
2* File: uStepperEncoder.h *
3* Version: 2.3.0 *
4* Date: December 27th, 2021 *
5* Authors: Thomas Hørring Olsen *
6* Emil Jacobsen *
7* *
8*********************************************************************************************
9* (C) 2020 *
10* *
11* uStepper ApS *
12* www.ustepper.com *
13* administration@ustepper.com *
14* *
15* The code contained in this file is released under the following open source license: *
16* *
17* Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International *
18* *
19* The code in this file is provided without warranty of any kind - use at own risk! *
20* neither uStepper ApS nor the author, can be held responsible for any damage *
21* caused by the use of the code contained in this file ! *
22* *
23********************************************************************************************/
34#include <Arduino.h>
35
36#define CS PB2
37#define DIN PB3
38#define DO PB4
39#define CLK PB5
41#define ENCODERDATATOSTEP 51200.0/65536.0
42#define ENCODERDATATOREVOLUTIONS 60.0/65536.0
43#define ANGLETOENCODERDATA 65535.0/360.0
52{
53 public:
57 uStepperEncoder(void);
58
66 void init( uStepperS * _pointer );
67
76 void setHome( float initialAngle = 0 );
77
88 float getAngle( void );
89
101 uint16_t getAngleRaw( void );
102
121 float getAngleMoved( bool filtered = true);
122
141 int32_t getAngleMovedRaw( bool filtered = true );
142
153 float getSpeed(void);
154
165 float getRPM(void);
166
175 uint16_t captureAngle( void );
176
184 uint8_t getStatus( void );
185
196 bool detectMagnet(void);
197
199 volatile int32_t smoothValue;
200
202 volatile float speedSmoothValue;
203
205 volatile uint16_t encoderOffset;
206
209 volatile uint16_t angle;
210
213 volatile int32_t angleMoved;
214
215
219 volatile uint16_t oldAngle;
220
221
224 volatile float curSpeed;
225
228
230 volatile uint8_t Beta = 5;
231
232 private:
233
236
242 void chipSelect(bool state);
243
245 uint8_t status;
246 int32_t userAngleOffset = 0;
247
248 volatile int32_t angleMovedRaw = 0;
249
250};
251
Prototype of class for the AEAT8800-Q24 encoder.
volatile int32_t angleMoved
int32_t getAngleMovedRaw(bool filtered=true)
Returns the angle moved from reference position in raw encoder readings.
volatile int32_t smoothValue
uint8_t getStatus(void)
Get encoder status.
uint16_t captureAngle(void)
Capture the current shaft angle.
float getAngleMoved(bool filtered=true)
Returns the angle moved from reference position in degrees.
void setHome(float initialAngle=0)
Define new reference(home) position.
volatile int32_t angleMovedRaw
volatile uint16_t oldAngle
void init(uStepperS *_pointer)
Initiation of the encoder.
float getSpeed(void)
Measure the current speed of the motor.
volatile posFilter_t encoderFilter
volatile float speedSmoothValue
uint16_t getAngleRaw(void)
Return the current shaft angle in raw encoder readings.
uStepperEncoder(void)
Constructor of uStepperEncoder class.
float getRPM(void)
Measure the current speed of the motor.
float getAngle(void)
Return the current shaft angle in degrees.
volatile uint16_t encoderOffset
void chipSelect(bool state)
Set the output level of the chip select pin.
volatile uint16_t angle
bool detectMagnet(void)
detect magnet
uStepperS * pointer
volatile uint8_t Beta
volatile float curSpeed
Prototype of class for accessing all features of the uStepper S in a single object.
Definition: uStepperS.h:279
Struct for encoder velocity estimator.
Definition: uStepperS.h:203