Sunday, December 23 2012
Gretchen was headed down to the City for the next 30 hours or so, and I thought before she left I might try replacing the Honda Civic Hybrid's oxygen sensor (which had been throwing an error code for the past couple weeks). I had a generic sensor that had to be spliced onto the existing sensor's connector, which was just as well since the existing sensor's connector was unreachable somewhere among the pipes and tubes at the back of the engine. Indeed, when I cut off the old sensor from its wires, there wasn't enough wire left on the connector (wherever it was) to bring it out into a place where I could easily work on it. I found myself having to strip its ends back in a cramped place inside the engine compartment where I couldn't even fit two of my hands. It was a nasty job, and it scratched up my knuckles and put me in a foul mood, one that had me openly advocating the dropping of a third nuclear bomb on Japan. I couldn't see how I was ever going to splice the new sensor's wires onto the old sensor's wires using the splicing kit that came with the new sensor. But then I realized the splice would be easy if I used wire nuts. Wire nuts aren't great for every splice, but they tend to be reliable and, best of all, they can almost be made one-handed. I managed to find just enough room to hold the wires with the tips of one finger while twisting on a nut with the other. Unfortunately, though, after all of that trouble, the car kept throwing the same damn error (even after I cleared it). But at least the car was drivable once more.
Today was a pseudoephedrine day. I took 120 milligrams, fired up my podcasts, and proceeded to do a number of experiments with an infrared rangefinder module attached to my desktop test Arduino (which isn't technically an Arduino, but an Atmega328 running on an Olimex board and manipulated using the pre-1.0 version of the Arduino IDE). I wanted to use this module to perform fuel level measurements in the household heating oil tank (the old ultrasonic rangefinder I had been using for making these measurements mysteriously stopped working over a year ago). I was pleased with the performance of the IR rangefinder, though by nature it precision curve is opposite of what it should be. In other words, it is most precise when measuring a full tank and least precise when measuring the tank near empty. This is because it works by measuring the angle of reflected light coming off whatever it is measuring the distance to, and that distance has an arctangent relationship (a kind of nonlinear similar to logarithmic) to that angle. I couldn't visualize how the IR module worked until I looked at its IR beam using a webcam (the beam is otherwise invisible). I saw that the IR beam was extremely narrow, which meant it was painting a smallish dot on the distant surface. All the receiver LED had to do was measure the brightness of that dot. The module's output was a simple analog signal.
This meant I would need to use an Arduino if I wanted to replicated the digital output of the old ultrasonic rangefinder. That had connected to the Solar Controller via the easiest-to-work-with of all bidirectional digital connections: I2C. I've already put considerable work into developing a semi-generic firmware for an Arduino-compatible microcontroller operating as an I2C slave. It seemed like it should be a simple matter to adapt that code to make a slave whose only job would be to digitize the analog signal from the IR rangefinder. Perhaps it could also take temperature readings (since, as I've learned, that that has a detectable effect on fuel level).
So I made a copy of my slave Arduino code and proceeded to elide all the parts related to the driving an LCD display or reading an infrared module (which allows me to enter data into the Solar Controller down in the basement using a multifunction home theatre remote). With all that code gone, the slave firmware was now small enough to fit into an Atmega8, the eight kilobyte controllers used in the first two generations of Arduino (of which I have several and for which I don't otherwise have much use).
I then built a simple circuit designed to accept an Arduino-compatible microcontroller in its socket and an IR rangefinder module. Connecting to another Arduino (functioning as a master) using the standardized four-pin I2C connector I use in all my projects, I hoped it would immediately start sending back digitized range readings. But something was wrong with my simple little slave Arduino circuit, and if it sent back readings at all, it was only during the initial burst when it was powered up. I'd been hoping not to have to spend much time testing and debugging this circuit, but now it seemed that just providing an I2C connection was not going to be enough. I would also be needing some sort of serial connection to monitor its behavior.
For linking purposes this article's URL is:feedback
previous | next