Colecago's Blog » Microprocessor, Project

Digital Cable Length Measurement

I bought an Olimex dev board on Sparkfun to help a friend on a car project.  I never ended up using it but saw an ad on Craigslist for some freelance engineering work so I made it into a encoder based wire counter.  The goal was to have a wire pulled off a reel and pinched on to a wheel so if someone pulled the wire or had some unwinder, the wheel would spin and an encoder would give feedback to a device that calculates the feet and inches.  Well after making the product things kinda fell through in a crappy way so I am posting build info up here.


The dev board has 6 buttons, several inputs, an LCD, buzzer, relay, and assorted other IO.  I ended up using the DALLAS input with an added cap from R8 on the micro side as a low pass filter to help with bouncing.  I used all the buttons, left/right changes the Pulses Per Inch (PPI), up/down changes the inches and feet offset, the center button resets to the setpoints, and the lower left button stores the values to EEPROM.  If you hit the center button upon power up, the EEPROM values are set to 0ft,0in,10ppi. I removed the Relay and Buzzer and tied into the relays terminal block for the encoder to plug into more conveniently.


You set PPI by finding your encoder Pulses per revolution, and then finding the circumference to find your inches per revolution, combine those (divide pulses by inches) to get pulses per inch.

Offset is used if you have to thread the wire so far before pulling, then you can keep track of that wire.


The code contains two interrupts, one for calculating adding and subtracting values for PPI and Offset adjustment.  If you hold the button long enough the speed of the change increases.  The second interrupt is INT0 as is connected to the encoder.  Every rising edge a pulse is added, inches are added based on PPI and feet are added at 12inches and inches are reset.  The main loop does all the button reading and lcd updating.  LCD updates when a button is pressed or when an onscreen value is changed.  I ended up using 99.2% of the flash and like 5% of the EEPROM.  I had to make my own printf function because I did not have enough space for the standard library.  Readbuttons is a routine that does all the I/O changes and matrix reading to do the button reading.


And that’s about it.  Here is a video of me showing it off with my raspy sick voice.  Not the greatest video, I  have a video camera but not a battery charger or stand so I used my phone.  Eventually I’ll get the better camera up and running.

I might put this thing in a box, I can tie in some better panel mount buttons, mount the screen, and maybe find a buyer.  If you have any questions about this build or want it, leave me a comment or email.


That’s it for now!

9 thoughts on “Digital Cable Length Measurement

  1. Thanks. How to contact you for more information about this?
    I meed make a counter for measuring cable. I use this for make a machine for measure well water level.
    Andhrus with camera system you have? I use a system for recording video for water well. I have a witch and video camera with fiber optic. Maybe we colaborare for this. My email is

    • I still have the unit buried somewhere in my electronics, it should still work fine and comes with an encoder already, but I don’t really have time for contract work above and beyond what it already does.

  2. Hi do you still have the feet to inches counter I am needing one, if so please contact me by email or you can call me at ———-

  3. Hi, kindly advise if you this display can show Actual length in meters, speed & limit (say from 100 to 10000.0), i prefer to use proximity switches no contact. thanks

    • It’s not programmed to do that currently, and that micro is all but maxed out. It would take a larger micro (there is a larger memory version in that size) and some new coding.

  4. I need a length counter like this, one question? can it subtract when reverse the cable?
    How can I get it?
    M e-mail is

    • The encoder I used only had one magnetic switch in it so I could only see one direction. If it was a 4 wire encoder, either pulse and direction or two pulse lines (quadrature) I could do adding or subtracting the distance depending on direction with some code changes.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.