Absolute position reglation in firmware
Absolute position reglation in firmware
Hello,
I finally made progress to my new regulation method for the LEGO firmware.
This new algorithm controls one motor so that its position matches the position set by the user. At any time, even when the motor is moving, the set position can be changed, and the control algorithm will move the motor towards the new position.
Compared to original speed regulation, absolute position regulation offers the following advantages:
* position consign can be changed at any time,
* target position is held automatically,
* motor can slow down before the target position is reached,
* can be used remotely with precise movements,
* smooth transition between acceleration, full speed and deceleration,
* regulated synchronized mode.
I made a page documenting the change here, with a short tutorial, examples and the NXC API.
I made a binary (version 1.29i-813df11) so that you can test it. If you want to see what changed in firmware code, you can see change logs on gitweb or clone the git repository. The change is on a wip branch in my repository, but I will push it to the master branch in the following days if no grave regression or API problem is found.
Nicolas.
I finally made progress to my new regulation method for the LEGO firmware.
This new algorithm controls one motor so that its position matches the position set by the user. At any time, even when the motor is moving, the set position can be changed, and the control algorithm will move the motor towards the new position.
Compared to original speed regulation, absolute position regulation offers the following advantages:
* position consign can be changed at any time,
* target position is held automatically,
* motor can slow down before the target position is reached,
* can be used remotely with precise movements,
* smooth transition between acceleration, full speed and deceleration,
* regulated synchronized mode.
I made a page documenting the change here, with a short tutorial, examples and the NXC API.
I made a binary (version 1.29i-813df11) so that you can test it. If you want to see what changed in firmware code, you can see change logs on gitweb or clone the git repository. The change is on a wip branch in my repository, but I will push it to the master branch in the following days if no grave regression or API problem is found.
Nicolas.
LEGO things http://ni.fr.eu.org/lego/ - NXT Improved Firmware (GCC) http://nxt-firmware.ni.fr.eu.org/ - Other robots http://apbteam.org
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: Absolute position reglation in firmware
Cool, sounds like EXACTLY what I have been wanting. I really hope this gets implemented into NXC.
Edit: I just flashed one of my NXT's with the FW, and used the "posreg.h" file, and it works SUPER well. Thanks SO much. John, please add this to the official NXC stuff.
BTW, is the FW based off of the original FW? or is it based off of a FW enhanced by John? Never-mind, the answer is no.
Edit: I just flashed one of my NXT's with the FW, and used the "posreg.h" file, and it works SUPER well. Thanks SO much. John, please add this to the official NXC stuff.
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: Absolute position reglation in firmware
You posted the following:
"TODO: document how to wait for a movement to be finished."
How about a function that returns how far from the target the motor is? If it returns a zero, then it is at its target. I think it would be the same as comparing the "MotorTachoCount" to the last requested position.
"TODO: document how to wait for a movement to be finished."
How about a function that returns how far from the target the motor is? If it returns a zero, then it is at its target. I think it would be the same as comparing the "MotorTachoCount" to the last requested position.
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Re: Absolute position reglation in firmware
Looks interesting but does it follow the same controlled pattern when slowing down? I mean a movement analogous to the NXT-G ramp up-ramp down sequence?
Forgive my lack of comprehension but I am confused by your graph, since all examples seem to end up at the same speed, even when the speed is being limited.
Forgive my lack of comprehension but I am confused by your graph, since all examples seem to end up at the same speed, even when the speed is being limited.
A sophistical rhetorician, inebriated with the exuberance of his own verbosity, and gifted with an egotistical imagination that can at all times command an interminable and inconsistent series of arguments to malign an opponent and to glorify himself.
-
- Posts: 358
- Joined: 01 Oct 2010, 06:37
- Location: Denmark
- Contact:
Re: Absolute position reglation in firmware
The vertical axis the the current position of the motor and the horizontal axis is the time in seconds. So you will need to guess the speed by looking at how far it has moved in relation to the time.
My blog: http://spillerrec.dk/category/lego/
RICcreator, an alternative to nxtRICeditV2: http://riccreator.sourceforge.net/
RICcreator, an alternative to nxtRICeditV2: http://riccreator.sourceforge.net/
Re: Absolute position reglation in firmware
I see, thanks.
A sophistical rhetorician, inebriated with the exuberance of his own verbosity, and gifted with an egotistical imagination that can at all times command an interminable and inconsistent series of arguments to malign an opponent and to glorify himself.
Re: Absolute position reglation in firmware
Great idea! I appreciate this very much! (I actually posted this to the wishlist to NXC already more than 1 year ago!)schodet wrote:Hello,
I finally made progress to my new regulation method for the LEGO firmware.
This new algorithm controls one motor so that its position matches the position set by the user. At any time, even when the motor is moving, the set position can be changed, and the control algorithm will move the motor towards the new position.
Re: Absolute position reglation in firmware
Nice you liked itmattallen37 wrote:Cool, sounds like EXACTLY what I have been wanting. I really hope this gets implemented into NXC.
Edit: I just flashed one of my NXT's with the FW, and used the "posreg.h" file, and it works SUPER well. Thanks SO much. John, please add this to the official NXC stuff.
BTW, is the FW based off of the original FW? or is it based off of a FW enhanced by John?Never-mind, the answer is no.
This is based on the original FW, but I am slowly merging enhanced FW feature as needed.
This can be done, but it is not always sufficient. The motor can be off by one or two degree depending on how well your PID coefficients are tuned.mattallen37 wrote:"TODO: document how to wait for a movement to be finished."
How about a function that returns how far from the target the motor is? If it returns a zero, then it is at its target. I think it would be the same as comparing the "MotorTachoCount" to the last requested position.
LEGO things http://ni.fr.eu.org/lego/ - NXT Improved Firmware (GCC) http://nxt-firmware.ni.fr.eu.org/ - Other robots http://apbteam.org
Re: Absolute position reglation in firmware
h-g-t wrote:Looks interesting but does it follow the same controlled pattern when slowing down? I mean a movement analogous to the NXT-G ramp up-ramp down sequence?
Forgive my lack of comprehension but I am confused by your graph, since all examples seem to end up at the same speed, even when the speed is being limited.
Exactly, on the graph you can see the slowing down when the position approaches the target position.spillerrec wrote:The vertical axis the the current position of the motor and the horizontal axis is the time in seconds. So you will need to guess the speed by looking at how far it has moved in relation to the time.
LEGO things http://ni.fr.eu.org/lego/ - NXT Improved Firmware (GCC) http://nxt-firmware.ni.fr.eu.org/ - Other robots http://apbteam.org
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: Absolute position reglation in firmware
That is good, but wouldn't it be better for John to add your single function to his tried and proven FW, than for you to add his countless modifications to your single one? I need RS-485 support, as well as the math (bitwise operators, sin, and cosin), among other things.schodet wrote:Nice you liked it
This is based on the original FW, but I am slowly merging enhanced FW feature as needed.
Well, I understand, but if it must be EXACTLY on the position, what difference will there be in making another function? I would just use a range to find out if it is at the right place. Something like the following:schodet wrote:This can be done, but it is not always sufficient. The motor can be off by one or two degree depending on how well your PID coefficients are tuned.
Code: Select all
if( MotorTachoCount (OUT_A)>=(TargetPosition-Threshold) && MotorTachoCount (OUT_A)<=(TargetPosition+Threshold) )
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Who is online
Users browsing this forum: Semrush [Bot] and 1 guest