Autodidact Ambitions 2 – Back to Step A

by | Apr 30, 2024 | LifeSkills, Pastimes, Technology | 78 comments

So to recap, I was trying to make a clock. I had acquired a Texas Instruments Launchpad for developing code to put on their MSP430 family of microprocessors. I had code that was blinking an LED on the Launchpad on intervals determined by the chip’s internal timer. Fantastic, now I can look at wiring up a circuit so that does something.

By this time, I had my shipment of parts, and that included the seven-segment display. That’s when I learned a few things about seven-segment displays I was previously happily ignorant of. To start off, they’re literally a bunch of LEDs in a brick. But, since having individual pins for each LED’s two leads would be a bit of a pain for everyone, they will tie all of one side together into a common pin and let the end user control the LEDs with the other end. This results in there being two main variants of seven-segment displays – common anode, and common cathode. In a common anode setup, each LED has its own ground pin, with a single positive pin for the lot. In a common cathode setup, there is one ground pin and a stack of positive pins.

You all (should) know what a digital clock display looks like, each digit is made up of seven straight lines, thus giving the seven-segment display its name. If I have a four-digit model that means…

Okay, so, why are there fourteen pins?

Well, first up, there are actually thirty-four LEDs in this brick, four digits with seven segments and a dot in the lower right each, and two for the colon separating the two pairs of digits. I meant it when I said it looked like a clock display. I have a common cathode setup, so we have… five cathode and nine anode pins. What’s so common about that? Truth is that the ‘common anode’ and ‘common cathode’ configuration refers to each digit in the brick. Each one gets a single pin of the common type for its own collection of lights and shares the pins on the other end with the other three digits. If I were to hook all five of the cathode pins to ground and start putting power into the anode pins we would see the same segment light up on all four digits with the exception of the colon. Turns out the two LEDs in the middle get their own separate circuit unrelated to the sharing going on between the digits.

So how in the heck do you display anything that isn’t four of the same digit?

You have to rely on the human eye and the brain’s laziness. Basically, if you cycle through lighting up each digit fast enough, the viewer sees them all as being on at the same time. How do we coordinate toggling so many pins together? Well, that sounds like a job for a shift register, and I just so happen to have figured out how to use those. Okay, actually, it sounds like a job for two, since we’ve got to control thirteen pins. Why only thirteen? Well, the colon has only two states, it’s either off or on, so one end can be connected directly to either the power or ground, and we can control it from the other pin.

While reading information related to my display, I found that the common cathode was known to potentially have voltages higher than the individual inputs because of the tied circuitry. That’s okay, I got a new type of shift register to play with. The TPIC6B595 was recommended by another Glib during the first shift register discussion, and it has the distinction of operating differently to the existing SN74HC595 I dove into there. Both have the same logic under the hood (the 595 common to their names) but the method of operation was different. The SN74 pushes current to downstream components (under the model where current flows from the positive to the ground), while the TPIC sinks the current to ground. Among the differences was that the TPIC was rated for higher voltages, since it segregated the logic from the current being controlled. It could go up to 50 volts on attached devices. That was well beyond what I risked getting up to. Together, the SN74 and TPIC were the ideal pair to drive this display – and I had both to work with.

So, I got out my breadboard and began wiring.

I had learned in my research on the display that the 220Ω resistor in front of the LED was indeed to take the 3.3 volt current I ran off of down to something within the operating range of the light. I also decided I wasn’t going to use the dot off to the lower right of any of the digits right now, so I lined up seven lines to seven LEDs to feed… which pins?

Looks like a Clock. Perfect.

