Ok here is the situation we are using the original CMUcam and we have to code loaded and the camera mounted. Our problem is that its not working, we tried different baud rates we tried the CMUCam2 and on the LCD display all we get is CMU Prg and a bunch of parameters, but its not all the ones that its supposed to display, it only displays half of the parameters and only one servo works and it drives in a circle, its not picking up the object.. So here is the schematic and code, i hope someone can help us here. Since the CMUcam is not working we went to the CMUCam2, So if anyone can help use i would appreciate it alot. We are currently using the CMUcam2 but if anyone has anymore info about either cams.
Code
'Camera Tracking Program
define osc 16
recdata var byte[10]
x var byte
confid var byte
trisb=0
portb=0
pause 1500
serout portb.1,6,["CMU Prg."]
serout portb.2,2,["RS", 13]
pause 1250
'Reset Camera
serout portb.2,2,["RS", 13]
gosub display
'Turn green camera LED on
serout portb.2,2,["L1 1",13]
gosub display
portb.3 = 1
'Turn on auto lighting adjust & flourscent band filter
serout portb.2,2,["CR 45 7 18 44", 13]
gosub display
serout portb.1,6,["A L"]
pause 20000
'Turn off auto lighting adjust
serout portb.2,2,["CR 18 44 19 32", 13]
gosub display
'Turn green Camera LED off
serout portb.2,2,["L1 2",13]
gosub display
portb.3 = 0
'Set poll mode--1 packet
serout portb.2,2,["PM 1", 13]
pause 100
'Set raw data
serout portb.2,2,["RM 3", 13]
for x = 0 to 10
portb.3 = 1
pause 250
portb.3 = 0
pause 250
next x
portb.6 = 1
'Track window command looks at center of Camera window
'Grabs data and sends it to track color function
'Track:
serout portb.2,2,["TW", 13]
pause 2000
portb.6 = 0
main:
portb.3 = 1
'Send command--track
'Will track last color grabbed by TW command
serout portb.2,2,["TC", 13]
'Gather the m statistics packet from TW command
serin2 portb.0,84,[str recdata\10]
confid = recdata[9]
if recdata[2] > 50 and confid > 20 then left
if recdata[2] < 40 and confid > 20 then right
if recdata[8] < 175 and confid > 25 then fwd
if recdata[8] > 200 and confid > 25 then bwd
serout portb.1,6,[254,1,"S"]
portb.3 = 0
pulsout portb.4, 668
pulsout portb.5, 676
pause 18
portb.3 = 1
goto main
left:
serout portb.1,6,[254,1, "L", #recdata[2]]
for x= 1 to 7
pulsout portb.4, 696
pulsout portb.5, 676
pause 20
next x
goto main:
right:
serout portb.1,6,[254,1,"R",#recdata[2]]
for x= 1 to 7
pulsout portb.4, 668
pulsout portb.5, 648
pause 20
next x
goto main:
fwd:
serout portb.1,6,[254,1, "F" , #recdata[8]]
for x= 1 to 7
pulsout portb.4, 696
pulsout portb.5, 648
pause 20
next
goto main:
bwd:
serout portb.1,6,[254,1,"B" , #recdata[8]]
for x= 1 to 7
pulsout portb.4, 640
pulsout portb.5, 704
next x
goto main:
display:
serin2 portb.0,84,20,main, [str recdata\3]
for x = 0 to 3
serout2 portb.1,16468,[" ",recdata[x]]
next x
pause 1500
serout2 portb.1,16468,[254,1]
return
[/img]
Code
'Camera Tracking Program
define osc 16
recdata var byte[10]
x var byte
confid var byte
trisb=0
portb=0
pause 1500
serout portb.1,6,["CMU Prg."]
serout portb.2,2,["RS", 13]
pause 1250
'Reset Camera
serout portb.2,2,["RS", 13]
gosub display
'Turn green camera LED on
serout portb.2,2,["L1 1",13]
gosub display
portb.3 = 1
'Turn on auto lighting adjust & flourscent band filter
serout portb.2,2,["CR 45 7 18 44", 13]
gosub display
serout portb.1,6,["A L"]
pause 20000
'Turn off auto lighting adjust
serout portb.2,2,["CR 18 44 19 32", 13]
gosub display
'Turn green Camera LED off
serout portb.2,2,["L1 2",13]
gosub display
portb.3 = 0
'Set poll mode--1 packet
serout portb.2,2,["PM 1", 13]
pause 100
'Set raw data
serout portb.2,2,["RM 3", 13]
for x = 0 to 10
portb.3 = 1
pause 250
portb.3 = 0
pause 250
next x
portb.6 = 1
'Track window command looks at center of Camera window
'Grabs data and sends it to track color function
'Track:
serout portb.2,2,["TW", 13]
pause 2000
portb.6 = 0
main:
portb.3 = 1
'Send command--track
'Will track last color grabbed by TW command
serout portb.2,2,["TC", 13]
'Gather the m statistics packet from TW command
serin2 portb.0,84,[str recdata\10]
confid = recdata[9]
if recdata[2] > 50 and confid > 20 then left
if recdata[2] < 40 and confid > 20 then right
if recdata[8] < 175 and confid > 25 then fwd
if recdata[8] > 200 and confid > 25 then bwd
serout portb.1,6,[254,1,"S"]
portb.3 = 0
pulsout portb.4, 668
pulsout portb.5, 676
pause 18
portb.3 = 1
goto main
left:
serout portb.1,6,[254,1, "L", #recdata[2]]
for x= 1 to 7
pulsout portb.4, 696
pulsout portb.5, 676
pause 20
next x
goto main:
right:
serout portb.1,6,[254,1,"R",#recdata[2]]
for x= 1 to 7
pulsout portb.4, 668
pulsout portb.5, 648
pause 20
next x
goto main:
fwd:
serout portb.1,6,[254,1, "F" , #recdata[8]]
for x= 1 to 7
pulsout portb.4, 696
pulsout portb.5, 648
pause 20
next
goto main:
bwd:
serout portb.1,6,[254,1,"B" , #recdata[8]]
for x= 1 to 7
pulsout portb.4, 640
pulsout portb.5, 704
next x
goto main:
display:
serin2 portb.0,84,20,main, [str recdata\3]
for x = 0 to 3
serout2 portb.1,16468,[" ",recdata[x]]
next x
pause 1500
serout2 portb.1,16468,[254,1]
return
[/img]