Skip to content

Commit f7a91fa

Browse files
Merge pull request #47 from simplefoc/dev
1.0.8 release PR
2 parents bfd07bd + c8174f5 commit f7a91fa

25 files changed

+973
-56
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.project
22
.DS_Store
3+
src/encoders/esp32hwencoder.bak/

README.md

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,13 @@ The intent is to keep the core of SimpleFOC clean, and thus easy to maintain, un
1010

1111
## New Release
1212

13-
v1.0.7 - Released 29 March 2024, for Simple FOC 2.3.2 or later
13+
v1.0.8 - Released July 2024, for Simple FOC 2.3.4 or later
1414

1515

16-
What's changed since 1.0.6?
17-
- Improvements to LinearHall driver, thanks to dekutree
18-
- Fix for ESP32 compiler warning, thanks to Yannik Stradmann
19-
- Added STM32 LPTIM encoder driver
20-
- Refactored communications code
21-
- Working telemetry abstraction
22-
- Working streams communications, ASCII based
23-
- Refactored settings storage code
24-
- Refactored I2CCommander
25-
- New utility class for simple trapezoidal motion profiles
26-
- Bugfixes [included](https://github.com/simplefoc/Arduino-FOC-drivers/issues?q=milestone%3A1.0.7+)
16+
What's changed since 1.0.7?
17+
- MA735 driver thanks to [@techyrobot](https://github.com/techy-robot)
18+
- ESP32HWEncoder driver thanks to [@mcells](https://github.com/mcells)
19+
- Bugfixes [included](https://github.com/simplefoc/Arduino-FOC-drivers/issues?q=milestone%3A1.0.8+)
2720

2821

2922
## What is included
@@ -48,9 +41,12 @@ Drivers for various position sensor ICs. In many cases these hardware-specific d
4841
- [AS5600 I2C driver](src/encoders/as5600/) - I2C driver for the AMS AS5600 and AS5600L absolute position magnetic rotary encoder ICs.
4942
- [MA730 SPI driver](src/encoders/ma730/) - SPI driver for the MPS MagAlpha MA730 absolute position magnetic rotary encoder IC.
5043
- [MA730 SSI driver](src/encoders/ma730/) - SSI driver for the MPS MagAlpha MA730 absolute position magnetic rotary encoder IC.
44+
- [MA735 SPI driver](src/encoders/ma735/) - SPI driver for the MPS MagAlpha MA735 absolute position magnetic rotary encoder IC.
45+
- [MA735 SSI driver](src/encoders/ma735/) - SSI driver for the MPS MagAlpha MA735 absolute position magnetic rotary encoder IC.
5146
- [AS5145 SSI driver](src/encoders/as5145/) - SSI driver for the AMS AS5145 and AS5045 absolute position magnetic rotary encoder ICs.
5247
- [TLE5012B SPI driver](src/encoders/tle5012b/) - SPI (half duplex) driver for TLE5012B absolute position magnetic rotary encoder IC.
53-
- [STM32 Hardware Encoder](src/encoders/stm32hwencoder/) - Hardware timer based encoder driver for ABI type quadrature encoders.
48+
- [STM32 Hardware Encoder](src/encoders/stm32hwencoder/) - STM32 Hardware timer based encoder driver for ABI type quadrature encoders.
49+
- [ESP32 Hardware Encoder](src/encoders/esp32hwencoder/) - ESP32 Hardware timer based encoder driver for ABI type quadrature encoders.
5450
- [SC60228 SPI driver](src/encoders/sc60228/) - SPI driver for SemiMent SC60288 magnetic encoder IC.
5551
- [MA330 SPI driver](src/encoders/ma330/) - SPI driver for the MPS MagAlpha MA330 absolute position magnetic rotary encoder IC.
5652
- [MT6816 SPI driver](src/encoders/mt6816/) - SPI driver for the MagnTek MT6816 absolute position magnetic rotary encoder IC.
@@ -120,6 +116,18 @@ Find out more information about the Arduino SimpleFOC project on the [docs websi
120116

121117
## Release History
122118

119+
What's changed since 1.0.6?
120+
- Improvements to LinearHall driver, thanks to dekutree
121+
- Fix for ESP32 compiler warning, thanks to Yannik Stradmann
122+
- Added STM32 LPTIM encoder driver
123+
- Refactored communications code
124+
- Working telemetry abstraction
125+
- Working streams communications, ASCII based
126+
- Refactored settings storage code
127+
- Refactored I2CCommander
128+
- New utility class for simple trapezoidal motion profiles
129+
- Bugfixes [included](https://github.com/simplefoc/Arduino-FOC-drivers/issues?q=milestone%3A1.0.7+)
130+
123131
What's changed since 1.0.5?
124132
- Added STSPIN32G4 driver
125133
- Added STM32G4 CORDIC code, for greatly accellerated trig functions on supported MCUs

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=SimpleFOCDrivers
2-
version=1.0.7
2+
version=1.0.8
33
author=Simplefoc <[email protected]>
44
maintainer=Simplefoc <[email protected]>
55
sentence=A library of supporting drivers for SimpleFOC. Motor drivers chips, encoder chips, current sensing and supporting code.

src/comms/SimpleFOCRegisters.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,7 @@ uint8_t SimpleFOCRegisters::sizeOfRegister(uint8_t reg){
642642
case SimpleFOCRegister::REG_CURD_LPF_T:
643643
case SimpleFOCRegister::REG_VOLTAGE_LIMIT:
644644
case SimpleFOCRegister::REG_CURRENT_LIMIT:
645+
case SimpleFOCRegister::REG_VELOCITY_LIMIT:
645646
case SimpleFOCRegister::REG_DRIVER_VOLTAGE_LIMIT:
646647
case SimpleFOCRegister::REG_DRIVER_VOLTAGE_PSU:
647648
case SimpleFOCRegister::REG_VOLTAGE_SENSOR_ALIGN:

src/drivers/simplefocnano/README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ void loop(){
3131
}
3232
```
3333

34+
### Additional functions
35+
3436
There are some extra features, you can check for faults, and clear the fault state:
3537

3638
```c++
@@ -50,6 +52,8 @@ if (driver.isSleeping())
5052
driver.wake();
5153
```
5254

55+
### Bus Voltage Sense
56+
5357
As shown in the example you can read the bus voltage:
5458

5559
:warning: *this is a slow function. Do not call it while motor is running!*
@@ -58,8 +62,17 @@ As shown in the example you can read the bus voltage:
5862
float val = driver.getBusVoltage(); // get the bus voltage, in Volts
5963
```
6064

65+
### SPI port
66+
6167
The driver's nCS pin is 10, and the constant PIN_nCS can be used:
6268

6369
```c++
6470
MagneticSensorAS5048A sensor = MagneticSensorAS5048A(PIN_nCS);
65-
```
71+
```
72+
73+
## Examples
74+
75+
The following examples for SimpleFOCNanoDriver can be found in our examples directory:
76+
77+
- [SimpleFOC Nano on AVR](https://github.com/simplefoc/Arduino-FOC-drivers/blob/master/examples/drivers/simplefocnano/simplefocnano_atmega/simplefocnano_atmega.ino) (5V, 10bit ADC range, like original Nano, using AS5048A sensor on SPI)
78+
- [SimpleFOCNanoDriver torque-voltage mode](https://github.com/simplefoc/Arduino-FOC-drivers/blob/master/examples/drivers/simplefocnano/simplefocnano_torque_voltage/simplefocnano_torque_voltage.ino) (3.3V, 12bit ADC range, using AS5048A sensor on SPI)

src/encoders/a1334/A1334.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ A1334::~A1334() {
1717

1818
void A1334::init(SPIClass* _spi) {
1919
spi = _spi;
20-
if (nCS>=0)
20+
if (nCS>=0) {
2121
pinMode(nCS, OUTPUT);
22-
digitalWrite(nCS, HIGH);
22+
digitalWrite(nCS, HIGH);
23+
}
2324
//SPI has an internal SPI-device counter, it is possible to call "begin()" from different devices
2425
spi->begin();
2526
readRawAngle(); // read an angle
@@ -42,13 +43,13 @@ A1334Angle A1334::readRawAngle() {
4243

4344

4445
uint16_t A1334::spi_transfer16(uint16_t outdata) {
46+
spi->beginTransaction(settings);
4547
if (nCS>=0)
4648
digitalWrite(nCS, 0);
47-
spi->beginTransaction(settings);
4849
uint16_t result = spi->transfer16(outdata);
49-
spi->endTransaction();
5050
if (nCS>=0)
5151
digitalWrite(nCS, 1);
52+
spi->endTransaction();
5253
return result;
5354
};
5455

src/encoders/aeat8800q24/AEAT8800Q24.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ void AEAT8800Q24::setConf2(AEAT8800Q24_CONF2_t value){
7878
uint16_t AEAT8800Q24::transfer16SPI(uint16_t outValue) {
7979
// delay 1us between switching the CS line to SPI
8080
delayMicroseconds(1);
81-
if (nCS >= 0)
82-
digitalWrite(nCS, LOW);
8381
spi->endTransaction();
8482
spi->beginTransaction(spiSettings);
83+
if (nCS >= 0)
84+
digitalWrite(nCS, LOW);
8585
uint16_t value = spi->transfer16(outValue);
86-
spi->endTransaction();
8786
if (nCS >= 0)
8887
digitalWrite(nCS, HIGH);
88+
spi->endTransaction();
8989
// delay 1us between switching the CS line to SSI
9090
delayMicroseconds(1);
9191
spi->beginTransaction(ssiSettings);

src/encoders/as5047/AS5047.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ AS5047::~AS5047() {
1717

1818
void AS5047::init(SPIClass* _spi) {
1919
spi = _spi;
20-
if (nCS>=0)
20+
if (nCS>=0) {
2121
pinMode(nCS, OUTPUT);
22-
digitalWrite(nCS, HIGH);
22+
digitalWrite(nCS, HIGH);
23+
}
2324
//SPI has an internal SPI-device counter, it is possible to call "begin()" from different devices
2425
spi->begin();
2526
readRawAngle(); // read an angle
@@ -230,13 +231,13 @@ uint16_t AS5047::calcParity(uint16_t data){
230231

231232

232233
uint16_t AS5047::spi_transfer16(uint16_t outdata) {
234+
spi->beginTransaction(settings);
233235
if (nCS>=0)
234236
digitalWrite(nCS, 0);
235-
spi->beginTransaction(settings);
236237
uint16_t result = spi->transfer16(outdata);
237-
spi->endTransaction();
238238
if (nCS>=0)
239239
digitalWrite(nCS, 1);
240+
spi->endTransaction();
240241
// TODO check parity
241242
errorflag = ((result&AS5047_ERRFLG)>0);
242243
return result;

src/encoders/as5047u/AS5047U.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ AS5047U::~AS5047U() {
1717

1818
void AS5047U::init(SPIClass* _spi) {
1919
spi = _spi;
20-
if (nCS>=0)
20+
if (nCS>=0) {
2121
pinMode(nCS, OUTPUT);
22-
digitalWrite(nCS, HIGH);
22+
digitalWrite(nCS, HIGH);
23+
}
2324
//SPI has an internal SPI-device counter, it is possible to call "begin()" from different devices
2425
spi->begin();
2526
readRawAngle(); // read an angle
@@ -291,13 +292,13 @@ uint16_t AS5047U::nop16(){
291292

292293

293294
uint16_t AS5047U::spi_transfer16(uint16_t outdata) {
295+
spi->beginTransaction(settings);
294296
if (nCS>=0)
295297
digitalWrite(nCS, 0);
296-
spi->beginTransaction(settings);
297298
uint16_t result = spi->transfer16(outdata);
298-
spi->endTransaction();
299299
if (nCS>=0)
300300
digitalWrite(nCS, 1);
301+
spi->endTransaction();
301302
errorflag = ((result&AS5047U_ERROR)>0);
302303
warningflag = ((result&AS5047U_WARNING)>0);
303304
return result;
@@ -321,26 +322,26 @@ uint16_t AS5047U::writeRegister24(uint16_t reg, uint16_t data) {
321322
buff[0] = (reg>>8)&0x3F;
322323
buff[1] = reg&0xFF;
323324
buff[2] = calcCRC(reg);
325+
spi->beginTransaction(settings);
324326
if (nCS>=0)
325327
digitalWrite(nCS, 0);
326-
spi->beginTransaction(settings);
327328
spi->transfer(buff, 3);
328-
spi->endTransaction();
329329
if (nCS>=0)
330330
digitalWrite(nCS, 1);
331+
spi->endTransaction();
331332
errorflag = ((buff[0]&0x40)>0);
332333
warningflag = ((buff[0]&0x80)>0);
333334

334335
buff[0] = (data>>8)&0x3F;
335336
buff[1] = data&0xFF;
336337
buff[2] = calcCRC(data);
338+
spi->beginTransaction(settings);
337339
if (nCS>=0)
338340
digitalWrite(nCS, 0);
339-
spi->beginTransaction(settings);
340341
spi->transfer(buff, 3);
341-
spi->endTransaction();
342342
if (nCS>=0)
343343
digitalWrite(nCS, 1);
344+
spi->endTransaction();
344345
errorflag = ((buff[0]&0x40)>0);
345346
warningflag = ((buff[0]&0x80)>0);
346347

src/encoders/as5048a/AS5048A.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ AS5048A::~AS5048A() {
1717

1818
void AS5048A::init(SPIClass* _spi) {
1919
spi = _spi;
20-
if (nCS>=0)
20+
if (nCS>=0) {
2121
pinMode(nCS, OUTPUT);
22-
digitalWrite(nCS, HIGH);
22+
digitalWrite(nCS, HIGH);
23+
}
2324
//SPI has an internal SPI-device counter, it is possible to call "begin()" from different devices
2425
spi->begin();
2526
readRawAngle(); // read an angle
@@ -103,13 +104,13 @@ uint16_t AS5048A::nop(){
103104
}
104105

105106
uint16_t AS5048A::spi_transfer16(uint16_t outdata) {
107+
spi->beginTransaction(settings);
106108
if (nCS>=0)
107109
digitalWrite(nCS, 0);
108-
spi->beginTransaction(settings);
109110
uint16_t result = spi->transfer16(outdata);
110-
spi->endTransaction();
111111
if (nCS>=0)
112112
digitalWrite(nCS, 1);
113+
spi->endTransaction();
113114
// TODO check parity
114115
errorflag = ((result&AS5048A_ERRFLG)>0);
115116
return result;

src/encoders/as5600/AS5600.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,25 @@ uint16_t AS5600::angle() {
3131
setAngleRegister();
3232
}
3333
_wire->requestFrom(_address, (uint8_t)2, (uint8_t)closeTransactions);
34-
result = _wire->read()<<8;
34+
result = (_wire->read()&0x0F)<<8;
3535
result |= _wire->read();
3636
return result;
3737
};
3838

3939

4040
uint16_t AS5600::readRawAngle() {
41-
return readRegister(AS5600_REG_ANGLE_RAW, 2);
41+
return readRegister(AS5600_REG_ANGLE_RAW, 2) & 0x0FFF;
4242
};
4343

4444

4545
uint16_t AS5600::readAngle() {
46-
return readRegister(AS5600_REG_ANGLE, 2);
46+
return readRegister(AS5600_REG_ANGLE, 2) & 0x0FFF;
4747
};
4848

4949

5050

5151
uint16_t AS5600::readMagnitude() {
52-
return readRegister(AS5600_REG_MAGNITUDE, 2);
52+
return readRegister(AS5600_REG_MAGNITUDE, 2) & 0x0FFF;
5353
};
5454

5555

@@ -74,17 +74,17 @@ AS5600Conf AS5600::readConf() {
7474

7575

7676
uint16_t AS5600::readMang() {
77-
return readRegister(AS5600_REG_MANG, 2);
77+
return readRegister(AS5600_REG_MANG, 2) & 0x0FFF;
7878
};
7979

8080

8181
uint16_t AS5600::readMPos() {
82-
return readRegister(AS5600_REG_MPOS, 2);
82+
return readRegister(AS5600_REG_MPOS, 2) & 0x0FFF;
8383
};
8484

8585

8686
uint16_t AS5600::readZPos() {
87-
return readRegister(AS5600_REG_ZPOS, 2);
87+
return readRegister(AS5600_REG_ZPOS, 2) & 0x0FFF;
8888
};
8989

9090

0 commit comments

Comments
 (0)