It took a frustrating amount of time to figure out that part. While the datasheet did tell me which pin number ran where, nowhere did it say which pin was which number. With the help of a multimeter and a YouTube video I eventually sorted out that the pins were numbered in the same convention as with ICs, that is, counterclockwise when looking down from above. So, what’s with that ’13, 9, 4, 2, 1, 12, 5, 3′ order for the segments? Simple – that pinout means the wires inside the brick are as short as possible, using the least material for the manufacture of the display. So, I was unable to get a neat and orderly set of jumper lines from my regimented row of resistors, as tying them to the proper pinout resulted in a nest of wires. Since there was nothing dictating which pin on the shift register tied to which pin on the display, I took the opportunity to line up the bits in a way that made sense to me. Left to right across the row of resistors I connected to EDCGFAB, creating a serpentine. So long as I mapped the bits correctly for my wiring, the order was arbitrary. And I wasn’t exactly using someone else’s code.

So, with it all wired up, I connected the breadboard to the Launchpad (which, like an Arduino has jumper pins for this very purpose) and hit ‘debug’ on CCS.

And nothing happened.

On that cliffhanger, I leave you until the next installment, as we dig into debugging.

About The Author

UnCivilServant

UnCivilServant

A premature curmudgeon and IT drone at a government agency with a well known dislike of many things popular among the Commentariat. Also fails at shilling Books

