Digital Measuring Roller Using Microbit & Tinkercad

7,366

79

2

Introduction: Digital Measuring Roller Using Microbit & Tinkercad

Are you bored of the old clunky measuring tape with which you can't even measure the circumference of any cylindrical object nor it converts the units and also it has a restricted length which can be measured with it. So in this Instructables with the help for few blocks of code and some 3D printed parts we will try to make a digital measuring roller which will overcome all these issues.


Upcoming steps will show the working principle and explanation of the code used if you are eager to build the device then you can skip down to step number 8 for build instructions.

Step 1: Supplies

Step 2: Principle of Working

The working principle behind the device we are going to make is pretty simple, the device will calculate the distance by counting number of turns on rotary encoder and converting that number to distance by multiplying the steps to distance per steps.

Step 3: How Rotary Encoder Works?

If you already know how a rotary encoder works then you can skip this step.
The rotary encoder consist of a circular plate with two concentric conductive rings(A & B) broken at regular intervals and there is a slider which is in constant contact with the plate as can be seen in image.

The ring is electrically connected to ground or positive using a high resistance and the slider is connected to opposite terminal.

When we rotate the knob of the encoder the plate rotates and the conductive rings passes below the slider leading to connection of conductive rings with slider and by monitoring the signal of A and B rings to see which ring gets connected to slider first we can find the direction of the rotation and by counting the number of times the connection made with a particular ring will help determining the number of steps the rotary encoder turned.

If you want to know more about rotary encoder, I found this awesome Instructables which will help you understand it better.

The encoder I have used contains 20 steps per turn so the resolution of the device turns out to circumference of the roller / number of steps per turn. in my case it is 3.35 which will be further used in the code.

Step 4: Tinkercad Circuits : Block Coding

To follow along with the explanation make a account on Tinkercad and copy the project from this link.
The Tinkercad circuits project also includes an Arduino with two buttons to simulate the clock wise and counter clockwise rotation of the rotary encoder with it.

lets understand what variables are used in the block code :

  • leastCount : it is the distance in mm which the roller will move under one step of rotary encoder (As discussed in the previous step How rotary encoder works?)
  • mode : It will determine the unit in which output is shown, there are four options currently mm, inch, cm, feet. With few tweaks you can add more units.
  • state : It is used to stop the execution of forever block when the mode button is selected so output on led matrix is not interrupted.
  • step : it will store the number of steps rolled.
  • stp : it will determine the direction of positive rolling which can be change by pressing A and B together as per user convenience.

In onStart Block we have initialized all these variables and the forever block show the measured value in the unit chosen by the user by multiplying the step with appropriate value according to the user.

Step 5: Button Press Blocks : Button A

We have utilized three blocks to determine which button or combination of buttons are pressed.


when Button A is pressed the block associated with button A will run where first we change the state variable which will stop the execution of internal blocks of forever block then it will change the variable mode by 1 and next use modulus operator to restrict the value between 0 to 3.

Further with the help of conditions if and else we determine the value of mode and show the string "Mode : mm" or the respective unit to the user.
At the end we turn back the state to 1 so forever block can run as expected.

Step 6: Button B & Button A+B

Button B is used for resetting the steps variable back to zero so the user can fresh start a new measurement

Button A+B is used to change the stp variable which in turn defines the positive direction of the roller if the user is left handed then the positive direction and the display will be on one side and if the user is right handed the display and positive direction will be opposite.

Step 7: Pin 1 and Pin 2 (signal Reading From the Rotary Encoder)

The pins A and B of rotary encoder is connected to the pin P1 and pin P2 of the micro bit and thus when the signal on the pins of microbit changes the blocks above runs.
so if pin P1 turns HIGH the block will run and first check whether the other pin is low or not which will help in determining the direction. if the pin turned high but the other pin is already high that will mean the direction is not what we supposed in this block(other block must have already ran before) and the variable step must not be changed.

Step 8: 3D Print

With all the explanation covered we can move now to build process.
But first we need some 3D printed parts to move ahead.

There are mainly three parts :

  • Main Body
  • Roller
  • The battery pack( optional )

If you already have the battery pack that comes with Micro Bit Go kit then you can skip printing the battery pack or if you want a battery pack which can be attached at the back of micro bit then also go with the battery pack assembly step.

