« property in the digital age | Main | software pwm »

pcomp midterm - post thoughts

So we presented our midterm yesterday. I should do a brain dump before my mind drifts to something else.

In the beginning I was mostly messing with sensors. A few that I played with that others might be interested are
- LED as a light sensor. Research can be found here.
- Range finder. Research is here.

The LED as a light sensor actually works, but the range was so restricted it was basically useless for our application. While a range finder would work best, it was probably too expensive for this project. So ultimately we stuck with photo sensors.

The thing with photo sensors (and with a lot of sensors, in fact) is that you often need to recalibrate them as you move them to different environments. As the project location changes, the reading from the sensors changes as well. This proved to be a difficult thing to debug because we were never guaranteed to sit on the same spot with the same lighting in the lab, and the first thing at hand when working on the project was always to recalibrate the sensors (and sometimes changing the resistors to get a higher/lower reading). I think it would be helpful to write some code to automatically calibrate the sensor at start up. Deciding what would be considered “a change” would be difficult though. Need to ponder more about it…

Midway through the project, we started playing with three chips that would help us get more umph out of arduino
- digital to 16 channel pwm chip.
- 11 analog channel to digital chip.
- another similar analog to digital chip but by Texas Instrument.

Most of my effort was put into figuring out how to drive the pwm chip, which would drive the LED’s. It has been years since I read a datasheet, so it was quite a challenge to get it into my head. Stefan was able to help me understand a lot about driving chips. One of the greatest challenges was how to quickly clock out the pwm data once we write it into the chip. To pull out the pwm data, the chip needs 4096 grayscale clocks between two latch clocks. In the beginning that’s what we did, but we would always have this flickering effect because clocking four thousand times by code was just too slow.

Our mission was to find an alternative clocking method. We knew the arduino had a clock, so we thought we could use that to drive grayscale. The trick was then to clock the latch after 4096 arduino clock cycles. At first we wanted to do this through a time interrupt, but the arduino was using all three timers available in the avr. Should we code everything in avr-c? It was definitely doable, but given the time constraint it was something I dreaded greatly. Luckily we found the code that drives the arduino (wiring.c in the arduino library), and found how the pwm is coded. Since the pwm runs on a timer-overflow interrupt, we through we could hijack that info and use it to clock the latch!! On first try, it seemed to work on some of the LED’s but not all.

A friendly conversation with Ilan (which actually span for more than 3 hours) made us realize that we didn’t need to clock grayscale four thousand times. Despite what the spec sheet said, we could clock it much less times and get the same effect. We just needed to scale both the programming section and the pulling section by the same number. Essentially we were sacrificing resolution for time. This brilliant idea saved us!

Now that our technical difficulties were (mostly) resolved, it was time to build the actual interface. Shlomit was great at getting the material we needed and constructing it. It was been a while since I had worked with tools, so it was great experience for me to help her in that regard. I also learned a great deal from Stefan on how to solder (big chunks) of wires. Soem random thoughts regarding this phase -

- We never really drew out a detailed sketch of what interface would look like. So when Shlomit started drilling holes I was kinda confused about what they would do. I think doing a sketch first of everything and then building it would help everybody get on the same page.
- When soldering large chunks of wires to gether, it helps to use the multimeter to test for continuity.
- Tape can be your best friend. We had a problem with the photocells being bent and the wires touching each other. We simply taped up one end so that they won't interfere.

People's reaction to the inteface was quite amusing. Even though one can see rows of LEDs and sensors, it was hard to tell its actual function. Once ppl realized that it lights up because of your movement (actually shadow), they always played with it a few more times, sometimes with their hands, someitmes just with their body. Even I was startled by it a couple times, when I was deep into thinking and would accidently trigger the lighting. I think the wow factor was definately there. Once the contruction is more solid, I would love to put this in a public space, where it would react to unsuspecting passer-bys. Their reaction would be priceless.