FPGA programming

November 16, 2008 | categories: Uncategorized | View Comments

After a little bit of work and screwing around with installers, I have programmed an FPGA for the first time. I wrote a short bit of Verilog that creates a 4-bit counter in a Xilinx Spartan 3A FPGA. Now, when I feed the FPGA a 50 MHz square wave on a certain pin, it counts the rising edges and outputs the count on 4 digital lines. Of course, it has to start over when it gets to 15.

The oscilloscope screenshot below shows the two highest order bits counting up in binary in response to the input signal.

Counting at 6.25 MHz

This may seem like a stupid way to spend your time-- who needs a 4-bit counter? You may be right.

However, the theory is that one skilled enough in Verilog might be able to develop not just a 4-bit counter, but, for example, a microprocessor with a custom co-processor designed for ephemeris calculations (or whatever calculations suit you). In reality, it's more likely that I would buy the Verilog to make the microprocessor and then just write the custom math processor myself.

It may prove a useless skill, but it definitely makes me less worried that some 14-year-old cyborg is going to make me obsolete in the next 45 minutes.

Read and Post Comments

Television: still stupid after all these years

September 28, 2008 | categories: Uncategorized | View Comments

Sharon and I recently moved to a new house, which resulted in a switch from Speakeasy DSL to RCN cable. As a result, we now have a TV signal coming into our house. Strangely, I don't think I have ever lived in a building with a cable connection, except for a 6 month stint in graduate school when I was busy enough building robots that I don't remember what room my roommates had the TV in. But now, I get to explore television as a visitor from the mid-80s. Here's what I remember from 1984 or so:

  • The Jeffersons: a show about a family with the last name "Jefferson"
  • Rhoda: a show about a woman named "Rhoda"
  • The Dukes of Hazzard: a show about a family with the last name "Duke" who live in Hazzard County. To liven things up, these Dukes engage in hazardous motoring in an orange car. This makes the name of the show a pun.

Now, show titles are abbreviated: CSI, ER, 24, NCIS. I don't know what these shows are about, but from the ads I've seen, they're about law enforcement and medical emergencies. We now have multiple editions, like CSI: Miami and CSI: New York. There appear to be a lot of shows about law enforcement, but that may be just an illusion induced by shows with opaque titles like Naruto (from a tv.com summary, I gather: a demon fox, an evil spirit trapped inside a baby, and "shinobi," which is a word I don't know). With the exception of the evil spirit trapped in the baby, which is creepy, these are trends that I expect to see in America, the land of the fearful, where Sarah Palin gets airtime. I'm happy to report that despite 150 channels, I don't feel like I've missed much in the last 20 years.

However, I did discover something new that I didn't expect: the glorification of the mistreatment of kids. One instantiation is "The Principal's Office." Pitched as a reality TV show on TruTV (I guess "tru" is the reality TV version of "true"), the episode I saw followed a high school principal around the halls as he caught kids beating on each other. The kids were taken to the principal's office, where he yelled at them, and the kids squirmed in a mix of resentment and embarrassment. It's obvious that the presence of a camera escalates the conflict between the kids and the principal, so we can safely assume that the goal of the show isn't to document a good principal at work. All that leaves is a man yelling at kids. The "man yelling" part doesn't bother me in the least, but I don't like the "at kids" part. "Hey, troubled kid, if you let us humiliate you on national TV, we'll give you $200." (Review from the Boston Globe with some more details.)

The second show is one on FuelTV called Camp Woodward. It's a thinly disguised advertisement for a sports camp in Pennsylvania that focuses on skateboarding, BMX and rollerblading. In the episode fraction I saw, one of the counselors explains that when he's at home in Florida skateboarding by himself, he doesn't throw tantrums, but when he's trying to teach kids to skate, if he can't land tricks, he gets angry and swears. Another section of the show details the tribulations of a 13-year-old who thinks his $100 for food has been stolen by rollerbladers. After being berated by his mom via cell phone, he finds his money in his shorts pocket. He repeats the lesson that he has learned that you should deposit all your money at the camp canteen as soon as you can, lest someone steal it.

Both of these shows mystify me-- I don't understand why suffering kids are now fair game for entertainment.

Morbid prediction: a reality show with the following theme will be produced in the next decade: life of a child soldier or life in a refugee camp. I think that's the bottom, and I don't see what else is going to stop us.

Read and Post Comments

Tower of epic fail in Dubai

July 20, 2008 | categories: Uncategorized | View Comments

A gentleman by the name of David Fisher has been getting some attention (examples: WSJ, New Yorker, Inhabitat) by describing his design for a new building in Dubai. It would be best for the world if bad ideas like these were ignored and forgotten, but without some knowledge of engineering, it's not obvious that his ideas are bad.

Fisher's tower is like a shish-kebab on a vertical skewer, where the skewer is an elevator shaft and the food are the apartments. Each apartment can rotate around the elevator shaft. This alone is perhaps impractical, or ugly, or dumb, but not impossible. If you could find a wealthy fool who wanted to build this, you could probably pull it off.

Where Fisher crosses the line into territory that I defend is with his claims about renewable energy. He says that there will be a wind turbine between each apartment, and solar panels on the roof of each apartment. According to his website, the building will "generate electricity for itself as well as other nearby buildings, making it the first skyscraper designed to be self powered." As Walter says in The Big Lebowski, "OVER THE LINE!"

