Interfacing the CMUCAM2 to the Prop chip
Bryan K.
Posts: 47
Is there any way to interface the CMUCAM2 to the Propeller 1 controller? I have been trying for the past several weeks, using different serial commands, defining the baud rate, and mode, but no luck. Any thoughts on compiling a serial communications program? I have gotten the CMUCAM2 to interface to the BASIC STAMP, however, the codes are COMPLETLY different.
Comments
Kerry
OBJ
__uart : "FullDuplex"
VAR
·__byte cambuffer[noparse][[/noparse]11]
PUB start(rxpin, txpin)· 'the receive and the transmit pins that the prop chip uses to communication with the CMUCAM
__uart.start(rxpin, txpin, 115_200) 'start uart
__sendcommand(string("RS",13))
__sendcommand(string("PM 1",13))
__sendcommand(string("MM 1",13))
__sendcommand(string("CR 19 33 18 44",13)) 'Auto White Balance and Auto Exposure both ON
__waitcnt((clkfreq * 5) + cnt) 'Let WB and AE settle for 5 seconds before disabling
__sendcommand(string("CR 19 32 18 40",13)) 'Auto White Balance and Auto Exposure both OFF
__sendcommand(string("TC 100 255 0 40 0 40",13)) 'track for a RED object
__sendcommand(string("RM 3",13))
PUB sendcommand(stringptr)
__uart.str(stringptr)
__waitforprompt 'wait for camera to respond with a ":" prompt
PUB waitforprompt
__repeat until (uart.rx == ":") 'wait for camera to respond with a ":" prompt
PUB track(cx,cy,cpixels,confidence) | x
__uart.str(string("TC",13)) 'send Track Color command
__repeat x from 0 to 10
____cambuffer[noparse][[/noparse]x] := uart.rx 'get current color tracking results from camera
__LONG[noparse][[/noparse]cx] := cambuffer[noparse][[/noparse]2]
__LONG[noparse][[/noparse]cy] := cambuffer[noparse][[/noparse]3]
__LONG[noparse][[/noparse]cpixels] := cambuffer[noparse][[/noparse]8]
__LONG[noparse][[/noparse]confidence] := cambuffer[noparse][[/noparse]9]
I have a avrcam.
How close to the cmucam?
Any help will be greatly appreciated.
thanks for the coding. I will try it soon, to see if it works. m not sure if it will work with the avrcam,i dont know anything about it. I have always used the Parallax controllers, and was successful with the BS2.
Never mind my question.
The format of the program I am sure it will work with the avrcam, the only difference·is the command set which is different.
I will try this afternoon.
CON
__CMUCam_tx_pin = 4
__CMUCam_rx_pin = 5
OBJ
__cmucam : "CMUCam"
PUB start | cx,cy,cpixels,confidence
__cmucam.start(CMUCam_rx_pin,CMUCam_tx_pin)······················································· 'start the CMUCam using assigned recieve pin and transmit pin
__repeat
____cmucam.track(@cx,@cy,@cpixels,@confidence)
____if(confidence < 8 OR cpixels < 2)
______cx := cy := cpixels := confidence := 0
____else······································································· 'found a color tracking target
______'YOUR CODE HERE
·
The FullDuplexSerial object has no problem in dealing with the 115200 bauds of the default cmucam2.
Tip: use the binary format to transmit packet values as single bytes.
Edit: I just read kerryw's code and mine's pretty much the same. It's pretty generic code!
It'd be nice if someone grouped this stuff into "object" format.
Post Edited (acantostega) : 10/25/2006 11:54:02 PM GMT
__sendcommand(string("CR 19 33 18 44",13)) 'Auto White Balance and Auto Exposure both ON
__waitcnt((clkfreq * 5) + cnt) 'Let WB and AE settle for 5 seconds before disabling
__sendcommand(string("CR 19 32 18 40",13)) 'Auto White Balance and Auto Exposure both OFF
Basically I turned them on for 5 seconds, this lets the CMUCAM settle on a good value, then I turned them both off. Try this if you haven't already.
Kerry