lars bldc parameter
This commit is contained in:
parent
8af848b01b
commit
dee14242cd
@ -68,7 +68,7 @@ USBCDC usbserial;
|
||||
#endif
|
||||
|
||||
const int voltage_lpf = 50;
|
||||
const float max_voltage_limit = 6;
|
||||
const float max_voltage_limit = 2.3;
|
||||
|
||||
|
||||
#ifdef ESPHWENC
|
||||
@ -90,9 +90,13 @@ CalibratedSensor encoder_calibrated(abs_inc_sensor, sizeof(encoder_calibration_l
|
||||
#ifdef MOTOR
|
||||
struct drv8323s_foc_driver drv8323s;
|
||||
// BLDCMotor motor = BLDCMotor(100); // 24N22P
|
||||
HybridStepperMotor motor = HybridStepperMotor(50); //, 3.7, 10, 4.5 / 1000);
|
||||
#endif
|
||||
//HybridStepperMotor motor = HybridStepperMotor(50); //, 3.7, 10, 4.5 / 1000);
|
||||
|
||||
|
||||
BLDCMotor motor = BLDCMotor(7, 0.7, 360, 0.15);
|
||||
// BLDCMotor motor = BLDCMotor(7);
|
||||
//BLDCDriver3PWM driver = BLDCDriver3PWM(16, 5, 17, 4);
|
||||
#endif
|
||||
void read_i2c(uint8_t addr, uint8_t reg, uint8_t *buf, uint8_t len) {
|
||||
Wire.beginTransmission(addr);
|
||||
Wire.write(reg); // MAN:0x2E
|
||||
@ -225,12 +229,13 @@ void setup() {
|
||||
digitalWrite(INLABC, 1); // enable
|
||||
// driver.init(&SPI);
|
||||
// status();
|
||||
motor.linkSensor(&encoder_calibrated);
|
||||
motor.linkSensor(&encoder_absolute);
|
||||
//motor.linkSensor(&encoder_calibrated);
|
||||
motor.linkDriver(drv8323s.focdriver);
|
||||
// motor.foc_modulation = FOCModulationType::SinePWM;
|
||||
motor.foc_modulation = FOCModulationType::SpaceVectorPWM;
|
||||
|
||||
motor.voltage_sensor_align = 4;
|
||||
motor.voltage_sensor_align = 1.5;
|
||||
motor.voltage_limit = max_voltage_limit;
|
||||
// motor.controller = MotionControlType::velocity_openloop;
|
||||
// motor.controller = MotionControlType::velocity;
|
||||
@ -252,7 +257,7 @@ void setup() {
|
||||
const char *zero_electric_angle_str = "zero_el_angle";
|
||||
const char *sensor_direction_str = "enc_dir_str";
|
||||
const int settle_time_ms = 150;
|
||||
if (!pref.isKey(encoder_calibration_lut_str) || pref.getBytesLength(encoder_calibration_lut_str) != sizeof(encoder_calibration_lut)) {
|
||||
if (motor.sensor == &encoder_calibrated && (!pref.isKey(encoder_calibration_lut_str) || pref.getBytesLength(encoder_calibration_lut_str) != sizeof(encoder_calibration_lut))) {
|
||||
encoder_calibrated.calibrate(motor, settle_time_ms);
|
||||
pref.putBytes(encoder_calibration_lut_str, &encoder_calibration_lut[0], sizeof(encoder_calibration_lut));
|
||||
pref.putFloat(zero_electric_angle_str, motor.zero_electric_angle);
|
||||
@ -263,7 +268,7 @@ void setup() {
|
||||
Serial.println("Skipping calibration");
|
||||
}
|
||||
|
||||
if (!pref.isKey(zero_electric_angle_str)) {
|
||||
if (!pref.isKey(zero_electric_angle_str) || motor.sensor != &encoder_calibrated) {
|
||||
motor.initFOC();
|
||||
pref.putFloat(zero_electric_angle_str, motor.zero_electric_angle);
|
||||
pref.putInt(sensor_direction_str, (int)motor.sensor_direction);
|
||||
@ -354,7 +359,7 @@ void foc_task_loop() {
|
||||
servo_state.controller_temperature = curr_pcb_temp_kelvin;
|
||||
servo_state.motor_temperature = NAN;
|
||||
|
||||
float curr_angle = encoder_calibrated.getAngle();
|
||||
float curr_angle = motor.sensor->getAngle();
|
||||
servo_state.curr_position = curr_angle;
|
||||
servo_state.curr_force = motor.voltage.d;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user