HomeTurtlegraficsGPanelRobotics WebTigerPython
 Python - Online
loslegen
Deutsch   English   

1. SETUP

 

 

YOU LEARN HERE...

 

how to prepare the micro:bit for programming with WebTigerPython and how to run a programme with your robot.

 

 

USB CONNECTION

 

Connect the micro:bit to the computer using the USB cable. MICROBIT will appear as a new external drive (visible in Windows File Explorer).

 

Your Python programmes are downloaded to the micro:bit via USB and executed there with MicroPython. The micro:bit must have firmware installed for this. The firmware is pre-installed on new micro:bits. If this is not the case, or if you have already programmed the micro:bit with another tool, you must reinstall the firmware. You can find instructions on how to do this below in the Install firmware section.


A. Using the Chrome browser

It is best to start WebTigerPython with the Chrome browser. This supports WebUSB and access to the micro:bit from the browser.

Select at the top right under the three dots Device - micro:bit.

Click on the USB symbol in the title bar and then on ‘BBC micro:bitCMSIS-DAP’ and select Connect.

The micro:bit is now connected to your computer. A new yellow button will appear in the title bar, which you can use to download the programme.

To test, enter the robot programme in the editor window.
from mbrobot import *
forward()
delay(2000)
stop()
 

Depending on the robot model, you may need to adjust the import line
from mbrobot_plus import *
from mbrobot_plusV2 import *

Switch on the robot's power supply and click on the yellow download button to download the program to the robot's micro:bit. The programme will start automatically and the robot will move forward for 2000 milliseconds.

B. Using other browsers

If you are using a different browser, you must first download the programme prepared for micro:bit to your computer and then copy (move) it to the MICROBIT drive.

Start WebTigerPython and select Device - microbit under the three dots on the right. Enter a test programme for the robot in the editor window.

Depending on the robot model, you may need to adjust the import line
from mbrobot_plus import *
from mbrobot_plusV2 import *

Click on the Export code button . You must then enter the programme name (e.g. Ex1). The Ex1.hex file prepared for the robot will be downloaded to the download folder on your computer. Open the Explorer and move this file to the MICROBIT drive using the mouse. The programme starts automatically and the robot moves forward for 2000 milliseconds.


 

INSTALL FIRMWARE

 

 

The firmware is already installed on a new micro:bit. You only need this option if you want to update or overwrite the firmware if the micro:bit was previously programmed with another tool.

 

To work with the robots, use micro:bit V2, which has more memory than the old version V1. The label ‘V2’ at the bottom right is only visible on micro:bit V2.

Download the ‘Firmware for V2’ from the official micro:bit website:
https://microbit.org/get-started/user-guide/firmware/

 


Press the reset button and connect the micro:bit to the computer using the USB cable (keep the reset button pressed). A new MICROBIT drive appears in the file explorer.

Copy the microbit-micropython.hex file to this drive (drag it over with the mouse). The firmware is copied to the micro:bit.

 

 

 

REMEMBER YOU...

 

If the micro:bit is connected to the computer with the USB cable, it will be visible as an external MICROBIT drive. If you are using the Chrome browser, the programmes are transferred via WebUSB. In WebTigerPython you use a yellow download button. If you are using a different browser, you must download your programme to the download folder on your computer using the Export code button and then move it to the MICROBIT drive using the mouse. The robot's power supply must be switched on for the motors to run.

If the programme download does not work as described above, it may be because the correct firmware is not installed on your micro:bit. You can reinstall the firmware at any time.

 

 

ADDITIVE: ROBOT CALIBRATION

 

What to do if the robot does not move in a straight line?
The disadvantage of low-cost robots is that they often lack precision. Some robots move exactly straight ahead when the forward() command is given, some tend to make a left turn, others a right turn. With the command
calibrate(offset, differential, arcScaling)
you can calibrate your robot more precisely. The calibrate() function requires three parameters, which are set to 0 by default.
offset (Range: (-10, 50)). Minimum power of the motors. Depending on the state of charge of the battery)
differential (Range: (-150, 150)). Controls the left or right twist. If the robot tends to move in a left-hand arc with the forward() command, you must select a negative value. If the robot tends to move in a right-hand arc when the forward() command is given, you must select a positive number.
arcScalling (Range: (-50, 50)). Calibrates the robot when travelling on a left or right arc (commands leftArc(radius) and rightArc(radius)) Positive value if the robot radius is too large, negative value if the robot radius is too small.

Example 1: Calibration when travelling straight ahead

Callibration with left-hand twist Callibration with right-hand twist
from mbrobot import *

calibrate(0, -15, 0)
forward()
delay(4000)
stop()
from mbrobot import *

calibrate(0, 20, 0)
forward()
delay(4000)
stop()

Example 2: Adjusting the radius for leftArc() and rightArc()

Callibration if the radius of the robot is greater than 20 cm
from mbrobot import *

calibrate(0, 0, 10)
leftArc(0.2)
delay(4000)
rightArc(0.2)
delay(4000)
stop()

You have to determine the size of the parameters for your robot by trial and error and the line calibrate() in all programmes in which you want to achieve more precise movement.