simpleFoc库支持绝对值编码器,霍尔编码器,磁编码器
一、 磁编码器 I2C
参数
* MagneticSensorI2C类构造函数
* @param chip_address I2C芯片地址
* @param bits 传感器分辨率的位数
* @param angle_register_msb angle read register msb
* @param _bits_used_msb number of used bits in msb
*/
MagneticSensorI2C(uint8_t _chip_address, int _bit_resolution, uint8_t _angle_register_msb, int _msb_bits_used);
应用
simplefoc已经将AS5600和AS5048的参数封装,若使用这俩芯片直接填参即可
MagneticSensorI2C sensor = MagneticSensorI2C(AS5600_I2C);//选填AS5600_I2C,AS5048_I2C
#include <SimpleFOC.h>
MagneticSensorI2C sensor0 = MagneticSensorI2C(AS5600_I2C);
MagneticSensorI2C sensor1 = MagneticSensorI2C(AS5600_I2C);
TwoWire I2Cone = TwoWire(0);
TwoWire I2Ctwo = TwoWire(1);
void setup() {
Serial.begin(115200);
_delay(750);
//针对最新版本ESP-Arduino 2.0.2,采用下面两句
I2Cone.begin(19,18, 400000UL); //SDA0,SCL0
I2Ctwo.begin(23,5, 400000UL);
sensor0.init(&I2Cone);
sensor1.init(&I2Ctwo);
}
void loop() {
sensor0.update();
sensor1.update();
//_delay(200);
Serial.print(sensor0.getAngle());
Serial.print(" - ");
Serial.print(sensor1.getAngle());
Serial.println();
}
别的没有到呢,用到更新。
版权声明:本文为qq_42927036原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。