Author Topic: programming CMUcam to track colors  (Read 3264 times)

0 Members and 1 Guest are viewing this topic.

Offline RipperTopic starter

  • Beginner
  • *
  • Posts: 1
  • Helpful? 0
programming CMUcam to track colors
« on: April 26, 2008, 12:05:16 PM »
I'm building a color tracking robot for a capstone project. I have a few questions about the programming of the robot. I'm using a PIC 16F877 microcontroller which will be operating 2 DC motors to control movement and steering and a single servo to control vertical tilt. I'm probably going to set up an H bridge with PWM for speed control of the DC motors.  But is there anyone who can help with the source code that controls the motors and servos? I'm probably going to use MPLAB to program the PIC unless anyone else has any other suggestions.Any help would be appreciated.Thanks  :-*
« Last Edit: April 26, 2008, 12:09:28 PM by Ripper »

Offline izua

  • Supreme Robot
  • *****
  • Posts: 682
  • Helpful? 0
Re: programming CMUcam to track colors
« Reply #1 on: April 26, 2008, 12:16:16 PM »
If you haven't programmed ucs before, and you just decided on PIC (but haven't bought anything) go with AVR. They have more power for their cost, compared to a PIC.

If you already have bought PIC kits and programmer, that's still ok. Learn to do some basic I/O and some compares in the language of your choice. You say MPLAB, but are you going with assambler, or with some other compiler? I'd suggest Oshonsoft Simulator if you don't have any previous experience. It's $25, it has a decent simulator (if you can cope with the idea of a visual basic simulator), and a pretty good BASIC compiler.
edit: there's also a demo version which can compile up to 50 lines of basic code.

Commanding the motors is an easy task, just output 1 on pin x and 0 on pin Y. if you want the motors to go the other way, switch values. You will need a push-pull driver for both pins (since a pic can't drive a motor by itself). Such an arrangement is usually found as a h-bridge.

But for the color tracking, that's difficult. You will need to colordepth * pixels just to store the image for one frame. So, if you have 8 bits of color and a resolution of 640/480 for the camera, you will need 24 * 640 * 480 bits, or 3 * 640 * 480 bytes of RAM to store the whole thing. That's 921600 bytes, close to 1 Meg. That pic has 4 banks of 128 bytes IIRC, some of which are reserved. So, now, you can't do color tracking on a controller.
Did I mention you'll have to store several frames, so you can check differences between them? :P
« Last Edit: April 26, 2008, 12:18:06 PM by izua »
Check out my homepage for in depth tutorials on microcontrollers and electronics.

Offline paulstreats

  • Supreme Robot
  • *****
  • Posts: 1,381
  • Helpful? 21
Re: programming CMUcam to track colors
« Reply #2 on: April 26, 2008, 12:19:10 PM »
If you use one of the PIC18 family such as the 18F4520, it is pin to pin compatable with the 16f that you are using. Because they are optimised for C, there is a free c compiler from microchip which will make the programming a lot easier. (also more code and memory space)


Get Your Ad Here