Life@ITP

October 1, 2005

Servo Motors

Filed under: Physical Computing

This week were had to wrok with servo motors. I didn’t get to do much with my servo motors. I wished I’d had done something creative with it as I realized that I could have added a few things to the servos to make it more interesting.

This is the code I used:

DEFINE OSC 4
start:
pulseWidth var byte
‘thes values can be vary with different motors
minPulse CON 75
maxPulse CON 250
refreshPeriod CON 20
main:
pulseWidth = 75
gosub pulseMotor
pause 500
pulseWidth = 200
gosub pulseMotor
pause 500
pulseWidth = 100
gosub pulseMotor
pause 500
pulseWidth = 80
gosub pulseMotor
pause 500GOTO main
pulseMotor:
low PORTD.2
PulsOut PORTD.2, pulseWidth
pause refreshPeriod
return

Anyways, I did have some problems at first, it was stupid really. My servo wasn’t getting enough power to turn and I was wondering what was wrong…and finally realized I had forgotten to put a resistor to the pic chip!






















Get free blog up and running in minutes with Blogsome | Theme designs available here