Autodidact Ambitions 9 – Rectification

by | Jun 18, 2024 | LifeSkills, Pastimes, Technology | 49 comments

When I left off, I’d spent hours dissecting the bevy of errors I’d made in designing and building a digital clock. I’d bodged together fixes for several of the issued but had two problems left unsolved. These were that A: segments on the display that were not supposed to be lit were flickering, and B: the buttons for setting the time merely sent the value going crazy.

While I did address the buttons first, the flickering was a simpler fix from a technical standpoint, so I’m going to talk about that first. Part of me was sitting around trying to figure out where the errant signal was coming from and why it went away when the colon lit up. Not being able to figure out where it was getting the extra juice to light up the LEDs partway was hampering my efforts to fix it. I had convinced myself that I needed to know why to correct for it. The truth was, wherever it came from, I had errant voltage on these data lines. I just needed to get rid of it. So I looked into the function of something I’d heard of and suspected would do just that.

My intuition says that a Pull-Down Resistor shouldn’t work. What it is is a resistor connected between a data line and ground. The idea is that you give a path to ground for errant electricity while providing enough resistance so that it doesn’t result in a short when you do want the line to go high. There is math to calculate how much resistance you need, but I don’t have the data that math needs. So I grabbed a pack of 4.7kฮฉ resistors, because it was cited as a common value for them. I had briefly thought I could run all eight lines through one resistor, then realized this was a stupid idea, as all I’d do was short the data lines together. So eight 4.7kฮฉ resistors it is. I tied them to a common ground plane that got attached to the rest of the ground lines.

But, where was I putting these resistors? There’s nowhere on the circuit board for them. I used a protoboard. I have a stack of different sized protoboards and picked the smallest I could get away with. So what is a protoboard? It’s a circuit board made up of a grid of holes at the standard 0.1″ spacing of most through-hole components. There are no traces connecting these holes, you have to bodge on your own wires. I used the same protoboard for both the pull-down resistors and the fix to the other problem.

When I left off my autopsy of my errors, I’d been fixated on fixing my code to compensate for the madness of the signal from the buttons on the board. My debouncing code simply couldn’t handle it. And there wasn’t enough space on the microcontroller for much more code to try anything more complex. And then I asked the question, “Why am I looking for a software solution to a hardware problem?” If I researched hardware debouncing circuits, I could try wiring one of those up and save me all the hassle of hammering the poor microcontroller.

When I went looking, I found three or four ways of handling the problem. I chose one that I could get my head around, and promptly stole their design. I did wrap my brain around how it worked before just implementing it. This is about learning. I’d probably never have come up with the idea for this mechanism if left to my own devices. I did see the same diagram from severl places, but this is the copy I worked off of:

Credit – DigiKey

What are we looking at?

Well, the button is the source of our bouncy signal. R1 and R2 are resistors, for which I used some more of the 4.7kฮฉ resistors because I had plenty of them. D1 is a diode. U1 is a new component for this device – an Inverter. Inverters do exactly what is on the tin – they output a signal opposite what their input is.

There are two steady states for this circuit. When the button is not pressed (the switch is open), power goes in via R1, crosses the Diode at D1, and into the inverter, causing it to output a low. When the button is being held (the switch is closed), the power comes in via R1, and goes directly to ground via the switch. In this second state, the inverter is outputting a high.

Of course, the important part is the transitions between these two states. The capacitor at C1 smooths out the transitions by charging or discharging depending upon whether the botton connects it to ground. This does generate an even rise or fall, but it’s a long curve relative to the signalling used in the rest of the device. This is why the inverter is there. Its output may be controlled by the signal coming in, but is powered from its own connection. This allows it to make a sharp transition between high and low, which it does only once the input signal crosses the threshold opposite where it started. These thresholds are the edges of the logic high and logic low bands that the chips operate on. The bottom two graphs in the diagram lay out this behavior. The inverter input is the second to last chart, while the last chart is its output.

So, our microcontroller gets a clean signal. Ironically, the mistake I made where I connected the switch controlling the buttons to ground would have been the configuration needed to work with this. I moved the bodge wire for that switch back to ground and broke the traces for the data lines from the buttons to the microcontroller in order to insert a completed debouncing circuit (or rather, two) in between.

And here is that circuit.

Work in progress

That does look ugly, doesn’t it?

The IC in the socket holds six individual inverter components, each working off two adjacent pins. It has a power and ground pin so that it can provide the outputs required. Each bundle of resistors, diode and capacitor is the debouncing circuit described in the earlier diagram. The sharpie marks are where I reserved space for the pull-down resistors and potential standoffs to connect it to the main board. The blue wires are the output, the white and yellow are the input from the buttons, while red and black are power and ground, respectively. It is an absolute bodge job. And it doesn’t look any better when hooked up to the clock’s main board.

There’s a bunch of shorts in between those boards.

Bodgey as it is, it worked. My flicker was gone, and the buttons did what they were supposed to, and the clock kept time… for an hour.

