Sunday, December 9, 2018

Lab Notebook: Two Digit Floating Point Static LED Display

This "Lab Book" posting is my thinking about a design problem I've been considering.

Problem:  I want a way to display a time interval that can be photographed as part of a test fixture.  I'm trying to convey a time value, which can vary from fractions of a microsecond to seconds.

Ideas:

The value that I'm trying to convey can vary over a large dynamic range, but it will always be a "round" number.  For example, it might be 10 milliseconds, or 85 microseconds, but it will never be 10.85 milliseconds.  Therefore, I really only need a couple of digits to convey the value, plus something to convey the metric time units. Using a two digit LED display, including decimal points, together with a three additional LEDs representing microseconds, milliseconds, and seconds, I can convey 99 seconds down to 10 nanoseconds.  For example, here's every decade of 85 from seconds to hundreds of nanoseconds:

85 seconds
8.5 seconds
.85 seconds (850 milliseconds)
85 milliseconds
8.5 milliseconds
.85 milliseconds (850 microseconds)
85 microseconds
8.5 microseconds
.85 microseconds (850 nanoseconds)
.08 microseconds (80 nanoseconds)

Normally, the precision of a number is expressed in the number of significant digits with which is it written.  For example, 85 microseconds +/- 10 nanoseconds would be written as 85.00 microseconds.  But here, since there are only two digits, the precision needs to be explicitly stated, rather than conveyed in significant digits. Since the timing resolution is independent of the scale, there will probably just be a note on the fixture to the effect of "All times are exactly as stated, +/- 10 nanoseconds."

Because the display is intended to be photographed at any possible exposure time, it needs to be static, with all active LEDs on at all times.  It can't be a multiplexed display, the way you'd normally drive a large number of LEDs, because at exposure times shorter than the refresh rate of the complete display, you would only see portions of the display lit in the photo.  With 2 digits of 7 segments each (14 LEDs), plus decimal points (two or three* LEDs), plus three time scale LEDs, that's a total of 19 or 20 LEDs that need to be driving simultaneously.

*Why would I want the third, rightmost decimal point?  It is not specifically needed, but since the middle and leftmost decimal point locations are so integral to conveying non-full-digit values, it might be useful to explicitly include both leftmost and rightmost so there is always a decimal place on and it is not unclear where it resides:

