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.
AS5045.h
00001 #ifndef AS5045_H 00002 #define AS5045_H 00003 00004 #include "mbed.h" 00005 00006 // Class which implements AS5045 encoder interface 00007 class AS5045 00008 { 00009 public: 00010 AS5045(PinName cs); // Constructor 00011 00012 int getPosition(); // Read tick amount from encoder (position) 00013 float getAngle(); // Convert position of the encoder to degrees 00014 00015 private: 00016 SPI _spi; // MBED SPI instance 00017 DigitalOut _cs; 00018 uint16_t EncoderByteData; // MBED digital output pin 00019 00020 static const float MAX_VALUE = 1024; // Maximum possible encoder position value (ticks for full rotation) 00021 static const float RESOLUTION = 0.3515625; // Encoder resolution (0.08789 degrees per tick) 00022 static const float SPI_FREQ = 500000; // Frequency of the SPI bus 00023 }; 00024 00025 #endif // AS5045_H
Generated on Thu Jul 14 2022 20:23:26 by
1.7.2