Make a small Measuring Wheel with Arduino UNO
Open Google map, input starting point and destination then the distance will display in your screen. Compared to traditional maps, the current electronic maps are of vast information and better distance calculation. However, how could it counts the distance? Is it uses satellite, tape or other tools? Satellite can explore topography and land resource but lack of precision; tape is inflexible and distance limited. Except these tools, is there anything else? Couple of days before, I was suddenly to find a man who holds a wheel rolling along the road. I was incontinent of curiosity, I came to talk with the man and knew he is a map worker and used the wheel to measure distance then draw routes. The distance measure wheel is convenient to take, flexible and precise. How could I resist its temptation to make a measuring wheel?
Relative to old tape, the wheel can slip freely and detect positive and negative (slip to left is positive, slip to right is negative). Let us see the working process.
Hardware Diagram
Main Hardware
In this project, I would love to chooseDFRduino UNO R3 that fully compatible withArduino UNO R3 as a main board. It adopts ENIG (emersion gold) technique, cost effective and more delicate. Moreover, we need another powerful component which is an encoder to count distance.
Incremental Photoelectric Rotary Encoder - 400P/R is compatible with controllers such as Arduino, PLC etc. It generates AB two-phase orthogonal pulse signals though the rotation of the grating disk and opt coupler. The output type is NPN open collector output, which could work with Microcontroller with internal pull-up resistors directly and realize speed, angle, angular velocity and other data measurement.
*Caution: NPN open collector output needs pull-up resistors for the oscilloscope display.
Main Components
Gravity: I2C 16x2 Arduino LCD with RGB Backlight Display
Cable Adapter Module 4
Gravity: IO Expansion Shield for Arduino V7.1
Digital Push Button (.NET Gadgeteer Compatible)
7.4V Lipo 2500mAh Battery (Arduino Power Jack)
D80mm Silicone Wheel For TT Motor
Circuit Diagram
Real Connected Picture
Reset: you could clear up data and make a restart measurement more convenient in this mode.
Detection: You can measure distance freely, up to down, right to left in this mode. Slipping to left, the value is positive; slipping to right, the result is negative (when the value is a positive one, rolling right and the result is decreasing).
Lock: when the measurement finished, you need to keep data. In this mode, all data is locked and would not change that helps you record results. It works with simply three presses.
I have print a crust by 3D printer to make it convenient to take and more beautiful. Is it looks a little unnatural? The crust is too square. I am sorry but I have tried my best. I believe your ideas must better than mine. The 3D printing file is in the end page.
*Caution: I have make a 80mm hub with 3D printer to suit the wheel.Tires of quality enviromentally friendly D80mm Silicone Wheel For TT Motor is still in use.
Code: Select all
#include <Wire.h>
#include "DFRobot_RGBLCD.h"

DFRobot_RGBLCD lcd(0x7c >> 1, 0xc0 >> 1, 16, 2);

//rgb_lcd lcd;

#define A 3
#define B 4
#define Key  12//key

#define D 79 //Diameter 79mm

float C = 0; //perimeter
unsigned int Distance;
int VA = 0;
int VB = 0;
unsigned long Count = 0;//count
unsigned int Count_1 = 0; //Negative count
unsigned char flag = 1, Mark = 0;
unsigned long lasttime = 0, Modetime = 0;

//Length measurement range is ± 6 M
void setup()
  lcd.setRGB(255, 255,0);
  lcd.setCursor(2, 0 );
  lcd.setCursor(2, 1 );
  lcd.setCursor(12, 1 );
  pinMode(A, INPUT_PULLUP); //Pull-up input
  pinMode(B, INPUT_PULLUP);
  pinMode(Key, INPUT);
  attachInterrupt(1, interrupt, RISING);
  C = D * PI;

void loop()
  if (millis() - 150 > lasttime)//Detect keys once every 150ms
    if (digitalRead(Key) == HIGH)
      if (digitalRead(Key) == HIGH)
        Mark += 1;
    if (Mark > 2)
      Mark = 0;

    while (digitalRead(Key) == HIGH);
    lasttime = millis();

  if (millis() - 100 > Modetime)//Refresh the data every 100ms
    if (Mark == 0) //Cleared
      lcd.setCursor(6, 0 );
      lcd.print("Reset    ");
      Distance = C * Count / 40;
      flag = 3;
      lcd.setCursor(11, 0 );
      lcd.print("     ");

    if (Mark == 1) //Calculate the measured value
      lcd.setCursor(6, 0 );
      lcd.setCursor(4, 1 );
      if (Count > 0 && Count < 0xffff)//Determine whether the length is positive
        lcd.print('-');//The length is negative
        Distance = C * Count / 40;

      else if (Count == 0 && Count_1 == 0 )//Determine whether the length is zero
        lcd.setCursor(4, 1 );
        lcd.print(' ');
        Distance = C * Count / 40;

      else//Length is positive
        Distance = Count_1 * C  / 40;

    else if (Mark == 2) //lock
      lcd.setCursor(6, 0 );
      lcd.print("Lock     ");
      Count = 0;
      Count_1 = 0;

    Modetime = millis();

  lcd.setCursor(5, 1 );//Displays the value of Distance
  lcd.print(Distance / 10000);
  lcd.print((Distance / 1000) % 10);
  lcd.print((Distance / 100) % 10);
  lcd.print((Distance / 10) % 10);
  lcd.print(Distance % 10);

void interrupt()//Interrupt handler
  VB = digitalRead(B);
  if (Mark == 1)//Detects whether the current mode is a measurement
    if (VB == 1)//To determine whether the positive measurement
      flag = 1;
      if (Count > 0xffff)
        Count_1 -= 1;

      Count += 1;
    else//Reverse measurement
      flag = 0;
      Count -= 1;
      if (Count > 0xFFFF)
        Count_1 += 1;
    //Count is cleared over the range
    if (Count < 0xFFFF && Count > 0x294A)
      Count = 0;

    else if (Count < 0xFFFFD6B5 && Count > 0xFFFF)
      Count = 0;
(327.63 KiB) Downloaded 451 times
I want the measurement results in Gravity LCD 1602 RGB can also be read and displayed in VB6 application then the data I will process on my VB6 application.
While VB6 only recognize RS232 port, do not know USB port, do I need to add part RS232 TTL Coverter?
How to schema with RS323 TTL converter and how to coding in VB6?
I am having issue with remaking this same project. I do not have the Push Button because DFRobot did not send it with my order. How can I by pass that I have the correct libraries and code but my LCD is not even lighting up with the "M:" and "D:". I did check to see if it works an it does as well as the rotary encoder.
rotary code.PNG