How to read the state of a 7 segment display - Page 1
Forum section: electronics / beginners

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: November 07, 2015, 03:53:26 pm
content: Hello i want to tackle a clock project but i would like to add Date and ms.The problem is the date on the clock.The concept is when the 4th digit of the year is 0,2,4,6,8 it means that its a leap year so an extra day gets added to the second month(total 29) the problem so far is i would like to complete the project using only logic ICs but i cant figure out how to read the state of the 7 segment display...For driving the display i went with CD74HC4511 the truth table for 0,2,4,6,8 is listed bellow.I tried designing a logic circuit but i could not find a solution on my problem...I understand my explaining of the problem is horrible but the recap is that i cant get the state of where the display read 0,2,4,6,8 so i know to add an extra day on February.Thanks in advance and sorry for the complexity of my explanation

author: Paul Price
author_rank: Super Contributor
timestamp: November 07, 2015, 04:01:22 pm
content: Decoding the 7-seg logic without a MCU is a big-big discrete logic problem and it seems that you haven't even got it that a Leap Year is not every 2-yrs, it is every 4-yrs and even that rule has a problem every four centuries. I could be just a beginner, but you could drive yourself crazy trying to get this to work perfectly with just discrete logic. To get this to work perfectly from any possible start year would require a look-up table identifying leap years and you would need one anyway to determine the day rollover for each of the twelve months. Otherwise, a modulus-4 counter could be preset to the correct 1 of four years on initially setting the clock time and date and get it to work right for a few years.Why in the world would you try to hack out the year from the 7-seg outputs of the 4511, rather than to get the year from the 4511's input pins? There is no need to do this when the year is otherwise easily revealed in the clock's discrete logic keeping count of the current year.

author: Ian.M
author_rank: Super Contributor
timestamp: November 07, 2015, 04:54:01 pm
content: A TTL discrete logic clock is so power hungry that its chances of running for four years uninterrupted are pretty small. A simple slide switch for leap year or not is your best option. In many countries, the user will be resetting the hour for daylight saving twice a year anyway. Its not a great idea to automate that as if you put the 'set' button in the battery compartment, you can force the user to check the backuo batteries for leaks twice a year!

author: Paul Price
author_rank: Super Contributor
timestamp: November 07, 2015, 05:06:19 pm
content: Don't be silly!TTL is a no-no, but a CMOS clock will run forever using just a few microamps. I think watchmakers have figured this out.

author: Ian.M
author_rank: Super Contributor
timestamp: November 07, 2015, 05:24:19 pm
content: Obviously a sane LSI clock design would use pure CMOS, but why did the O.P. link to a 74HCTdatasheet if there isn't TTL in the mix somewhere?Unless it has an external timing reference better than mains frequency, it will likely drift enough each year that manually resetting, and the extra complexity to do hardware daylight saving or implement a radio time signal or GPS time decoder without using a MCU or FPGA is fairly prohibitive, so my advice to put the 'set' button in the battery compartment stands anyway, unless the O.P is going to use a supercap for backup. (Don't use NiMH - they are a reliability P.I.T.A in trickle charged backup applications.)

author: Paul Price
author_rank: Super Contributor
timestamp: November 07, 2015, 05:30:40 pm
content: What is sanity got to do with building a clock from discrete logic?But putting the setup switches in the battery compartment may require removing the batteries to get to the setup switches.

author: Gyro
author_rank: Super Contributor
timestamp: November 07, 2015, 05:34:43 pm
content: QuoteAs usual in these cases, we don't have enough information on how the OP has implemented the rest of the clock circuit - maybe he is using 3v3 CMOS logic, (EDIT:and just using 5V for the display drive), maybe it even includes a basic clock chip.Maybe the OP can give a few more details of his implementation?

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: November 07, 2015, 05:41:28 pm
content: Thanks for your answersWell the first thing is that the clock input will be a simple 555 timer IC or a crystall oscillator followed by 2 dividers to drop the frequency from 4.096MHz to 1Khz (first division 4.096MHz / 2048 = 2Khz second division 2kHz/2 = 1 Khz)Anyway now that is read your answers i am quite skeptical on the whole discreet logic thing ... what is the most efficient analog way to make a clock with an input frequency and have the rest done by analog circuitry ?Open to suggestions thank you.

author: Gyro
author_rank: Super Contributor
timestamp: November 07, 2015, 05:44:59 pm
content: Actually I'm really confused now.... If you're using a 4511 to drive the display, then why are you trying to decode the 7 Segment outputs. You have the BCD input to the 4511 (even if you are using its Latch function then you could latch and decode the BCD externally). It's really easy to decode "0,2,4,6,8" in BCD.

