Removed unnecessary fillets, surfaces, and construction elements from each part; Eliminated duplicate parts; Restructured file and folder organization.
This commit is contained in:
parent
dcf22ec341
commit
328dd0e0aa
192 changed files with 130019 additions and 721896 deletions
44
controller/fw/embed/lib/AS5045/AS5045.cpp
Normal file
44
controller/fw/embed/lib/AS5045/AS5045.cpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
#include "AS5045.h"
|
||||
|
||||
|
||||
MagneticSensorAS5045::MagneticSensorAS5045(uint16_t as5040_cs, uint16_t as5040_mosi, uint16_t as5040_miso,
|
||||
uint16_t as5040_sclk): AS5040_CS_(as5040_cs),
|
||||
AS5040_MOSI_(as5040_mosi),
|
||||
AS5040_MISO_(as5040_miso),
|
||||
AS5040_SCLK_(as5040_sclk),
|
||||
spi(nullptr),
|
||||
settings(AS5145SSISettings) {
|
||||
}
|
||||
|
||||
MagneticSensorAS5045::~MagneticSensorAS5045() = default;
|
||||
|
||||
auto MagneticSensorAS5045::init(SPIClass *_spi) -> void {
|
||||
this->spi = _spi;
|
||||
settings = AS5145SSISettings;
|
||||
pinMode(AS5040_CS_, OUTPUT);
|
||||
pinMode(AS5040_MISO_, INPUT);
|
||||
pinMode(AS5040_MOSI_, OUTPUT);
|
||||
pinMode(AS5040_SCLK_, OUTPUT);
|
||||
|
||||
spi->setMISO(AS5040_MISO_);
|
||||
spi->setMOSI(AS5040_MOSI_);
|
||||
spi->setSCLK(AS5040_SCLK_);
|
||||
spi->begin();
|
||||
this->Sensor::init();
|
||||
}
|
||||
|
||||
float MagneticSensorAS5045::getSensorAngle() {
|
||||
float angle_data = readRawAngleSSI();
|
||||
angle_data = (static_cast<float>(angle_data) / AS5045_CPR) * _2PI;
|
||||
return angle_data;
|
||||
}
|
||||
|
||||
uint16_t MagneticSensorAS5045::readRawAngleSSI() const {
|
||||
spi->beginTransaction(settings);
|
||||
digitalWrite(AS5040_CS_, LOW);
|
||||
uint16_t value = spi->transfer16(0x0000);
|
||||
digitalWrite(AS5040_CS_, HIGH);
|
||||
spi->endTransaction();
|
||||
delayMicroseconds(30);
|
||||
return (value >> 3) & 0x1FFF; // TODO(vanyabeat): Add error checking MAGNETIC OWERFLOW and etc.
|
||||
}
|
32
controller/fw/embed/lib/AS5045/AS5045.h
Normal file
32
controller/fw/embed/lib/AS5045/AS5045.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
#pragma once
|
||||
|
||||
#include "SimpleFOC.h"
|
||||
#include "SPI.h"
|
||||
|
||||
#ifndef MSBFIRST
|
||||
#define MSBFIRST BitOrder::MSBFIRST
|
||||
#endif
|
||||
|
||||
#define AS5045_BITORDER MSBFIRST
|
||||
#define AS5045_CPR 4096.0f
|
||||
#define _2PI 6.28318530718f
|
||||
|
||||
static SPISettings AS5145SSISettings(1000000, AS5045_BITORDER, SPI_MODE0);
|
||||
|
||||
class MagneticSensorAS5045 final: public Sensor {
|
||||
public:
|
||||
MagneticSensorAS5045(uint16_t as5040_cs, uint16_t as5040_mosi, uint16_t as5040_miso, uint16_t as5040_sclk);
|
||||
|
||||
virtual ~MagneticSensorAS5045();
|
||||
|
||||
float getSensorAngle() override;
|
||||
|
||||
virtual void init(SPIClass *_spi = &SPI);
|
||||
|
||||
[[nodiscard]] uint16_t readRawAngleSSI() const;
|
||||
|
||||
private:
|
||||
uint16_t AS5040_CS_, AS5040_MOSI_, AS5040_MISO_, AS5040_SCLK_;
|
||||
SPIClass *spi;
|
||||
SPISettings settings;
|
||||
};
|
10
controller/fw/embed/lib/AS5045/library.properties
Normal file
10
controller/fw/embed/lib/AS5045/library.properties
Normal file
|
@ -0,0 +1,10 @@
|
|||
name=AS5045
|
||||
version=1.0.1
|
||||
author=vanyabeat <vanyabeat@protonmail.com>
|
||||
maintainer=vanyabeat <vanyabeat@protonmail.com>
|
||||
sentence=Simple library to work with AS5040 and Simple FOC (for Robotroller in Robosemmbler) Fork from https://github.com/runger1101001
|
||||
paragraph=Simple library to work with AS5040 and Simple FOC and simple library intended for hobby comunity to run the AS5040 magnetic sensor using FOC algorithm. It is intended to support as many BLDC/Stepper motor+sensor+driver combinations as possible and in the same time maintain simplicity of usage. Library supports Arudino devices such as Arduino UNO, MEGA, NANO and similar, stm32 boards such as Nucleo and Bluepill, ESP32 and Teensy boards.
|
||||
category=Device Control
|
||||
url=https://docs.simplefoc.com
|
||||
architectures=*
|
||||
includes=SimpleFOC.h
|
42
controller/fw/embed/lib/DRV8313/DRV8313.cpp
Normal file
42
controller/fw/embed/lib/DRV8313/DRV8313.cpp
Normal file
|
@ -0,0 +1,42 @@
|
|||
#include "DRV8313.h"
|
||||
|
||||
DRV8313Driver::DRV8313Driver(int phA, int phB, int phC, int en1, int en2, int en3, int slp, int rst,
|
||||
int flt) : BLDCDriver3PWM(phA, phB, phC, en1, en2, en3), slp_pin(slp), rst_pin(rst),
|
||||
flt_pin(flt) {
|
||||
}
|
||||
|
||||
int DRV8313Driver::init() {
|
||||
// Get state from flt pin
|
||||
if (_isset(flt_pin)) {
|
||||
pinMode(flt_pin, INPUT);
|
||||
if (digitalRead(flt_pin) == HIGH) {
|
||||
// if the fault pin is high the driver is in fault state
|
||||
// reset the driver
|
||||
if (_isset(rst_pin)) {
|
||||
pinMode(rst_pin, OUTPUT);
|
||||
digitalWrite(rst_pin, LOW);
|
||||
delay(1);
|
||||
digitalWrite(rst_pin, HIGH);
|
||||
delay(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return BLDCDriver3PWM::init();
|
||||
}
|
||||
|
||||
void DRV8313Driver::enable() {
|
||||
// Enable the driver
|
||||
if (_isset(slp_pin)) {
|
||||
pinMode(slp_pin, OUTPUT);
|
||||
digitalWrite(slp_pin, HIGH);
|
||||
}
|
||||
BLDCDriver3PWM::enable();
|
||||
}
|
||||
|
||||
void DRV8313Driver::disable() {
|
||||
if (_isset(slp_pin)) {
|
||||
pinMode(slp_pin, OUTPUT);
|
||||
digitalWrite(slp_pin, LOW);
|
||||
}
|
||||
BLDCDriver3PWM::disable();
|
||||
}
|
20
controller/fw/embed/lib/DRV8313/DRV8313.h
Normal file
20
controller/fw/embed/lib/DRV8313/DRV8313.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
#pragma once
|
||||
|
||||
#include "SimpleFOC.h"
|
||||
|
||||
class DRV8313Driver : public BLDCDriver3PWM {
|
||||
public:
|
||||
DRV8313Driver(int phA, int phB, int phC, int en1 = NOT_SET, int en2 = NOT_SET, int en3 = NOT_SET, int slp = NOT_SET,
|
||||
int rst = NOT_SET, int flt = NOT_SET);
|
||||
|
||||
int init() override;
|
||||
|
||||
void enable() override;
|
||||
|
||||
void disable() override;
|
||||
|
||||
private:
|
||||
int slp_pin;
|
||||
int rst_pin;
|
||||
int flt_pin;
|
||||
};
|
10
controller/fw/embed/lib/DRV8313/library.properties
Normal file
10
controller/fw/embed/lib/DRV8313/library.properties
Normal file
|
@ -0,0 +1,10 @@
|
|||
name=DRV8313 Simple FOC
|
||||
version=1.0.0
|
||||
author=vanyabeat <vanyabeat@protonmail.com>
|
||||
maintainer=vanyabeat <vanyabeat@protonmail.com>
|
||||
sentence=Simple library to work with DRV8313 and Simple FOC (for Robotroller in Robosemmbler)
|
||||
paragraph=Simple library to work with DRV8313 and Simple FOC and simple library intended for hobby comunity to run the BLDC and Stepper motor using FOC algorithm. It is intended to support as many BLDC/Stepper motor+sensor+driver combinations as possible and in the same time maintain simplicity of usage. Library supports Arudino devices such as Arduino UNO, MEGA, NANO and similar, stm32 boards such as Nucleo and Bluepill, ESP32 and Teensy boards.
|
||||
category=Device Control
|
||||
url=https://docs.simplefoc.com
|
||||
architectures=*
|
||||
includes=SimpleFOC.h
|
46
controller/fw/embed/lib/README
Normal file
46
controller/fw/embed/lib/README
Normal file
|
@ -0,0 +1,46 @@
|
|||
|
||||
This directory is intended for project specific (private) libraries.
|
||||
PlatformIO will compile them to static libraries and link into executable file.
|
||||
|
||||
The source code of each library should be placed in a an own separate directory
|
||||
("lib/your_library_name/[here are source files]").
|
||||
|
||||
For example, see a structure of the following two libraries `Foo` and `Bar`:
|
||||
|
||||
|--lib
|
||||
| |
|
||||
| |--Bar
|
||||
| | |--docs
|
||||
| | |--examples
|
||||
| | |--src
|
||||
| | |- Bar.c
|
||||
| | |- Bar.h
|
||||
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
||||
| |
|
||||
| |--Foo
|
||||
| | |- Foo.c
|
||||
| | |- Foo.h
|
||||
| |
|
||||
| |- README --> THIS FILE
|
||||
|
|
||||
|- platformio.ini
|
||||
|--src
|
||||
|- main.c
|
||||
|
||||
and a contents of `src/main.c`:
|
||||
```
|
||||
#include <Foo.h>
|
||||
#include <Bar.h>
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
PlatformIO Library Dependency Finder will find automatically dependent
|
||||
libraries scanning project source files.
|
||||
|
||||
More information about PlatformIO Library Dependency Finder
|
||||
- https://docs.platformio.org/page/librarymanager/ldf.html
|
Loading…
Add table
Add a link
Reference in a new issue