Tuesday, May 22, 2012

Week 8: Programming Progress


After last week's experiments with the Arduino, we knew that the device was capable of controlling and powering a servo. The next step was to control the servo by using input from the FSR. A quick search online led us to more tutorials, and we learned how the Arduino's pins and inputs work. To control the servo, we needed to connect its positive wire to the Arduino's 5v pin and the servo's negative wire to the ground pin. For control, The Arduino has an array of pins numbered 1-13 through which the device can send signals. The servo's third wire was then connected to pin 9. 
Connecting the FSR required the use of the breadboard. We powered the breadboard by connecting the 5v and ground pins to the + and - sides of the breadboard (this required us to rearrange the servo connectors to the breadboard rather than directly on the Arduino). The FSR was wired in parallel to the Arduino's A0 (analog input) pin along with a 10K resistor  as illustrated in the diagram below (Figure 7):

Figure 7: The wiring diagram of the FSR to the Arduino (http://www.ladyada.net/learn/sensors/fsr.html)

With both the sensor and the servo wired to the Arduino, we tried various programs. This first one we tested  successfully controlled the servo using the FSR (Figure 8). However, the servo speed could not be controlled by the pressure applied to the FSR.

Figure 8: Early FSR servo control

The next program we tried measured FSR voltage by using the Arduino's map() function. This function reads from the analog input in specified increments from 0 to 1023. We hypothesized that this would allow the Arduino to send varying amounts of voltage to the servo. When tested, this program was partially successful (figure 9).

Figure 9: Proportional servo control

As seen in the video, the servo speed can be varied based on pressure applied to the sensor. However, we could not stop the servo from spinning when no pressure was applied. This could have been caused by our servo modification. Since the potentiometer inside the servo is detached to allow continuous rotation, the Arduino is unable to determine the exact position of the servo. This could cause the program to attempt to return the servo to its zero position indefinitely, 
For next week, we hope to have the twin FSR system ready and mounted to the glove for testing.

No comments:

Post a Comment