Looking for an advanced motor control tutorial

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
rghansen
Posts: 67
Joined: 12 Oct 2010, 17:44

Looking for an advanced motor control tutorial

Post 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.
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Looking for an advanced motor control tutorial

Post 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).

Code: Select all

PosRegSetAngle(OUT_A, 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.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
rghansen
Posts: 67
Joined: 12 Oct 2010, 17:44

Re: Looking for an advanced motor control tutorial

Post 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.)
Last edited by rghansen on 19 Mar 2011, 11:49, edited 1 time in total.
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Looking for an advanced motor control tutorial

Post by mattallen37 »

Sorry for not being clear. Yes, you need John's latest 1.31.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
rghansen
Posts: 67
Joined: 12 Oct 2010, 17:44

Re: Looking for an advanced motor control tutorial

Post 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.
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: Looking for an advanced motor control tutorial

Post by HaWe »

is there meanwhile a stable RampUp/Dn without switching off when target speed reached?
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Looking for an advanced motor control tutorial

Post 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...
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Looking for an advanced motor control tutorial

Post 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.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: Looking for an advanced motor control tutorial

Post 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?
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Looking for an advanced motor control tutorial

Post 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.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests