Page 2 of 2

Re: Looking for an advanced motor control tutorial

Posted: 19 Mar 2011, 22:11
by HaWe
Well, aint there already such a precast function? I thought I once had read about that anywhere around here...?

Re: Looking for an advanced motor control tutorial

Posted: 19 Mar 2011, 22:21
by mattallen37
I don't remember hearing about it, and I don't see anything like that in the templates list.

Re: Looking for an advanced motor control tutorial

Posted: 19 Mar 2011, 22:26
by HaWe

Re: Looking for an advanced motor control tutorial

Posted: 21 Mar 2011, 18:53
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

Re: Looking for an advanced motor control tutorial

Posted: 21 Mar 2011, 20:15
by rghansen
schodet wrote:
There is a tutorial here: Absolute position regulation
Just what I was looking for. Thanks.

Re: Looking for an advanced motor control tutorial

Posted: 21 Mar 2011, 20:19
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)?

Re: Looking for an advanced motor control tutorial

Posted: 21 Mar 2011, 20:35
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 :)

Re: Looking for an advanced motor control tutorial

Posted: 21 Mar 2011, 21:10
by HaWe
yes, sure, ok!
:)

Re: Looking for an advanced motor control tutorial

Posted: 22 Mar 2011, 02:14
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).

Re: Looking for an advanced motor control tutorial

Posted: 22 Mar 2011, 10:25
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