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.
Diff: SPI_Encoder.h
- Revision:
- 1:7826ec4d9405
- Parent:
- 0:21ae825df645
- Child:
- 3:d3694519bd73
--- a/SPI_Encoder.h Mon Jul 22 17:45:28 2019 +0000
+++ b/SPI_Encoder.h Fri Aug 30 03:06:00 2019 +0000
@@ -4,18 +4,20 @@
#include "mbed.h"
#define encoder_num 4
+#define PI 3.14159265359
+/* cui amt203 */
class SPI_Encoder
{
public:
- SPI_Encoder(PinName mosi, PinName miso, PinName sclk, PinName cs0, PinName cs1, PinName cs2, PinName cs3);
+ SPI_Encoder(PinName mosi, PinName miso, PinName sclk, PinName _cs0, PinName _cs1, PinName _cs2, PinName _cs3, float t);
void getPosition(int num);
+ bool setZero(int num);
+ void inverse(int num);
- uint16_t EncoderByteData[encoder_num];
- uint16_t Encoderposition_last[encoder_num];
- uint8_t temp[2][encoder_num];
- uint16_t Steps[encoder_num];
+ float angle[encoder_num];
+ float velocity[encoder_num];
private:
SPI encoder;
@@ -23,6 +25,10 @@
DigitalOut cs1;
DigitalOut cs2;
DigitalOut cs3;
+ float delta_t;
+ bool direction[4];
+ uint8_t temp[2][encoder_num];
+ uint16_t EncoderByteData[encoder_num];
uint8_t _SPI_T (int num, uint8_t SPITransmit);
void _switching(int num, int value);
};