Page 1 of 2
Looking for an advanced motor control tutorial
Posted: 19 Mar 2011, 08:25
by rghansen
I recently found references to a whole group of new[?] motor control functions
http://bricxcc.sourceforge.net/nbc/nxcd ... index.html including SetMotorRegulationTime. However, I haven't been able to find any detailed information about these routines. Could someone with extensive experience with these routines write a brief "Advanced NXT motor control for dummies" tutorial?
Can I use these routines with my current antiquated 1.28 firmware or do I need a the newest version of the John's EF?
A lot of experimenting with the normal motor control routines (OnFwdRegEx and all of his friends) convinced me that they were inadequate for fast, precise motor control. I'm hoping that these new[?] routines could help me to achieve this (see
http://www.youtube.com/watch?v=ezUei3z6MJM) with a lot less work.
Re: Looking for an advanced motor control tutorial
Posted: 19 Mar 2011, 10:06
by mattallen37
Yes they are new. I only know about some of the functions from first hand experience. I don't really understand the concepts used in motor control all that much; however, I found some of those commands to be extremely useful/easy to use. I am speaking specifically of the new absolute position regulation functions. I use these two lines to set it up.
Code: Select all
PosRegEnable (OUT_A);//Starts the precess I guess.
PosRegSetMax (OUT_A, 0, 0);//You can set the max speed and acceleration that the FW will use to get to the specified position. 0 is max, and the only number I use.
I use this line in the control, to tell the FW where I want to motor to be (degrees).
Those are all you need to have the FW automatically make the motor go to the position you specify. It doesn't matter what position you were at previously, it just goes to the new one.
No, you do need the latest FW to use the functions.
Re: Looking for an advanced motor control tutorial
Posted: 19 Mar 2011, 11:45
by rghansen
By latest firmware, do you mean John's FW?
Do you notice a significant speed increase when you set PosRegSetMax (OUT_A, 0, 0)?
Do you notice an accuracy improvement with SetMotorRegulationTime( 10 )?
In any case, thanks for the info. (Add thanks again for the BrickLink hint.)
Re: Looking for an advanced motor control tutorial
Posted: 19 Mar 2011, 11:48
by mattallen37
Sorry for not being clear. Yes, you need John's latest 1.31.
Re: Looking for an advanced motor control tutorial
Posted: 19 Mar 2011, 11:51
by rghansen
Then maybe it's time for me to install 1.31.
Please tell me that doing this is a no brainer that even I can do and that all my fears about being left with a "softly ticking brick" are entirely unfounded.
Re: Looking for an advanced motor control tutorial
Posted: 19 Mar 2011, 11:54
by HaWe
is there meanwhile a stable RampUp/Dn without switching off when target speed reached?
Re: Looking for an advanced motor control tutorial
Posted: 19 Mar 2011, 12:28
by mattallen37
doc-helmut wrote:is there meanwhile a stable RampUp/Dn without switching off when target speed reached?
I am not really sure what you are asking...
Re: Looking for an advanced motor control tutorial
Posted: 19 Mar 2011, 12:35
by mattallen37
I would say it is high time to update.
It is very easy to do. I have re-flashed my bricks many times (I have 5 NXT's, and I have re-flashed some of them about 10 times), I don't give it a second thought anymore. I always use the BCC Firmware Download tool. I used to always have to do it twice, the first time it would start clicking, and the second time it would actually download. John fixed that issue with the latest release however (I think he added a pause), so now it takes a little longer, but it only takes one try (at least the four times I have used it so far). There are obviously no guarantees, but I think it is worth whatever risk there may be.
Re: Looking for an advanced motor control tutorial
Posted: 19 Mar 2011, 13:21
by HaWe
IIRC there once was a RampUp/Dn API function which didn't work correctly because the motors always are switched to "off" in the moment the speed limit has been reached.
Is there now a correct working RampUp/Dn API function which lets the motors ramp up or down to a speed target (I suppose you guessed that ) and lets them drive at the target speed if once reached the targetted speed limit?
Re: Looking for an advanced motor control tutorial
Posted: 19 Mar 2011, 21:58
by mattallen37
I am not really sure why you would need an API. Couldn't you program a really simple piece of code to do the same thing? Maybe I am misunderstanding, but you want it to essentially go to a target PWM %, but not instantly? For example, you set the speed to 100 (from 0), and you don't want the motor to instantly be going 100%, you want it to slowly speed up? I can think of several methods you could use to do something like that.