My installation of SimpleFOCStudio is having problems. Some functions work, others do not. Right now it is not receiving telemetry from the ESP32. This set of data repeats and does not change. The “Pull parameters” does work.
It could be my code too. That last field I believe is the data from the AS5600 sensor. It seems quite random upon reset of the ESP32 but once the data stream starts, the values never change. It USED to work and the “Angle” display would track the motor sensor but I have been unable to get it to work again.
Here is the current code:
**
* ESP32 position motion control example with magnetic sensor
*/
#include <SimpleFOC.h>
MagneticSensorI2C sensor = MagneticSensorI2C(AS5600_I2C);
// Motor instance
BLDCMotor motor = BLDCMotor(11);
// define BLDC driver
BLDCDriver3PWM driver = BLDCDriver3PWM(16,17,18,19);
// angle set point variable
// float target_angle = 0;
Commander command = Commander(Serial);
void doMotor(char* cmd) { command.motor(&motor, cmd); }
void setup() {
Serial.begin(115200);
Wire.setClock(400000);
// initialise magnetic sensor hardware
sensor.init();
// link the motor to the sensor
motor.linkSensor(&sensor);
// driver config
// power supply voltage [V]
driver.voltage_power_supply = 14.8;
driver.init();
// link the motor and the driver
motor.linkDriver(&driver);
// choose FOC modulation (optional)
motor.foc_modulation = FOCModulationType::SpaceVectorPWM;
// set motion control loop to be used
motor.controller = MotionControlType::angle;
// maximal voltage to be set to the motor
//motor.voltage_limit = 4;
// angle P controller
//motor.P_angle.P = 20;
// maximal velocity of the position control
//motor.velocity_limit = 20;
// The letter (here 'M') you will provide to the SimpleFOCStudio
command.add('M',doMotor,"motor");
// comment out if not needed
motor.useMonitoring(Serial);
// initialize motor
motor.init();
// align sensor and start FOC
motor.initFOC();
Serial.println(F("Motor ready."));
_delay(1000);
}
void loop() {
motor.loopFOC();
motor.monitor();
command.run();
}
// all looks good 24 dec at 11 am...loaded onto board