Reading value from 4 digit 7 segment display and get it in integer form.

Hi,
Thats my first question on this forum. a bit new to arduino. here is the problem i am facing. i had the 4 digit 7 segment display its embedded in some other device. i want to read that value displayed on 4 digit 7 segment display using arduino and send it to some other device.
How can i read what value is displayed on 4 digit 7 segment display and get it in the form of integer.

Thanks

please....Urgent help required.

It would depend if you want to get invasive or passive. If you have access to the driver electronics, you could read the digits electronically, but if you don't wish to open up the device you want to monitor, it would be quite difficult I think.

Regards,

Graham

The internal structure of the device is very complex however i have access to the 12 pinouts of the 4 digit 7-segment display of the device. how can i use it to get to get the integer displayed on 4 digit 7-segment.

@ghlawrence2000 can't understand the invasive or passive in this regard ?

Hi hussain,

What I meant by invasive or passive, if you have access to the wiring of the display, you can run those out to your Arduino, that was what I was calling invasive..... If you did not have access to the inside of the box, your only other option was passively decoding the display optically (nightmare!)

Ok, so the 12 wires you are seeing is actually 13, and those are the same wires that you will need to connect to your arduino......... Via a bit of clever logic, you should be able to figure what each digit is.

The schematic of your display will be very similar to the attachment.

Hope this gives you some clues! :wink:

Regards,

Graham

CAUTION!! You have not told us which model of Arduino you are using. There is a high likelihood that your display will be driven with 5 volt logic, if you are using a DUE, then you will need to take appropriate precautions!!!! You have been warned!

Hi Graham,
Thanks alot for your great insight.

I am using Arduino UNO (328P).
is BC547 transistor available easily? whats the rquirement of it?

i think digital_read command is the key in it? am i correct?
can you give any reference in which something like that has been done?

Attached are the pinouts of the 4 digit 7-segment display (12 pinouts).

Once again thanks and looking forward to hear from you.

Regards
Hussain

Your 2 pictures are a good start, but need to see more really. Don't concern yourself with the BC547, since your display board is already a working unit, it is likely it will already have transistors of some sort on it.

To answer your question what are the BC547 needed for : Your 7 segment display has 7 individual LEDS, each taking approx 15mA to illuminate to full brightness, if you display '8' all segments will be lit and total anode/cathode current would be 7*15mA=105mA . What is the maximum pin current of your microcontroller?

This is likely not relevant since your display board is already a functional display, all you need to do is tap off the signal wires and ground and couple them up to your Arduino. However, imagine that you wanted your Arduino to drive that same display, then those transistors are not only required because your Arduino has a limit per pin of 40mA, but if you wanted to get creative, you could also drive the LED at variable brightness, not just 'full on'.

digitalRead() is involved, although there are other ways, that would be the easiest for you to play and learn .....

The problem you immediately face, is whether the 1,2,3,4 pins are active High or active Lo, not that it is a problem, but whichever way around they are, it will affect your programming.

example....

#define inPin1 12
#define inPin2 13
#define inPin3 14
#define inPin4 15
#define inPina 16
#define inPinb 17
#define inPinc 18
#define inPind 19
#define inPine 20
#define inPinf 21
#define inPing 22
#define inPindp 23

int units, tens, hundreds, thousands, finalvalue, number;
bool val1, val2, val3, val4, a, b, c, d, e, f, g, dp;
int readsegments()
{                          //          a
  a = digitalRead(inPina); //         _
  b = digitalRead(inPinb); //    f  /g/ b
  // etc for all the pins  //   e  /_/ c
  f = digitalRead(inPinf); //      d
  g = digitalRead(inPing);

  if ( a && b && c && d && e && f && !g) return 0;
  if ( !a && b && c && !d && !e && !f && !g) return 1;
  if ( a && b && !c && d && e && !f && g) return 2;
  //etc for all digits
  if ( a && b && c && !d && !e && f && g) return 9;
}

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  val1 = digitalRead(inPin1); // =1's cathode/anode ? 1000's cathode/anode
  val2 = digitalRead(inPin2); // =10's cathode/anode ? 100's cathode/anode
  val3 = digitalRead(inPin3); // =100's cathode/anode ? 10's cathode/anode
  val4 = digitalRead(inPin4); // =1000's cathode/anode ? 1's cathode/anode

  if (val1 == 1) // 1= active high 0=active low
  {
    number = readsegments();
    units = number;
  }
  if (val2 == 1) // 1= active high 0=active low
  {
    number = readsegments();
    tens = number;
  }
  if (val3 == 1) // 1= active high 0=active low
  {
    number = readsegments();
    hundreds = number;
  }
  if (val4 == 1) // 1= active high 0=active low
  {
    number = readsegments();
    thousands = number;
  }
  finalvalue = thousands + hundreds + tens + units;
}

