October 05, 2005

Servo Motors and PWMing of LEDs

This week's lab: Using a servo motor (and doing analog out).

I had a few spare moments in the lab, so I created an entirely new (but basically same-as-before) breadboard setup with the 10K resistor on the PIC's reset (upper left pin), power to the board and to the PIC, and the LED indicator light on the bottom. I figure it will be nice to be able to have two projects going at the same time, instead of having to pull all the attached wires each time my project changes. Plus, I think I'm a better solderer now, and I have hindsight on my side, so I was able to make a slightly cleaner board (the real improvement over the last one is in my serial connector. I did a much better job of soldering the header pins and laying it out this time).

The most difficult part of this lab was finding the servo motor. I trekked all around Chelsea trying to find a store that would sell it to me (there was talk about some store on 22nd street but I never found). I eventually had to go up to 30th street by 7th Av, a place called American Hobby Center, or something like that.

So what is a servo motor? Seattle Robotics has a good beginner's guide to the servo. Basically, it's a small motor that has a roughly 180-degree range of motion, and the shaft of the motor moves according to the time that a voltage is pulsed to it. It is connected to +5V and ground, and there is a control wire as well (this is the input to tell the servo how far to turn).

Luckily, there is a command in PicBasic Pro, PULSOUT that we can use to specify a length of time to send a signal to the motor. This is how we can specify how far the motor should turn. Sending a short pulse will cause the motor to reset back to its starting state.

One other neat thing I found out about from the Seattle Robotics link above is that servos move at a speed proportional to how far they have to go. This makes sense considering what I observed while using the little motor, but I didn't realize it before.

So what did I build? I came up with two ways to use the motor: manual and automatic. In manual mode, twisting a potentiometer varies the analog input to the PIC, which then translates this into a length of time to pulse the motor, with the result being that you twist the pot, and the motor twists along with you.

In automatic mode, the motor rotates until it hits a trip-switch that I built. When the switch is tripped, it resets and starts over. I think there's something really fascinating about watching the motor twist until it hits the wire and then abruptly resetting once it does. You can watch the movie below to see for yourself.

This first image is a close-up of the motor with the trip-switch. The trip-switch is just the yellow and white wires wrapped around each other. When the motor pushes the first wire, it touches the second and closes the switch.
servo1.jpg

This second picture is an overview of the entire board. It shows the switch in the upper right corner of the board and the yellow and red leds in the middle on the right side of the board. The yellow and red LEDs act as indicators of which state (automatic or manual) the board is operating in.
servo2.jpg

The LEDs also dim and glow according to the state of the stepper motor. This is done using PWM, or pulse-width modulation. The LEDs are PWM'd a certain length of time depending on the position of the motor's gear. Pulse-width modulation is when the PIC outputs a square wave voltage; the proportion of time the wave is HIGH and LOW (or ON and OFF) creates an average voltage. If the modulation is fast enough, the eye cannot see the individual on-off changes and perceives the LED as being dim (or bright). I was never able to keep the LEDs from flickering a bit. It was a trade-off between faster response of the stepper motor and smoother lighting of the LEDs.

pcomp_servo_movie.jpg

The code.


Posted October 5, 2005 12:56 AM. Categories: Labs , Week 4 | Permalink

October 04, 2005

Device, Instrument, Tool Project

This is the second group project for Physical Computing. You can see the description of all the group projects here.

During the first week, we gathered observations on an action that influenced a medium. This is what we found:

Action: Setting up and re-arranging a playlist using iTunes.
In a party setting, using iTunes to manipulated song playlists can be frustrating. iTunes expects only a single person to be creating and arranging playlists at any one time. Having multiple people trying to set up a playlist or just choose a song to play doesn't work very well when there is only one mouse. In addition, in a party situation a rather delicate device like the computer would be best kept out of sight (and spill-range).

itunes1.jpg

The goal of the activity is to arrange the songs in a playlist in a desired order and have those songs play, in that order.

A person involved in this activity needs to be quite focused on the computer: They may have to use the keyboard to enter text to search on, and then they also must use fine motor controls to select the specific songs they want to play, and then either create a new playlist or drag them to a specific playlist. Next, they must order the playlist, and finally they need to click "play." The person doing the task typically needs to use both hands and must remain focused on the computer screen the whole time.

itunes2.jpg


The only characteristics to take as given in this medium are the song files on the computer. Mouse- and keyboard-driven input are not the only means of sending information to a computer, and in order to find a tool that allows more expressive action in this medium, we expect to have to look to alternative forms of inputting song information to the computer.

Here is a video of a sample observation of someone attempting to create a playlist:
pcomp_project2_obs_movie.jpg


What's Ahead
As a first-draft idea, we plan to create a kind of a cartridge-based song selection system, using CDs as a visual/tactile metaphor for actual songs. A playlist can be arranged by arranging the order of the CD jewel cases in a standing CD rack.

Posted October 4, 2005 01:36 AM. Categories: Group Projects , Week 4 | Permalink