Search This Blog

Showing posts with label CMUCam2. Show all posts
Showing posts with label CMUCam2. Show all posts

Monday, May 5, 2008

CMUCam2+ with Basic Atom Pro continued...

After initializing, calibrating, and configuring the CMUCam2+, it is now ready for service to do object tracking, motion sensing, or even histogram capture. The code samples provided use the CMUCam in polled mode so that the CMUCam is not continuously dumping information the Basic Atom Pro. This allows the Basic Atom Pro to request the data when ready, rather than using interrupt code.

Since the CMUCam does not work with the hardware serial port functions (hserin,hserout) on the Basic Atom Pro, it could be a little tricky using an interrupt and using the software serial port functions to get data that is being sent as fast as the CMUCam can send it. Since the Midnight Prowlerbot is now using a connection to a laptop from the CMUCam instead, data is no longer polled, but is sent as fast as possible and the laptop buffers it up. The code presented is code that was used on the Midnight Prowlerbot when the CMUCam2+ was connected to the Basic Atom Pro instead of a laptop.


To get a color using the following code, the Midnight Prowlerbot generated a sound which permitted the user up to 10 seconds to place the object directly in front of the CMUCam. After the ten seconds expired, a sound was generated to let the user know that the color was being obtained. A final sound occurs to let the user know that the color was obtained. Here is the code:



The tracking code is very simple but is in a seperate subroutine for convenience. Note that since raw mode on the CMUCam2+ was configured for raw data that the data obtained through tracking will not be readable. The benefit of the raw data mode is that the TC response length will always be the same, whereas in non-raw mode, or readable mode, the response length varies depending on whether the values returned are single digit, two digit, or three digit. here is the code:


And finally, here is the main code that was used. Please note that functions such as searching for the object being tracked and other functions have been removed because this code is just showing how the previously posted subroutines are being used together to make the CMUCam2+ usable with the Basic Atom Pro. Besides, I found that using the CMUCam2+ built in tracking was much faster and more reliable than trying to respond quickly enough to overcome the communications delays between the CMUCam2+ and Basic Atom Pro and track reliably.

Instead, I eventually just used the built in tracking to automatically move the pan and tilt servos and acquired the values through the TC responses. This allowed tracking to be responsive and allowed the Basic Atom Pro to also be responsive since it wasn't bogged down trying to do tracking, which required even more communication. Here is the code:

Monday, March 10, 2008

CMUCam2+ and Basic Atom arghh...


After several weeks of reading, experimentation, search, and more experimentation, the CMUCam2+ finally worked with the Basic Atom module. It even worked with the Basic Atom Pro module without any changes necessary. For those that have worked with both the Basic Atom and Basic Atom Pro, this concern will sound familiar - for those that have not, the problem is simply that the Basic Atom Pro chip is not based on a Microchip Pic as the Basic Atom is and thus it has different characteristics and quirks. Fortunately, none of those quirks surfaced in this case.
Shown is a view of the CMUCam 2+ board that is available from Acroname. Most of the information needed on this sensor can be obtained from either Acroname or Carnegie Mellon University. Carnegie Mellon University developed the technology that the CMUCam 2+ is based on and licenses it.

The first tip to getting the CMUCam2+ working with a Basic Atom module is to buy or build a RS232 to TTL interface to allow connecting the CMUCam 2+ to a computer. Acroname offers a RS232 to TTL interface, but Futurlec has a similar module for less than $5.00 as of 12/2007. The GUI for the CMUCam devices is invaluable and essentially required for focusing the lens and assessing the light levels needed for accurate detection. There are models of the CMUCam that include the RS232 interface, but they are a little bulkier.

Now connect the GND’s on the Basic Atom module or Atom Bot Board to the CMUCam2+ serial connector, ignore the 5V pin on the serial connector, and connect OUT on the serial connector to your IN input on the Basic Atom module and IN on the serial connector on the CMUCam2+ to OUT on the Basic Atom module.

The baud rate has to be 38400 or less on the Basic Atom for communications to be reliable. Using “I38400” provided the greatest speed that was reliable. The hardware port does not seem to work, even when using an interface chip.

It is crucial to use the following command to the CMUCam 2+ from the Basic Atom for communications to work: “DM 20”. This is a delay command that instructs the CMUCam 2+ to delay before starting a transmission. The DM command had to be “DM 100” for the Basic Atom Pro. The DM command MUST be issued after any RS command (reset) or communications will not work properly—even at lower baud rates.