Question about B2Bot ?

i search on internet and i see B2Bot, a robot with CMUcam on a servo head, two DC motors and a custom controller . But, i don’t see code. I need this project, because i want do it or similiar it.
If you have or know about,please help me. (mail :

Only information I could find on B2Bot by searching on Google was a brief caption on the robot gallery page of the old CMUCam site:

“Here is B2Bot, a robot with CMUcam on a servo head, two DC motors and a custom controller called Cerebellum that we are in the process of releasing now.”

Here’s what little information I can give you. If they were just releasing the Cerebellum board, that was probably the CMUCam 1. They’re now up to the CMUCam 3.

The Cerebellum is out of production now, but was originally developed by Botrics, a very small company spun out of the Carnegie Mellon University Robotics Club. While it may have been used by others, as far as I know it was only ever seriously used in-house. We still have a few of the gutted boards kicking around the Robotics Club room, in the bin appropriately labeled “controller graveyard.”

If you’re looking to create something similar, I’d suggest taking a look at the SpoonBot build with the CMUCam 3. The faster processor on the new model allows both motor control and image processing to be done on the same processor. While those particular instructions don’t include an independent pan mechanism, it should be easy enough to add one. Example firmware for the CMUCam 3 is also included in the available software package.

If your intention is to use a CMUCam 1 or 2 that you already have lying around, I’d direct you to Kevin Watson’s website, where he has a collection of documents about setting up and communicating with the CMUCam 2. The CMUCam 1 used similar protocols. The old CMUCam site also has links to manual and sample code for using the CMUCam 1 and CMUCam 2.

Hope some of that is of use to you. If you’re attached to the particular B2Bot project for some other reason, I would guess it’s around 7 years old now, so it would probably be difficult to find someone that could help you. Sorry.


Thanks your help. B2Bot is really old. But i see it similiar my project. My project is a robot have 2 wheels controled DC motor,and one custom wheels. I use data from cmucam2 to control robot tracking object. I really don’n make robot before, so i need help. I use DSPIC and mplab. i read Ryan’s information, but i didn’t know much. If you made successful or know about it, please talk with me.

The best way to start is to break the project down into sections:

  1. The CMUCam itself
  2. The communication channel between the dsPIC and the CMUCam
  3. Sending the correct commands to and interpreting the response from the CMUCam
  4. The control algorithm to turn the extracted vision information into motor movement
  5. Outputting the motors control signals.

Taking them in that order:

  1. If you haven’t already done so, download the Java GUI for the CMUcam 2 available on the download page. Hook the CMUCam 2 up to your computer’s serial port (or buy a USB-serial converter) and get it so you can connect to the camera from your computer. This will require hooking up power to the camera as well. Once you get communication going, you can experiment with the various capabilities of the camera, and this will help you get your thresholding settings right.
  2. If you’re already need to purchase a USB-serial converter for step 1, think about getting one that outputs on the TTL level instead of the standard RS-232 levels. The popular model that does this are FTDI Cables. This will allow you to interface with the camera on the same interface that your microcontroller (a.k.a. uC, this is your dsPIC) will use. Otherwise, you can use the standard Dsub 9 connector connected directly to your RS-232 (serial) port.
    If you get a TTL serial module, this will also allow you to test your uC’s serial port. Verifying that both ends of the connection are working independently will save you a lot of trouble trying to figure out whether your code, your uC, or the CMUcam is at fault.
    To get basic serial communication running, consult the library documentation that came with MPLAB. The serial port on the dsPIC is called the USART port (Universal Synchronous/Asychronous Receiver/Transmitter some models drop the synchronous so it just becomes UART) in the documentation. Using the libraries that Microchip provides will save you a lot of headaches trying to figure out which registers you need to set to which values. To start off, try making a simple program that will echo back on the serial port any characters that it receives, so if you run a terminal program on your computer (I suggest TeraTerm if you’re on Windows) and type in characters, you should see them echoed back to you. If it’s not working (and you have local echo turned off), you won’t see any characters appear when you type. At this point, if you don’t know how serial ports on computers work in general, it would be a good time to go do a Google search, because you’ll be very lost if you don’t. Once you’re sure that you have a working program and that you understand why it works, move on to the next step.
  3. Download the CMUcam 2 manual and read through it. Once you’ve read all of it, a good place to start working is the “Testing the Firmware” steps on page 12 (numbered as page 11). This will allow you to interface with the camera from your computer, but you’ll get to see the interface that your uC will be using instead of the pretty Java interface, and you’ll get a sense of which commands you need to send to do what, and what the responses from those commands look like. After you’ve finished “Testing the Firmware,” you can move on to some of the other commands listed on the command glossary starting on page 29. Try to run the same commands in the same order that your program will need to and write down which commands you used and what the expected response from each is.
    Then use what you learned about how to use your uC’s USART port to write a basic program that does simple interactions with the camera. Try hooking up an LED or some other simple feedback device to the uC that you can turn on in your program once it has successfully sent and received a response to each of the list of commands. If your particular uC happens to have two USART ports (some do, some don’t), you can hook one to the camera and the other to the computer, which can be a good way for your uC to give you lots of information about what it’s doing. You won’t have this luxury, though, if you only have one USART port.
    Once you’ve got communication going between the CMUcam and your uC, and you’ve essentially written the program that will get the CMUcam to track objects (this is where the settings you found in step 1 will come in), move on to the next step.
  4. Assuming you’re just doing basic color blob tracking, the target information will be returned to you as two points that form a rectangle that bound the blob, and a centroid, which you can think of as a “center of mass” for the color blob. At least for basic tracking purposes, you can just make use of the centroid and ignore the rest. If all you want to do is just have your robot follow a target around, the easiest control algorithm to use is simply to steer based on the position of the centroid. If the centroid is in the center of the camera’s view, drive straight. As the centroid moves more to the left, steer more left, and similarly for turning right. If you have a tilt axis on your camera, you can control that using the vertical position of the centroid. If you’re using a simple two motor differential drive (one left, one right), your control algorithm could look something like:
    steer = k * (centroid_x - screen_width/2)
    left_wheel = speed + steer
    right_wheel = speed - steer
    where k is a constant that describes how quickly the robot will turn. Now that you have a method to transform your vision data into motion control data, you can move on to controlling the motors.
  5. How you control your motors will be very dependent on how you have your system set up. It’s probably going to condense down to outputting some a square wave with some parameter that is dependent on the speed you want that motor to go. If you are using a simple H-bridge motor controller, the parameter to control is the [i]duty cycle of the wave, or what percentage of time the output line stays high. If you’re using a modified servo or an RC motor controller that accepts servo control signals, you will encode the desired speed by the amount of time the wave stays high: a 1.5 millisecond pulse is usually off, while 1-1.5 ms is backwards and 1.5-2 ms is forward (1 ms and 2 ms are full backward and full forward). After this pulse, the standard is to wait about 20ms before sending another pulse. If you want some help with this section, you’ll have to post more information about your electrical design.

Hopefully that’s enough to get you started. As you said, the CMUcam 2 is a fairly old piece of hardware, the dsPIC is newer, and so you will be lucky if you find somebody who’s done a similar project on the same hardware. But in the end, you’ll have more fun if you actually do it yourself, if you’re willing to put in the time. At this point, I’d say you have the choice to either spend time learning how to use the hardware you have, or you can spend money getting new hardware. Don’t be afraid to ask questions, but don’t expect somebody to hand you a perfect answer fully formed.

Good luck,


Thanks Ryan very much. I agree with your advice about my question. I wiil try finish my project and of course i will question if i need.

Harakiri, how are you doing? I made a CMUcam robot. I have used mplab and a ucontroller (not a DSPIC but a 16F690) to make a CMUcam2 robot: a CMUcam2, 2 motors with wheels and a third wheel in the back so it won’t tip over. The ucontroller sends commands out it’s UART serial port to the CMUcam. TheCMUcam sends back the T packet that holds the target’s X and Y location. From these you get steering commands that go to each motor. Let me know if you want more/better help.

Hi steve d and evrybody
I’m doing it. If you have experience about it,please help me. For control 2 motors,do you use PID ? And how you get steering command from T packets?
Do You can send me your project because really this first i made robot. Mail :

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
and download some sample code from bottom of the page:

PIDControlTheory_rev3.pdf (38.6 KB)
CMUcam2_fe manual.pdf (2.93 MB)

PIDControlTheory_rev3.pdf (38.6 KB)
CMUcam2_fe manual.pdf (2.93 MB)

Thanks Steve very much. In fact, it’s very interesting. I’m trying do it. And if i don’t known, i will need your help. If you have picture about your robot, i need it.

I have a problem when connect dspic33fj256gp710 with cmucam2. TTL of dspic33fj256gp710 use logic is 3,3V,but serial on CMUcam2 is 5V. How i can’t connect them?

A simple way to convert from 3.3V to 5V is to use a Logic Level Converter. If you search for Logic Level Converter you will be able to find one that fits your needs. I used the one from SparkFun last year and it worked great.

When i transmit data from dspic to cmucam2 by use uart, cmucam2 isn’t work. I think beacause uart in dspic has logic is 3,3V,in cmucam2 is 5v. Is it true? If it true,you help about IC convert 3,3V logic to 5v logic. I see SparkFun but,in my country,i can’t buy it,so i look up a IC convert.

When i use CMUcam2 in demo mode,if I transmit data from PC,CMUcam2 run, but when I send data from dsPIC33FJ256GP210,it don’t run. I connect UART of dsPIC33 with 74HC254,then connect with CMUcam2. Please help me, why it don’t run.
Data I send :
“CR 18 32 19 32\r”;
“HR 0\r”;
“SM 15\r”;
“TC 110 135 15 30 15 30\r”;
When i try connect PC and CMUcam2,when i sent data from PC to CMU,CMU transmit version. Then,i continue sent data, but i don’t see CMU sent.

How do you have the 74HC254 connected? It appears that it will only send data one direction at a time; since you’re using a two-wire system, that’s ok, but you’ll need to run one of the lines “backwards”: i.e. the CMUcam and dsPic should both have their transmit line connected to the A port and their receive line connected to the B port, then connect the direction pin to Vcc so that data flows from port A to port B. If you’re not doing this, it could explain why you’re able to send data but not receive it. Once you’ve done this, make sure you set the direction pin accordingly, else you won’t get any communication at all.

Since you’re using 5v and 3.3v, there’s a simpler solution available: Because the SX52 processor that the CMUcam is based on will accept a logic “high” value of 2.0 volts or higher, you should be able to just connect the transmit line of the dsPic straight to the receive line of the CMUcam. For the other direction, you’ll still have to shift the voltage down, but since the receive line of the dsPic is fairly high impedance, you can just use a resistor divider. Connect it like this:

-------                       -------
       |                     |
CMUcam |                     | dsPic
       |       R1            |
       |            |        |
-------             >         -------
                 R2 >

Resistors R1 and R2 in this configuration are called a voltage divider. The voltage the dsPic will see is equal to R2/(R1+R2) so if you pick values like R1=12K, R2=18K then the if the CMUcam sends 5v, the dsPic will see 3v.

If pretty sure you’re properly electrically connected, also make sure that your serial parameters are properly set on the dsPic: proper baud rate, 1 stop bit, 8 data bits, no parity, no flow control, etc. The baud rate calculations also depend on what frequency the dsPic is running at, so make sure you’re either calculating them correctly, or that if you’re using a library it knows what frequency you’re running at. Try connecting to the computer like I suggested as well; it’s an easy way to make sure these settings are correct.