lbenson
Senior Member
This project provides pan and tilt control through an 08M of a Quickcam 9000 webcam. The webcam itself runs off of a Linksys NSLU2 which has been modified to run the openWRT Linux operating system as described here:
http://johnarthur.wordpress.com/2008/03/25/a-high-resolution-ip-webcam/
The project uses two servos from Trossen Robotics, shown here:
http://www.trossenrobotics.com/store/p/3139-Pan-and-Tilt-Kit-with-Servos.aspx
The picaxe program allows the user to type single-letter commands to control the pan and tilt. The commands are as follows:
"p" activate pan servo
"t" activate tilt servo
"0" home the active servo
"1" step one left or up
"2" step one right or down
"3" step 5 left or up
"4" step 5 right or down
"5" step 10 left or up
"6" step 10 right or down
"7" step to limit left or up
"8" step to limit right or down
The program steps smoothly from the current position to the requested one. 254 of the 256 program bytes of the 08M are used.
The video from the webcam is served through an ip address on the NSLU2. My purpose ultimately is to make a remote "rivercam" of this, showing a spot I love to view during the time that I am not present. The video would be served over the internet, and the commands for pan and tilt would be passed from the viewing computer to the NSLU2 to the picaxe.
http://johnarthur.wordpress.com/2008/03/25/a-high-resolution-ip-webcam/
The project uses two servos from Trossen Robotics, shown here:
http://www.trossenrobotics.com/store/p/3139-Pan-and-Tilt-Kit-with-Servos.aspx
The picaxe program allows the user to type single-letter commands to control the pan and tilt. The commands are as follows:
"p" activate pan servo
"t" activate tilt servo
"0" home the active servo
"1" step one left or up
"2" step one right or down
"3" step 5 left or up
"4" step 5 right or down
"5" step 10 left or up
"6" step 10 right or down
"7" step to limit left or up
"8" step to limit right or down
The program steps smoothly from the current position to the requested one. 254 of the 256 program bytes of the 08M are used.
The video from the webcam is served through an ip address on the NSLU2. My purpose ultimately is to make a remote "rivercam" of this, showing a spot I love to view during the time that I am not present. The video would be served over the internet, and the commands for pan and tilt would be passed from the viewing computer to the NSLU2 to the picaxe.
Code:
' 08Srv_1D test servo
#picaxe 08m
symbol panSpot = b13
symbol tiltSpot = b12
symbol activeServo = b11
symbol activeSpot = b10
symbol lastSpot = b9
symbol panServo = 1
symbol tiltServo = 2
symbol servoMin = 75
symbol servoMax = 225
symbol servoCenter = 150
symbol tiltMin = 155
pause 15000 ' wait 10 seconds
activeSpot = servoCenter
panSpot = activeSpot ' center
tiltSpot = activeSpot ' center
lastSpot = activeSpot - 1
'high 0 'set up for serout
ActiveServo = tiltServo ' tilt servo is active
gosub servoOut
ActiveServo = panServo ' pan servo is active
gosub servoOut
main:
do
serin 4,N2400,b1
' serout 0,N2400,(b1, " ", #b1, " ")
select b1
case "p"
activeServo = panServo
activeSpot = panSpot
lastSpot = panSpot ' make sure we move with new servo
case "t"
activeServo = tiltServo
activeSpot = tiltSpot
lastSpot = tiltSpot ' make sure we move with new servo
case "0"
activeSpot = servoCenter
case "1"
inc activeSpot
case "2"
dec activeSpot
case "3"
activeSpot = activeSpot + 5
case "4"
activeSpot = activeSpot - 5
case "5"
activeSpot = activeSpot + 10
case "6"
activeSpot = activeSpot - 10
case "7"
activeSpot = servoMax
case "8"
activeSpot = servoMin
endselect
if activeSpot > servoMax then
activeSpot = servoMax
endif
if activeSpot < servoMin then
activeSpot = servoMin
endif
if activeServo = tiltServo and activeSpot < tiltMin then
activeSpot = tiltMin
endif
if activeSpot <> lastspot then
' serout 0,N2400,(#activeServo, " ", #activeSpot)
gosub servoOut
lastspot = activeSpot
if activeServo = panServo then
panSpot = activeSpot
else
tiltSpot = activeSpot
endif
' pause 50
endif
loop
servoOut: ' smoothly move from lastSpot
b2 = activeSpot - lastSpot
b3 = 1
if activeSpot < lastSpot then
b2 = lastSpot - activeSpot
b3 = $FF ' minus one
endif
' serout 0,N2400,(#b2, " ", #b3, " ", #lastSpot, " ", #activeSpot,10,13)
activeSpot = lastSpot
for b4 = 1 to b2 ' move smoothly to new activeSpot
activeSpot = activeSpot + b3
' serout 0,N2400,(#b4, " ", #b3, " ", #activeSpot,10,13)
pulsout activeServo,activeSpot
pause 20
pulsout activeServo,activeSpot ' twice seems to make it work
pause 20
next b4
return
Attachments
-
83.9 KB Views: 423