| 1 | |
|---|
| 2 | <!DOCTYPE html |
|---|
| 3 | PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
|---|
| 4 | <html> |
|---|
| 5 | <head> |
|---|
| 6 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
|---|
| 7 | |
|---|
| 8 | <!-- |
|---|
| 9 | This HTML is auto-generated from an M-file. |
|---|
| 10 | To make changes, update the M-file and republish this document. |
|---|
| 11 | --> |
|---|
| 12 | <title>NXTMotor</title> |
|---|
| 13 | <meta name="generator" content="MATLAB 7.8"> |
|---|
| 14 | <meta name="date" content="2009-07-17"> |
|---|
| 15 | <meta name="m-file" content="script_NXTMotor"> |
|---|
| 16 | <link type="text/css" rel="stylesheet" href="../../style.css"> |
|---|
| 17 | </head> |
|---|
| 18 | <body> |
|---|
| 19 | <p class="header">RWTH - Mindstorms NXT Toolbox</p> |
|---|
| 20 | <div class="content"> |
|---|
| 21 | <h1>NXTMotor</h1> |
|---|
| 22 | <!--introduction--> |
|---|
| 23 | <p>Constructs an NXTMotor object</p> |
|---|
| 24 | <!--/introduction--> |
|---|
| 25 | <h2>Contents</h2> |
|---|
| 26 | <div> |
|---|
| 27 | <ul> |
|---|
| 28 | <li><a href="#2">Syntax</a></li> |
|---|
| 29 | <li><a href="#5">Description</a></li> |
|---|
| 30 | <li><a href="#22">Limitations</a></li> |
|---|
| 31 | <li><a href="#26">Example:</a></li> |
|---|
| 32 | <li><a href="#28">See also</a></li> |
|---|
| 33 | <li><a href="#31">Signature</a></li> |
|---|
| 34 | </ul> |
|---|
| 35 | </div> |
|---|
| 36 | <h2>Syntax<a name="2"></a></h2> |
|---|
| 37 | <p><tt>M = NXTMotor(PORT)</tt></p> |
|---|
| 38 | <p><tt>M = NXTMotor(PORT, 'PropName1', PropValue1, 'PropName2', PropValue2, ...)</tt></p> |
|---|
| 39 | <h2>Description<a name="5"></a></h2> |
|---|
| 40 | <p><tt>M = NXTMotor(PORT)</tt> constructs an NXTMotor object with motor port <tt>PORT</tt> and default attributes. <tt>PORT</tt> may be either the port number (0, 1, 2 or MOTOR_A, MOTOR_B, MOTOR_C) or a string specifying the port ('A', 'B', 'C'). To |
|---|
| 41 | have two motors synchronized <tt>PORT</tt> may be a vector of two ports in ascending order. |
|---|
| 42 | </p> |
|---|
| 43 | <p><tt>M = NXTMotor(PORT, 'PropName1', PropValue1, 'PropName2', PropValue2, ...)</tt> constructs an NXTMotor object with motor port(s) <tt>PORT</tt> in which the given Property name/value pairs are set on the object. All properties can also be set after creation by dot-notation |
|---|
| 44 | (see example). |
|---|
| 45 | </p> |
|---|
| 46 | <p>Available properties are:</p> |
|---|
| 47 | <div> |
|---|
| 48 | <ul> |
|---|
| 49 | <li><tt>Port</tt> - the motor port(s) being used, either a string composed of the letters <tt>'A'</tt>, <tt>'B'</tt>, <tt>'C'</tt>, or a single value or array of the numbers 0, 1, 2. A maximum of 2 motors is allowed. If 2 motors are specified, the bot |
|---|
| 50 | will drive in sync mode, good for driving straight ahead |
|---|
| 51 | </li> |
|---|
| 52 | </ul> |
|---|
| 53 | </div> |
|---|
| 54 | <div> |
|---|
| 55 | <ul> |
|---|
| 56 | <li><tt>Power</tt> - integer from -100 to 100, sets power level and direction of rotation (0 to 100%) |
|---|
| 57 | </li> |
|---|
| 58 | </ul> |
|---|
| 59 | </div> |
|---|
| 60 | <div> |
|---|
| 61 | <ul> |
|---|
| 62 | <li><tt>SpeedRegulation</tt> - if set to <tt>true</tt> (default), the motor will try to hold a constant speed by adjusting power output according to load (e.g. friction) - this |
|---|
| 63 | is only valid for single motors |
|---|
| 64 | </li> |
|---|
| 65 | </ul> |
|---|
| 66 | </div> |
|---|
| 67 | <div> |
|---|
| 68 | <ul> |
|---|
| 69 | <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 |
|---|
| 70 | </li> |
|---|
| 71 | </ul> |
|---|
| 72 | </div> |
|---|
| 73 | <div> |
|---|
| 74 | <ul> |
|---|
| 75 | <li><tt>ActionAtTachoLimit</tt> - if set to 'Brake' (default), the motor will brake once the <tt>TachoLimit</tt> (which must not be 0) is reached, forcing a hard stop at precisely the desired position (+/- some degrees). Otherwise set |
|---|
| 76 | to 'Coast'. |
|---|
| 77 | </li> |
|---|
| 78 | </ul> |
|---|
| 79 | </div> |
|---|
| 80 | <p>For a list of valid methods, see the "See also" section below.</p> |
|---|
| 81 | <h2>Limitations<a name="22"></a></h2> |
|---|
| 82 | <p>When driving with 2 motors (i.e. in sync-mode), a <tt>TachoLimit = 0</tt> (which means driving forever) and with <tt>ActionAtTachoLimit = 'Brake'</tt>, stopping the bot (either via the motor object's function <tt>Stop</tt> or via the command <tt>StopMotor</tt>) will always result in a "hard stop" (as if you had called <tt>Stop('brake')</tt>), even if the parameter of the stop-command was 'off' (indicating a soft stop into coast mode). There is no workaround to |
|---|
| 83 | this (apart from using the command with <tt>ActionAtTachoLimit = 'Coast'</tt>, in this case the stop-parameters "brake" or "off" will be interpreted as expected). |
|---|
| 84 | </p> |
|---|
| 85 | <h2>Example:<a name="26"></a></h2><pre class="codeinput"> <span class="comment">% Construct a NXTMotor object on port 'B' with a power of</span> |
|---|
| 86 | <span class="comment">% 60, disabled speed regulation, a TachoLimit of 360 and</span> |
|---|
| 87 | <span class="comment">% send the motor settings to the NXT brick.</span> |
|---|
| 88 | mb = NXTMotor(<span class="string">'B'</span>, <span class="string">'Power'</span>, 60) |
|---|
| 89 | mb.SpeedRegulation = 1; |
|---|
| 90 | mb.TachoLimit = 360; |
|---|
| 91 | SendToNXT(mb); |
|---|
| 92 | </pre><h2>See also<a name="28"></a></h2> |
|---|
| 93 | <p><a href="SendToNXT.html">SendToNXT</a>, <a href="ReadFromNXT.html">ReadFromNXT</a>, <a href="WaitFor.html">WaitFor</a>, <a href="Stop.html">Stop</a>, <a href="ResetPosition.html">ResetPosition</a>, </p> |
|---|
| 94 | <h2>Signature<a name="31"></a></h2> |
|---|
| 95 | <div> |
|---|
| 96 | <ul> |
|---|
| 97 | <li><b>Author:</b> Aulis Telle, Alexander Behrens, Linus Atorf (see AUTHORS) |
|---|
| 98 | </li> |
|---|
| 99 | <li><b>Date:</b> 2008/10/22 |
|---|
| 100 | </li> |
|---|
| 101 | <li><b>Copyright:</b> 2007-2008, RWTH Aachen University |
|---|
| 102 | </li> |
|---|
| 103 | </ul> |
|---|
| 104 | </div> |
|---|
| 105 | <p class="footer"><br> |
|---|
| 106 | Published with wg_publish; V1.0<br></p> |
|---|
| 107 | </div> |
|---|
| 108 | <!-- |
|---|
| 109 | ##### SOURCE BEGIN ##### |
|---|
| 110 | %% NXTMotor |
|---|
| 111 | % Constructs an NXTMotor object |
|---|
| 112 | %% |
|---|
| 113 | %% Syntax |
|---|
| 114 | % |M = NXTMotor(PORT)| |
|---|
| 115 | %% |
|---|
| 116 | % |M = NXTMotor(PORT, 'PropName1', PropValue1, 'PropName2', PropValue2, ...)| |
|---|
| 117 | %% |
|---|
| 118 | %% Description |
|---|
| 119 | % |M = NXTMotor(PORT)| constructs an NXTMotor object with motor |
|---|
| 120 | % port |PORT| and default attributes. |PORT| may be either the port |
|---|
| 121 | % number (0, 1, 2 or MOTOR_A, MOTOR_B, MOTOR_C) or a string |
|---|
| 122 | % specifying the port ('A', 'B', 'C'). To have two motors |
|---|
| 123 | % synchronized |PORT| may be a vector of two ports in ascending |
|---|
| 124 | % order. |
|---|
| 125 | %% |
|---|
| 126 | % |M = NXTMotor(PORT, 'PropName1', PropValue1, 'PropName2', PropValue2, ...)| |
|---|
| 127 | % constructs an NXTMotor object with motor port(s) |PORT| in which the given |
|---|
| 128 | % Property name/value pairs are set on the object. All properties can also be set after |
|---|
| 129 | % creation by dot-notation (see example). |
|---|
| 130 | %% |
|---|
| 131 | % Available properties are: |
|---|
| 132 | %% |
|---|
| 133 | %% |
|---|
| 134 | % * |Port| - the motor port(s) being used, either a string composed of the |
|---|
| 135 | % letters |'A'|, |'B'|, |'C'|, or a single value or array of the |
|---|
| 136 | % numbers 0, 1, 2. A maximum of 2 motors is allowed. If 2 motors |
|---|
| 137 | % are specified, the bot will drive in sync mode, good for driving |
|---|
| 138 | % straight ahead |
|---|
| 139 | %% |
|---|
| 140 | %% |
|---|
| 141 | % * |Power| - integer from -100 to 100, sets power level and direction of rotation (0 to 100%) |
|---|
| 142 | %% |
|---|
| 143 | %% |
|---|
| 144 | % * |SpeedRegulation| - if set to |true| (default), the motor will try to hold a |
|---|
| 145 | % constant speed by adjusting power output according to load (e.g. |
|---|
| 146 | % friction) - this is only valid for single motors |
|---|
| 147 | %% |
|---|
| 148 | %% |
|---|
| 149 | % * |TachoLimit| - integer from 0 to 99999, specifies the angle in degrees |
|---|
| 150 | % the motor will try to reach, set 0 to run forever |
|---|
| 151 | %% |
|---|
| 152 | %% |
|---|
| 153 | % * |ActionAtTachoLimit| - if set to 'Brake' (default), the motor will brake |
|---|
| 154 | % once the |TachoLimit| (which must not be 0) is reached, forcing a hard |
|---|
| 155 | % stop at precisely the desired position (+/- some degrees). |
|---|
| 156 | % Otherwise set to 'Coast'. |
|---|
| 157 | %% |
|---|
| 158 | %% |
|---|
| 159 | %% |
|---|
| 160 | % For a list of valid methods, see the "See also" section below. |
|---|
| 161 | %% |
|---|
| 162 | %% Limitations |
|---|
| 163 | % When driving with 2 motors (i.e. in sync-mode), a |TachoLimit = 0| |
|---|
| 164 | % (which means driving forever) and with |ActionAtTachoLimit = 'Brake'|, |
|---|
| 165 | % stopping the bot (either via the motor object's function |Stop| or via |
|---|
| 166 | % the command |StopMotor|) will always result in a "hard stop" (as if you had |
|---|
| 167 | % called |Stop('brake')|), even if the parameter of the stop-command was |
|---|
| 168 | % 'off' (indicating a soft stop into coast mode). There is no workaround |
|---|
| 169 | % to this (apart from using the command with |ActionAtTachoLimit = 'Coast'|, |
|---|
| 170 | % in this case the stop-parameters "brake" or "off" will be interpreted |
|---|
| 171 | % as expected). |
|---|
| 172 | %% |
|---|
| 173 | %% |
|---|
| 174 | %% |
|---|
| 175 | %% Example: |
|---|
| 176 | % Construct a NXTMotor object on port 'B' with a power of |
|---|
| 177 | % 60, disabled speed regulation, a TachoLimit of 360 and |
|---|
| 178 | % send the motor settings to the NXT brick. |
|---|
| 179 | mb = NXTMotor('B', 'Power', 60) |
|---|
| 180 | mb.SpeedRegulation = 1; |
|---|
| 181 | mb.TachoLimit = 360; |
|---|
| 182 | SendToNXT(mb); |
|---|
| 183 | %% |
|---|
| 184 | %% See also |
|---|
| 185 | % SendToNXT, ReadFromNXT, WaitFor, Stop, ResetPosition |
|---|
| 186 | %% |
|---|
| 187 | %% |
|---|
| 188 | %% Signature |
|---|
| 189 | %% |
|---|
| 190 | % * *Author:* Aulis Telle, Alexander Behrens, Linus Atorf (see AUTHORS) |
|---|
| 191 | % * *Date:* 2008/10/22 |
|---|
| 192 | % * *Copyright:* 2007-2008, RWTH Aachen University |
|---|
| 193 | % |
|---|
| 194 | |
|---|
| 195 | ##### SOURCE END ##### |
|---|
| 196 | --> |
|---|
| 197 | </body> |
|---|
| 198 | </html> |
|---|