-
Notifications
You must be signed in to change notification settings - Fork 597
check for floating point error due to insufficient precision #37
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
Conversation
Hey Jurgen, shaft_angle += target_velocity*Ts the combination I am thinking that maybe just having the shaft angle as I'll look into it a bit and let you know, because I would like to keep track of the actual shaft angle and not initialize it to 0 during the course of motion control. This will maybe change in the future releases of the library though. |
Hello Antun! The reason why I used (_2PI * 4) as a limit and not (_2PI) is, because I had the same problem with 360° spinning servos before. Anyways, I think that it would be the best, if the shaft angle should stay between 0 and 2*pi and the number of turns should be counted in a int32 varibable. Cheers, |
Hello Antun! The coding implies, that the value pulse_counter is incremented all the time and the Angle is calculated by this value. Therefore, I think it will be a good idea, to keep the angle between 0 <= angle < 2*pi, and to save the rotations in a separate variable. Currently I have stated to implement the new rotations variable, but need some more days to finish the programming. |
Hey Jurgen, You are right, I am aware of this actually. This is surely a problem, but in a context of this library it was an ok solution. But this has to be changed! Now, I would suggest you to update the code for your application but not to waste too much time on the pull-request. Finally, since this code change requires core changes in the library, and a lot of testing for all types of sensors and drivers. I am not sure I feel comfortable a pull-request without in depth analysis. I hope you understand what I mean. If you have time to deal with this I will be happy to see your changes and what works for you, but introducing this to the Simple FOC library might take a bit longer :D |
Dear Antun! Thank you for your feedback, which I understand and have similar thoughts about. The main problem is the small number of data types in the Arduino environment: https://learn.sparkfun.com/tutorials/data-types-in-arduino/all, which don't have 64-bit data types, i.e. no double and no long long. Of course, I understand that you'd like to keep a total angle that includes all revolutions, but with a hardware setup that requires 12 bits per second for the encoder and 12 bits (or more) for the motor speed, the left over bits (<= 8) for the minutes are really small. I also understand that core changes in the library will create a lot of effort in testing all types of sensors and drivers. To cut a long story short, I would suggest that I stop making any changes until you decide how to resolve this issue as there is no point making all the changes and no one has time to review and approve the pull request. Cheers, |
Hi Everybody, Yours thoughts ? (I can do a mistake of understanding too :) ) Best regards |
Hey guys, Yes, I'll revive the pull-request as soon as we updated the internal interfaces and the API. I think it will help me a lot to discuss it with you guys. @Polyphe the electrical angle is a property of the motor. And in order for the sensor to know it it would need to know the number of pole pairs of the motor. This is feasible, but I would like to avoid it. Resetting the counter is a good idea and it is inline with what Jurgen has proposed. And we will definitely go deeper into this topic in the next few releases. What I would like to do, in combination with this change is to add a possibility to combine more position sensors:
|
Hi @askuric, shaft_angle = shaftAngle(); --> remove What do you think about ? I think @ATILIUS-REGULUS are totally right about of this issue, because when we reach the limits, the motor misbehaves for the above reasons, as you know. Best regards. |
Hey @Polyphe We are not arguing that this is a problem. I am aware of this and we will fix it. And it is good that you guys point it out so that we don't into it faster. But there is a lot of small things like this one in this library, small checks that have not been handled for the sake of the readability/clarity/simplicity. This library never really had the optimality and long term robustness as it's primary goal. Im sure you've already seen these kinds of trade-off made in code. |
Hello everybody! Cheers, |
Hey guys, Jurgen, I'm going to adapt the code a bit, but the idea is the same. So thanks once again. |
I am guessing this is somthing that I am also running into. After about 5 minutes of running in velocity mode with any of the as5047 sensors. The motor eventually slows down and draws quite a lot of current. The slower I run velocity the longer it spins but eventually it will always stall. |
Hello carbonadam! |
Hey Adam, my guess is that you're running into the precision bug we have with magnetic sensors. Depending on how fast it's spinning, motors stop after a few minutes. That code fixes the problem for my AS5048A sensors. I will adapt it to the AS5047, because the diagnostic and magnitude registers are different, but in the meantime it should actually work as is for reading the angles. |
At BLDCMotor::velocityOpenloop(float target_velocity) was an error due to insufficient precision with the float value shaft_angle.
If a motor run with 0.5 rad/s on a F446RE, the motor stopped after about 14 minutes in the open_loop_velocity_example, when shaft_angle reached a value of 512.00.