DRV8353RH & 48V 1000W ,Position Control

Hi everyone,

I am developing an application that uses position control , now I am using DRV8353RH EVM and a 48v 1000W motor with ESP32.
I am facing an issue with the closed loop system. in an open loop, it performs a bit, ok even if it is vibrating in open-loop it gives some output regarding input.

I am using

  • DRV8353RH EVM Driver
  • 48v1000W Motor
  • Optical encoder with 600ppr
  • Current Sense low side

The motor vibrates a lot it’s creating more noise in open-loop as well as in closed loop

#include <SimpleFOC.h>

#define INH_A 21
#define INH_B 19
#define INH_C 18

#define EN_GATE 5

#define IOUTA 34
#define IOUTB 35
#define IOUTC 32

// Motor instance
BLDCMotor motor = BLDCMotor(26);
BLDCDriver3PWM driver = BLDCDriver3PWM(INH_A, INH_B, INH_C, EN_GATE);

LowsideCurrentSense cs = LowsideCurrentSense(0.007f, 10.00f, IOUTA, IOUTB, IOUTC);

// encoder instance
Encoder encoder = Encoder(4, 2, 2400);
void doA(){encoder.handleA();}
void doB(){encoder.handleB();}

float target_angle = 0;

// commander interface
Commander command = Commander(Serial);
void doTarget(char* cmd) { command.scalar(&target_angle, cmd); }

void setup() {

  encoder.init();
  encoder.enableInterrupts(doA, doB);
  motor.linkSensor(&encoder);

  driver.voltage_power_supply = 30;
  driver.pwm_frequency = 15000;
  driver.init();
  motor.linkDriver(&driver);
  cs.linkDriver(&driver);

  motor.voltage_sensor_align = 0.5;
  
 motor.controller = MotionControlType::angle;
  motor.motion_downsample = 0.0;
  
  motor.PID_velocity.P = 0.2;
  motor.PID_velocity.I = 5.0;
  motor.LPF_velocity.Tf = 0.02;
  motor.P_angle.P = 20.0;
  motor.LPF_angle.Tf = 0.0;
  motor.PID_current_q.P = 3.0;
  motor.PID_current_q.I = 100.0;
  motor.LPF_current_q.Tf = 0.02;
  motor.PID_current_d.P = 3.0;
  motor.PID_current_d.I = 100.0;
  motor.LPF_current_d.Tf = 0.02;

  motor.velocity_limit = 100.0;
  motor.voltage_limit = 2.0; 
  motor.current_limit = 2.0;

  Serial.begin(115200);

  motor.useMonitoring(Serial);
  // motor.monitor_variables = _MON_CURR_Q | _MON_CURR_D;
  // motor.monitor_downsample = 1000;

  motor.init();

  cs.init();
  cs.gain_a *=-1;
  cs.gain_b *=-1;
  cs.gain_c *=-1;
  motor.linkCurrentSense(&cs);
  motor.initFOC();
  motor.target = 0;
  command.add('T', doTarget, "target angle");

  _delay(1000);
}


void loop() {
  motor.loopFOC();
  motor.move(target_angle);
  motor.monitor();
  command.run();
}

looking for Support to attain smooth position control

Hello @Mr.Manibharathi_BM

Welcome to the forum.

ESP32 has serious ADC problems, and using it for current sensing is not recommended.

All that said, you will benefit from PID tuning.

Cheers,
Valentine

Hey @Mr.Manibharathi_BM,

The code looks ok. Could you please elleborate a bit more or post a video because the noise itself is not really enough to determine the cause.
You can upload a video to the site directly (no need to pass through YouTube or Google photos)

Alors can you increase the current sense amplification gain?
What are the currectbs that you’re expectyto measure?

In my case with such a small shunt 0.7mOhm I usually start with the amplification gain of 80 or so. Which gives me a ±20amp range on 3.3v logic.
With the amp gain of 10 you’ll have a lot of measurement noise.

Hi @Antun_Skuric @Valentine

This is my motor test setup


DRV8353RH has 4 variable Gain setting of 5v/v , 10v/v , 20v/v , 40v/v
it as 6x,3x,1x PWM modes i am using 3xpwm

for a small gimble motor with TMC6300 and Optical encoder 600ppr works fine without any issue

now I am increasing amplification gain to 40v/v
I am feeling the same issues

Additional information about my setup:

  • Motor phase resistance = 0.3 Ohms
  • Adjustable current shunt amplification gain (5,10,20,40 v/v)
  • 3x PWM mode
  • IDrive 150/300 mA as per my Mosfet calculation
  • Mosfet Vds Monitor to 1V

nFault-led blinks always I don’t know where the fault is arising

I can’t attach the video directly here because of the 4MB limitation

open loop velocity test Video

Position Control will work with the Encoder alone Right?

Your fault led is on because your overcurrent protection is activated I think. The motion of the motor in the video is scary :smiley:
This is no at all how its supposed to sound.

You have to lower your voltage limit a lot when doing the open loop test. If your phase resistance is 0.3Ohm you can set you voltage limit to around 0.5 to 1 Volt to have the current of under 3Amps.

I= V_{limit}/R_{phase} = 1V/0.3\Omega = 3.33 {A}

co in your code make sure to add this line when in open-loop mode

motor.voltage_limit = 1; // Volts

The current sense gain will only influence the FOC_torque mode, if you are in the voltage mode or in any of the open-loop modes then the current sensing is not used and the gain will not change anything.

2 Likes