[NXC]Motor-control-functions
[NXC]Motor-control-functions
Hello
I am currently examining the commands RotateMotor() and RotateMotorPID().
I have come to the conclusion that the motor always overshoots the target position. I could not eliminate the problem by changing the PID values.
http://mindstormsforum.de/viewtopic.php ... 9f5cd891a0
I came across a program that controls the motors better than the firmware. (written in NXC for PC based programs)
http://mindstormsforum.de/download/file ... 9f5cd891a0
http://www.mindstorms.rwth-aachen.de/tr ... torControl
Is there a possibility, that we NXC programmers get such a function? I'm not really happy with the current functions
_________________________________________________________________________________________________________________________________
http://roboticsaumair.jimdo.com
I am currently examining the commands RotateMotor() and RotateMotorPID().
I have come to the conclusion that the motor always overshoots the target position. I could not eliminate the problem by changing the PID values.
http://mindstormsforum.de/viewtopic.php ... 9f5cd891a0
I came across a program that controls the motors better than the firmware. (written in NXC for PC based programs)
http://mindstormsforum.de/download/file ... 9f5cd891a0
http://www.mindstorms.rwth-aachen.de/tr ... torControl
Is there a possibility, that we NXC programmers get such a function? I'm not really happy with the current functions
_________________________________________________________________________________________________________________________________
http://roboticsaumair.jimdo.com
Re: [NXC]Motor-control-functions
There have been a number of discussions on this topic here in the past. Here's one thread where I posted an NXC function that could be used as an alternative to the stock RotateMotor function:
http://sourceforge.net/apps/phpbb/mindb ... =10#p12513
Of course, NXC users are strongly encouraged to create functions that do exactly what they need and then share them with others.
John Hansen
http://sourceforge.net/apps/phpbb/mindb ... =10#p12513
Of course, NXC users are strongly encouraged to create functions that do exactly what they need and then share them with others.
John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
http://bricxcc.sourceforge.net/
Re: [NXC]Motor-control-functions
I've seen this already. This is the result:Here's one thread where I posted an NXC function that could be used as an alternative to the stock RotateMotor function:
https://www.dropbox.com/s/f8hn8jwymiywx ... ontrol.jpg
I can not see any improvement...
So there will never be new motor functions.Of course, NXC users are strongly encouraged to create functions that do exactly what they need and then share them with others.
_________________________________________________________________________________________________________________________________
http://roboticsaumair.jimdo.com
Re: [NXC]Motor-control-functions
I am really curious why every adjustment of any P, I, D -Values in RotateMotorPID doesn't have any effect on overshooting: this is always 40-50° in every single case...
Re: [NXC]Motor-control-functions
I have no idea where you got that graph from. Perhaps you could post the full source code which you used to produce it? What does the graph look like using the stock RotateMotor API function? What do the graphs look like when you use RotateMotorExPID and pass in various different values for the parameters?matzzn wrote: I've seen this already. This is the result:
https://www.dropbox.com/s/f8hn8jwymiywx ... ontrol.jpg
I can not see any improvement...
The code I pointed you toward is easily modifiable and you absolutely will get different curves depending on how you modify the code. Modify it until it does what you want.
There will be new motor functions when someone helps me write better ones. Are you willing to help?So there will never be new motor functions.
John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
http://bricxcc.sourceforge.net/
Re: [NXC]Motor-control-functions
I took your code, changed the rotation to 90° and monitored the rotation-count in Labview.I have no idea where you got that graph from. Perhaps you could post the full source code which you used to produce it?
I don't know if there's a difference to RotateMotorPID but here are some graphs with different values:RotateMotorExPID
P,I,D
20,40,80
20,40,100
20,40,120
http://mindstormsforum.de/download/file ... c6cad61984
http://mindstormsforum.de/download/file ... c6cad61984
http://mindstormsforum.de/download/file ... c6cad61984
20,60,80
20,60,100
20,60,120
http://mindstormsforum.de/download/file ... c6cad61984
http://mindstormsforum.de/download/file ... c6cad61984
http://mindstormsforum.de/download/file ... c6cad61984
40,40,80
40,40,100
40,40,120
http://mindstormsforum.de/download/file ... c6cad61984
http://mindstormsforum.de/download/file ... c6cad61984
http://mindstormsforum.de/download/file ... c6cad61984
40,60,80
40,60,100
40,60,120
http://mindstormsforum.de/download/file ... c6cad61984
http://mindstormsforum.de/download/file ... c6cad61984
http://mindstormsforum.de/download/file ... c6cad61984
What values should i change? (with reference to the graph)Modify it until it does what you want.
I don't know much about low-level programming but here is a good motor control code:There will be new motor functions when someone helps me write better ones. Are you willing to help?
http://www.mindstorms.rwth-aachen.de/tr ... torControl
download:
// + MotorControl.nxc
// |-+ Controller.nxc
// |-- MotorFunctions.nxc
// |-- SpeedFromPosLookup.nxc
// |-- ControllerCore.nxc
Re: [NXC]Motor-control-functions
The links you posted all result in this message:
http://bricxcc.sourceforge.net/nbc/nxcd ... tants.html
Any other values are truncated down to the next lower value that is a multiple of 32.
I am not a PID control expert so I do not know what values will work best. The function I posted is high level code which is pretty straight-forward. The modifications I think you could make are not so much to PID values but to such things as what percent of the required rotation is ramp up, what percent is full power, what percent is ramp down, how long is the motor braked when the destination is reached, etc... I would recommend trying rotations much much greater than 90 degrees since rotating a quarter turn at any speed faster than really slow doesn't give any control routine - either firmware or user-level code - to respond to rotation changes in time to avoid overshoot, etc...
What speed are you using when you tell the motor to turn 90 degrees? Have you tried a wide variety of speeds?
Have you tried the absolute position regulation API functions at all? They start with PosReg*.
I don't think there is any way I can use the code you link to for a general motor control routine.
John Hansen
PID values can only be multiples of 32. Use the PID_0 through PID_7 constants which are 0, 32, 64, 96, 128, 160, 192, and 224Du bist nicht berechtigt, diese Seite anzusehen, von ihr herunterzuladen oder auf sie zu linken.
http://bricxcc.sourceforge.net/nbc/nxcd ... tants.html
Any other values are truncated down to the next lower value that is a multiple of 32.
I am not a PID control expert so I do not know what values will work best. The function I posted is high level code which is pretty straight-forward. The modifications I think you could make are not so much to PID values but to such things as what percent of the required rotation is ramp up, what percent is full power, what percent is ramp down, how long is the motor braked when the destination is reached, etc... I would recommend trying rotations much much greater than 90 degrees since rotating a quarter turn at any speed faster than really slow doesn't give any control routine - either firmware or user-level code - to respond to rotation changes in time to avoid overshoot, etc...
What speed are you using when you tell the motor to turn 90 degrees? Have you tried a wide variety of speeds?
Have you tried the absolute position regulation API functions at all? They start with PosReg*.
I don't think there is any way I can use the code you link to for a general motor control routine.
John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
http://bricxcc.sourceforge.net/
Re: [NXC]Motor-control-functions
why that??Any other values are truncated down to the next lower value that is a multiple of 32.
is that a mathematical calculation problem?
Re: [NXC]Motor-control-functions
The pictures shows that different pid values result in a overshoot of the target position.The links you posted all result in this message:
With such rough values ​​I need not even begin to find a good PID controller.PID values can only be multiples of 32. Use the PID_0 through PID_7 constants which are 0, 32, 64, 96, 128, 160, 192, and 224
With a good motor controller you should get good results at any speed and angle. I know it's possible that the firmware reacts fast enough.I would recommend trying rotations much much greater than 90 degrees since rotating a quarter turn at any speed faster than really slow doesn't give any control routine - either firmware or user-level code - to respond to rotation changes in time to avoid overshoot, etc...
What speed are you using when you tell the motor to turn 90 degrees? Have you tried a wide variety of speeds?
An intelligent regulation can decide when the rotation speed must be reduced to avoid overshooting.
Yes, everything remains the same as with the normal motor functions.Have you tried the absolute position regulation API functions at all? They start with PosReg*.
I can already see this do not lead to a result. I should probably make my own motor functions.
Re: [NXC]Motor-control-functions
It seems very unlikely to me that the PosReg* absolute position regulation API functions produce "the same" results as the RotateMotor* API functions for "everything". They work completely differently from how the RotateMotor functions work so it seems impossible to me that they perform identically, which seems to be what you are suggesting.
If you have not tried all the PID constants values to see what impact they have on the firmware's internal motor control routine then you do not know that they cannot produce good results.
If you have not tried adjusting the ramp up and ramp down portions of the total motor movement in the routine I posted then you can't possibly say that you've tried everything to get that routine to work in a way that suits your needs.
John Hansen
If you have not tried all the PID constants values to see what impact they have on the firmware's internal motor control routine then you do not know that they cannot produce good results.
If you have not tried adjusting the ramp up and ramp down portions of the total motor movement in the routine I posted then you can't possibly say that you've tried everything to get that routine to work in a way that suits your needs.
John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
http://bricxcc.sourceforge.net/
Who is online
Users browsing this forum: No registered users and 8 guests