cancel
Showing results for 
Search instead for 
Did you mean: 

B-G431B-ESC1 - using it in torque mode and an OUTSIDE SPEED LOOP

HudsonSam
Associate II

I am using the B-G431B-ESC1 inverter board to drive my brushless motor (10 pole pairs) using the FOC algorithm. The brushless motor comes equipped with hall sensors used for commutation and an MT6701 quadrature encoder with a 1024 PPR resolution.

NOTE: I do not intend to use the hall sensors in this application. Only the encoder. However, if you believe there is a way to use them for commutation in torque control mode, I'd like to kknow more about how to set that up. 

I am using an ESP32 where my PID controller is coded. My ESP32 receives speed setpoint input from the end-user and speed feedback from the MT6701 encoder on the BLDC motor. The output of my PID controller on the ESP32 will be the PWM signal that is sent to the PWM input of the B-G431B-ESC1 board.

I have set the control loop of the inverter board to be the torque loop, since my speed loop (outer loop) is sitting on my ESP32.

With all that said, I have a question on how to configure the parameters of this board for such a scenario.

First, even though my motor has hall sensors and an encoder, as far as the inverter board is concerned it has none. All the inverter board needs to do is control the current/torque loop based on the PWM input provided from my ESP32 PID controller.

So that means, in FOC Wizard,

1) I am setting hall sensors and encoders to “OFF” under the MOTOR tab.
2) I am setting the Speed Sensor Mode to default value - not that it matters since it is not being used anyway.
3) Under Drive Settings, I am setting control mode to : Torque Control
4) Under Stage Configuration: I am setting Open Loop OFF, Potentiometer OFF and Electronic Speed Control OFF as well

Is this correct? Am I missing a step or parameter that needs to be modified ? 

Thanks, 

4 REPLIES 4
cedric H
ST Employee

Hello @HudsonSam ,

Few remarks on my side. FOC algorithm requires an electrical angle information to drive your motor. When there are no sensors, this angle information is computed from what we call an observer based on current sensing. Having an encoder to do only the external speed loop and not taking benefit of it to do the current loop regulation is at my humble opinion a conception mistake. I do not see why you could not use your encoder for both, internal current regulation loop and external speed loop. Here also, I would be interested to understand why you need to implement this speed loop outside the inverter board.

Last point, to implement what you described, I advise you to enable the Electronic Speed Control to configure the timer connected to the PWM input properly and change the code in order to convert the PWM duty cycle into torque ramp command instead of speed command.

Hope it helps.

Cedric

HudsonSam
Associate II

Hello @cedric H ,

Thank you for your prompt reply. You asked why am I implementing the speed loop outside, and to be honest I would much prefer to use the inverter board but have found it to be a little difficult and frustrating, mostly because I am very new to STM boards and limited myself in the past to Arduino's ecosystem for my prototypes. I managed to get the B-G431-ESC1 inverter board to work with my bldc motor using the Speed Sensor Mode (Observer + PLL (sensorless)). It took a while, but I managed to get it working. The issue was primarily how to "ARM" the ESC before I provide the PWM input. I realize now that apparently I have to send a 1060 us pulse first, wait for a bit, and then provide the PWM input. 

Note: I'm using a bldc motor that comes equipped with hall sensors and an MT6701 encoder; Original motor set up was primarily used with a regular driver (trapezoid algos), where the hall sensors were used for commutation and the MT6701 encoder was used in my speed loop (implemented on my ESP32 controller). However, I quickly realized that response time of the motor was VERY slow and I needed a better & faster driver (FOC algorithm), and the inverter board from STM came recommended. 

Anyway, my next step was connecting the hall sensors to the inverter board (connecting the encoder was the following step) and switch the Speed Sensor Mode to Hall Sensors. This was a test only. It didn't work at all. I could not figure out why. My wiring checks out. My simple code is just issuing a PWM signal between 1060 us and 1860 us (... or rather 2127 & 3733).  But the motor would not move. I even tried the Motor Pilot and that didn't help either. 