78 Comments

  1. UnCivilServant

    It’s actually been so long since I wrote the first few of these that I’ve forgotten what was in each article.

    I also hope that I made sense…

    • EvilSheldon

      It did to me, so you should be fine. From your description, I think that I even know what you did wrong…

      • Ownbestenemy

        Same. Good work UnCiv

      • UnCivilServant

        So, what do you think happened?

      • EvilSheldon

        It’s a little hard to tell, but it looks like you may have connected the common cathodes on your LED module directly to the drain pins on the TPIC. That’s not going to work. You need a pull-up circuit that will pull the cathode up to +3.3V until the drain grounds it.

      • UnCivilServant

        I’m afraid it was sillier than that.

      • UnCivilServant

        Part of me wants to tell you what the issue turned out to be – but that’s also a large chunk of the next article, so I don’t want to spoil it.

      • EvilSheldon

        Don’t spoil it! I need something to look forward to on Tuesdays!

  2. Not Adahn

    I connected to EDCGFAB

    RUFKM? I saw FYC and KMFDM at CBGB. IYKYK. YKINMKBYKIOK.

      • Sean

        I think you meant CTFO.

    • ZWAK will kindle all of the dreams it took a lifetime to destroy

      It’s CBGB&OMFUG, Shitlord!

      I can’t even with this.

    • Gender Traitor

      EDCGFAB

      I think that’s actually an alternate guitar tuning Joni Mitchell used for a few of her songs (I forget which ones) on a 7-string guitar that Martin custom-made for her.

    • rhywun

      Are you having a stroke?

      • Not Adahn

        TANSTAAFL.

    • Fatty Bolger

      ASUFUTIMAEHAEHFUTBW. – Joe Biden

  3. juris imprudent

    Tried to post this in morning links, try again here.

    Interesting perspective, and the materialism aspect is focal both to old-school Marxists as well as capitalists (which delivers the prosperity, but destroys even as it creates).

  4. The Other Kevin

    Once again you’re giving me flashbacks from my college days. I used 7 segment displays a lot back then. Since you’re interested, have you picked up an old digital circuitry textbook? I’m not sure if they teach this stuff now, but they did back in the early 90’s.

    • UnCivilServant

      I’ve been beating my head against the brick wall of problems because the unstructured learning is more fun.

      I porbably should invest in something along those lines, like I did for the MSP430, but my personality flaws get in my way,

  5. Richard

    “EDCGFAB”

    I’ve never been able to “hear” music by looking a score. What’s that sound like when strummed on a guitar?

    • Gender Traitor

      (Note to self: when late to a thread, read through ALL the earlier comments before opening your mouth keyboard.)

      • Richard

        I just assumed that great minds think alike.

      • Gender Traitor

        🤜🤛

      • UnCivilServant

        Wait, you’re getting ready to fight?

  6. Richard

    I’ve spent some time inspecting your nicely-formatted featured image. I see the source and sink shift register chips. When I do breadboarding I try to reserve red and black wires for VCC and ground so your production looks ALL WRONG to me. Yes, I hate looking at other people’s code too, despite how good it may be.

    • UnCivilServant

      The jumper wires in the breadboard are color coded by length.

      The bodge wires that show up to be soldered on later are color coded to standard for power and ground.

  7. Yusef drives a Kia

    Ever try multiplexing? Timer interrupts?
    The old Forrest Mims books are a great reference, have fun!

    • UnCivilServant

      It’s a clock, it throws a timer interrupt every second so I can update the time.

  8. juris imprudent

    You know UCS, I have to hand it to you – no one else would be bread-boarding in one article and forging iron in another. For a bureaucrat you’re an exceptionally creative guy.

    • UnCivilServant

      Thank you. Though I suppose having a day job that doesn’t fill my mental needs might actually contribute.

      Funny you mention it. I just found my anvil… all 2lbs of it. I should figure out how and where to get a forge set up.

    • Not Adahn

      Wait ’til he starts drawing his own wires.

      • UnCivilServant

        I did once start making chainmail.

        Then I realized fusing each link was tedious.

  9. Gustave Lytton

    if you cycle through lighting up each digit fast enough, the viewer sees them all as being on at the same time

    Cue video of flickering LCDs.

    • UnCivilServant

      Exactly! The cameras are never synched to the refresh cycle of the displays.

    • EvilSheldon

      You can often see this in cheap red-dot firearm optics, that use PWM to control the dot brightness instead of current regulation.

  10. kinnath

    US drug control agency will move to reclassify marijuana in a historic shift, AP sources say

    The U.S. Drug Enforcement Administration will move to reclassify marijuana as a less dangerous drug, The Associated Press has learned, a historic shift to generations of American drug policy that could have wide ripple effects across the country.

    The DEA’s proposal, which still must be reviewed by the White House Office of Management and Budget, would recognize the medical uses of cannabis and acknowledge it has less potential for abuse than some of the nation’s most dangerous drugs. However, it would not legalize marijuana outright for recreational use.

    Chicken shits

    • kinnath

      Once OMB signs off, the DEA will take public comment on the plan to move marijuana from its current classification as a Schedule I drug, alongside heroin and LSD. It moves pot to Schedule III, alongside ketamine and some anabolic steroids, following a recommendation from the federal Health and Human Services Department. After the public comment period and a review by an administrative judge, the agency would eventually publish the final rule.

  11. Timeloose

    Your project is interesting and I’m really enjoying it. I’m two levels below the PCB in my 9-5, so I have more fun figuring out how the chip is working.

    However, I have a analog brain, so I want to re-make the clock refresh cycle with a RC circuit and some MOSFET transistors for ladder logic.

    • UnCivilServant

      Which direction is below the PCB?

      • Timeloose

        From a product perspective: The clock (system) is top level, the PCB (schematic) is the next lowest, then the individual components, followed by the active or passive element(s) in the components, then finally the refined materials that makes the components, followed by the raw materials used to make the components.

      • Richard

        I just read about this. With one hand orient the PCB according to the galactic plane. With your other hand make a fist with your thumb extended. Your curved fingers represent the direction of galactic rotation and your thumb is “up” or “above the plane”. Everything on the other side is below the plane.

      • kinnath

        Well done, grasshopper.

      • Timeloose

        Ha!! Nice one Richard.

      • R C Dean

        👍

  12. UnCivilServant

    I just noticed that in a far more recent design, I repeated a mistake from the previous design I had identified and corrected after delivery of the PCBs.

    I could rant about the details, but that would spoil parts of article 8.

  13. ron73440

    So, with it all wired up, I connected the breadboard to the Launchpad (which, like an Arduino has jumper pins for this very purpose) and hit ‘debug’ on CCS.

    And nothing happened.

    I hate when that happens!

    Especially with electronics.

    I am good with diagnosing mechanical failure, but electronic troubleshooting is a skill I haven’t learned, although I did manage to figure out the radio in my wife’s ’09 Corolla was causing her battery drain.

    Didn’t know how to fix it, so I removed the fuse and she has a Bluetooth speaker in the car now.

    • UnCivilServant

      “Nothing” is one of the most difficult behaviors to diagnose. It could be almost anything, and you have to start ruling things out.

      Do I have power at the right voltage?
      Is the voltage getting where it’s supposed to?
      Do I have any shorts?
      Are the connections good?
      Have I hooked up the wires to the right places?
      Is there a bug in the code?

      • Timeloose

        “Never” and “always” is much easier to diagnose than “often”, “occasionally”, and “rarely” especially when rarely is parts per million.

        Low battery and issues with ground(s) cause many of the issues in car electronics outside of the software.

      • UnCivilServant

        Okay, Intermittant problems are the hardest. I’ll stipulate to that.

      • Ted S.

        Did you check the thermostat?

      • UnCivilServant

        That’s next project.

        Wait, no, that’s a thermocouple.

  14. ron73440

    OT: Any PKD fans?

    I started watching A Scanner Darkly when R.J had it for the Thursday movie and thought it looked interesting, so around 20 minutes in I quit and got the book.

    Book had me really interested in the different plot points, cop losing identity to cover, is someone trying to kill him, and then he got put into the institution and there were hints about a larger conspiracy.

    Then it just ended, no resolution, no answers.

    Are all of his books like that?

    I want to start Do Androids Dream of Electric Sheep?,/em> is it worth it?

    • Nephilium

      Quite a few of his books are like that. The movie does have some resolution in the ending (moreso than the book if memory serves). Personally, A Scanner Darkly is probably my favorite PKD adaptation. I love nearly everything about it, including the trippy rotoscoped animation (and will always love the bicycle argument scene).

      Do Androids Dream of Electric Sheep has a lot more meat to it than the movie does, including explaining why people want artificial animals, and a new religion. I find PKD’s short stories to be much more approachable than his novels.

      • ron73440

        The bicycle argument had me rolling and that’s where I stopped watching and read the book.

        I’ll watch the movie this weekend.

  15. The Late P Brooks

    And nothing happened.

    Better than smoke, or lightning.

    • pistoffnick (370HSSV)

      Very, very frightening!

      • ron73440

        Galileo!

  16. The Late P Brooks

    Low battery and issues with ground(s) cause many of the issues in car electronics outside of the software.

    Is it doing something that doesn’t make any sense? Start looking for bad grounds.

    • Sean

      You’re not my supervisor!

    • Timeloose

      Low battery presents similar issues to a bad or high impedance ground. The IC or single transistor will not turn on or will have some of the IC turn on, the device could turn on in some indeterminate state or condition, or devices could oscillate on and off. Manufacturers put what is called a power on reset state to prevent a lot of this, but some components are not advanced enough to have them (think a dumb protection diode, transistor, or SS relay).

      • pistoffnick (370HSSV)

        …IC or single transistor will not turn on…

        Try some red wine and candle light

    • Nephilium

      Well, since all the grounds are stolen from indigenous people, it’s all bad.

      • Ted S.

        The only good thing about bad grounds is letting them slide.

    • ron73440

      Start looking for bad grounds.

      I see you are familiar with Dodges.

      • Timeloose

        Very familiar. I also still check wheel studs for a “L”. If you know you know.

  17. R C Dean

    I have zero background and little understanding, but I do find the thought process to be interesting. It never hurts to get a glimpse into the complexities of things that you take for granted.

  18. R C Dean

    I have started taking pics with my phone of things that have small print, then zooming in on my phone to read it. Just in the last few days, that his included the temple of my glasses (to get the specs for the frames) and an LED light module in our vent hood.

    Pretty sure this makes me officially old.

    • kinnath

      Welcome

      • R.J.

        Indeed. Join the club. Soon, you will need a phone with a better camera and a 10 inch screen.

    • Sean