Let's Make Robots!

Capturing Data from 7-Segment Display

Something I've wanted to do for a while is to be able to digitize the data from cheap sensors with a 7-segment display.

I decided to give it a try with some USB charge meters.

I purchased four of these meters.

I opened up one of the blue ones and probed the pins to see how the 7-segments were wired.

The display was controlled with anodes for each of the 8 (includind decimal point) segments and each digit was controlled with a single cathode. There were 12 pins cotrolling the LEDs but I didn't want to use 12 I/O pins to monitor the display so I used a couple 74HC165 parallel to serial shift registers.

I initially wrote a driver in Spin but It was clear the segments were on for a very short amount of time so I switched over to assembly.

The code still never "sees" a "v" so I'm not sure if I have a bad connection somewhere or if the voltage levels from the display don't trigger the '165 chips.

I added some pull-up resistors to the pins in hopes of getting better logic states to capture. I think the pull-up helped.

I had some resistor networks which made the job of attaching a bunch of pull-ups a lot easier.

Since I now had access to both the current and the voltage, I could compute the Watts. I could also use a microcontroller to keep track of time and add time dependent parameters to my new meter.

I took Ladvien's advice and used an OLED from ITead Studio. Since the OLED uses 3.3V and draws less then 20mA when displaying a bit of text, I plugged the OLED display directly in the QuickStart's header and powered the display from an I/O pin.

I'm using the display in SPI mode since the object I found for the display used SPI. (I had tried adapting the object to I2C but my I2C version didn't work as well as the SPI code.)

 

I was powering the above meter and QuickStart from four AA NiMH in the black battery box. The OLED is displaying the data from the meter (top left) and the time dependent parameters.

I'm not sure if this is a practical way of reading current and voltage but it was something I'd been wanting to try.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

I knew the propeller did not have ADC but this is.....  Different!

Except as a learning exercise I am not sure I see the point. As a learning exercise I say well done.

This was one of those dumb ideas I couldn't get rid of.

I have a bunch of these sorts of cheap meters and I've often wished they had a digital output so I could log the data.

As I said in the last sentence of the blog, I wasn't sure this was a practical way to measure voltage and current with a microcontroller but I think there are some sensors with 7-segment displays which don't have an easy to interface counterpart in the same price range as the versions with 7-segment displays. For example there are some relatively inexpensive blood oxygen monitors with 7-segment displays. Similar monitors with digital output are much more expensive (at least they were the last time I checked). In this case it would be less expensive to tap into the 7-segment display than to purchase a monitor with digital output. There are probably other sensors where the only inexpensive alternative are versions with 7-segment displays (though I can't think of any others right now). This technique should allow these devices to be monitored with a microcontroller.

While there may be some practical applications for this technique, the main reason I did this was because I couldn't get the idea out of my head.

If an "earworm" is a song you can't get out of ones head, maybe this should be called a "brainworm" since it was an idea I couldn't get out of my head. (There's probably a real name for this sort of thing.)

Back in the days when dinosaurs (8080s and 6800s) ruled the earth, it was fairly common to use chips with 7 segment outputs as micro peripherals.  ADCs were rare and expensive, but a 3 1/2 digit voltmeter chip was relatively cheap.  Since the output was multiplexed 7 segment, similar things had to be done.  One way was to use each digit strobe to strobe the 7/8 segment bits into a latch, then read all 3/4 latches while they were steady.  This was usually a special interface and no LED display was attached.  Voltage levels can be converted using comparators.  That might be better than pullups.  In those days, memory (ROM / EPROM and RAM) were quite expensive and small and processors were slow.  So, some people used calculator chips (with 7 seg LED outputs) to do their math.  It was easier and cheaper, and sometimes even faster, than doing it in code, especially if you needed scientific calculator ability.

Anyway, enough reminiscing.  Cool project and very handly.  Pretty ingenious of you.

I like the idea of incorporating the calculator IC into the system. I never thought of using a calculator IC as a math co-processor when I played with the Z80.

I wish I could have gotten a clean read on the segments with a logic analyzer but my Saleae wouldn't read the segments. The '165 chips couldn't read the segments with the Saleae attached either.

The assembly code ignores any reads which don't produce a full character. This might be why I never see the "v" character. The three segments might not all be displayed at once.

If I had some comparators and latches and knew how to use them, I'd give those a try. Maybe I should get some some and learn something new (or would that be learning something old?).

I suppose I could "or" some reads together to see if a "v" ever shows up.

As it is, the code watches for an "A" and kind of guesses based on time when to read the volts. This usually works but sometimes it thinks there are 5+ amps and just a few millivolts.