I suspect it may be the parameters of the Hall Effect, where I know that my sensor displacement is 60 deg, but I have no idea what the Placement electrical angle is and the manufacturer in China is of no help. I tried using Motor Profiler (V1.2.5)  but I could not stay connected to the inverter board at all - it would connect for a split second but then cut-off and tell me "firmware error 0.2" and I have no clue what that means. I downloaded an earlier version of Profiler 5.4.8 and was able to connect and profile my motor well enough but it does not include Hall Profiling. Anyway, all to say that I suspect it might be a wrong placemnet electrcial angle being specified and so I abandoned it. 

Then I decided I'll just revert back to old setup with speed loop outside the inverter board and only use the inverter board to control torque (output of my speed PID loop). But that didn't work either. I suspect it must be an arming issue? or maybe torque mode setup is incorrect - you mentioned that I should enable ESC, which I had disabled previously since I didnt' think I needed to use it in torque mode - but if I need it then I'll update and try again. 

After that, my next step is to connect the encoder instead of the hall sensor on my inverter board. I have all the specs for my encoder. I haven't done that yet and plan on doing it today (any advice or docs would be most appreciated). 

Ideally, I do not want to use my own speed loop outside of the inverter board. I would much rather send the speed setpoint and have the inverter board take over but setting it all up has been very challenging to say the least. 

Any help is appreciated and be as detailed as possible please. 

Thank you 

HudsonSam
Associate II

UPDATE:

I connected the encoder to the inverter board direct. It's a quadrature encoder (MT6701). I only connected the VCC, GND and A, B ... I did not connect Z for now. I'm more interested in speed control. 

I set up the config parameters on FOC Wizard as:

- Motor: activated Quadrature Encoder (De-activated Hall Effect)
- Speed Sensing Mode: Selected Quadrature Encoder 
- Speed Sensor Config: Quadrature Encoder selected but Auxillary sensor was TURNED OFF.
- Drive Settings: Speed control
- Stage Configuration: open loop and potentiometer are OFF, but Electronic Speed Control is ON

- User Interface: Start/Stop on Control Board is ON, and Motor Control Protocol Over USART A is ON

I then use motor pilot and connect to the inverter board, but when I press on START, I can see the current draw increasing on my PSU, but the motor itself is not moving at all. In fact, if I try to give it a little spin or nudge, I can feel like the brakes are ON. Current is being sent to the motor but the motor brake won't release? Does that make any sense? 

How do I "release the brake"?

P.S. I also tried is with my own code on the ESP32 through the PWM input and essentially sent a PWM signal of 3000 and again, I could see the current draw rising but the motor is locked or rather the brakes are ON 

Can anyone help me diagnose what is happening here? 

UPDATE II:

Over the weekend I found out I have an issue with programming the EEPROM of my MT6701 to ensure I have max PPR resolution (1024). Even though I was successful in doing that, I found out that after a power cycle on the MT6701, the registers were reset to default values. Try as I may, I was not able to "save" the new EEPROM values.

This meant that with every power cycle, I needed to first write to the registers (using I2C) the maxPPR resolution required, and then switch to using the encoder in quadrature mode. I can only do this if MT6701 rm feedback is being read by my own ESP32 board. This means I am not able to use my encoder by directly connecting it to the inverter board; the default resolution is 1 PPR and that's just not gonna work. I need 1024. 

So now my only option to move forward is to use the inverter board in torque mode. @cedric H your last comment to me regarding this set up was :

"Last point, to implement what you described, I advise you to enable the Electronic Speed Control to configure the timer connected to the PWM input properly and change the code in order to convert the PWM duty cycle into torque ramp command instead of speed command."

I have done that, but am wondering:

a) Given that the FOC Wizard will have no hall sensor and no encoder ... that means we are relying on sensorless operation. Does that mean at low speeds control will be difficult ? Please keep in mind, the inverter is in torque mode and the speed loop is outside the inverter board ... and it has the MT6701 encoder feeding it high resolution feedback on rpm. 

b) if it will be an issue at low speeds to have proper closed loop control of torque, would it help to connect the hall sensors to be used by the inverter board in torque control mode somehow? 

Thanks,