85 milliseconds displays as 85. milliseconds, to explicitly differentiate it from .85 and 8.5 on the display.  This also indicates another problem with this scheme, however, because virtually all 7-segment displays include the decimal point at the right side of the digit. (HEY! A survey of Digikey attempting to verify that assertion turns up this part:



It includes a "Left Decimal Point" and "Right Decimal Point" on the same digit, suitable for use as my leftmost digit.  The dual-decimal point feature is sufficiently unusual that it doesn't appear to be mentioned anywhere in the description of the part on the Digikey website...  If this or some other dual-decimal point digit is not sufficient for my needs, I'm going to end up having to improvise a left-most decimal point, or I could just add a third digit, and then only ever have right decimal points, but also 7 more LEDs, and a higher explicit precision display.  I think I'll make that decision based on other considerations, like brightness, size, color, etc.

Anyway, to make the 19 or 20, or possibly 27 LEDs statically illuminated, I'll need 27 output bits, so I'll probably just drive them directly using a 74AC164 serial in / parallel out shift register.  (If I end up wanting to drive my display electronics at 5V but still have a 3.3V MCU driving everything, I might end up instead using a 74ACT164, which requires a 5V supply, but has TTL input switching levels, meaning that my 3.3V inputs would have more margin.  Though, really, even 74AC should work fine at 5V with 3.3V inputs.

Saturday, December 8, 2018

Surviving a Nuclear Attack

I am hopeful this is information nobody will ever need. But it seems like one of those things that's better to know than not. Plus, maybe it will be a good conversation starter at your next dinner party...

Obviously, if you are too close to a nuclear explosion, you're dead. But there's an intermediate range, at which there's a lot of steps you can take to improve your chance of survival, both immediately and in the longer term. Obviously, the prepper / survivalist market has written a LOT about this, but here's my short "What To Do" immediately after a nuclear detonation. Also, please note that this is not comprehensive, nor am I an expert. Much of this is common sense, but it does include some info that surprised me when I learned it. Ultimately, you are responsible for your own safety, so try to keep calm and do what you can to stay alive.

The First Instant:  Seek cover from the flash and immediate radiation exposure - If you suddenly experience a flash brighter than the sun, DO NOT LOOK AT OR TOWARD IT. In fact, turn away from it, and get as much cover between you and the flash as possible. If the detonation is a high yield explosion, the flash may last many seconds. The flash isn't just visible light. It is intense radiation across the spectrum from long-wave thermal IR to gamma. Closer in to ground zero, the flash will ignite fabric and paper. There are photos of Japanese atomic bomb survivors with the patterns from the fabric of their clothes seared into their skin by the differential absorption of thermal radiation. Flash fire is an immediate hazard as things around you, and possibly your clothes, may burst into flames. If this happens, try to put out / remove the fire as quickly as possible, even while seeking cover.

The First 10-60 Seconds:  Seek cover from blast. Time is of the essence: If you're too close to the explosion, you won't have sufficient time to seek cover from blast effects, but then if you're that close, you may well be incinerated anyway. Try to get away from and seek cover from things that will become shrapnel when the blast wave hits, particularly glass. Windows will shatter inward and the glass shards will embed in everything they hit. In the immediate aftermath, medical care may be unavailable, and you want to try to minimize the risk of injuries that can get infected. Glass shrapnel can also be difficult to remove because it is not as easy as metal to identify in x-rays. If you get to cover, and then it seems like no blast wave comes, DO NOT LOOK OUT TO CHECK. Your sense of time may be distorted by the stress of the situation, and you don't want to stick your head out just as the blast sprays you with high speed debris. If, for some reason the blast doesn't reach you, you are still better off staying under cover anyway (see "The First Three Minutes" next.)

The First Three Minutes:  Stay shielded from the fireball. The primary nuclear reaction in a detonation is over in about the first 30 nanoseconds. However, during that initial nuclear reaction, many different radioactive materials are produced, and they continue through their radioactive decay chain. Some of the materials have very short half-lives. This means that the fireball and subsequent mushroom cloud is still emitting a great deal of ionizing radiation. The activity rate drops off over time, but staying under cover for even three minutes will significantly reduce your acute radiation dosage. Gamma radiation is very penetrative, so the more material you have between you and the fireball, the better. Ideally, it would be something REALLY thick, like a mountain. Usually there's not a convenient mountain between you and the blast to duck behind,  but if you can get behind a landscape feature, or a large concrete structure (as long as it won't also fall and crush you) it will help. And anything is better than nothing!

The Next Few Hours: Threats include fires, structural damage, and the immediate fallout. About 20 minutes after the detonation of the Hiroshima atomic bomb, the burning of the large number of wooden structures combined into a firestorm. In the case of Nagasaki, however, there was insufficient fuel for the firestorm to form. The thermal energy of the blast can also vaporize a lot of water from the surface, which can condense on the fallout particles and drop back to the ground as "black rain."  It is extremely radioactive, so if possible, avoid exposure to it, and absolutely do not drink it. Unfortunately, many of the burn and radiation victims after the atomic bombing of Hiroshima were desperate for anything to drink, and so consumed the deadly black rain.

The Next Few Days to Weeks:  Now you're trying to limit your exposure to the longer-lived radioactive contaminants, like iodine, and minimize their damage to you. If you have them, take iodide tablets according to the instructions. This is especially important for children. It will saturate the thyroid gland with non-radioactive iodine and limit the absorption of any radioactive iodine from the environment. Taking vitamin C may also help your body deal with the damage of radiation exposure. Try not to inhale, eat, or drink any fallout. Food in sealed containers will remain safe even if exposed to radiation. If you have a shelter, stay in it. If you don't, you have to decide if it's better to try to flee the fallout area, or stay under whatever improvised cover you have. If you do have to go out, wear a dust mask, or make an improvised face cover. Before you go back into a shelter area, strip off contaminated outer clothes and leave them outside. Clean the fallout off your skin, but make sure not to embed it into your skin by over-scrubbing.

Finally, any event that results in you needing this information will also mean that the world has changed. At least a lot, possibly catastrophically. But try to help others if you can, and focus on staying safe, healthy, and alive.

Friday, December 7, 2018

Plastic Deformation of the Word Führer

I'm currently reading "I Will Bear Witness - A Diary of the Nazi Years, 1933 - 1941" by Victor Klemperer. Klemperer was a German Jew who lived in Dresden with his non-Jewish wife. On February 13, 1945, he was finally ordered by the Gestapo to report for deportation (and almost certain death) in three days, on February 16th. That night, however, Dresden was firebombed by the Allies, and the chaos saved Klemperer's life as he escaped the city with thousands of other refugees.

In his entry for July 14, 1934, more than 10 years before the final spasms of World War II in Europe destroyed his home city, Klemperer wrote (translated from the original German), "Observant Jews purify vessels that have become tref [ritually unclean] by burying them. In the same way the word 'leader' [Führer] will have to be buried for a long time before it is pure and serviceable again."  Now, 82 years later, and 73 years past the end of the Nazi Third Reich, the word führer still carries connotations of evil that it may never shed. The Mirriam-Webster English-language definition of führer is "Tyrant." Though it once just meant "leader" in German, under its use as Hitler's self appointed title, it changed; the definition was bent too far, and now may never spring back to what it once was. Even in other languages non-native German speakers know the word / title that evoked such passion, and for many, terror, so many years ago.

What other words will history change out from under us?  Leave a comment...

Thursday, December 6, 2018

Christmas Recipes

Here's some Christmas treat recipes that I've been meaning to post for ages.  I hope to get others posted soon!

Homemade Caramels

(Special thanks to my cousin Stacy for this recipe. I'm not sure where she got it!)

1 Cup Butter (2 Sticks)
4 Cups Sugar
2 Cups Light Karo Syrup
2 (12 oz) Cans Evaporated Milk
1 teaspoon Vanilla

- Generously butter pan
- Add butter, sugar, and Karo syrup to a large saucepan over medium heat until mixture begins to boil (5-10 min)
- Gradually add evaporated milk, maintaining boil
- Stir until firm (this taks a while)
- Add vanilla
- Pour into pan and refrigerate
- Cut and wrap

Peanut Butter Blossom Cookies

Another favorite Christmas season treat, the cookies with a Hershey Chocolate Kiss candy in the middle of each one.

I got this recipe from my mom, though I think she got it from a Hershey's Kiss package sometime in the past.

48 Hershey’s Kisses (see note below)
½ cup shortening
¾ cup creamy peanut butter
1/3 cup sugar
1/3 cup packed light brown sugar
1 egg
2 tablespoons milk
1 teaspoon vanilla
1 ½ cup flour
1 teaspoon baking soda
½ teaspoon salt
Granulated sugar

- Heat oven to 375 degrees.
- Remove wrappers from chocolates.
- Beat shortening and peanut butter in a large bowl until well blended.
- Add 1/3 cup sugar and brown sugar.  Beat until fluffy.
- Add egg, milk, and vanilla; beat well.
- Stir together flour, baking soda, and salt; gradually beat into peanut butter mixture.
- Shape dough into 1-inch balls. (See note below.)
- Roll in granulated sugar; place on ungreased cookie sheet.
- Bake 8 to 10 minutes or until lightly brown.
- Upon removal from oven, immediately press a chocolate kiss into the center of each cookie.
- Remove from cookie sheet and cool on wire rack.  Cool completely.

Makes 4 dozen cookies. 

Note: I modify this slightly by making the dough into ¾ inch balls and using more Kisses as needed.  This increases the ratio of chocolate to cookie, which is always a good thing.  I also reduce the baking time to about 7 minutes (for the smaller cookie) and use baking parchment paper on the cookie sheet, instead of baking directly on the cookie sheet. 


Wednesday, December 5, 2018

Bad Lockbox Design

This is from my backlog of previously unfinished posts. I'm trying to go back and finish some up. This was from early 2012:

I was recently staying at the Hsinchu Sheraton hotel in Taiwan, and as with most hotels, there was a lockbox / safe in the room to store your valuables while you're out of the room. This particular lock box had an interesting security vulnerability: Every button on the keypad produced a friendly, and uniquely identifiable, press-tone.

Hotel Lockbox with Button-Identifying Tones

Someone wanting to know the combination for the lockbox would need only hide an audio recording device anywhere in earshot of the box to record the tones. From that recording, they could determine every button pressed when either setting the combination or subsequently opening the box. There's a good reason that lock keypads usually use a single tone to indicate button press on all the keys! It's helpful to have audio feedback that you have, in fact, pressed the key, and that you haven't bounced it. But having a unique tone for each button is only slightly more secure than having every key announce itself with a recorded voice enunciation as you press it: "EIGHT!" "SIX!" "SEVEN!" "FIVE!"  That, by the way, is a level of dumb I haven't yet encountered, but I'm sure it's out there somewhere.

Anyway, I wonder if the Hsinchu Sheraton has upgraded these in the last 6.5 years?  If you've stayed there recently, or you've seen some other "security" device design fails, post a comment!

Tuesday, December 4, 2018

Fun With Homophones

Native English speakers are generally familiar with many of the common homophones, words that sound the same but are spelled differently and often have radically different meanings:

To, Too, and Two
There, Their, and They're
Your, You're, and Yore
Raze and Raise - This pair has the distinction of being homophones AND antonyms!

When I was in elementary school, we were taught that these were homonyms, but some definitions require homonyms to have both the same pronounciation (that is, be homophones) but also have the same spelling (and thus be homographs).  An example of such is pole (a long round support), pole (a fixed point to which other points and lines are referred - the origin of a polar coordinate system) and Pole (a native of Poland.)

Here are some less common homophones:

Undo and Undue - The popularity of the word "undo" has increased markedly since the advent of CTRL-Z type undo features in many software packages. For me, the concept bleeds over into "real life." I have found myself, immediately after breaking something or otherwise making a poor choice, thinking "Undo!  Undo!"  Undue, however, remains a much less common, though occasionally very useful, word.

Away and Aweigh - Here again is a really common word and its much less common homophone.  Indeed, many people don't even realize that the naval song "Anchors Aweigh" is not, in fact, "Anchors Away."  Last year in a pop-up Halloween Store I saw a costume for "Sexy Sailor Girl" labelled "Anchors Away."  In that case, it could have actually been a somewhat clever naughty double entendre, but it was probably just a mistake.

Wet and Whet - As a verb, whet means "to sharpen," so a knife-sharpening tool is sometimes called a "whetstone." Since a sharpening stone is often used with water on it, it is both a whetstone and a wet stone.

Do you have any favorites homophones?  Do you think these should all be called homonyms?  Leave a comment!

Monday, December 3, 2018

Wrecking Ball Analogy

Imagine that right outside your house hangs an enormous wrecking ball.  And when I say enormous, I mean REALLY big.  Like far bigger than your house.  The chain from which it hangs extends out of sight into the clouds, and for the purpose of this analogy, there are always clouds, so you don't worry too much about what the other end of that chain connects to.  It has always been there, since long before your house was built.  It just hangs there, a few inches off the ground. It usually doesn't move, or at most it sways a few inches either way if the wind gets really heavy.  But your house is about a foot away from it, so no problem.  Then, one day, there's an earthquake.  The shaking stops in less than a minute, but you go outside, and notice that the wrecking ball is now slowly swinging away from your house... Five, ten, twenty feet, and it's actually speeding up as it moves away.  What would you do?

I would hope, when you read the situation as I've described it, that you instantly realize that the wrecking ball swinging away from your house is enormously dangerous.  This is the start of a catastrophe that will destroy your house, because the ball will soon come back, with its unstoppable mass, and you need to get anyone in the house out immediately. You would not, I hope, take the time to explore the spot uncovered by the wrecking ball moving back, or follow the wrecking ball away to see exactly how far it goes. You have only minutes, possibly only seconds, to take life saving action.

You may have already guessed where I'm going with this.  Replace "wrecking ball" with "ocean" and the situation I'm describing is the start of a tsunami - a "tidal wave." Interestingly, the physics of the situation are pretty comparable.  Often the first indication of an impending tsunami, other than the earthquake itself, is the ocean "rolling out," "receding" or "dropping." Often people are intrigued and follow the water out.  This is not a good idea.  If you ever see the ocean dropping quickly, you should get away from it and seek higher ground.  And take as many people as you can quickly convince to join you.  Because that ocean, like the swinging wrecking ball, is going to come back  And when it does, it is probably going to destroy everything near the coast.

If you think in terms of possible outcomes, seeking high ground on even the possibility of a tsunami is the winning strategy. If you run away, and nothing happens, you might look a little silly. But if you don't run away, and the water comes in, you may well end up dead. It seems like an easy decision to me. So if you see the ocean suddenly dropping, get away, seek high ground, and warn everyone around you to do the same immediately.