author: Paul Price
author_rank: Super Contributor
timestamp: November 07, 2015, 05:46:36 pm
content: 74HCTxxxx logic chips might be much easier to acquire than some older CD4xxxxx, and chosen not because there would be some TTL chip chosen to complete or complement this conspicuously complexed CMOS circuit circus.Trying to get a TTL 555 to run at 4MHz might be crystal-clear concept that is completely compromising your clever clock-calender's capability.

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: November 07, 2015, 05:53:33 pm
content: Quote from: Gyro on November 07, 2015, 05:44:59 pmExcuse me but i cant explain things well.I would like to tap off the values going to the display driver so i can know what the screen is showing

author: Gyro
author_rank: Super Contributor
timestamp: November 07, 2015, 06:00:07 pm
content: Ah, ok, sorry. From the post title and original post I was thinking that you were trying to decode the 7 signals going to the display itself. Decoding the 4 bit BCD data shouldn't take too much logic.P.S. Your simplest / Easiest decode would be to use a 74HC(T)42 BCD-Decimal decoder and a few diodes and a pullup resistor to OR the outputs that you want (if you're cheap, like me), alternatively an external 8 input NAND gate (HC30) to 'NOR' them - the 74HC42 outputs are active Low. That way you can select whatever digits you want.

author: Ian.M
author_rank: Super Contributor
timestamp: November 07, 2015, 06:29:06 pm
content: If one wants 5V logic, 74AC, maybe mixing in some 4000 series if you cant find all the functions you want in AC, will have pretty low power consumption.There is absolutely no need to start from 4.096MHz, use a 32.768KHz crystal and divide it down using a 74HC4060 oscillator/divuder chain chip. That gives you 2Hz out for timekeeping, and intermediate outputs including 1024Hz and 2048Hz suitable for an alarm beeper, and 512Hz for display multiplexing. If you really need finer timekeeping than 1/2 second, a 1.6384MHz cristal gives you 100Hz out of a '4060, suitable for 1/100 second timing, with either 200Hz or 400Hz for multiplexing and 1.2KHz or 2.4KHz for the beeper.The *ONLY* possible use for a 555 is in a test jig to crank up the clock's timekeeping pulse so you can check various counter rollovers and alarm triggering faster than realtime, but a simple jumper to take a different divider output tap from the '4060 would be vastly preferable so leave the 555 in the parts draw!An all electronic analog clock is *much* *much* worse - its a mess of charge pumps and comparators and you'll be hard put to divide by more that 10 in one stage. Analog decoders for a digital readout are even worse - each individual number needs its own window comparator so that's 10 for a decimal digit. Multiplexing the readout to drive the display is no picnic either! Analog clocks only get simple when all the HHMMSS counting and display is done by mechanical gearing

author: Gyro
author_rank: Super Contributor
timestamp: November 07, 2015, 06:35:25 pm
content: Ugh, no! 74AC and 4000 series mixed??? AC is too fast to use reliably without a ground-plane and 4000 series is too slow to meet the minimum edge rates on AC logic clocked devices, latches etc.Edit: and 4000 series doesn't have input clamps good enough to handle under / overshoots from AC logic. Sitck with HC and HC

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: November 07, 2015, 06:47:57 pm
content: i wanted to get excaclty 1KHz out so i can output milliseconds as well as seconds too

author: Ian.M
author_rank: Super Contributor
timestamp: November 07, 2015, 07:01:21 pm
content: @Gyro: My mistake - I was thinking HC but typed ACIf one does need to do that, you are right, it gets messy. Series resistors to protect the input clamps going one way and Schmidt triggers or even comparators with extra hysterisis going the other.@Chris: The '4060 can give a 1KHz output from a 1.024MHz or 4.096MHz crystal. Some modern 74HC4060 datasheets are unintelligible (e.g. NXP). The Fairchild one still gives the internals of the divider chain and the number of clock pulses to flip a particular output in the timing diagrams.https://www.fairchildsemi.com/datasheets/MM/MM74HC4060.pdfThe TI one isn't bad but doesn't give as much detail as the Fairchild one.

author: Kalvin
author_rank: Super Contributor
timestamp: November 07, 2015, 07:09:29 pm
content: I am a bit confused tooIf I have understood you correctly, you are building a clock using discrete logic. The clock is to display seconds, minutes and hours. You will also make a logic to display days, months and years. For the display driver you are using 74HC4511s, which will take a BCD digit in and drive a 7-segment display.Now, your problem seems to be how to detect a leap year (which is by the way every fourth year unless the year is divisible by 100) and add one extra day for February.So, you just need to detect whether the year is 04, 08, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60 ... etc. You should see the pattern here.