You are only expecting 1 of the 1,2,3,4 pins to be high (or low) at the same time, the remaining 3 pins will be low (or high).

The example code is fraught with problems, for example there is no protection built in for if the number changes when you are only half way through reading the 4 digits..... There is no action taken for decimal point or -ve numbers.... But you should have enough of an idea now to get you started ::slight_smile:

Regards,

Graham

Very convenient that the PCB has the pin designations for the displays provided.

The fact is, you do not want to try and decode the multiplexed signals to the display; there are too many complications involved with attempting to match and decode the rapidly changing signals.

What we do want to know is what chips are being used to drive the display? Just follow the connections back, and see also what chips are connected in turn to those. Believe me, that will be much more productive than attempting what you first propose.

More complete photos of the PCB would be of interest - you have done a good job with the photos so far.

Thanks graham and Paul.
i spent alot of time on it. still with some problems
i made minor changes as you guided in the your code.
Now here are results and findings
when 20 is on the display as shown in fig
the output comes out to be as shown in the figure.

i check voltages using multimeter of the 12 pinouts of 4digit 7-segment and it shows
1.5V on pin1
1.5V on pin2
1.5V on pin3
1.5V on pin4
pins A B C D E F G shows like that
if 2 is on display C and F shows 0V
and rest shows 1.1V
but what about 0 with it.
how it is going to read both 2 & 0 (20) together ?

i go back a bit on the circuit inside. there is an IC (circled RED in pic attached) which had connections with the 12 pinouts.
Please help... stuck there....

Regards
Hussain

#define inPin1 2
#define inPin2 3
#define inPin3 4
#define inPin4 5
#define inPina 6
#define inPinb 7
#define inPinc 8
#define inPind 9
#define inPine 10
#define inPinf 11
#define inPing 12
#define inPindp 13

int units, tens, hundreds, thousands, finalvalue=0, number;
bool val1, val2, val3, val4, a, b, c, d, e, f, g, dp;
int readsegments()
{                          //          a
  a = digitalRead(inPina); //         _
  b = digitalRead(inPinb); //    f  /g/ b
  c = digitalRead(inPinc);
  d = digitalRead(inPind);
  e = digitalRead(inPine);  
  f = digitalRead(inPinf); 
  g = digitalRead(inPing);

  if ( a && b && c && d && e && f && !g) return 0;
  if ( !a && b && c && !d && !e && !f && !g) return 1;
  if ( a && b && !c && d && e && !f && g) return 2;
  if ( a && b && !c && d && !e && !f && g) return 3;
  if ( !a && b && c && !d && !e && f && g) return 4;
  if ( a && !b && c && d && !e && f && g) return 5;
  if ( !a && !b && c && d && e && f && g) return 6;
  if ( a && b && c && !d && !e && !f && g) return 7;
  if ( a && b && c && d && e && f && g) return 8;
  if ( a && b && c && d && !e && !f && g) return 9;
}

void setup() {
  Serial.begin(9600);
  
  // put your setup code here, to run once:

}

void loop() {
  val1 = digitalRead(inPin1); // =1's cathode/anode ? 1000's cathode/anode
  val2 = digitalRead(inPin2); // =10's cathode/anode ? 100's cathode/anode
  val3 = digitalRead(inPin3); // =100's cathode/anode ? 10's cathode/anode
  val4 = digitalRead(inPin4); // =1000's cathode/anode ? 1's cathode/anode

  if (val1 == 1) // 1= active high 0=active low
  {
    number = readsegments();
    units = number;
  }
  if (val2 == 1) // 1= active high 0=active low
  {
    number = readsegments();
    tens = number;
  }
  if (val3 == 1) // 1= active high 0=active low
  {
    number = readsegments();
    hundreds = number;
  }
  if (val4 == 1) // 1= active high 0=active low
  {
    number = readsegments();
    thousands = number;
  }
  finalvalue = thousands*1000 + hundreds*100 + tens*10 + units;
  Serial.print(finalvalue);
  Serial.print("\n");
  delay(1000);
}

pic1

had to send pics separately...

pic3

hussain_sheikh:
i go back a bit on the circuit inside. there is an IC (circled RED in pic attached) which had connections with the 12 pinouts.
Please help... stuck there....

No pic attached.....

So are you saying it is reading the numbers right, or not?

You say when 2 is on the display c and f show 0V, that is correct.

What concerns me slightly, is that 1.1V is not logic level "1" or HIGH. Which side of the resistors have you taken to the Arduino? Have you taken the wires to the Arduino from those numbered pins you showed us on the circuit board? I think you are using the LED side of the resistor as your feed to the Arduino, that's why you are seeing 1.1V as high, I think the other side of the resistor should give you the more usual 5V or there abouts.

Can YOU dictate what numbers are shown on the 7 segment displays? What I mean is, for fault finding purposes it would be very useful :slight_smile:

Graham

The IC circled in red is a Latch, I think you can get actual 5V high and 0V low from the pins of that IC which would at least allow the Arduino to see correct logic levels for the segment pins. The next problem is, where is the drive for the 1,2,3,4 pins coming from? Because you have the same problem, we need to be dealing with 5V / 0V, NOT 1.5V which is logically indeterminate.....

As I said in my initial description of my suggested code, it has major problems, as Paul said, it is complex trying to decode multiplexed displays, but not impossible. If you want a challenge and maybe learn something, this a good way of doing it! What I don't think is helping you is the voltage the Arduino is seeing. We can work on improving the code once you know that the levels are good and being identified correctly.

The way a multiplexed display works, is, you set the a-g information on the latch (the red circled ic), then 'strobe' the 1 pin lets say with 5V, and that will light the 'thousands' digit.........., then you turn off the 5V to pin 1, and all digits are off.............. Now you change the a-g information on the latch again, this time you send 5V to pin 2, this time the 'hundreds' digit is lit, turn off the 5V to pin 2, do the same for pin 3, then the same for pin 4, then repeat for pin 1, etc........... It is an illusion that all the digits are on at the same time, they all only light up for a short amount of time.....

This 'short amount of time' is the problem paul is talking about, because synchronising and hoping to accurately read the a-g segment information can be tricky.

Regards,

Graham

Yes, it's a latch all right, and I also see in that photo, a ULN2803, both of which are very conveniently labelled with the segment designations.

I was kind of afraid of this, because it implies the latch is used as an output device for a microprocessor and that means the microprocessor itself is generating all the patterns and the basic data is "hidden" inside. I gather this device is some sort of digital scales; you really should explain what it is and why you want to copy the readings?

OK, you need some "hardware". A "latch" is the clue. For each display, you need a latch - a 74HC165 would be eminently suitable - and a multiplexer such as a 74HC4051. The latch samples the segment data as it goes from the 74HC377 to the ULN2803 as it is at this stage, at logic levels. You then need to feed corresponding digit drive data - again at logic levels - into the 74HC4051 whose "common" terminal strobes the 74HC165 latch enable (active low - if the digit drive signal is active high, it must be inverted). You will need a pull-up on that strobe pin or a pull-down before an inverter.

The Arduino can then - at leisure - select the digit drives one at a time in the multiplexer, wait long enough for that digit to be selected, disable the multiplexer to prevent the data changing, shift out the segment data from the 74HC165 and repeat the process for each digit. Seven pins to do this, an extra pin for each latch/ multiplexer combination you need to add for other displays.

ok let me tell you what i am trying to do here.

i have some load cells and with it its digital indicator(containing 7-segment displays) now i am trying to form a communication between my android tablet and load cell so that i can get the calculated weight reading to my android tablet application via Arduino.

any other suggestions i can get that weight reading to my android without actually opening up the circuit of the digital indicator?

Thanks
Hussain

IP webcam, connected to broadband or wifi router and just use browser on the tablet is probably easiest.

Merry christmas :smiley:

Graham

IP webcam its web video sharing.
How can it perform the required function?
User dont have to enter weight manually it just get data of weight by pressing button on custom application.

http://www.wifiscales.co.uk/

Something like that should do you without messing about with Arduino....

Graham

I shall regard it as "solved" then. :smiley: