Arduino library for SPI based ERCFS rotary encoder.
Experimental
Warning: This library is not tested with hardware yet. So use with care, feedback welcome.
ECRFS is a library for the ERCF 1 05SPI 360 Z rotation encoder. This devices decodes 360.0° in 16384 steps which implies an accuracy of about 0.022°. The angle is calculated every 350 μs, so 2850 times per second.
As the device can handle up to 800 rpm = 75 milliseconds per rotation. To have a fair indication of rpm and direction one has to sample 4 times so roughly once every 20 ms.
Feedback as always, is welcome. Please open an issue.
See - https://forum.arduino.cc/t/will-this-rotary-encoder-work-with-arduino/1351596
| Name pin | Colour | 3 wire SPI | 4 wire SPI |
|---|---|---|---|
| Supply +V | Red | 1 | 1 |
| Ground | Grey | 2 | 2 |
| MOSI | Grey | NC | 3 |
| MISO | Grey | 3 | 4 |
| CLOCK | Grey | 4 | 5 |
| SELECT CS | Grey | 5 | 6 |
Angle math
- https://github.com/RobTillaart/Angle
- https://github.com/RobTillaart/AngleConvertor
- https://github.com/RobTillaart/AverageAngle
- https://github.com/RobTillaart/runningAngle
Decoders
- https://github.com/RobTillaart/AMT25
- https://github.com/RobTillaart/AS5600 magnetic rotation meter.
- https://github.com/RobTillaart/ERCFS this library
- https://p3america.com/ercf-1-05spi-360-z/ home of ERCFS datasheet.
Related rotary decoder libraries
- https://github.com/RobTillaart/rotaryDecoder
- https://github.com/RobTillaart/rotaryDecoderSwitch
- https://github.com/RobTillaart/rotaryDecoder8
- https://github.com/RobTillaart/rotaryDecoderSwitch5
The ERC 1 05SPI 360 could be compatible, also 14 bit SPI device. To be investigated.
If you have a ERCFS device, please let me know your experiences with the sensor and this (or other) library.
#include "ERCFS.h"- ERCFS(uint8_t select, SPI_CLASS * mySPI = &SPI) HARDWARE SPI
- ERCFS(uint8_t select, uint8_t dataIn, uint8_t dataOut, uint8_t clock) SOFTWARE SPI
- bool begin() initializes the communication.
- uint16_t getRawValue() returns a value from 0..16383
- float getAngle() returns an absolute angle from 0..360.0°, optional with offset correction.
- void setOffset(float offset = 0) set an offset in degrees for the angle.
- float getOffset() returns the current offset in degrees.
- uint32_t lastRead() timestamp in microseconds since start. Note this wraps every ~70 minutes however for RPM measurements one need to read the device far more often.
- void setSPIspeed(uint32_t speed) idem, clipped to max 2 MHz.
- uint32_t getSPIspeed() idem.
- bool usesHWSPI() idem.
- improve documentation
- test with hardware
- add examples
If you appreciate my libraries, you can support the development and maintenance. Improve the quality of the libraries by providing issues and Pull Requests, or donate through PayPal or GitHub sponsors.
Thank you,