Reading the value from 4digit 7segment display Need Help!!!

Hello Arduino community. I have a problem getting out data from fuel level sensor and using them for further calculations with Arduino Mega.
Problem is that Fuel Level sensor Control Unit have ARM processor and I can not read value from serial port from processor. I thing that simple solution will be to read data from display.

So far I figure it out that display is multiplexed. I red this topic but its not helpful

Please assist.

display_read.ino (2.18 KB)

This is the photo of fuel level sensor computing unit

photo1.jpg

danielkulo:
I thing that simple solution will be to read data from display.

So far I figure it out that display is multiplexed.

Guess you figure wrong then on "that simple solution".

photo2.jpg

Please read this:- How to use this forum it will tell you what sort of information you need to post in order to get a useful answer.

This would normally be a schematic and your software.

Are the signals from the display 5V or 12V? I can't see any ground connection between your display and the fake Mega.

Thank you Paul, Mike that you answer to this topic. I was reading few of your post before.
Im new to this. Sorry for not providing info. My bad.

Display is using 3.3V input. I figure it out with scope that signal between two number is delayed by 2.5 ms. Display is with common cathodes. I mean it should be because segments are turning on when multimeter + probe is on “number pin” and multimeter - probe is the current segment pin. When I try other way around with probes, segments are not lightning up.

Scope picture is included in attachment.

This is the code.

Please tell me what I am doing wrong. I can not get the number from display to serial monitor.

#define inPin1 21
#define inPin2 20
#define inPin3 18
#define inPin4 19
#define inPina 11
#define inPinb 5
#define inPinc 8
#define inPind 6
#define inPine 7
#define inPinf 9
#define inPing 4
#define inPindp 10

int ones=0, tens=0, hundreds=0, finalvalue=0, number=0;
int decimal=0;
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);  //   e  /_/ c
  d = digitalRead(inPind);
  e = digitalRead(inPine);
  f = digitalRead(inPinf); //      d
  g = digitalRead(inPing);
  dp = digitalRead(inPindp);

 
 Serial.print(a);
 Serial.print(b);
 Serial.print(c);   
 Serial.print(d);
 Serial.print(e);
 Serial.print(f);
 Serial.print(g);
 Serial.println();
   
  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);
 
 pinMode(inPina, INPUT); 
 pinMode(inPinb, INPUT); 
 pinMode(inPinc, INPUT); 
 pinMode(inPind, INPUT); 
 pinMode(inPine, INPUT); 
 pinMode(inPinf, INPUT); 
 pinMode(inPing, INPUT); 
 pinMode(inPindp,INPUT); 
  
 pinMode(inPin1, INPUT);  
 attachInterrupt(digitalPinToInterrupt(inPin1), readpins1, FALLING);
 attachInterrupt(digitalPinToInterrupt (inPin2), readpins2, FALLING); 
attachInterrupt(digitalPinToInterrupt (inPin3), readpins3, FALLING); 
attachInterrupt(digitalPinToInterrupt (inPin4), readpins4, FALLING); 
}

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

//  if (val1 == 1) // 1= active high 0=active low
//  {
//    number = readsegments();
//    decimal = number;
//  }
//  if (val2 == 1) // 1= active high 0=active low
//  {
//    number = readsegments();
//    ones = number;
//  }
//  if (val3 == 1) // 1= active high 0=active low
//  {
//    number = readsegments();
//    tens = number;
//  } 
//  if (val4 == 1) // 1= active high 0=active low
//  {
//    number = readsegments();
//    hundreds = number;
//  }

//  finalvalue = (hundreds*100) + (tens*10) + ones + decimal/10;
  //Serial.print(finalvalue);
  //Serial.print("\n");
  //delay(500);
  //println(finalvalue);
 //Serial.println(finalvalue);
}


void readpins1()
{
    decimal = readsegments();
}


void readpins2()
{
    number = readsegments();
    ones = number;
}

void readpins3()
{
    number = readsegments();
    tens = number;
}

void readpins4()
{
    number = readsegments();
    hundreds = number;
}

P.S I don’t know how to put picture in preview mode in the message. Sorry :confused:

Your photograph:-
fb53ae573669a23dd78b41c210f3ad47a62edda5.jpg
Thanks for the code, where is the schematic?

As the code with everything commented out in the loop function you will not see anything in the serial monitor.
Variables used in an ISR and the main body must be declared as volatile. You can not / should not print while in an ISR.

I don’t know how to put picture in preview mode

You can’t, you have to click on the reply box:-
Image guide
image guide

OK, you are getting some of the ideas about how to use the forum. Here is your scope image:
scope.jpg

I can see the logic in your code - you use the cathode drivers as interrupt sources to read each digit. That is the logical way to do it though I cannot see why you have "number" as an intermediary in some interrupt routines and not others. Never mind. :grinning:

The problem which I foresaw, is this: Your scope display (is that a photograph, or virtual?) is apparently showing the drive on two cathode commons. It seems to be quite "stiff", driven by a totem pole. I gather you have "piggy-backed" connections to the display and are attempting to read the anodes. These are red LEDs and their voltage will be about 2.0 V with current limiting resistors between them and the 3.3 V drive. This means they never reach a logic HIGH on a 5 V Mega 2560 (or any other 5 V Arduino).

End of story.

Paul__B, thanks a lot. Scope is showing two 1st and 2nd number pin voltage of 4 of them. And yes, ist a photo. All 4 "number" pins are on the same cathode as well as pins for each segment of the display. I post the photo to show you to see the frequency and the voltage. So is it possible to read those pins with Arduino DUE, because it seems that this model have 3,3 V digital pins?

P.S I don't understand you what do you mean

That is the logical way to do it though I cannot see why you have "number" as an intermediary in some interrupt routines and not others.

Can you please show me in code? I'm trying now to read bits from CPIN register on avr level. I will provide you the code tomorrow.

Also, i will put the schematics for you Paul. Thank you guys for helping me.

danielkulo: So is it possible to read those pins with Arduino DUE, because it seems that this model have 3,3 V digital pins?

Yes, that would probably work, but an alternative would be to use one or two 74HC*T*14s as level shifters. One would probably suffice since you can figure out what the digits are with only six of the seven segments - I leave you to figure out which. A DUE sounds like major overkill. :astonished:

danielkulo: Can you please show me in code?

Yeah! :grinning:

danielkulo: void readpins1() {    decimal = readsegments(); }

Direct read

danielkulo: void readpins2() {    number = readsegments();    ones = number; }

Indirect read. Why?