Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

driverAlign() ignores gain sign, always "MOT: Success: 3" #386

Open
4ndreas opened this issue Feb 29, 2024 · 4 comments · Fixed by #422
Open

driverAlign() ignores gain sign, always "MOT: Success: 3" #386

4ndreas opened this issue Feb 29, 2024 · 4 comments · Fixed by #422
Assignees
Labels
bug Something isn't working

Comments

@4ndreas
Copy link

4ndreas commented Feb 29, 2024

I try to get current sensing working on a custom STM32G431CUBx board. With low side current sensing based on three shunt resistors and the internal op amps.

So far the motor spins fine without current sensing.
Also I tested the CS with a DC current on each phase to calibrate the Gain and verify the hardware -> all ok.

But the dirverAlign() funktion always returns MOT: Success: 3

I set the Gain to "70" and stepp thru the calibration

ab_ratio and ac_ratio are about ~2

CS_align1

at the end of the function all gains are <0 ->MOT: Success: 3

CS_align2

But if I invert the gain to "-70"

the currents are inverted and the ratio is ~2 so:

CS_align3

this changes the gains again:
-> Success: 3

CS_align4

So something is wrong I'm not where the problem is, my gain should be positive since if I disconnect the motor and input a DC current to on phase the ADC value goes up. To test this I just enabled the low side mosfet and hocked up a second power supply ind constant current mode.

Also my Currents are off by a factor of 10 my opamp gain is 7 but then the measured current values are by 10 to high (but this is probably a different problem)
The DC supply is set to 1A and the ADC values go up by like ~80 digits my shunt resistor is 0.01 Ohms.

IDE you are using

  • Arduino IDE
@4ndreas 4ndreas changed the title driverAlign() ignores gain sign allways "MOT: Success: 3" driverAlign() ignores gain sign always "MOT: Success: 3" Feb 29, 2024
@4ndreas 4ndreas changed the title driverAlign() ignores gain sign always "MOT: Success: 3" driverAlign() ignores gain sign, always "MOT: Success: 3" Feb 29, 2024
@Candas1
Copy link
Collaborator

Candas1 commented Feb 29, 2024

Hi,

This is how the code works.
It will just give you success 3 if the gains are negative, even if it's correct.

That's not a problem but it could be improved.

@runger1101001
Copy link
Member

I agree we should change the code to only return 3 (or 4) if the gains were actually inverted compared to the user supplied setting. It's not a hard fix, so could be in the next release.

@runger1101001 runger1101001 added bug Something isn't working and removed possible bug labels Feb 29, 2024
@runger1101001 runger1101001 self-assigned this Feb 29, 2024
@4ndreas
Copy link
Author

4ndreas commented Feb 29, 2024

Thank you, it is a little bit confusing and I was not sure if the output was intended.
It would help, if you change the sign of the gain it should somehow influence the outcome downstream ...

@askuric askuric linked a pull request Jul 14, 2024 that will close this issue
@askuric
Copy link
Member

askuric commented Jul 22, 2024

Hi guys,
The new current sense init #422 is in the release v2.3.4.
It has several new features and that make it easier to use and has the suggested modification. :D
The new code returns 3 or 4 only if the gains are actually inverted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants