Skip to content

Recent Articles

11
Jun

Ice Twisters

I’m watching this scientific train wreck of a movie called Ice Twisters, about a government-funded cloud-seeding experiment gone wrong. The EPG gives it three out of four stars, a rating clearly not awarded, in any part, based on scientific accuracy.

Here’s the worst bit of science so far. The research team developed a Predator-like drone that flies a swarm formation, creating rain clouds (the drones are called SERIFs, but I don’t remember the exact acronym). The first test run of the swarm of 2000 drones is initially successful, causing the expected rain. But soon, violent, brief storms begin to form in the surrounding areas, accompanied by dramatic drops in temperature, and icy tornadoes. Anyone caught a tornado is instantly frozen. And that’s not the bad science. Read on.

The team brings in Charlie, a former scientist (now a science calamity fiction author) to “think outside the box”. The principal investigator is Joanne. Other scientists include Damon, Gary, and Phil. Here’s the dialogue from the scene, with the worst parts in italics.

Charlie: “There was a very loud sonic boom during the storm.”

Damon: “You, uh, heard thunder.”

Charlie: “No, no, it wasn’t thunder, it was something else. These SERIFs, you say they make the clouds, then seed them with silver iodide? How, exactly, are they doing this?”

(Cut to CG shot of the drones doing their thing in the sky.)

Joanne: “They use tiny wind turbines to supply power to their propulsion systems, so there’s no limit to how long they can stay airborne.

Once up, each one has a revolutionary moisture evaporator designed to condense liquid nitrogen out of the upper atmosphere.

Charlie: “Upper atmosphere? I thought these were in the troposphere.”

Joanne: “They are, right at the ceiling, just below the tropopause.”

(Charlie walks over to a large diagram of the atmosphere, gestures toward it.)

Charlie: “Your SERIFs are here, taking any moisture in the atmosphere, and processing it into liquid nitrogen, right? Making this area extremely dry at first, right? Correct me if I’m wrong.”

Joanne: “No, you’re right.”

Charlie: “All right. There’s a subatomic reaction happening. It’s drawing moisture from the upper atmosphere. The effect of this process is creating…vertical weather.

What kills me is that it’s not necessary to create such bullshit. Movies are better when they’re more believable, and “science” movies like this have to be on their best behavior when creating their disasters.

Anyway, enough procrastinating. Project time!

23
May

The Nissan LEAF Finally Arrived

On Friday, May 20, 2011, I finally took delivery of the Nissan LEAF I had on order for so long. I reserved it in April of 2010, and ordered it September 23, 2010.

My New LEAF

Overall, I quite like it. My only other car is a 1995 Acura Integra GS-R that I bought new. It was a basic car, but well engineered, and very fun to drive.

The LEAF is a huge step up in luxury. Much quieter, about a thousand more airbags, computerized, cool. It has a range of about 100 miles, which is fine for my daily commute. It’s smooth, and has excellent fit and finish. The traction motor control is excellent. It has a really cool backup camera that draws lines predicting where you’ll go based on steering angle input. It has an excellent Bluetooth hands-free system, and it can play music directly off my iPhone via A2DP.

The computer systems leave a lot to be desired, though. I don’t think they’re generally any worse than those of other cars, but now that I own one, I see lots of places where they really failed to create a great product. I’ll write an article about that later.

12
Apr

Trouble with Static C++ Constructors in ChibiOS/ARM

For the last few days I’ve been troubleshooting a problem with a C++ thread class I created to aid in the static allocation of threads under ChibiOS.

The problem boiled down to the fact that the ChibiOS ARM port (specifically, the ARM7 port, but it’s probably true for most ports) isn’t properly executing the constructors for statically (globally) allocated class objects. To clean up the other post, I moved the troubleshooting material to this post.

Note: I’ve discussed this with the author of ChibiOS, and he hopes to resolve the issue in ChibiOS version 2.3.2.

When any object with a vtable pointer is allocated on the stack (i.e. at run time), it works. But when it is allocated as a global variable, the vtable pointer is NULL. Here’s the test code and output:

As you can see, the constructor isn’t getting called, (and vtable initialization isn’t happening) for the statically-allocated object f, but does get called for object g, allocated on the stack.

This is a GCC issue. It needs to call static ctors (and dtors, theoretically), but it’s failing to do so. It could be a mis-configured build of the toolchain, or a bug in the run-time library, or something else along those lines.

Thoughts While Troubleshooting

It currently fails on ARM (on an AT91SAM7X). The symptom is typical of exceeding the allocated stack space: the processor appears to reset (that is, it re-starts execution from the start of code).

There are two failure modes: in the first, it fails in ThreadEntry(), where the the thread context is cast to a pointer to the BaseThread class, and the virtual entry() method is called, executing the CThread subclass’ implementation. If I remove the call to entry() and just implement some code directly in ThreadEntry(), it works fine.

The second failure mode has to do with what I put in the modified ThreadEntry(). Although it executes, subsequent execution later in the program fails (by failure, it is meant that the processor appears to reset).

At this point, I’m not sure what is wrong. Code seems well-enough aligned, when the GCC .map file is examined. The self/this pointer in ThreadEntry() has the correct value. I’ve tried with very large stacks to ensure I’m not overrunning the stack. I’ve tried a non-template class hierarchy to be sure virtual method dispatch works correctly (it does).

I’m going to try twiddling some outputs on the MCU (instead of calling the stdlib routines I have been). Without JTAG debugging, it’s going to be difficult to figure this out.