DIY

Digital Measuring Instrument on Microbit

Various tools, rulers, calipers, tape measures, etc. are used to measure the distance. When measuring the radius of spherical surfaces, various techniques are used. For example, you can measure the radius with a rope, string, etc. and then transfer to a ruler or use a centimeter, etc. There are also special instruments for measuring such surfaces, for example, a circometer.
The master suggests making electronic measuring tool. Such instruments can measure both spherical surfaces and planes.
The instrument is made on the basis of Microbit * and its assembly will be interesting and informative for beginner amateurs of electronics.
* Micro: bit (BBC Micro Bit) is a compact, self-contained microcomputer for learning programming in MakeCode, Scratch, javascript and microPython.
Tools and materials: -Microbit board; -Microbit expansion board;
-2 AAA batteries;
-1 bolt M3/M2.5;
-4 x 2 mm screws;
-Bearing 623 (3 mm x 10 mm x 4 mm);
-Rotary encoder; -Resistor 10 kOhm – 2 pcs; -10 rubber O-rings (inner diameter ~ 15 mm); – 3D printer or access to it;
Step one: how it works
The principle of operation of the device is quite simple, the device calculates the distance by reading the number of revolutions of the rotary encoder and converting it into distance.
An encoder is a rotation sensor. The simplest sensor has a handle that can be turned clockwise or counterclockwise. Depending on the angle of rotation and direction, a digital signal is issued informing which position the knob is in or in which direction it has been turned.
The encoder used by the master contains 20 steps per revolution. In this case, this value is 3.35, which will be further used in the code.
Step two: Tinkercad schemas – block coding
Tinkercad is a free online 3D modeling program that runs in a web browser and is simple and easy to use.
The Tinkercad schematic project includes Arduino with two buttons to simulate clockwise and counterclockwise rotation of the rotary encoder. You can download the project here.
The following variables are used in the block code:
lessCount: this is the distance in mm that the roller will move in one step of the rotary encoder
mode: will determine the unit in which the output is displayed, currently there are four options : mm, inch, cm, feet. With a few tweaks, you can add more data.
state: used to stop block execution when the mode button is pressed.
step: save the number of steps passed.
stp: will determine the direction of movement of the encoder. It can be changed by simultaneously pressing buttons A and B.
All these variables are initialized in the onStart block, and the forever block shows the measured value in the units selected by the user.
The wizard used three blocks to determine which button or combination of buttons is pressed.
When button A is pressed, the block associated with button A will work. You can select a value in a block from 0 to 3.
Then, using if and else, we define the mode value and show the user the line “Mode: mm” or cm, etc.
At the end, we return the state to 1.
Button B is used to reset the step variable back to zero so that the user can start a new measurement again.
The A + B button is used to change the stp variable, which in turn determines the positive direction of the roller.
Pins A and B of the encoder are connected to pin P1 and pin P2 of the microbit, and thus when the signal on the pins microbit changes, commands are executed.
If the value at pin P1 becomes large, the script (block) will run and first check the second pin, which will help in determining the direction of rotation of the encoder.
Step three: 3D printing
Next you need to print the parts on a 3D printer.
Digital measuring Roller.stepMainBody.stlRoller.stlHolder.stlSnap1.stl
Step four: battery holder
After printing, prepares the battery compartment (can be used from a broken toy). Installs springs.
Strips the ends of the wires. Ties them in a knot. Puts wires through holes. Installs on the other ends JST connectors compatible with Micro Bit.
Step five: roller
The roller has a diameter of 20 mm and the master uses o-rings with an inner diameter of 15 mm so that they fit snugly against the roller and do not rotate on the body when moving over the surface.
Then you need to install the roller on the encoder handle and check it work. It is important that there are no skips on the encoder when moving.
Step six: diagram for rotary encoder
Rotary encoder cannot be used directly with Micro bit, you need to make a small circuit with resistors.
Master mounts the board below.
Step six: bearing
Then he installs the bearing into the housing. Make sure the bearing is tight. If it is loose, you can wind up the Teflon tape. If, on the contrary, the bearing is not installed in the seat, then you can slightly heat its outer race and press in the bearing.
Step Seven: Assembly
Then you can start assembling the device.
Place the main body over the roller (vertically, hole D at the top).
Insert the angle encoder shaft D into the roller, then unfold the assembly into the housing.
Install the screw and tighten it. Make sure there is sufficient clearance between the main body and the roller.
Connect the wires coming out of the encoder circuit to the microbit adapter.
Attach the microbit adapter to the main body with screws.
Install the battery compartment along with the batteries and Microbit.
Step Eight: Programming
Programming a micro bit is simple, you need to copy the code from Tinkercad to the Makecode environment javascript.
Now open Makecode, create a new project and go to javascript.
Paste the code into the text area.
Now connect the micro bit to the Makecode by clicking the three dots along with the download button.
You can now upload the code directly to your micro: bit by clicking the second option in the three-dot menu.
< img class = "aligncenter" alt = "Digital measuring tool on Microbit" src = "https://usamodelkina.ru/uploads/posts/2021-01/1611515134_1-35.jpg"/> Everything is ready. Now you can start testing the tool. The user is not limited by the length of the tape and can easily measure the circumference of any round object. The measurement results are displayed on the microbit board with a creeping line on the LED display.
The entire assembly and programming process of such a device can be viewed at video.

< cente r>

Source:

usamodelkina.ru

Check Also
Close