EFeru / hoverboard-firmware-hack-FOC

With Field Oriented Control (FOC)
GNU General Public License v3.0
1.15k stars 953 forks source link

Current sensing possible? #200

Closed PaddyCube closed 1 year ago

PaddyCube commented 3 years ago

Your System

Hello and thanks for this cool Firmware. Is it possible to get current sense of each Motor in mA or A? Meaning how much current gets drawn. I'm not familiar with bldc motors but I used this to detect overload/blocking situation and to shut off at dc motors. So is there a way to limit the Power of motors to 100W or so by sense the current?

Patrick

NickLD commented 3 years ago

@PaddyCube You can specify a current limit (per motor) in the config.h: https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/blob/eb20cc0acad0da91ead7d207fa6a83f1778f03e1/Inc/config.h#L154 https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/blob/eb20cc0acad0da91ead7d207fa6a83f1778f03e1/Inc/config.h#L155

The Config comments should guide you well on what to set for them :)

PaddyCube commented 3 years ago

Thank you for this hint. What happen if one of these limits gets reached? Does it stop, stop and go to error state, turn off, simply continue feed max current to motors or what? Also can we recover from such a situation? I'm using USART commands to control the robot. So I will need to add actual current consumption to feedback structure, which seems to be feasable. Reason for this, I want to use this information to detect overload situation or if robot stuck. In such a case, I need to stop and apply some recovery tasks.

NickLD commented 3 years ago

As the I_DC_MAX define states, "Above this value, current chopping is applied." So, in the event motor attempts to pull more than that amount of current, it will apply 'current chopping' which effectively limits the current.

I do not believe even in a stall situation that the motor driver will disable/fault. I could be wrong and you should verify/test this. The drivers IIRC should only disable if it detects a Hall or motor-phase connection issue or fault.

CarlDavey commented 2 years ago

I would find this useful also. I have a 4wd drive configuration using a teensy 4.0 and the Arduino example. For control I have a RC radio with two way telemetry via FrSky S.Port. A readout of current consumption on the radio display would be amazing.

In the Arduino Sketch feedback is currently: https://github.com/EFeru/hoverboard-firmware-hack-FOC/blob/eb20cc0acad0da91ead7d207fa6a83f1778f03e1/Arduino/hoverserial/hoverserial.ino#L129

In the comms.c source code there is reference to the current consumption variables: https://github.com/EFeru/hoverboard-firmware-hack-FOC/blob/eb20cc0acad0da91ead7d207fa6a83f1778f03e1/Src/comms.c#L132

Can I simply add some additional variables to the feedback functions?

And an awesome project, thank you.

Candas1 commented 2 years ago

You can check what I did here https://github.com/Candas1/hoverboard-firmware-hack-FOC/commit/2036a3e4e7feaf64ce18bd4edfed2c6108f66035

CarlDavey commented 2 years ago

You can check what I did here Candas1@2036a3e

Nice one, that will work. I will also change the struct and checksum calculation in my arduino sketch.