-
Notifications
You must be signed in to change notification settings - Fork 59
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
New "LPF" filter for PID Conrolers in motor.cpp producing "NaN´s" after some (long) time..... #161
Comments
Update: it may give Nan´s after stopImmidialetly, i don´t know why... |
I think its because stopImmediately resets the control loop time inside the pid controller, "Ta" then becomes 0 and you get division by zero. This is a quick fix I did on PID.cpp: Ta = max(Ta, 0.000001); |
This is a good hint, but why? Ta is computed inside PID, its just the delta time, why should it stop working just like that and not recover, because cycletime would be possibly 0 for the pid on a reset, but just for one iteration? somehow it dies and keeps to be dead, even when mower is rebootet. Maybe: why is Ta computet as float? And why would the .h define of Ta would be a double?? its a time?! it should be millis or micros and that is ONLY an unsigned long?
This is flawed for sure. But anyway, the PID seems flawed now i checked it out... I meant something else: the LPF filter giving Nan´s --> to the PID (initial post) : function for PID rpm input --> motorRightOrLeftLpf(motorRightOrLeftRpmCurr); giving Nan´s after some time |
And something else, i read about those microcontrollers... this extensively using of floats for absolutely no reason but reading for human mind is not a good thing to do. cm, meters etc.. times ... everything should be integers and translated only in console or register for readability but not computing. all this floats are just eating away on computeprecision and hardware recources, nothing else. |
Actually, i think this its just the LPF, not the PID, the PID controller might recover because it gets casted to int (?). Might actually come from here: Sunray/sunray/lowpass_filter.cpp Line 23 in 637bcb6
Then y and y_prev become NaN. Tf is 0 by default. I dont have the LPF on my version so I cant say for sure. |
What the description said, possibly due to an overflow. Observed a long time and validated with console, mower conrol loop runs with 50Hz. Mower will stop after ~ 1 - 2 hours and drives are dead, because pid is outputting 0, beside rpm set is given.
It just stops working and there are sudden NaN´s coming from function call motorRightOrLeftLpf(motorRightOrLeftRpmCurr); (logged)
motorRightPID.TaMax = 0.25; //motorRightPID.x = motorRightLpf(motorRightRpmCurr); //gives a NaN after some time.................. motorRightPID.x = motorRightRpmCurr; motorRightPID.w = motorRightRpmSet; motorRightPID.y_min = -pwmMax; motorRightPID.y_max = pwmMax; motorRightPID.max_output = pwmMax; motorRightPID.output_ramp = MOTOR_PID_RAMP; motorRightPID.compute(); motorRightPWMCurr = motorRightPWMCurr + motorRightPID.y;
The text was updated successfully, but these errors were encountered: