Go Down

### Topic: 7-Segment Display Wiring and Programming (Read 101945 times)previous topic - next topic

#### guitarboy667

#15
##### Dec 23, 2010, 08:06 am
So would 4 AA or similar batteries in series be a suitable power source? I saw the voltage is typically 6 volts per segment.

That would have a ~3 A current? So then a resistor of roughly 2 Ohm? That can't be right.

So then I have a wire going from each of the segments to the shift register (which pins of the register?). I have one wire going from the Arduino to the shift register. I have a common ground that would connect to the battery, the 7 segment, and the Arduino. Could I get away with a resistor only between the battery and the 7-segment display? Is that how it is connected?

#16
##### Dec 23, 2010, 09:26 am
4 AAs would probably be marginal, as soon as they dropped a little you'd be out of voltage. 5 would be okay. You could power the arduino from batteries 1-3 (4.5V into VCC, not Vin), and the segments from batteries 1-5 (7.5v). I have used 3 AAs like this, the arduino was still going well at 4.25V.
So if you had 5 batteries, thats 7.5V, less say 6.5V for a segment, that's 1V across the resistor and transistor of the shift register, so you'd see maybe 0.5V across the resister.
So with ohms law, V=IR, V/I = R => 0.5V/0.02A = 25 ohms. 27 or 33 are  standard values.
You need a resister per segment of each LED if you are using shift registers. More below on why 1 resister per segment.
If you had all segments on in 1 digit, that would be 140mA.
How many digits were you planning on? I don't recall.

You have 3 wires going from the arduino to the shft registers, assuming you have the output of one shift register feeding the input of the next.  The shift_out_clock goes to each part. The shift_data_out goes to part1, its output goes to part 2, etc.
To prevent a bunch of flickering while all this shifting is going on, you also have a load_data line that moves the data from the input shift register to the output drive pin so all the displays update at once.   Then you shiftout bytes until all digits are shifted, and toggle the load line to update the outputs.
The other option is to use more wires, and shift to each digit individually.
Have a common shift_data_out, shift_clock, but individual load_data to each part for the actual output update.

Wire up your shift register - which one are you using? tpic6b595 open drain shift register, which can take higher output voltages (the voltage will go up to the battery voltage when the pin is high)? Or a standard TTL/CMOS part, in which case you will need an NPN transistor like I showed in an earlier post.
Select the mapping you want to use, maybe this:
bit 7 = decimal point
bit 6  = segment G
bit 5 = F
bit 4 = E
bit 3 = D
bit 2 = C
bit 1 = B
bit 0 = segment A
Then to turn on a segment, a bit = LOW will equal a segment turned on for the tpic6b595,
or if the shift register drives a transisor as shown earlier, a bit = HIGH will equal a segment turned on.
Lets go with HIGHs:
for #1, data out for a shift register would be 0B00000110 for segments B & C
for #0, 0B00111111 for segments A,B,C,D,E,F
for #7, 0B00000111 for segments A,B,C and so on.
for L,   0B00111000 for segments D,E,F, and so on.

You have 7.5V  going to the common ANODE of each digit, the segments go thru resistors to the shift register, the battery- goes to the arduino ground.
You could try just 1 resister between the 7.5V and the ANODE of each digit, but you will find the segments changing brightness as the different segments turn on & off. 1 or 2 segments vs 5,6,7 segments all sharing the same 20mA, you see? And you have to limit for the least amount of segments on so you don't burn it out.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

#### guitarboy667

#17
##### Dec 26, 2010, 11:32 pm
I will be using 8 digits. There will be two different 4-digit numbers, so essentially two different displays, so I think it'd be easier as far as programming is concerned to wire those two separately?

I have the 9 volt pack thing for the Arduino.

So I think I follow all that. I may just wire each individually, but idk which would be easier to code. I have a keypad that the user inputs numbers on and I want to display the user's input on the display one number at a time, so they know that their input has been registered. I also need to simply display 4 digit numbers arrived at in different parts of the code as well. Whichever wiring would work best for that would be good.

At this point I supposed I'll just need to translate the input and calculated digits into outputs for the display. With the user input I could have several if then statements that say, for example, if button "1" is pressed then output
for #1, data out for a shift register would be 1B11111001 for segments B & C, but that seems a little sloppy.

Then the other portion will be converting say 3097 into data to be sent to the shift register.

I was planning on using the tpic6b595 open drain shift register you suggested.

#18
##### Dec 27, 2010, 12:10 am
"9 volt pack thing" what is that? The 9V wallwart?

With the mega, you have plenty of IO, you can have separate control pins for each shift register.

Take a look at this code. I totally do not get how the first highlighted part sets up the shift register for the second highlighted part to display digits, but am told it works.

Code: [Select]
`unsigned long currentmillis = 0;unsigned long previousmillis = 0;unsigned long interval = 10;int latchpin = 8; // connect to pin 12 on the 74HC595int clockpin = 12; // connect to pin 11 on the 74HC595int datapin = 11; // connect to pin 14 on the 74HC595int ones_seconds = 0;int tens_seconds = 0;int ones_minutes = 0;int tens_minutes = 0;int tenths = 0;int hundredths= 0;[glow]int segdisp[10] = {  63,6,91,79,102,109,125,7,127,111 }; //segment references using 74HC595 Shift Registers//The above numbers light up different segments of a digit[/glow]int time_update = 0;// added new flagvoid setup(){  pinMode(latchpin, OUTPUT);  pinMode(clockpin, OUTPUT);  pinMode(datapin, OUTPUT);}void loop(){  currentmillis = millis();  // read the time.  if (currentmillis - previousmillis >= interval) // 10 milliseconds have gone by  {    previousmillis  = currentmillis;  // save the time for the next comparison    time_update = 1;    }  // set flag to upate & shift out  if (time_update == 1){  // no updating if not at 10ms interval, skip this whole section    // increment the counters, roll as needed, shift the digits out    time_update = 0; // reset for next pass thru    hundredths = hundredths +1;    if (hundredths == 10){      hundredths = 0;      tenths = tenths +1;    }    if (tenths == 10){      tenths = 0;      ones_seconds = ones_seconds +1;    }    if (ones_seconds == 10){      ones_seconds = 0;      tens_seconds = tens_seconds +1;    }    if (tens_seconds == 6){      tens_seconds = 0;      ones_minutes = ones_minutes +1;    }    if (ones_minutes == 10){      ones_minutes = 0;      tens_minutes = tens_minutes +1;    }    if (tens_minutes == 10){      tens_minutes = 0;    }[glow]    // counters are all updated now, just do the shiftout one time here:    digitalWrite(latchpin, LOW); // send the digits down to the shift registers!    shiftOut(datapin, clockpin, MSBFIRST, segdisp[hundredths]); // print the % first "hundredths" digit    shiftOut(datapin, clockpin, MSBFIRST, segdisp[tenths]); // print the tens of hundredths digit    shiftOut(datapin, clockpin, MSBFIRST, segdisp[ones_seconds]); // print the % first "seconds" digit    shiftOut(datapin, clockpin, MSBFIRST, segdisp[tens_seconds]); // print the tens of seconds digit    shiftOut(datapin, clockpin, MSBFIRST, segdisp[ones_minutes]); // print the % first "minute" digit    shiftOut(datapin, clockpin, MSBFIRST, segdisp[tens_minutes]); // print the tens of minutes digit    digitalWrite(latchpin, HIGH);[/glow]  } // end if time to be updated} // end void loop`
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

#### guitarboy667

#19
##### Jan 01, 2011, 08:13 pm
http://www.sparkfun.com/products/734

Is this the shift register you recommend?

#20
##### Jan 01, 2011, 09:47 pm
Yes - altho you can find it less expensively if you look around.
Example,
http://parts.digikey.com/1/parts/527098-ic-pwr-8-bit-shift-regis-20-dip-tpic6b595n.html
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

#### guitarboy667

#21
##### Jan 08, 2011, 10:48 pm
Alright, so I think I understand the wiring. I just want to tackle this stage before I start code.

So is the 1 pin of the 7-segment display the positive and the 5 the negative or vice versa?

Or are both positive? I think it's that, right?

So then the wiring for the rest of the 7-segment is, for example,
DRAIN0 (on shift register)-33 OHM Resistor-Pin 7 on 7-segment display

(The batteries I'm using actually are 1,500 mAh)

I have a common ground to the shift register (just to one of the GND pins, right?), battery pack, and Arduino.

So the SER IN is the shift_data_out line and SER OUT goes to the next SER IN.

I assume that the pins of the Arduino for the shift_data_out line, shift_out_clock line, and the load_data line don't matter?

I think I'm just a bit confused about those 3 lines in general.

I believe I understand the shift_data_out line.

What pins on the shift register does the shift_out_clock line and  load_data line go to?

#22
##### Jan 09, 2011, 11:50 pm

So is the 1 pin of the 7-segment display the positive and the 5 the negative or vice versa?
Or are both positive? I think it's that, right?
>> Both pins 1 & 5 go to the positive of the supply.  They are internally connected on the device.

So then the wiring for the rest of the 7-segment is, for example,
DRAIN0 (on shift register)-33 OHM Resistor-Pin 7 on 7-segment display
>> Yes.

(The batteries I'm using actually are 1,500 mAh)
>> If you have all 7 segments of a digit on, that's 7 x 20mA = 140mA, I don't remember how many digits you have altogether. 4? Then if you all 4 displaying "8888" you can expext to draw 560mA, you will get maybe 3 hours of life form 1500mA batteries.  Most likely longer as you will have fewer segments on at any one time.

I have a common ground to the shift register (just to one of the GND pins, right?), battery pack, and Arduino.
>> Connect all 3 grounds from the shift register.

So the SER IN is the shift_data_out line and SER OUT goes to the next SER IN.
>> Yes.

I assume that the pins of the Arduino for the shift_data_out line, shift_out_clock line, and the load_data line don't matter?
>> Correct.

I think I'm just a bit confused about those 3 lines in general.

I believe I understand the shift_data_out line.

What pins on the shift register does the shift_out_clock line and  load_data line go to?
>> shift_out_clock goes to SRCK
>> Low on SRCLR will clear the input register, tie it high if not used.
>> Low on G will enable the output transistors so 0s & 1s will show up on your display. With G high, no outputs will turn on.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

#### guitarboy667

#23
##### Jan 11, 2011, 04:38 am
I finished the wiring, but I'm not getting any response to the code. I imagine the other code is only for that shift register mentioned and I'll need to do a lot more work to get this one running.

I currently only have one display connected. I wanted to make sure this way works before I made more.

#24
##### Jan 11, 2011, 05:19 am
Post your code and a schematic of what you have so far, I'm sure we can get you going.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

#### guitarboy667

#25
##### Jan 12, 2011, 04:38 am
Wait, do I need to connect the positive of the battery power to Vcc?

#26
##### Jan 12, 2011, 05:33 am
Basically this is the idea, plug your parts in the correct places.
You may not need the diode to drop the voltage a little to the shift register, the recommended  operating voltage is 5.5, absolute max is 7, so you may be okay with just the 4 batteries as the 1.5V/battery will drop some as they are used.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

#### guitarboy667

#27
##### Jan 12, 2011, 07:35 pm
So I can not use SRCLR by tying it high meaning connecting it to 5V? And I don't have to do anything with G?

I just connected Vcc to the Arduino's 5V.

#### guitarboy667

#28
##### Jan 12, 2011, 07:43 pm
Is either SRCK or RCK connected to ground?

#### guitarboy667

#29
##### Jan 12, 2011, 07:47 pm
Basically I just need to know which is clock, data, and latch.

I assume data is SER IN, but I don't know which of the other two is which.

Go Up