author: Gyro
author_rank: Super Contributor
timestamp: November 07, 2015, 07:26:02 pm
content: QuoteHaha, glad it's not JUST me who does that!Luckily most of the 'useful' 4000 unique chips got duplicated as 74HC4xxx. I dread the day that HC gets hard to find!

author: Richard Crowley
author_rank: Super Contributor
timestamp: November 07, 2015, 07:42:03 pm
content: Quote from: ChrisGreece52 on November 07, 2015, 03:53:26 pm"ms" = milliseconds? The numbers will fly around so fast you can't see them!QuoteNo. Leap years happen every 4 years. You cannot determine leap year by simply looking at the unit's digit.There are even more rules than that, but it seems unlikely that your clock will still be running when the next exception occurs (in 2100)You could have looked up:https://en.wikipedia.org/wiki/Leap_year#AlgorithmQuoteSorry, that just does not make any sense. You already HAVE the BCD digit to feed INTO the 4511.Why on earth do you think you must DECODE the 7-segment levels to recover the BCD digit. Makes zero sense.QuoteYou will need to explain to us why you think you want to do something like this. It makes no sense.QuoteCan you explain to us WHY you want to construct a clock circuit like this? This method has not been practical since perhaps before you were born.A 555 timer chip is completely impractical as a timing source for any kind of clock.And, unless you use an above-average crystal oscillator (or one made specifically for clocks), it will also have significant drift.QuoteWhat do you mean "analog circuitry"? Nothing you have been discussing is "analog" in any sense of the word. This is really confusing.

author: Gyro
author_rank: Super Contributor
timestamp: November 07, 2015, 07:58:06 pm
content: QuoteWe already clarified that one earlier in the thread, the OP was intending to decode the BCD, not the 7 segment signals. That's what he was saying in your next quote. Language issue.

author: RogerRowland
author_rank: Regular Contributor
timestamp: November 08, 2015, 07:24:39 am
content: Regarding digital clocks and 4000 series CMOS, which may have some helpful insights, I guess you've seen this?

author: German_EE
author_rank: Super Contributor
timestamp: November 08, 2015, 10:36:04 am
content: You did not say if the LED displays that you are using are common cathode or common anode, but for this reply it does not matter.Connect the seven segment drive lines to the address inputs of an EEPROM, you can feed two digits in given the number of address lines on a 1Mb device. One pin on the data lines can be programmed to change state when it is a leap year. If you have a two digit year display then you only need to program 99 addresses.http://www.atmel.com/Images/doc0353I.pdfAll done in one chip, no microprocessor required

author: Kalvin
author_rank: Super Contributor
timestamp: November 08, 2015, 11:42:12 am
content: Quote from: German_EE on November 08, 2015, 10:36:04 amActually OP is not trying to read the lines driving the 7-segment display, but the BCD coded signals driving the display driver. There was some sort of terminology issue, and OP did made a correction in later posting. I was confused as well.Anyway, using a EEPROM/EPROM/Flash as a programmable logic chip is almost like cheating here.Creating a logic for detecting a leap year from BCD numbers is not that difficult, as I tried to hint in my previous message.

author: German_EE
author_rank: Super Contributor
timestamp: November 08, 2015, 12:15:16 pm
content: Cheating?Me?I learned tricks like using EPROMs as programmable logic from an expert, a guy who could look at a PC card and tell you what each chip did without even a schematic or a block diagram. This was a man who used EPROMs as frequency dividers and 16:1 multiplexors as 16 bit memories, the guy was a wizard of logic.

author: Gyro
author_rank: Super Contributor
timestamp: November 08, 2015, 12:58:29 pm
content: Me too, I've used them for implementing relay attenuators. Usually free to implement because I have loads of old EPROMS in my junk box.

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: November 08, 2015, 03:06:12 pm
content: Quote from: RogerRowland on November 08, 2015, 07:24:39 amThats where i got the idea!

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: November 08, 2015, 03:12:44 pm
content: Quote from: German_EE on November 08, 2015, 12:15:16 pmI would not like to your EPROMs because i dont have the knowledge im an electronics engineering at my second year and we just now got to learn about Boolean algebra .... i dont consider myself to be in a hobbyist level but i am not a pro ... so yeah ill stick with simple stuff for now

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: November 08, 2015, 03:41:45 pm
content: Quote from: Richard Crowley on November 07, 2015, 07:42:03 pm