How to build a crane?
Step 1. Technical knowledge: (review from previous lesson No. 6)
Get to know your servo motor. 360° servo motor vs 180°servo motor;
One of the major components we needed to build a crane is an engine, in our case a 360° servo motor. There are two types of servo motors, a 180° servo motor and a 360° server motor. A 180 ° servo motor is a geared motor that can be controlled precisely to a specific position within a range of 0° to 180 ° and can maintain a particular position until it is instructed to move to another position. On the other hand, a 360° server motor can rotate continuously but not stay in a particular angle, but we can control the speed instead.
Both types of servo motors are controlled by electrical pulses. Those pulses are signals that will turn on and off very quickly. Typically, a servo motor needs to get 50 signals per second (50Hz) or 1 signal every 0.2 seconds (20 milliseconds) respectively, whereby the signal length (pulse) itself is only between 1 to 2 milliseconds long. The length of this signal determines the turning degree or speed of the servo motor. The technical term for this method is Pulse Width Modulation (PWM).
Both 360° servo and the 180° servo are identical in size an look, but there is an opening for accessing the fine-tuning screw underneath the 360° servo motor. This fine-tuning screw is used when the motor does not stop completely at the stop command or 90-degree command. Turning it a little bit to the left or right would stop the motor completely.
Step 2. PWM with micro:bit:
In order to send “Pulses” to the servo motor using the micro:bit, we could go to the “Pins” tab under the “Advanced” tab or use the servo blocks under the “MuseRobotic” tab. If you cannot find the “MuseRobotic” tab, you could install the tab following the instruction in step 2 from following link: https://muselab.cc/2018/03/15/how-to-connect-microbit-to-the-internet/
This command block is mainly used for 180° servos.
Alternatively we can also use:
We can find servo command blocks for both 180° and 360° servo motor.
Note: In order to maximize the functionality of your Muselab micro:bit Booster, it should be initialized as follow:
Step 3. Build the crane.
Below we are using the Muse Crane of the Muse Mechanical Set I (3in1)
Step 4. Build the remote control
Step 5. Write the code!
For this code example we are using the fastest and easiest way. Please connect your dimmer and servo motors as shown below:
Dimmer 1
Please note that P12 is output only, for why you must attach one of the servo motors to it, because it is not able to read the value from your dimmer!
Code to control servo 1:
Code to control servo 2:
By now, you should be already quite familiar with the micro:bit PXT editor. Your challenge now is to find the correct blocks in the sidebar , to reconstruct the code. (HINT: Have a closer look on the colours of the blocks shown in the pictures!)
Now it’s time for practice. Enjoy your crane!