Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed Watchdog stm32-sensor-base2
AS5045/AS5045.h@14:b3530522908e, 2020-12-14 (annotated)
- Committer:
- ruslanbredun
- Date:
- Mon Dec 14 10:20:16 2020 +0000
- Revision:
- 14:b3530522908e
- Parent:
- 12:406f75196a12
- Child:
- 17:0c8440955d31
11.12.20
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ommpy | 0:d383e2dee0f7 | 1 | #ifndef AS5045_H |
ommpy | 0:d383e2dee0f7 | 2 | #define AS5045_H |
ommpy | 0:d383e2dee0f7 | 3 | |
ommpy | 0:d383e2dee0f7 | 4 | #include "mbed.h" |
ommpy | 0:d383e2dee0f7 | 5 | |
ommpy | 0:d383e2dee0f7 | 6 | // Class which implements AS5045 encoder interface |
ommpy | 0:d383e2dee0f7 | 7 | class AS5045 |
ommpy | 0:d383e2dee0f7 | 8 | { |
ommpy | 0:d383e2dee0f7 | 9 | public: |
ommpy | 0:d383e2dee0f7 | 10 | AS5045(PinName cs); // Constructor |
ommpy | 0:d383e2dee0f7 | 11 | |
ommpy | 0:d383e2dee0f7 | 12 | int getPosition(); // Read tick amount from encoder (position) |
ruslanbredun | 12:406f75196a12 | 13 | float getAngle(); // Convert position of the encoder to degrees |
ommpy | 0:d383e2dee0f7 | 14 | |
ommpy | 0:d383e2dee0f7 | 15 | private: |
ommpy | 0:d383e2dee0f7 | 16 | SPI _spi; // MBED SPI instance |
nestedslk | 5:97117a837d2c | 17 | DigitalOut _cs; |
nestedslk | 5:97117a837d2c | 18 | uint16_t EncoderByteData; // MBED digital output pin |
ommpy | 0:d383e2dee0f7 | 19 | |
nestedslk | 4:f6e22dd39313 | 20 | static const float MAX_VALUE = 1024; // Maximum possible encoder position value (ticks for full rotation) |
ruslanbredun | 12:406f75196a12 | 21 | static const float RESOLUTION = 0.3515625; // Encoder resolution (0.08789 degrees per tick) |
ruslanbredun | 14:b3530522908e | 22 | static const float SPI_FREQ = 500000; // Frequency of the SPI bus |
ommpy | 0:d383e2dee0f7 | 23 | }; |
ommpy | 0:d383e2dee0f7 | 24 | |
ommpy | 0:d383e2dee0f7 | 25 | #endif // AS5045_H |