Steel Bound Keys: Replacement Risk

May 11, 2013

I’ve been out of a car since someone rammed mine about a month ago. On two occasions thus far, I have rented a car from a local Enterprise office so that I could get a few things done, like buy a lot of groceries or obtain a copy of the police report about the collision. The people at the Enterprise office/location have been great, and seem to handle the stress of being very busy quite well. I’m surprised just how busy it is since the place isn’t located next to an airport.
Steel bound keys

The second rental I got was a Toyota Corolla. All the keys were bound together with a steel cable along with a tag showing the replacement cost. I can understand the rental company wanting to impress upon its customers that losing keys is a bad thing, but the steel cable isn’t helping. With all the keys bound together, that means if one key is lost, all the keys are lost. This will make life more difficult for a customer who loses the keys, and will increase the replacement cost. Further, it makes giving more than one driver access to the car less convenient since two people can’t each have a key simultaneously.

Most ridiculously and silly, though, is the inclusion of the valet key next to the regular full-function keys.

This bit of absurdity really has nothing to do with the local rental office. I’m sure it’s just company policy.

What to do on the Enterprise-D

May 1, 2013

I found myself recently contemplating what I would do if I found myself on the Enterprise-D from Star Trek.

First, I would find the holodeck and destroy it before it could destroy me. That thing is way too dangerous. Where was the months long, if not years long, investigation into what went wrong the first time someone was hurt in there? After it managed to take control of the ship, why weren’t these things removed immediately from the entire fleet? I’m not going to take any chances; I won’t even step inside that room. I can use one of those phaser thingys to scar the walls while standing outside after I wreck the power supply and control system.

Second, I would install fuses and circuit breakers. It seems like every time something slams into the Enterprise, nasty dangerous sparks fly out of exposed cabling. The crew members doing damage control have enough to worry about without sparks igniting something. It shows up on lots of fiction shows set in space in the future. I guess we’re supposed to think that people will forget how to make fuses or how to use circuit breakers because sparks get safer, but hat doesn’t make any sense.

For that matter, why are there so many wires that can fall down from the ceiling of the bridge? Didn’t they network together everything? They ought to be able to send plenty of data on a single cable, and I bet some things don’t even need much bandwidth. That leaves power. How much power do they need in the ceiling? Do they have 50kW stage lighting?

Oh, that’s right. It is stage lighting because it’s a stage. That makes the Enterprise-D much less exciting, but still not bad. In that case, I’d bring my camera.

That won’t help the resale value

April 13, 2013

My left arm hurts, but otherwise I seem ok. My car, however, didn’t fare so well. It looked almost new earlier this Friday despite being a 2007 model.

I took a left turn at a busy intersection. The light was green, three cars went in front of me, and a few more in the adjacent lane. I got most of the way through. Then it went something like this:

Why does my arm hurt? Why is the left window now opaque? Why is everything suddenly a bit quieter than it was a moment ago? What does the left side of my face feel? Why am I looking at the road I just came from? Why do I smell something like gunpowder?

Oh. Crap.

Somehow during all of that, I pushed in the clutch so the engine was still running. I had to get out through the passenger side door. I was a bit dazed and became a little jittery after a while. I didn’t realize there was an airbag in the side of the seat until I saw the aftermath.

There were people turning left to go the direction I was going just prior to turning left myself who were kind enough to ask if I needed help. For some reason, they were all women. If wasn’t so dazed I might have tried to get a name. One even parked nearby and stayed for a while. Bad time for a good excuse.

The emergency responders were friendly people, too. The first cop I talked with seemed pretty jovial. He noticed the shirt I was wearing and we got to talking about science fiction shows. (Unlike my arm, the shirt appears to be unscathed.) He turned out to be a Firefly fan, and apologized for geeking out. I’m not sure why; there is a reason I got the shirt.

I tore away one of the airbags so I could see out the left window. They are a bit abrasive, but no further injuries from that task. The jovial cop even offered a knife. I was able to drive home, but I won’t be going far, if anywhere, in the car until it gets fixed. I hope its frame isn’t damaged; it sure did prove sturdy, though. Since the impact occurred during the turn, my car must have spun more than 180 degrees but didn’t quite end up facing the exact opposite direction for that side of the road.

60 Gigahenries Per Second

March 24, 2013

I found this ad recently on Slashdot:

60 Gigahenries Per Second

60 Gigahenries Per Second

It prominently shows the text “60GH/s”, which seems quite peculiar to me. That is the proper way to write 60 gigahenries per second. The unit Henry (H) is the SI derived unit for electrical inductance. I’m sure inductance plays a role in whatever the product is, but I doubt that henries per second is something worth advertising. I think henries per second is equivalent to ohms (Ω), the unit of electrical resistance. I’m sure there are cheaper ways to get something with 60GΩ, like use the insulation on whatever electrical cable is nearby and decide that the difference in resistance is within the margin of error.

