« Lab 3 - Analog Input | Main | Beer Garden Sound Meter -- Project 1 »
October 04, 2004
Lab 4 - Analog Out
Lab 4: Servo/Analog out. I had problem with the servo responding bizarrely to the analog input. I also built a musical instrument of sorts using freqout.
-----
I ran into a problem in the second step. Following the instructions in the lab, the analog output (using PWM) would only go from 1 to 1.5 volts, instead of 1 to 2 volts. As a result the servo would only move in 50% of it's full range. This is what fixed it. I changed the equation in the lab:
pulseWidth = minPulse + (pulseRange * (sensorValue/10)) / 100
to this:
pulseWidth = minPulse + ((pulseRange * (sensorValue / 100)) /10)
I'm not sure exactly why this works, but one possibility is that pulseRange * (sensorValue / 10) creates a number too large for the chip to process. Dividing it by 100 creates a manageable value that can be then divided by 10. Unfortunately, this results in the loss of some resolution in the reading/translation of the analog input.
Did anyone else have this problem?
Here's a video of the servo.
For my application, I made something like a musical instrument. I used analog input from a pot as a parameter for the freqout function. I tried to use two pots and two freqout functions to get harmony, but I'm not sure the chip is capable of that. It resulted in this cool rhythm though.
Here's a video with sound.
Posted by rus200 at October 4, 2004 01:44 PM