View Single Post
  #8   Spotlight this post!  
Unread 09-11-2009, 22:58
steve d steve d is offline
Registered User
FRC #1277
 
Join Date: Jan 2007
Location: Groton, ma
Posts: 38
steve d is an unknown quantity at this point
Re: Question about B2Bot ?

Hi, yes, for 2 motors I used a PID loop. I did it without and with, try it, it's interesting. I attached a paper on PID loops that I got from this website, by Matt Krass, team 358. I also attached CMUcam manual.
I get the steering commands from the M packet like this:
1) using the IC's UART (serial port), send a initialize sequence:
' Send command - Set poll mode - only sends one return packet, keeps bit rate low for DSPIC
serout toCMUCam, CamBaud, ["PM 1", 13]
' Send command - Set raw data mode - also suppress Ack:/Nak:
serout toCMUCam, CamBaud, ["RM 1", 13]
2) send a track color command:
serout toCMUCam, CamBaud, ["TC Rmin Rmax Gmin Gmax Bmin Bmax",13 ]
3) using the IC's UART, receive from the camera an "M" packet
' Raw mode M packet format, 9 bytes: Byte0 always 255, Byte1 always
' Char M, Byte2 Mx, Byte3 My, 8yte8 Pixels, byte9 Confidence
serin2 fromCMUCam, CamBaud2, [STR RD\10]
Keep in mind, this is just a few lines cut out from the program.
The Mx and My bytes are the center of the color blob. Get an Xerror and Yerror by getting the difference from blob center to image center, say 100,80. so, Xerror = Mx - 100 and Yerror = My - 80. Use those errors to get steering commands.

Also, check out the CMUcam at http://www.parallax.com
and download some sample code from bottom of the page:
http://www.parallax.com/Portals/0/Do...AppModDemo.zip
Attached Files
File Type: pdf PIDControlTheory_rev3.pdf (38.6 KB, 233 views)
File Type: pdf CMUcam2_fe manual.pdf (2.93 MB, 91 views)