You see, my shoddy construction came back to bite me. It all started going haywire because that mess is about as reliable as it looks.

However – It did work. That means I figured out the problem and solved it. Now if only I had it in a more reliable format.

Well, what do we have here?

Taa Daa!
Hopefully I’ve not made as many mistakes this time around.

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

49 Comments

  1. UnCivilServant

    To prove I am quixotic, I am waiting on two more cricuit boards for the next stage of getting this darn thing right…

    • Yusef drives a Kia

      I started with discrete hardware only, making synths and basic logic circuits, you learn a lot working without ICs.

    • Sensei

      Never fear you’ll still have bodge of some kind even on the latest board revision!

    • Not Adahn

      To me really quixotic, you’ll need to power it with a windmill.

  2. rudimentary teats formerly known as pistoffnick (370HSSV)

    Rectifier!?!?

    I hardly even know her!

    • Sensei

      So you’re being direct?

      • EvilSheldon

        Booooooooooo!!!

      • Yusef drives a Kia

        Full Bridge!

      • The Other Kevin

        He’s alternating between being funny and serious.

      • Gustave Lytton

        You guys always amp up the puns.

      • JaimeRoberto (carnitas/spicy salsa)

        Surprisingly Swissy hasn’t shown the least bit of resistance.

      • Fourscore

        At least it’s current

      • The Other Kevin

        Swiss is currently on his lunch break.

    • The Other Kevin

      That is a fun song. Always like that one.

  3. UnCivilServant

    I’m going to guess there aren’t too many Glibs around today. It is awfully quiet.

    • Sean

      Almost too quiet…

      • UnCivilServant

        Ambush!

        *fires erratically into the foliage*

      • cyto

        Well, several prominent “alt-right voices” have recently been silenced….. anyone seen the FBI running about?

    • Gender Traitor

      I’ve been tasked with redoing a draft org chart using titles instead of names. ๐Ÿ˜ต

      • Tundra

        I’m reviewing measurements on some line drawings

        *shoots self*

      • Sensei

        You work at a credit union. Everybody is a Vice President!

      • Gustave Lytton

        I miss the days when this was normal instead of personality driven org charts and subsequent reorgs every time someone leaves.

      • UnCivilServant

        Having had to deal with and/or perform small scale restructuring after many retirements, I can say that you’re not always (or even often) going to find a perfect drop-in replacement for a role. You will have to take into account the individual aptutides and possibly shuffle things around a bit to reflect the distribution of skills and potential in who you’ve got.

      • Gender Traitor

        You work at a credit union. Everybody is a Vice President!

        Dammit! Now I want to be a VP! ๐Ÿ˜’

        VP of Handling Payroll Hassles? ๐Ÿ˜•

    • Mojeaux

      Had a late-night request from a client.

      • R C Dean

        OK, Winstonโ€™s Mom.

      • Mojeaux

        My humble self can never live up to Winston’s Mom.

    • Not Adahn

      I had to take inventory of the equipment on two of our fire trucks.

      It’s warm out there.

      • UnCivilServant

        why are you inventorying the fire truck?

      • Not Adahn

        I’m on the ERT, so maintaining the equipment is part of the job. My shift has two trucks to do this month — the formerly newest cab-over class A pumper from Edina, and a GMC LeBehemoth that still has a 1984 Olympic decal on the passenger window.

        The newest truck is the new ladder engine we got last month. None of the local FDs have ladders that can reach to the top of our buildings.

  4. The Other Kevin

    These are always a fun read. I enjoy seeing your thought processes. I’m pretty sure you’re not an NPC.

    “Autodidact Ambitions” sounds like the title of a Moby album.

    • UnCivilServant

      I can’t say I’m familiar with their music.

      • The Other Kevin

        Really? He was popular-ish in the 90’s, kind of electronic music with sampling. If you’ve seen any of the Jason Bourne movies, they use the same Moby song “Extreme Ways” at the end of all of them.

      • UnCivilServant

        My mother controlled the radio during the 90s, and at the time she was into country music.

      • rudimentary teats formerly known as pistoffnick (370HSSV)

        ^
        !
        !
        child abuse

      • R.J.

        He was fantastic as the heavy metal singer “Beef” in the movie “Suck.” He performed covered in blood and meat, and had all kinds of fake tattoos. Definitely a good sport about his peaceful vegetarian image.

    • Sean

      I donโ€™t think Iโ€™d want to watch a documentary of it.

      I’m certain I don’t.

  5. cyto

    This article is fantastic. I had many flashbacks to my own “just a quick project” foibles.

    I laughed with you, but I was really laughing at myself.

    Thanks!

    • UnCivilServant

      This quick project has stretched out to more than six months already…

    • Sensei

      Legit LOL.

    • Tundra

      ๐Ÿ˜ณ

    • Mojeaux

      I feel seen.

    • Fourscore

      A man could do that but he’d have to stand up

    • Not Adahn

      She has herself on her shirt.