1
1
Motion Base
2
- ===========
2
+ ============================
3
+
4
+ .. sku: A090
3
5
4
6
.. include :: ../refs/base.motion.ref
5
7
@@ -9,162 +11,266 @@ Atomic Motion Base v1.1 adds INA226 to implement current and voltage detection.
9
11
10
12
Support the following products:
11
13
12
- |Motion |
14
+ |Motion |
15
+
16
+ |Motion Base v1.1 |
17
+
18
+
19
+ UiFlow2 Example:
20
+ --------------------------
21
+
22
+ Motion Base
23
+ ^^^^^^^^^^^^^^^^^^^^^^^^
24
+
25
+ Open the |atoms3_lite_motion_base_example.m5f2 | project in UiFlow2.
26
+
27
+ This example controls the servo to rotate to a specified angle and sets the motor to rotate.
28
+
29
+ UiFlow2 Code Block:
30
+
31
+ |example.png |
32
+
33
+ Example output:
34
+
35
+ None
36
+
37
+ Motion Base v1.1
38
+ ^^^^^^^^^^^^^^^^^^^^^^^^
13
39
14
- | Motion Base v1.1 |
40
+ Open the | atoms3_motion_base_v1.1_example.m5f2 | project in UiFlow2.
15
41
42
+ The example program switches the motor's running speed when the screen button is pressed, and the screen displays the current, voltage, and power.
16
43
17
- Micropython Example:
18
- ----------------------------
44
+ UiFlow2 Code Block:
45
+
46
+ |motion_base_v1.1_example.png |
47
+
48
+ Example output:
49
+
50
+ None
51
+
52
+ MicroPython Example:
53
+ --------------------------
19
54
20
55
Motion Base
21
- ++++++++++++++++++++++++++++
56
+ ^^^^^^^^^^^^^^^^^^^^^^^^
57
+
58
+ This example controls the servo to rotate to a specified angle and sets the motor to rotate.
59
+
60
+ MicroPython Code Block:
22
61
23
62
.. literalinclude :: ../../../examples/base/motion/atoms3_lite_motion_base_example.py
24
63
:language: python
25
64
:linenos:
26
65
66
+ Example output:
67
+
68
+ None
69
+
27
70
Motion Base v1.1
28
- ++++++++++++++++++++++++++++
71
+ ^^^^^^^^^^^^^^^^^^^^^^^^
72
+
73
+ The example program switches the motor's running speed when the screen button is pressed, and the screen displays the current, voltage, and power.
74
+
75
+ MicroPython Code Block:
29
76
30
77
.. literalinclude :: ../../../examples/base/motion/atoms3_motion_base_v1.1_example.py
31
78
:language: python
32
79
:linenos:
33
80
34
- UIFlow2.0 Example:
35
- ----------------------------
81
+ Example output:
36
82
37
- Motion Base
38
- ++++++++++++++++++++++++++++
83
+ None
39
84
40
- |example.png |
41
85
42
- .. only :: builder_html
86
+ **API **
87
+ --------------------------
43
88
44
- |atoms3_lite_motion_base_example.m5f2 |
89
+ Motion
90
+ ^^^^^^^^^^^^^^^^^^^^^^^^
45
91
46
- Motion Base v1.1
47
- ++++++++++++++++++++++++++++
92
+ .. class :: base.motion.Motion(i2c, address=0x38)
48
93
49
- |motion_base_v1.1_example.png |
94
+ Create an Motion object.
95
+
96
+ :param I2C i2c: The I2C port to use.
97
+ :param int address: The device address. Default is 0x38.
50
98
51
- .. only :: builder_html
99
+ UiFlow2 Code Block:
52
100
53
- | atoms3_motion_base_v1.1_example.m5f2 |
101
+ | __init__.png |
54
102
103
+ MicroPython Code Block:
55
104
56
- class Motion
57
- ------------
105
+ .. code-block :: python
58
106
59
- Constructors
60
- -------------
107
+ from base import Motion
108
+ from machine import I2C
61
109
62
- .. method :: Motion(i2c, address)
110
+ i2c0 = I2C(0 , scl = Pin(39 ), sda = Pin(38 ), freq = 100000 )
111
+ motion = Motion(i2c0, 0x 38 )
63
112
64
- Initialize the Servo8.
113
+ .. method :: get_servo_angle(ch)
65
114
66
- - ``i2c ``: I2C port to use.
67
- - ``address ``: I2C address of the servo8.
115
+ Get the angle of the servo.
68
116
69
- UIFlow2.0:
117
+ :param int ch: The servo channel. Range: 1~4.
118
+ :returns: Specify the servo angle for the specified channel. Range: 0~180.
119
+ :rtype: int
70
120
71
- |__init__.png |
121
+ UiFlow2 Code Block:
122
+
123
+ |get_servo_angle.png |
124
+
125
+ MicroPython Code Block:
126
+
127
+ .. code-block :: python
128
+
129
+ motion.get_servo_angle()
130
+
131
+ .. method :: set_servo_angle(ch, angle)
132
+
133
+ Set the angle of the servo.
134
+
135
+ :param int ch: The servo channel. Range: 1~4.
136
+ :param int angle: The servo angle. Range: 0~180.
137
+
138
+ UiFlow2 Code Block:
139
+
140
+ |set_servo_angle.png |
141
+
142
+ MicroPython Code Block:
143
+
144
+ .. code-block :: python
145
+
146
+ motion.set_servo_angle()
147
+
148
+ .. method :: get_servo_pulse(ch)
149
+
150
+ Get the pulse of the servo.
151
+
152
+ :param int ch: The servo channel. Range: 1~4.
153
+ :returns: Specify the servo pulse for the specified channel. Range: 500~2500.
154
+ :rtype: int
155
+
156
+ UiFlow2 Code Block:
157
+
158
+ |get_servo_pulse.png |
159
+
160
+ MicroPython Code Block:
161
+
162
+ .. code-block :: python
163
+
164
+ motion.get_servo_pulse()
165
+
166
+ .. method :: write_servo_pulse(ch, pulse)
167
+
168
+ Write the pulse of the servo.
169
+
170
+ :param int ch: The servo channel. Range: 1~4.
171
+ :param int pulse: The servo pulse. Range: 500~2500.
172
+
173
+ UiFlow2 Code Block:
72
174
73
- Methods
74
- -------
175
+ |write_servo_pulse.png |
75
176
76
- .. method :: Motion.get_servo_angle(ch)
177
+ MicroPython Code Block:
77
178
78
- Get the angle of the servo.
179
+ .. code-block :: python
79
180
80
- - `` ch ``: Servo channel (1 to 4).
181
+ motion.write_servo_pulse()
81
182
82
- UIFlow2.0:
183
+ .. method :: get_motor_speed(ch)
83
184
84
- | get_servo_angle.png |
185
+ Get the speed of the motor.
85
186
86
- .. method :: Motion.set_servo_angle(ch, angle)
187
+ :param int ch: The motor channel. Range: 1~2.
188
+ :returns: Specify the speed for the specified channel. Range: -127~127.
189
+ :rtype: int
87
190
88
- Set the angle of the servo.
191
+ UiFlow2 Code Block:
89
192
90
- - ``ch ``: Servo channel (1 to 4).
91
- - ``angle ``: Angle of the servo (0 to 180).
193
+ |get_motor_speed.png |
92
194
93
- UIFlow2.0 :
195
+ MicroPython Code Block :
94
196
95
- | set_servo_angle.png |
197
+ .. code-block :: python
96
198
97
- .. method :: Motion.get_servo_pulse(ch )
199
+ motion.get_motor_speed( )
98
200
99
- Get the pulse width of the servo.
201
+ .. method :: set_motor_speed(ch, speed)
100
202
101
- - `` ch ``: Servo channel (1 to 4).
203
+ Set motor speed.
102
204
103
- UIFlow2.0:
205
+ :param int ch: The motor channel. Range: 1~2.
206
+ :param int speed: The motor speed. Range: -127~127.
104
207
105
- | get_servo_pulse.png |
208
+ UiFlow2 Code Block:
106
209
107
- .. method :: Motion.write_servo_pulse(ch, pulse)
210
+ | set_motor_speed.png |
108
211
109
- Set the pulse width of the servo.
212
+ MicroPython Code Block:
110
213
111
- - ``ch ``: Servo channel (1 to 4).
112
- - ``pulse ``: Pulse width of the servo (500 to 2500).
214
+ .. code-block :: python
113
215
114
- UIFlow2.0:
216
+ motion.set_motor_speed()
115
217
116
- | write_servo_pulse.png |
218
+ .. method :: read_voltage()
117
219
118
- .. method :: Motion.get_motor_speed(ch)
220
+ Read voltage (unit: V).
119
221
120
- Get the speed of the motor.
222
+ :returns: The voltage value in volts.
223
+ :rtype: float
121
224
122
- - ``ch ``: Motor channel (1 or 2).
225
+ .. note ::
226
+ This method is supported only on Motion Base v1.1 and later versions.
123
227
124
- UIFlow2.0 :
228
+ UiFlow2 Code Block :
125
229
126
- | get_motor_speed .png |
230
+ | read_voltage .png |
127
231
128
- .. method :: Motion.set_motor_speed(ch, speed)
232
+ MicroPython Code Block:
129
233
130
- Set the speed of the motor.
234
+ .. code-block :: python
131
235
132
- - ``ch ``: Motor channel (1 or 2).
133
- - ``speed ``: Speed of the motor (-127 to 127).
236
+ motion.read_voltage()
134
237
135
- UIFLOW2:
238
+ .. method :: read_current()
136
239
137
- | set_motor_speed.png |
240
+ Read current (unit: A).
138
241
139
- .. method :: Motion.read_voltage() -> float
242
+ :returns: The current value in amperes.
243
+ :rtype: float
140
244
141
- Read voltage (unit: V)
245
+ .. note ::
246
+ This method is supported only on Motion Base v1.1 and later versions.
142
247
143
- .. note ::
144
- This method is supported only on Motion Base v1.1 and later versions.
248
+ UiFlow2 Code Block:
145
249
146
- UIFlow2.0
250
+ | read_current.png |
147
251
148
- | read_voltage.png |
252
+ MicroPython Code Block:
149
253
150
- .. method :: Motion.read_current() -> float
254
+ .. code-block :: python
151
255
152
- Read voltage (unit: A )
256
+ motion.read_current( )
153
257
154
- .. note ::
155
- This method is supported only on Motion Base v1.1 and later versions.
258
+ .. method :: read_power()
156
259
157
- UIFlow2.0
260
+ Read power (unit: W).
158
261
159
- |read_current.png |
262
+ :returns: The power value in watts.
263
+ :rtype: float
160
264
161
- .. method :: Motion.read_power() -> float
265
+ .. note ::
266
+ This method is supported only on Motion Base v1.1 and later versions.
267
+
268
+ UiFlow2 Code Block:
162
269
163
- Read power (unit: W)
270
+ | read_power.png |
164
271
165
- .. note ::
166
- This method is supported only on Motion Base v1.1 and later versions.
272
+ MicroPython Code Block:
167
273
168
- UIFlow2.0
274
+ .. code-block :: python
169
275
170
- | read_power.png |
276
+ motion.read_power()
0 commit comments