NXC Motor Control
-
- Posts: 323
- Joined: 29 Sep 2010, 05:03
NXC Motor Control
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
Thanks
Andy
Re: NXC Motor Control
I'm actually curious, I never heard (or read) of sth like that in NXC...
Re: NXC Motor Control
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.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?
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).
RWTH - Mindstorms NXT Toolbox for MATLAB
state of the art in nxt remote control programming
http://www.mindstorms.rwth-aachen.de
MotorControl now also in Python, .net, and Mathematica
state of the art in nxt remote control programming
http://www.mindstorms.rwth-aachen.de
MotorControl now also in Python, .net, and Mathematica
Re: NXC Motor Control
Linus,
I can't get any info about NXC RAMPUP / RAMPDOWN commands. Can you post a reference please?
I can't get any info about NXC RAMPUP / RAMPDOWN commands. Can you post a reference please?
Re: NXC Motor Control
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
John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
http://bricxcc.sourceforge.net/
Re: NXC Motor Control
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)
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
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
John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
http://bricxcc.sourceforge.net/
Re: NXC Motor Control
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.
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
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
RWTH - Mindstorms NXT Toolbox for MATLAB
state of the art in nxt remote control programming
http://www.mindstorms.rwth-aachen.de
MotorControl now also in Python, .net, and Mathematica
state of the art in nxt remote control programming
http://www.mindstorms.rwth-aachen.de
MotorControl now also in Python, .net, and Mathematica
Re: NXC Motor Control
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.
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.
Who is online
Users browsing this forum: Semrush [Bot] and 1 guest