Looking for an advanced motor control tutorial

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: Looking for an advanced motor control tutorial

Post by HaWe »

Well, aint there already such a precast function? I thought I once had read about that anywhere around here...?
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 don't remember hearing about it, and I don't see anything like that in the templates list.
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 »

schodet
Posts: 139
Joined: 29 Sep 2010, 11:21
Contact:

Re: Looking for an advanced motor control tutorial

Post by schodet »

Sorry for the delay, I only visit Mindboards from time to time...

Yes, if you enable the absolute position contro, this includes automatic Ramp Up/Down. All you need is to choose a maximum speed and acceleration using PosRegSetMax.

There is a tutorial here: Absolute position regulation
LEGO things http://ni.fr.eu.org/lego/ - NXT Improved Firmware (GCC) http://nxt-firmware.ni.fr.eu.org/ - Other robots http://apbteam.org
rghansen
Posts: 67
Joined: 12 Oct 2010, 17:44

Re: Looking for an advanced motor control tutorial

Post by rghansen »

schodet wrote:
There is a tutorial here: Absolute position regulation
Just what I was looking for. Thanks.
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: Looking for an advanced motor control tutorial

Post by HaWe »

fine, thank you!
Now is there also a ramp up/dn for driving without encoder limit (ramp up or down to speed limit and then drive ahead forever until stopped by extra command)?
schodet
Posts: 139
Joined: 29 Sep 2010, 11:21
Contact:

Re: Looking for an advanced motor control tutorial

Post by schodet »

doc-helmut wrote:fine, thank you!
Now is there also a ramp up/dn for driving without encoder limit (ramp up or down to speed limit and then drive ahead forever until stopped by extra command)?
Hum... yes, use a really large angle :)
LEGO things http://ni.fr.eu.org/lego/ - NXT Improved Firmware (GCC) http://nxt-firmware.ni.fr.eu.org/ - Other robots http://apbteam.org
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: Looking for an advanced motor control tutorial

Post by HaWe »

yes, sure, ok!
:)
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Looking for an advanced motor control tutorial

Post by mattallen37 »

Helmut, is this what you want?

Code: Select all

task MotorRamp(){
  while(true){
    if(CS<Speed){
      CS++;
      OnFwd(OUT_A, CS);
    }
    if(CS>Speed){
      CS--;
      OnFwd(OUT_A, CS);
    }
    Wait(RampWait);//Slow it down for the effect.
  }
}
You can update the "Speed" as often as you want. To make the motor go in reverse, just multiply the Speed by -1. The "RampWait" is to adjust the ramping slope.

Edit: The Wait also allows another task to run (it yields to another task).
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 »

hi,
thanks matt, looks fine too! :D
speed is probably power percentage (pwr),
and I propose that it should be taken abs(CS), abs(pwr) to fit for negative rotations, too (edit: not sure about that).
I'll have to look for a way to stop this task intermediately by another task but If I remember correctly I should have already a solution in my BT Motor Control task.

Now nearly all application uses are fine:
ramp up/dn without limits (matt)
ramp up/dn with absolute encoder targets (schodet)

now only 1 is left:
ramp up/dn when using RotateMotor/Ex/PID for relative encoder targets
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 1 guest