The main Body is printed upside down and the top part may need support, although I have printed it without support. It is the matter of tweaking over the bridging parameters of the 3D Printer.

Step 9: The Battery Pack (Optional)

The battery pack is printed in Three parts body and two outer flanges, I have separated out then so the prints don't need supports, but if you want to print it directly then you can with the help of step file included in step above. Anyways when you have the two flanges joined at the side of main body then you need two springs to make contact by inserting the spring end from the hole at the side of the main body.
Now add two wires and tie a knot and insert it on the other side of the body so it works like connector.

Further if you have JST connector compatible with Micro Bit then solder those wire with it or use simple 2.54 mm female headers as I have used.

Step 10: Add O-Rings to the Roller

The roller has diameter of 20mm and i have used O-Rings with 15mm ID so that the O-Rings fit tightly on the roller and don't rotate on the body when rolled over the surface.
When you have inserted all the O-Rings verify the friction between the surface and the roller by rolling it over the surface to confirm that rotary encoder will rotate well so it don't skip steps otherwise it will cause error.

Step 11: Rotary Encoder Circuit

The rotary encoder can't be used directly with Micro bit, we need to make a small circuit having resistors in pull up configuration( the pins are normally HIGH, when rotated it gets connected to GND or vice versa).
You can make the circuit given above on perforated board with 4 wires coming out of the circuit for connection to Micro bit (3V, GND, P1, P2).
Make sure the wires are small in length other wise when whole thing is capsulated the wire will obstruct with the roller.

Step 12: Add the Bearing to Main Body

Now Add the 623 Bearing (3mm x 10mm x 4mm) into the main body and make sure that it is slightly tight, if not you can use Teflon tape to increase the outer diameter of the bearing, if the bearing is extra tight then try to heat the bearing then insert it (Do it carefully).
The inner hole of bearing will be used for pivoting M3/M2.5 bolt which will be inserted in the roller. So do check the fitting of nut in the bearing beforehand.

Step 13: Assembly

Now with all the preparations complete we can move toward the assembly. I want to breakdown the assembly into few simple steps which you can also see in the animation above:

  1. Place the Main body above the roller(vertically placed with D hole on top side).
  2. insert the rotary encoder D shaft into the roller from top and then turn the both together into the section made for rotary encoder.
  3. Now insert the Pivot bolt M3/M2.5 from the other side into the roller and tight it into the roller, while making sure there is sufficient clearance between the main body and the roller.
  4. Now check for the linearity of the roller if not adjust the encoder & then tight the nut on the rotary encoder to fix it on the main body
  5. Connect the wires coming out of the rotary encoder circuit to the micro bit adapter on respective positions.
  6. Now tight the micro bit adapter to the main body with small screws.
  7. Now attach the battery and Microbit to the adapter.

Step 14: Lets Program the Micro Bit

Programing the micro:bit is as simple as the journey so far was, we just need to copy the code from Tinkercad to Makecode JavaScript environment.

  1. First download the code from Tinker cad.
  2. Open the file download and copy whole code from it.
  3. Now open Makecode, create a new project and go to JavaScript
  4. Paste the code in the text area.
  5. Now pair the micro:bit with the Makecode by clicking the three dots along with download button.
  6. Now you can download the code directly to your micro:bit by clicking the second option in the three dots menu.

Step 15: Woohoo....! You Got a Digital Measuring Tool.

Wow !! You have finally made a measuring tool for your self which is far better than that of your old measuring tape. You are now not restricted to the length of your measuring tape & easily measure the circumference of any round object and .

If any difficulties occur during the build process do comment down below, I would love to help.

Block Code Contest

Grand Prize in the
Block Code Contest

Be the First to Share

    Recommendations

    • Make it Glow Contest

      Make it Glow Contest
    • First Time Author Contest

      First Time Author Contest
    • PCB Challenge

      PCB Challenge

    2 Discussions

    1
    jessyratfink
    jessyratfink

    9 days ago

    That's awesome! What a fun way to measure irregular objects :)

    1
    Makertronics
    Makertronics

    Reply 9 days ago

    Thanks for your beautiful comment! 😊