Page 1 of 2
NXC Motor Control
Posted: 04 Dec 2010, 17:48
by gloomyandy
Folks, I'm trying to to a comparison of an experimental motor control algorithm for leJOS with the existing leJOS one and the standard Lego firmware one. However I'm struggling a little with how to control the rate at which the motors accelerate from one speed to another (i.e. from rest to the target speed) when using the Lego firmware. Is there some way to set this value in NXC? So say for instance I wanted to set the ramp up rate to be 100 degrees/s/s how would I do this?
Thanks
Andy
Re: NXC Motor Control
Posted: 04 Dec 2010, 18:32
by HaWe
I'm actually curious, I never heard (or read) of sth like that in NXC...
Re: NXC Motor Control
Posted: 05 Dec 2010, 14:58
by linusa
gloomyandy wrote:However I'm struggling a little with how to control the rate at which the motors accelerate from one speed to another (i.e. from rest to the target speed) when using the Lego firmware. Is there some way to set this value in NXC? So say for instance I wanted to set the ramp up rate to be 100 degrees/s/s how would I do this?
You can't control the time during which this happens, unfortunately. You can set distance of acceleration / deceleration, i.e. the TachoLimit. But I'm afraid there is no easy and obvious connection to the time spend.
Overall I wasn't very satisfied with the RAMPUP and RAMPUP down modes. The problem: You have to specify a TachoLimit, and when the motors reach this TachoLimit, the firmware turns off power to the motors and sets runstate IDLE, which means they end up in coast mode.
So if you want to accelerate to a certain power (not speed, LEGO firmware doesn't use "degrees / s" as unit as you probably know), you have to send a RAMPUP with a certain TachoLimit to the motors, and then you have to set a normal RUNNING with the desired power at the exact moment the motor switches to IDLE. This can lead to a noticable "dead spot", a very short point in time where the motor is not running (actively powered).
Overall, this was really not a nice option. Especially it seemed to get more complicated when you enable the speed regulation feature. I wouldn't recommend to use RAMPUP / RAMPDOWN at all, only in very special exceptions.
So, after all, I used the SetOutput command in NXC to update the Power register for our
MotorControl program (e.g. for the SmoothAcceleration feature). This works, as long as you don't use speed regulation (if I remember correctly).
Re: NXC Motor Control
Posted: 05 Dec 2010, 15:12
by HaWe
Linus,
I can't get any info about NXC RAMPUP / RAMPDOWN commands. Can you post a reference please?
Re: NXC Motor Control
Posted: 05 Dec 2010, 21:17
by afanofosc
rampup and rampdown are runstates. If you search the online help or the compiled help files included with BricxCC you will find OUT_RUNSTATE_RAMPUP, OUT_RUNSTATE_RAMPDOWN, and the RunState output iomap field documentation which describe the way these states work. As Linus said, you have to monitor the runstate so that you switch to running again when the firmware switches it to idle.
John Hansen
Re: NXC Motor Control
Posted: 05 Dec 2010, 21:23
by HaWe
thanks,
what I actually did was typing
RAMPUP
RAMPDOWN
into the editor, positioning the cursor upon each keyword, and pressing F1
- nothing happend except the error msg "Dieses Programm kann die Webseite nicht anzeigen." (This program can not display the webpage)
Re: NXC Motor Control
Posted: 06 Dec 2010, 19:02
by afanofosc
Try Ctrl+Space to bring up the code completion window and then type in something you think might exist. The list will be filtered and you will be able to tell whether it exists or not. Better yet, just read the Output module section of the NXC Guide in its entirety.
John Hansen
Re: NXC Motor Control
Posted: 06 Dec 2010, 19:26
by HaWe
well, now I meanwhile know that it's written in the iomaps.
Before this I assumed is could be sort of motor control function or procedure (like OnFwd or RotateMotorEx).
But as long as I didn't know, neither
rampup [F1]
nor [ctrl+SPACE] and then typing "rampup" leads to the goal - the latter shows nothing too.
There had to be sort of word-fragment search I guess.
Re: NXC Motor Control
Posted: 07 Dec 2010, 03:28
by linusa
afanofosc wrote:Better yet, just read the Output module section of the NXC Guide in its entirety.
Exactly what I've been recommending for years
. Along with the document "Executable File Specification" of the LEGO Mindstorms NXT SDK. They have a section about motor commands and parameters that helps as well.
http://mindstorms.lego.com/en-us/suppor ... x#Advanced
Re: NXC Motor Control
Posted: 07 Dec 2010, 11:29
by HaWe
is this post addressed to me?
I never needed rampup or -down, so I never had to find anything about it yet - I only never heard of a rampup or -down function before and the reason is clear now.
And as it's a faulty runstate I think I also won't need it in future.
But the Java thing what Gloomyandy wrote about would be fine to have in NXC, too.