Digitally reading analog gauges

analog gauge

While working on his masters degree in controls and robotics, Hack-A-Day reader [Kenn Sebesta] developed a cheap method for digitally reading analog gauges. This method was necessitated by needing to take over 3000 measurements using a dial indicator during his thesis work. The system is implemented in Matlab and uses a webcam to take a picture of the gauge. Once picture is taken it goes through several steps: First, it is reduced to a single color. Then, edge extraction is used to find the lines. Next, the lines are thickened. Finally, the Hough transform is applied to find the longest line: the needle. All that is left to do is measure the arc back to the zero point and match it to your scale. Using this method Kenn’s laptop can take 4 measurements per second.

Comments

  1. joel says:

    interesting… well played lol

  2. Dick says:

    Nice hack, but there are digital dial indicators available for under $30, sometimes under $20 on sale. This one also has a port to connect it to your computer.

    http://www.harborfreight.com/cpi/ctaf/displayitem.taf?Itemnumber=93294

  3. madd_matt says:

    It seems to me like you can do some really intersting things in matlab, i’ve never tried it.

    The student version is $100, which is reasonable. Does anybody have any comments on matlab and its usefulness?

  4. John says:

    Matlab is a fantastic program. I use it a lot at school (working toward mechanical engineering). I would recommend it strongly. After playing around with it you will find that it is very useful for things you hadn’t even considered before. However, the learning curve is pretty steep so be prepared for that.

  5. Kenn Sebesta says:

    “Nice hack, but there are digital dial indicators available for under $30, sometimes under $20 on sale.”

    Hey, thanks for the find! I’ll have to look into buying one of these. However, I still think the matlab script can be really useful as A) only Americans have a harbor freight right next door, god bless its souless corprate soul, and B) once you start dealing with specialty equipement such as 10cm dial indicators, you don’t want to have to dish out hundreds of dollars again.

    Even better, you can use this to measure any kind of dial gage whatsoever. Need a cheap telemetry system for your car on SCCA weekends? Webcam!

  6. zoe adams says:

    Just want to second matlab’s usefulness. If you’re familiar with programming in general the learning curve isn’t that bad, and it’s benefit is how quickly way complex mathematical analysis can be scripted (for example, fouier transforms and laplace transforms are included method) (it doesn’t generate “efficient” code though, no biggie)

    also, we did this digital reading project as undergrads at UC Riverside , cool.

  7. Mark says:

    GNU Octave (http://www.octave.org) is a Free Matlab work-alike.

    By itself, it doesn’t have all the libraries that Matlab comes with, so get octave-forge (http://octave.sf.net) which has many useful libraries.

    I used Octave for my thesis work. It works well.

  8. dan says:

    talk about analog to digital conversion!

  9. Bob Mottram says:

    That’s nice if you have to integrate a computer with some legacy analogue system.

  10. Fred Thompson says:

    Uh…how is “one color” both red and yellow?

  11. kenn sebesta says:

    “Uh…how is “one color” both red and yellow?’

    There’s only one color there, what you’re seeing at is just a false-color image. With matlab, you can set the colormap to be use number of ranges, for instance colormap(gray) will show increasing values as lighter shades of gray, whereas colormap(jet) will show low values as blue and high values as red. So this was probably colormap(hot), which shows things on a reddish-yellowish scale.

  12. justin says:

    This functionality is also in the IMAQ Vision Toolkit for LabVIEW (maybe CVI, too) from National Instruments. It’s pretty automatic. Unfortunately, it’s very not free.

  13. Steve says:

    That’s redic. There’s clearly an area in the example image where there is a ring of black that only the needle passes through, all that needed to be done was to find the bright pixels in this ring…no “longest line” “thickening” “edged extraction” were needed, unless it is just to show off for the prof.

  14. Corey says:

    He said he gets 99% acuracy by reading the gague just like it is now. My thought is that if you used an opaque tape and made a disk that would cover the innermost graduated scale and the short needle, then a second ring to cover the outermost scale it might reduce the number of errors?
    You would then only have one set of lines to measure and they would always be those of the main needle.

    Just a thought {:?D

  15. Kenn sebesta says:

    “That’s redic…”

    While that might be true for this one image, remember that you’re looking at about the best image I had. Many others are *not* so clear, and with a reflection in the glass, you could quite easily have another area of “mass”, which would give you a false positive.

    In fact, a better, more robust algorithm would incorporate your idea, using a barycenter to double check the accuracy of the hough transformation. I didn’t incorporate it out of sheer laziness on my part. The hough transformation is exactly one line in matlab. What you propose is much more complicated, believe it or not.

    What’s surprising about computer vision is that it’s incredibly hard for the computer to do what we do so naturallly. A slight shift in light can totally cripple your image analysis program. feel free to improve upon the program and send me your comments.

  16. lyle says:

    I have to say it would have been much easier to just purchase an LVDT instead of using a dial indicator “connected” to the computer.

  17. Kenn sebesta says:

    “if you used an opaque tape and made a disk that would cover the innermost graduated scale and the short needle, then a second ring to cover the outermost scale it might reduce the number of errors?”

    And a good thought it was! in fact, I did almost exactly this for another experiment, when the face wasn’t quite so big, the light wasn’t quite so good, and the background was green instead of white. We just took the lens off, painted the background white, and put everything back together. Helped out enormously.

  18. Wilks Rendai says:

    Maybe I’m missing something – wouldnt it’ve been simpler to use a DTI with a Red needle, and chroma-extract it, then apply its angle using sin to a fixed profile of the dial?
    Not to be picky! I love overcomplicating hacks too!

  19. skids says:

    Analogue gaugue and LCD/LED digit reading is definitely something there should be dirt cheap rf devices for. But I suppose there are a lot of things there should be dirt cheap devices for :-)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 92,324 other followers