I used a PIC16F819 microcontroller and a sensor from an old computer mouse (the remaining parts of one of my other projects Crazy Mouse) to make this simple measuring tape.
Do you want to make yourself? If yes read the rest of this instructable.
Remove these ads by
Signing UpStep 1: What you need
- Printed circuits (find files in the next step)
- Copper board
- Sandpaper
- Iron
- Circuit board acid
- 1mm drill
- Soldering tools
- 1x PIC16F819 microcontroller + socket
- An old mouse (or one of its IR shaft encoders)
- 3x BC547 transistors
- 3x common anode 7 segments
- 1x 100uF electrolyte capacitor
- 1x 470ohm resistor (1/8 watt)
- 7x 10k resistors (1/8 watt)
- 2x Simple push buttons
- 1x Simple switch
- 2x AA batteries with a battery holder
- 1x Wheel (+ maybe some gears)
- A box for this measuring tape









































Visit Our Store »
Go Pro Today »




LRButton = 0;
if (EEPROM_Read(0) == CorrectROMValue)
{
unsigned short int k;
OneMeterTicks = EEPROM_Read(1);
k = EEPROM_Read(2);
OneMeterTicks = (OneMeterTicks << 8) + k;
}
LOneMeterTicks = OneMeterTicks;
while (1)
{
if ((!RButton) && LRButton)
{
Ticks = 0;
if (OneMeterTicks != LOneMeterTicks)
{
EEPROM_Write(0, CorrectROMValue);
EEPROM_Write(1, (unsigned short)(OneMeterTicks >> 8));
EEPROM_Write(2, (unsigned short)OneMeterTicks);
LOneMeterTicks = OneMeterTicks;
}
}
LRButton = RButton;
if (EEPROM_Read(0) == CorrectROMValue) (*if the user did not calibrated yet the value stored in posiition 0 of EEPROM is zero so if only already calibared read calibration value from EEPROM, CorrectROMValue is an arbitrary constant value*)
{
unsigned short int k;
OneMeterTicks = EEPROM_Read(1); (*read first byte of calibrated value fromm EEPROM*)
k = EEPROM_Read(2); (*read 2nd byte of calibrated value fromm EEPROM*)
OneMeterTicks = (OneMeterTicks << 8) + k; (*join 2 bytes together*)
}
LOneMeterTicks = OneMeterTicks; (*store OneMeterTicks value to LOneMeterTicks*)
while (1) (* the endless loop to run the reset of the program*)
{
if ((!RButton) && LRButton) (*if RButton is Up (=0) but in last state was down (LRButton=1)*)
{
Ticks = 0; (*zero the display value*)
if (OneMeterTicks != LOneMeterTicks) (*if OneMeterTicks not equals last saved OneMeterTicks means that the user changed calibration value so it must be saved to EEPROM*)
{
EEPROM_Write(0, CorrectROMValue); (*write the value that indicates already calibrated to EEPROM*)
EEPROM_Write(1, (unsigned short)(OneMeterTicks >> 8)); (*write 1st byte of calibration value to EEPROM*)
EEPROM_Write(2, (unsigned short)OneMeterTicks); (*write 2nd byte of calibration value to EEPROM*)
LOneMeterTicks = OneMeterTicks; (*store new value of OneMeterTicks value to LOneMeterTicks*)
}
}
LRButton = RButton; (*store the sate of RButton in LRButton*)
INTCON.INTF = 0;
what is means with this coding
Cycle++;
if (Cycle == DigitChangeCycle)
{
SS1 = 0;
SS2 = 0;
SS3 = 0;
if (Ticks < 0)
n = -Ticks;
else
n = Ticks;
n *= 100;
if (UButton == 1)
n /= (unsigned long int)(OneMeterTicks * 2.54);
else
n /= (unsigned long int)OneMeterTicks;
Digit[2] = n / 100;
n = n % 100;
Digit[1] = n / 10;
Digit[0] = n % 10;
dig = Digit[DigitIndex];
SSA = ((dig == 1) || (dig == 4));
SSB = ((dig == 5) || (dig == 6));
SSC = (dig == 2);
SSD = ((dig == 1) || (dig == 4) || (dig == 7));
SSE = ((dig != 0) && (dig != 2) && (dig != 6) && (dig != 8));
SSF = ((dig == 1) || (dig == 2) || (dig == 3));
SSG = ((dig == 0) || (dig == 1) || (dig == 7));
if (DigitIndex == 0) SS1 = 1;
if (DigitIndex == 1) SS2 = 1;
if (DigitIndex == 2) SS3 = 1;
Cycle = 0;
DigitIndex++;
if (DigitIndex == 3) DigitIndex = 0;
if ((DigitIndex == 2) && (Digit[2] == 0)) DigitIndex = 0;
if ((DigitIndex == 1) && (Digit[2] == 0) && (Digit[1] == 0)) DigitIndex = 0;
}
To:
if (Ticks < 0)
n = -Ticks;
else
n = Ticks;
n *= 100;
if (UButton == 1)
n /= (unsigned long int)(OneMeterTicks * 2.54);
else
n /= (unsigned long int)OneMeterTicks;
Your code to display n on the LCD
"if (INTCON.INTF)" ensures that B0 pin changed.
"if (Sensor1)" means that if the other receiver that is connected to A4 pin is 1.
"if (RButton)" means that is user held down the Reset button in order to calibrate.
When the B0 pin changes from 0 to 1, if the A0 pin is 1 it means that wheel if rotating forward, and if the A0 pin is 0 it means that wheel if rotating backward. So if the user wants to calibrate the program changes the Ticks/Meter constant that is stored in the ROM of PIC, and if the user want to measure (not holding down Reset button) program counts the number of ticks made by rotating toothed wheel and convert it to meter using the conversion ratio.
if not, what is that IR shaft encoder a trasmitter or a receiver? Thanks in advance for the answer.
i just want to ask if we can use meter, ft, inches, cm, etc. units at the same time?
can ii do it in less than a 3 weeks
processor unit. What would I, need to make these changes to increase the measuring capacity of your tape measure ?
How accurate is it?
OK, dumb question incoming (sorry, I have to ask it) but, 1 cm or 1 inch...? That's a big discrepancy. If you were talking about 1cm per 1/2 kilometer or 1 inch per 300 yards or something along that line, then it's not that big a deal. But, if it's less than that then I question the accuracy.
Can you be a little more specific about it's accuracy, please?
Thanks!