Raspberry Pi + Linux Interrupt Latency: 10μs

March 1, 2013

I decided I wanted to use a capacitive relative humidity sensor in a project with a Raspberry Pi, but that meant timing the charing or discharging of the sensor in an RC circuit. These things don’t have much capacitance, and the data sheet suggests it might not give good results under 1kHz. That makes it look like it’ll need microsecond timing at least to provide usable data.

I first tried making two consecutive calls to clock_gettime() and found that it takes between 2 to 5μs to complete one call on an otherwise idle Raspberry Pi. This wasn’t good enough, so I figured I’d dip into the kernel to see what could be done. The impact of scheduling processes and context switches should be minimized by solving the problem in the kernel. Thus far, this is the most involved attempt I’ve made at messing with the Linux kernel. The result was a bit messy, but I got it working. If you want a peek, its on Github.

I modified the code in bcm2708_gpio.c to record the time from a free-running timer whenever the output of a GPIO was changed, or an input state change triggered an interrupt. After managing to get the code to do about what I intended (sysfs has an extra directory level that I haven’t figured out), I connected two GPIO lines together, set one to be an input and one an output, and set the edge of the input to falling. There is nothing special about the falling edge for this test, but the edge had to be set to trigger the interrupt. Then I set the output to one, then zero, and checked the results.

I found that the timing showed 10 to 11μs would elapse between the output state change and running the GPIO interrupt handler when an X server is also running. Without X, I saw a latency of just under 9μs. The timer was configured to increment once every 4ns, so its precision should be more than adequate for these results. I suppose I could have added a significant digit. I’m surprised the times were so high; given the times on the consecutive calls to clock_gettime(), I was hoping for something better.

I know there are people who will blame Linux for the poor result, but this result is the system timing itself; it includes the hardware. What I saw in the BCM2835 documentation seemed to suggest the processor has an interrupt vector table with one entry, just like Microchip’s PIC16F84, an old 8-bit microcontroller. If so, that would suggest something else causes so much latency that there wasn’t a point in having a larger interrupt table. Even some of Atmel’s AVR 8-bit microcontrollers, like the ATtiny25, have several entries, so it isn’t expensive to do.

While BCM2835 offers poor interrupt response times, it does have nice graphics, runs Linux, and can run all the development tools needed for all this messing around in the kernel. No microcontroller is going to do that, unless it is part of a Rube Goldberg machine. I did build the kernel on my AMD64 deskunder computer, though. It’s much faster.

My biggest surprise doing all this is that it is possible to cause a segmentation fault in the kernel and not crash a single process. Do it a few times, though, and it might crash something. It logged me out once.

Programming Mistakes: The “OnOff” Flag

December 10, 2012

Lets suppose that you’re writing a program that controls whether something is either on or off. You’ve got a boolean variable or a bit flag value to control the state of this gizmo. You might be tempted to call it something like “gizmoOnOff”. Don’t do that; it’ll make your code look stupid.

For an example as to why you shouldn’t, I’m going to use C for the programming language and define a bit flag. Also, I’ll be using English as the human language. All of this still holds true for other combinations.

Here is a hypothetical data structure where the problem starts:

struct ControlFlags {
   int gizmoOnOff : 1;
   // other flags, too, but only one for this example
};

Later, that data structure will be used. This is where the name is all wrong:

struct ControlFlags cf;
// assume the above is now useful . . .
if (cf.gizmoOnOff)
   // . . .

One part of writing good code is attempting to write it in a self-explanitory way. The more naturally the code reads, the better. In the example, the program seems to be checking if the gizmo is in the “OnOff” state. Is it on-off? What does that mean? That the gizmo is either on or off? If so, what state can it have that is neither on nor off? Is it Schrödinger’s Gizmo?

cf.gizmoOnOff = 0;  // gizmo in a superposition state? or not?

Almost certainly a superposition state is not what was meant, but what state is meant by a cleared flag? Is it on or off? With both in the name, the code does not provide an answer. If the programmer meant for a set flag to indicate that the gizmo is on, then the name should be “gizmoOn”:

if (cf.gizmoOn)
   // . . .

This code is very clear about what it is checking because it is much more self-explanitory. It reads almost like it is written in English; it clearly checks for the on state. Anyone reading that code will not have to make assumptions about how the value of gizmoOn is used to understand the code. Such assumptions are not always correct, and they should be avoided in anything as technical as a computer program. Take for example flags for buttons:

struct Buttons {
   int aUpDown : 1;
   int bUpDown : 1;
};