Before we even look at the available energy closely, we can be certain that it won't work. One of the central problems of renewable energy is its low power density. According to the ever trusty Vaclav Smil, wind and solar typically yield 1-10 W/m^2; skyscrapers require in excess of 1000 W/m^2, (Energy in Nature and Society, pp. 311, 317). But perhaps Mr. Smil is wrong. Let's take a closer look.

Judging by the drawings of Fisher's tower (since removed), it would be about 300 x 50 m. Ignoring the narrowing of the tower as it rises, roughly 20% of the area is devoted to wind turbines. That's around 15000 x 0.2 = 3000 m^2. (Fisher has described two versions of the tower, one at ~300 m with 60 floors, another at 420 m with 80 floors. Here, I analyze the shorter of the two.)

Fisher claims that the average wind speed in Dubai is 16 km/h, or 4.4 m/s.

Assuming a Rayleigh distribution for the wind speed, the average power available as kinetic energy in the wind is (6/pi) * 0.5 * (density of air) * area * (average velocity)^3.

The density of air is 1.2 kg/m^3.

That's (6/3.14) * 0.5 * 1.2 * 3000 * (4.4^3) = 290 kW. If the wind turbines were 30% efficient, which would be pretty good for a vertical axis turbine stuck in a building, the yield would be 100 kW.

This ignores the narrowing of the building, the lack of wind near the ground, and obstruction from other buildings.

The building has around 50 m * 50 m * 60 floors = 150000 m^2 of floor space, so the areal power density is about 0.67 W/m^2. Say a room is 5 m in a side, so it has area of 25 m^2. That gives you 17 W per room.

But let's not leave out the solar power! Fisher claims that 20% of each roof will be exposed to sunlight. On average, then, if photovoltaics yield around 1 W/m^2, we should expect a power density based on floor area of 0.2 W/m^2, which is another 5 W per room, 22 W total. That might be enough to light a single compact fluorescent light bulb in each room.

Oh, and the average temperature in Dubai is 27 C. I guess they can run the air conditioning when all the lights are off.

I should end by saying that I share Mr. Fisher's enthusiasm for renewable energy. My concern is that his tower of epic fail gives the work that I spend all day on a bad name. We should be building wind turbines and installing solar panels as fast as we can, but we should do it in ways that optimize their performance. Put the solar panels where they will never be shaded by the floor above them, and put the wind turbines on ridgelines where the wind is strongest. Integrating turbines and panels into buildings with the expectation that they will produce energy to spare is moronic.

(And all you energy reporters should be ashamed of yourselves for repeating Fisher's void claims without any skepticism. That means you, Paul Goldberger and Evelyn Lee!)

Read and Post Comments

Useful code excerpts for the MSP430F2012

June 29, 2008 | categories: Uncategorized | View Comments

Here are a couple little code excerpts that took me some time to figure out. I'm hoping that Google might help the rest of the world's MSP430F2012 programmers save 5 minutes. (If they all find it, a total savings of 55 minutes!)

The MSP430F2012 defaults to a clock speed of 1 MHz, sourced from an onboard DCO. In order to get the DCO to be accurate, you have to load calibration constants from flash.

BCSCTL1 = CALBC1_1MHZ; // DCO calibration: set range DCOCTL = CALDCO_1MHZ; // DCO calibration: set DCO step and modulation

Then you can initialize the timer to count in increments of 100 ms.

TACCTL0 = CCIE; // CCR0 interrupt enabled, compare mode TACCR0 = 50000; TACTL = TASSEL_2 + ID_1 + MC_1; // SMCLK as source; divide by 2; up mode

Anyway, I hope this is useful to someone out there.

Read and Post Comments

Top engineers shun massacre machinery

June 26, 2008 | categories: Uncategorized | View Comments

Philip Taubman had an interesting article on the front page of the New York Times yesterday: "Top Engineers Shun Military; Concern Grows." The article profiles an engineer by the name of Paul Kaminski who worked for the Air Force designing planes for several decades. Kaminski now heads a task force that is attempting to deal with the difficulties the military is having recruiting engineers. According to Taubman, the number of engineers working for the Air Force has decreased 35-40% over the last 14 years. The reasons cited for the decline include:

  • better pay in high tech firms
  • more cachet at Google or the like
  • more engineering students from foreign countries who can't get security clearances
  • lack of exposure to new technology in the military

Strangely, Taubman omits what I suspect, perhaps foolishly, is the central cause-- top engineers are driven to solve problems. As I consider the central problems facing the world today, I do not notice an alarming lack of weapon systems. The US military is already extremely good at killing. If you're really a top engineer, you can choose where to work. I can't imagine why someone would be drawn to weaponry when there are so many obvious unsolved problems elsewhere.

As an interesting footnote, the article gave no hints of what Mr. Kaminski's task force will do about the lack of people willing to carry out the jobs they have in exchange for the salaries they offer. One solution might be to stop trying to build so many damn weapon systems.

I have told my sons that they are not under any circumstances to take part in massacres, and that the news of massacres of enemies is not to fill them with satisfaction or glee. I have also told them not to work for companies which make massacre machinery, and to express contempt for people who think we need machinery like that.

--Kurt Vonnegut, Slaughterhouse Five

Read and Post Comments

« Newer posts -- Older posts »