root/tags/version-4.02/RWTHMindstormsNXT/doc/functions/help/NXC_MotorControl.html @ 823

Revision 823, 11.4 KB (checked in by atorf, 4 years ago)

/!\ Create tag for version-4.02

Line 
1
2<!DOCTYPE html
3  PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4<html><head>
5      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6   <!--
7This HTML is auto-generated from an M-file.
8To make changes, update the M-file and republish this document.
9      --><title>NXC_MotorControl</title><meta name="generator" content="MATLAB 7.9"><meta name="date" content="2009-10-07"><meta name="m-file" content="script_NXC_MotorControl">
10<link type="text/css" rel="stylesheet" href="../../style.css">
11  </head><body><div class="content"><h1>NXC_MotorControl</h1><!--introduction--><p>Sends advanced motor-command to the NXC-program MotorControl on the NXT brick</p><!--/introduction--><h2>Contents</h2><div><ul><li><a href="#2">Syntax</a></li><li><a href="#5">Description</a></li><li><a href="#26">Limitations</a></li><li><a href="#32">Example</a></li><li><a href="#35">See also</a></li><li><a href="#37">Signature</a></li></ul></div><h2>Syntax<a name="2"></a></h2><p><tt>NXC_MotorControl(Port, Power, TachoLimit, SpeedRegulation, ActionAtTachoLimit, SmoothStart)</tt></p><p><tt>NXC_MotorControl(Port, Power, TachoLimit, SpeedRegulation, ActionAtTachoLimit, SmoothStart, handle)</tt></p><h2>Description<a name="5"></a></h2><p>The NXC-program "MotorControl" must be running on the brick, otherwise this function will not work. It is used to send advanced motor commands to the NXT that can perform better and more precise motor regulation than possible with only classic direct commands.</p><p>While one command is being executed (i.e. when the motor is still being controlled if a <tt>TachoLimit</tt> other than 0 was set), this motor cannot accept new commands. Use the NXTMotor classes command <tt>.WaitFor</tt> to make sure the motor has finished it's current operation, before sending a new one. If the NXC-program receives a new command while it is still busy, a warning signal (high beep, then low beep) will be played.</p><p>The command <tt>StopMotor</tt> (or NXTMotor's method <tt>.Stop</tt>) is always available to stop a controlled motor-operation, even before the <tt>TachoLimit</tt> is reached.</p><p><b>Input:</b></p><div><ul><li><tt>Port</tt> has to be a port number between 0 and 2, or an array with max. 2 different motors specified.</li></ul></div><div><ul><li><tt>Power</tt> is the power level applied to the motor, value between -100 and 100 (sign changes direction)</li></ul></div><div><ul><li><tt>TachoLimit</tt> - integer from 0 to 99999, specifies the angle in degrees the motor will try to reach, set 0 to run forever. Note that direction is specified by the sign of <tt>Power</tt>.</li></ul></div><div><ul><li><tt>SpeedRegulation</tt> must be <tt>false</tt> for "normal", unregulated motor control. If set to <tt>true</tt>, single motors will be operated in speed regulation mode. This means that the motor will increase its internal power setting to reach a constant turning speed. Use this option when working with motors under varying load. If you'd like to have motor movement with preferrably constant torque, it's advisable to disable this option. In conjunction with multiple motors (i.e. when <tt>Port</tt> is an array of 2 ports), you have to disable <tt>SpeedRegulation</tt>! Multiple motorss will enable synchronization between the two motors. They will run at the same speed as if they were connected through and axle, leading to straight movement for driving bots.</li></ul></div><div><ul><li><tt>ActionAtTachoLimit</tt> is a string parameter with valid options <tt>'Coast'</tt>, <tt>'Brake'</tt> or <tt>'HoldBrake'</tt>. It specifies how the motor(s) should react when their position counter reaches the set <tt>TachoLimit</tt>. In COAST mode, the motor(s) will simply be turned of when the <tt>TachoLimit</tt> is reached, leading to free movement until slowly stopping (called coasting). The <tt>TachoLimit</tt> won't be met, the motor(s) move way too far (overshooting), depending on their angular momentum. Use BRAKE mode (default) to let the motor(s) automatically slow down nice and smoothly shortly before the <tt>TachoLimit</tt>. This leads to a very high precision, usually the <tt>TachoLimit</tt> is met within +/- 1 degree (depending on the motor load and speed of course). After this braking, power to the motor(s) is turned off when they are at rest. HOLDBRAKE is similar to BRAKE, but in this case, the active brake of the motors stays enabled (careful, this consumes a lot of battery power), causing the motor(s) to actively keep holding their position.</li></ul></div><div><ul><li><tt>SmoothStart</tt> can be set to <tt>true</tt> to smoothly accelerate movement. This "manual ramp up" of power will occur fairly quickly. It's comfortable for driving robots so that they don't loose traction when starting to move. If used in conjunction with <tt>SpeedRegulation</tt> for single motors, after accleration is finished and the full power is applied, the speed regulation can possibly even accelerate a bit more.</li></ul></div><div><ul><li><tt>handle</tt> (optional) defines the given NXT connection. If no handle is specified, the default one (<tt>COM_GetDefaultNXT()</tt>) is used.</li></ul></div><h2>Limitations<a name="26"></a></h2><p>If you send a command to the NXT without waiting for the previous motor operation to have finished, the command will be dropped (the NXT indicates this with a high and low beep tone). Use NXTMotor classes <tt>WaitFor</tt> to make sure the motor is ready for new  commands, or stop the motor using NXTMotor's method <tt>.Stop</tt>.</p><p>The option <tt>SmoothStart</tt> in conjunction with <tt>ActionAtTachoLimit == 'Coast'</tt> is not available. As a workaround, disable <tt>SmoothStart</tt> for this mode.</p><p>With ActionAtTachoLimit = 'Coast' and synchronous driving (two motors), the motors will stay synced after movement (even after <tt>.WaitFor()</tt> has finished). This is by design. To disable the synchonization, just use <tt>StopMotor(port, 'off')</tt>.</p><h2>Example<a name="32"></a></h2><h2>See also<a name="35"></a></h2><p>WaitForMotor, NXT_SetOutputState, NXT_GetOutputState, NXC_ResetErrorCorrection, MOTOR_A, MOTOR_B, MOTOR_C</p><h2>Signature<a name="37"></a></h2><div><ul><li><b>Author:</b> Linus Atorf (see AUTHORS)</li><li><b>Date:</b> 2009/07/20</li><li><b>Copyright:</b> 2007-2009, RWTH Aachen University</li></ul></div><p class="footer"><br>
12</p></div><!--
13##### SOURCE BEGIN #####
14%% NXC_MotorControl
15% Sends advanced motor-command to the NXC-program MotorControl on the NXT brick
16%%
17%% Syntax
18% |NXC_MotorControl(Port, Power, TachoLimit, SpeedRegulation, ActionAtTachoLimit, SmoothStart)|
19%%
20% |NXC_MotorControl(Port, Power, TachoLimit, SpeedRegulation, ActionAtTachoLimit, SmoothStart, handle)|
21%%
22%% Description
23% The NXC-program "MotorControl" must be running on the brick, otherwise
24% this function will not work. It is used to send advanced motor commands
25% to the NXT that can perform better and more precise motor regulation
26% than possible with only classic direct commands.
27%%
28% While one command is being executed (i.e. when the motor is still being
29% controlled if a |TachoLimit| other than 0 was set), this motor cannot
30% accept new commands. Use the NXTMotor classes command |.WaitFor| to make
31% sure the motor has finished it's current operation, before
32% sending a new one. If the NXC-program receives a new command while it
33% is still busy, a warning signal (high beep, then low beep) will be
34% played.
35%%
36% The command |StopMotor| (or NXTMotor's method |.Stop|) is always available to
37% stop a controlled motor-operation, even before the |TachoLimit| is reached.
38%%
39%%
40%%
41% *Input:*
42%%
43% * |Port| has to be a port number between 0 and 2, or an array with max. 2
44% different motors specified.
45%%
46%%
47% * |Power| is the power level applied to the motor, value between -100 and
48% 100 (sign changes direction)
49%%
50%%
51% * |TachoLimit| - integer from 0 to 99999, specifies the angle in degrees
52% the motor will try to reach, set 0 to run forever. Note
53% that direction is specified by the sign of |Power|.
54%%
55%%
56% * |SpeedRegulation| must be |false| for "normal", unregulated motor
57% control. If set to |true|, single motors will be operated in speed
58% regulation mode. This means that the motor will increase its internal
59% power setting to reach a constant turning speed. Use this option when
60% working with motors under varying load. If you'd like to have motor movement
61% with preferrably constant torque, it's advisable to disable
62% this option.
63% In conjunction with multiple motors
64% (i.e. when |Port| is an array of 2 ports), you have to disable
65% |SpeedRegulation|! Multiple motorss will enable synchronization between the two
66% motors. They will run at the same speed as if they were connected
67% through and axle, leading to straight movement for driving bots.
68%%
69%%
70% * |ActionAtTachoLimit| is a string parameter with valid options
71% |'Coast'|, |'Brake'| or |'HoldBrake'|. It specifies how the motor(s) should react
72% when their position counter reaches the set |TachoLimit|. In COAST
73% mode, the motor(s) will simply be turned of when the |TachoLimit| is
74% reached, leading to free movement until slowly stopping (called
75% coasting). The |TachoLimit| won't be met, the motor(s) move way too far
76% (overshooting), depending on their angular momentum.
77% Use BRAKE mode (default) to let the motor(s) automatically
78% slow down nice and smoothly shortly before the |TachoLimit|. This leads
79% to a very high precision, usually the |TachoLimit| is met within +/- 1
80% degree (depending on the motor load and speed of course). After this
81% braking, power to the motor(s) is turned off when they are at rest.
82% HOLDBRAKE is similar to BRAKE, but in this case, the active brake of
83% the motors stays enabled (careful, this consumes a lot of battery
84% power), causing the motor(s) to actively keep holding their position.
85%%
86%%
87% * |SmoothStart| can be set to |true| to smoothly accelerate movement.
88% This "manual ramp up" of power will occur fairly quickly. It's
89% comfortable for driving robots so that they don't loose traction when
90% starting to move. If used in conjunction with |SpeedRegulation| for
91% single motors, after accleration is finished and the full power is
92% applied, the speed regulation can possibly even accelerate a bit more.
93%%
94%%
95% * |handle| (optional) defines the given NXT connection. If no handle is
96% specified, the default one (|COM_GetDefaultNXT()|) is used.
97%%
98%%
99%% Limitations
100%%
101% If you send a command to the NXT without waiting for the previous motor
102% operation to have finished, the command will be dropped (the NXT
103% indicates this with a high and low beep tone). Use NXTMotor classes |WaitFor|
104% to make sure the motor is ready for new  commands, or stop the motor
105% using NXTMotor's method |.Stop|.
106%%
107% The option |SmoothStart| in conjunction with |ActionAtTachoLimit ==
108% 'Coast'| is not available. As a workaround, disable |SmoothStart| for
109% this mode.
110%%
111% With ActionAtTachoLimit = 'Coast' and synchronous driving (two motors),
112% the motors will stay synced after movement (even after |.WaitFor()| has
113% finished). This is by design. To disable the synchonization, just use
114% |StopMotor(port, 'off')|.
115%%
116%%
117%% Example
118%%
119%%
120%% See also
121% WaitForMotor, NXT_SetOutputState, NXT_GetOutputState, NXC_ResetErrorCorrection, MOTOR_A, MOTOR_B, MOTOR_C
122%%
123%% Signature
124%%
125% * *Author:* Linus Atorf (see AUTHORS)
126% * *Date:* 2009/07/20
127% * *Copyright:* 2007-2009, RWTH Aachen University
128%
129
130##### SOURCE END #####
131--></body></html>
Note: See TracBrowser for help on using the browser.