TigerJython4Kids
robotics Robotik
movemini
Deutsch   English   

WORKSHEET 2: MOVEmini

 

 

ASSEMBLY AND OPERATION PRINCIPLES

 

It is quite easy to assemble the MOVEMini. You find a assembly instruction here. You may also have a look at this YouTube-Video.

The motors are not standard DC motors but continuous running servo motors. They are attached to the additional driver board, which is connected to micro:bit pins P0, P1, P2, 3V and GND. The right motor is controlled via P1 and the left motor via P2.

 

 

At the top of the board, you see 5 color LEDs called neopixels controlled via P0.  

 

 

STARTING UP

 


NeoPixels

It is always exciting to put a device into operation for the first time. You should not test the entire system right now, but perform small tests to check the proper functioning of individual components. Start with the color LEDs, called neopixels. To use the LEDs you need to import a piece of software called a module or a library which provides additional software components like functions and classes. Then you create a variable np (the name arbitrary) by calling NeoPixel(). As parameters you define the pin, where the LEDs are attached and the total number of LEDs.

from neopixel import *
np = NeoPixel(pin0, 5)

Now you can easily set the RGB color of each pixel individually by selecting the pixel (i = 0..4) like in a list with np[i] and assigning it a tuple of  RGB values (3 numbers between 0 and 255).

For example, to set the LED with index 1 to a green color:

np[1] = (0, 10, 0)

However the LED does not light up unless you call:

np.show()

Write the program and execute it.
Now it's time to play around with the LEDs, for example:

Blink all pixels in any color
Create a running light, e.g.. the pixels are turned on and off in turn

Attention: If your pixels are not lit, you probably forgot np.show()!


Motors

Basically, a  servo motor is controlled with a PWM signal. (Refer to Chapter 8: Moving Robots) However, servo motors typically do not rotate continuously, but only up to a certain position depending on a parameter called duty cycle. The servos used here are a special type that run continuously. Here the rotation speed and direction is controlled by the duty cycle.

It is easy to create a PWM signal on P1 (for the right motor) by calling

pin1.write_analog(duty_cycle)

Here the duty_cycle is given as a number between 0 and 1023 (that correspond to a duty cycle of  0..100%). The motor is rotating faster and faster for values between about 73 and 93. For values between about 73 and 63, it's getting faster and faster, but turns in the opposite direction.

Create a program that runs the right motor for 1 second with the duty_cycle from 63 to 73. At the end stop the motor by calling write_analog(0). Print out the current duty_cycle in the console window.

Do the same test with the left motor.

 

 

MOVING FORWARD AND TURN

 

To drive forward, both wheels must rotate at the same speed. Because the motors are arranged opposite, their rotation have to be opposite for a forward move. However because of inaccuracies you cannot achieve a straight forward movement. Adjust the number 72 so that this is almost the case. To turn left, you stop the left wheel.

It makes sense to define some useful functions, e.g.

Program:

from microbit import *

def forward(speed):
    pin1.write_analog(72 - speed)
    pin2.write_analog(72 + speed)

def left(speed):
    pin1.write_analog(72 - speed)
    pin2.write_digital(0)

def stop():
    pin1.write_digital(0)
    pin2.write_digital(0)
► Copy to clipboard

Create a program so that the robot moves forward for 3 s and then turns left for 0.7 s. Repeat this 4 times and stop.

Complete the function collection with backward() and right() and do some more test runs.

 

 

DRIVE LIGHTING AND DIRECTION INDICATORS

 

Now you can combine your knowledge and realize some interesting robot applications.

Suggestions:
The robot moves endlessly on a approximate square, until you click the A button. When moving forward, the three middle pixels are turned on in white color such as headlights of a car. When turning the corresponding outermost pixels is lit in yellow color, such as direction indicators.

Improve the program so that the yellow direction indicator is flashing

Improve the program so that the rover stops immediately when you click the button A

Improve the program so that you can restart it by clicking the button B

Improve the program so that meaningful state information is shown on the 5 by 5 LED display
Expand the program so that the robot makes left and right turns.
 

 

 

A ROBOT REMOTE CONTROL

 

Use a second micro:bit to control the robot remotely as follows:

No button pressed → stop
Left button pressed → turn to the left
Right button pressed → turn to the right
Both buttons pressed → move straight ahead

Refer to chapter 7. Bluetooth, to learn how to program the communication between the remote control and the robot.