The guys are leaving the building as I arrive for class. "Hey! How are you?"
"Grouchy," I say. I have been for the last couple days.
"Well, we have good news! We got the microcontroller programmed for that one sensor! We thought we'd never get it done"
"Yeah, we were stuck, so we just asked Dr. Smith and he straightened us out in, like, fifteen minutes!"
That is cheering. "Great! What's next?" There's so much more to do.
"We showed Dr. Flight and he says that before we do the next sensor, we should get it talking to the base station."
That's what Mountain Girl and I have been working on all week. We've been making the progress of the slow loris. It's been excruciating. "You guys want to do that? That'll be fine with us," I tell them.
They exchange a glance and shrug. "Okay. As long as we can ask you stuff, since you know more about that part of it. Let's meet on Monday."
"Sure." We head on our separate ways. After my class, I go up to the lab to meet Mountain Girl for our usual afternoon coding and debugging session. We've been working on a "skeleton" for the weather station code to handle the connectivity of the microcontroller to the PC and on the PC end we've been modifying the base station code to load in and display the weather data. If we can get it working, the boys can probably just paste their code into the skeleton, and then deal with the host of problems that'll cause.
Mountain Girl designed some nifty gauges for the interface. It looks great, but the needles on the gauges aren't moving. The problems that remain are (1) something mysterious with the TCP/IP connection, (2) the data types aren't right except that they are, (3) the dummy data generating routine isn't acting like we think it is (although I think we got that fixed), and (4) something stupid we haven't thought of, because there always is.
She's already heard from the guys about their success of the morning.
"They want to take over the communications part. I think we should let them," I tell her. "So let's make it a short day today."
"Okay."
The first thing we try is slowing down the data transmission rate. I modify the microcontroller so that it only sends out one packet per second instead of thousands. Now when the system runs, the data are picked up and we don't get an error on the TCP line. But. The data are being incremented not by one, but by 512.
512 is a lovely number, that's two to the power of nine, and so very, very suggestive.
The Hamsters are little endian creatures, while the software used to create the base station (written by Mac dweebs) is big endian. This refers to the order in which the bytes of data are stored. When your data is two bytes wide, but your memory is only one byte wide, you have to break your data in half and store one half first: the big end or the little end. I used a byte swapping function in the base station to handle this, but the byte swapper is not working, as witnessed by our increments of 512. That's our increment showing up in the wrong byte.
I delete the byte swapper and replace it with a rotate bits function, which does the same thing, except that the rotate bits function works. This time, we run the system and the data are picked up, and we don't get an error, and the data are incremented bytwo. (Mathematically astute people would have realized that the increment of one to the high byte would have shown up as an increment of 256.)
"Does that matter?" asks Mountain Girl as we watch the data tick in, incremented by twos. "It's only weather and they don't need it to be that precise."
"Well, it's probably something simple. If the Hamster is sending data, then the PC ought to be receiving it." I consider our logic and set the base station to check the weather Hamster's connection twice as often, then sit back in my chair and watch the data load in, properly and with no missing samples. "So how long did that take? Fifteen minutes?"
"And all the hours we've put in this week."
734 words | April 8, 2005 10:11 PM | Ivory tower