You might assume that if aUpDown is set that the button is pressed; that seems to be the common assumption among people who work on software. Or you may figure that since up comes before down in the name that a set flag indicates the button is up. There is software out there that indicates a pressed button with a set flag, but hardware often indicates that same state with a cleared flag. For instance, read out the data from an old NES or Playstation controller when no buttons are pressed and all the button flags will be set. In this case, naming a button flag something like “aUp” makes this clear and helps prevent others looking at the code from making the wrong assumption.

Naming the flag with only one state will also prevent someone from making fun of you by asking something like “Why is this check here since the button cannot be up-down?” or “So I set this flag to turn the gizmo on-off, and clear it to turn it . . . into a unicorn?” I suppose that is better than transforming the gizmo into Unicron.

Rebel Resistor Mho

December 7, 2012

resistorMhoAdafruit has got a plush resistor toy thingy on the way. They’re naming it Mho. It must be the rebellious resistor who wants to be known as a conductor. Mho will probably change its color bands like people dye hair so that they indicate Mho’s conductance.

I know maybe two people who will understand that and might get a giggle out of it. For everyone else, one of the names proposed for the unit of conductance, the multiplicative inverse of resistance, was Mho. It does still get some use in that capacity. I first came across it in Issac Asimov’s Understanding Physics; he was quite amused by the name.

1+1=10

October 21, 2012

I found this in the mail recently:

1+1=10

Town of Jupiter: 1+1=10

A difference? More like you can make a sum in binary. I may be employed for software development, but that isn’t a big part of what happens here. Nor are electronics. This makes it doubtful they intended to use binary, in which case they can make a difference by having someone else teach math.

Air conditioner debugged!

October 19, 2012

This last Monday morning, I noticed that my air conditioner wasn’t providing cool air just before I was going to leave for work. In this southern locale, air conditioning is nice even this late in the year. I had the thermostat set to 81F and it had climbed to 83F, so its not like I keep the place cold. A quick inspection revealed that the fan in the condenser/heat exchanger unit wasn’t spinning. This began my second repair odyssey in as many weeks.

When I came back from work, I investigated what I had. The condenser is a Rheem RAMB-030JAZ. It has a ten year warranty on some parts and was manufactured on April 2002. Figures. I researched that while a fan moved fresh cooler air from outside into the house. The thermostat showed 80F by morning, so it wasn’t too bad. It also helped that it wasn’t raining.

Honeywell R8242A without ants

Honeywell R8242A without ants

Tuesday morning, I opened up the condenser and started poking around. I found it has a Honeywell R8242A relay that switches power to the fan and compressor inside the condenser. The relay is very open; the contact moved by a magnet to open and close the circuit is visible and even movable by hand. It also has 240VAC, so I decided to only try moving the contacts with a large screw driver. Doing this manually did nothing, but my multimeter showed that 240VAC was present. There was some blackish junk under the moving contacts;  a close look showed that junk was a bunch of ants. Ants! My nemesis had denied me cool air! Oh, I’m going with singular for nemesis here since one ant poses no problem, but many ants together form a single nemesis. The picture here was after I removed the ants; I just didn’t think to take a picture sooner.

Condenser way too close to the power box

Condenser way too close to the power box

Anyway, the ants needed to be removed, so I first had to cut power to that relay. I first switched to off all the breakers that had a label indicating they had anything to do with the air conditioning. This did not remove power.  The option that I found in my research was to remove a fuse from a box that supplies power to the condenser. That box is so close to the condenser that it will not fully open nor stay open. This prevented my from getting a good view of anything inside. I tried to get it out with one hand only to discover that the sides of this fuse assembly inside the box include exposed metal with both ends of 240VAC. I felt a burning sensation, and fortunately the instinctive response was the same. That left my hand sore for half an hour, but otherwise I was fine. Good thing I couldn’t use both hands. I wonder if there is a good reason to not cover those surfaces, or if leaving them exposed is done to make things cheaper.

I discovered that one of the unmarked breakers in the house can also cut power to the condenser. I suppose I should have tried that first. With that done, I cleaned out the ants, switched the breakers back, and pressed down on the relay. The compressor and fan started up just fine. Now I need to kill more ants.

Radio is useless

October 18, 2012

While driving home from work today, I decided to turn on the radio for once since the music I put on the CD I had wasn’t as good as I thought it would be. After I found a radio station (they were all lost when I fixed the cruise control), I heard that there was a 20% chance of rain, and even thunderstorms might visit the area tonight. I could barely make out those words over the loud pattering of a heavy downpour while I drove in a dark occasionally lost to lightning. That reinforced why I seldom bother to listen to the radio, so I turned it off. I guess I shouldn’t be expecting an improvement.


Follow

Get every new post delivered to your Inbox.

Join 41 other followers