Click here to Skip to main content
15,884,836 members
Articles / Desktop Programming / Windows Forms

C328R Serial Camera Example with xBee using C#

Rate me:
Please Sign up or sign in to vote.
3.00/5 (6 votes)
5 Apr 2009CPOL3 min read 61K   1.3K   22   11
C328R Serial Camera Example with xBee using C#

Introduction

This is an example program on how to capture pictures with the CR328R serial camera using an xBee module hooked to your PC and an xBee module hooked to the CR328R camera.  In theory you shoudl be able to use a serial interface from you PC directly hooked into the camera and be able to use this software.

Background

I am buidling a tank robot that can be driven with a Wii Mote interfaced with my PC, and my PC then relays the commands to my tank using the xBee Pro, which has a 1 mile range. When I did that I wanted to upgrade the range of the camera I was using because my old camera's range was only 100' or less. So I decided to use a serial camera and the xBee module so the range of my camera would be the same range of my tank.

I built my work on this application based on the great work of Pavel Bánský, who created a class to get pictures from the CR328R camera from a hardware device called the Tahoe development board that used the .NET Micro Framework. Because he used the .NET Micro Framework I only had to modify the code to use the SerialPort class and to account for the small buffer size the xBee has.

Hardware Connections

I hooked the TX pin of the camera to the DIN pin of the xBee. Then I hooked the Rx pin of the camera to the DOUT of the xBee. Because the camera and xBee module both work at 3.3 volts I used a 3.3V voltage regulator to power the camera and xBee. I also hooked a resistor in series with an LED between the PWM0 pin and ground. This will let you know when your xBee is receiving information.

My xBee Pro is set to 57600 baud.

Software

When the program starts hit "Init" so the camera can start up and initialize to the baud rate of the xBee.  After that you can hit "Get Now" which uses the GetJpegPicture function to take the picture and immediatly start transfering it to your computer.  Or you can hit "Snapshot" which stores the JPEG image on the built in memory on the camera, then start transfering it to your computer.  Once these work for you hit "Movie" to display a clip of 10 sequential pictures. 

Points of Interest

I was only able to get the JPEG options for this camera working so the GetRawPicture function doesn't work.  I believe this is due to the small buffer size of the xBee.  Because the GetRawPicture function doesn't work framerate is limited.  In 80X64 I have only been able to get 1 frame every 1.14 seconds, in 160x128 I can only get a frame every 2.5 seconds, and it gets progresevly worse from there.  I am hoping in the fugure to figure out a way to get GetRawPicture working.

It's can befrustrating working with this camera.  Sometimes it seems it doesn't want to take pictures so you have to hit Reset or Init Camera.  It seems like if you don't constantly take pictures the camera or xBee goes to sleep so I have to hit Reset to wake it up.  Other times I have to restart the application. 

Outstanding Tasks

1. Make it more reliable.
2. Speed. Try to get GetRawPicture working to see if I can get the framerate up by reducing the color depth.

History

4/4/2009 - First Release 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionCamera trap Pin
Sachit Naik22-Apr-13 20:36
Sachit Naik22-Apr-13 20:36 
GeneralAnother camera please do help me Pin
tarekkkkk28-Nov-10 9:52
tarekkkkk28-Nov-10 9:52 
QuestionA little assistance Pin
ushal26-Oct-09 13:55
ushal26-Oct-09 13:55 
GeneralXBee Camera Pin
dktran25-Aug-09 15:29
dktran25-Aug-09 15:29 
GeneralRe: XBee Camera Pin
pyrokin30-Aug-09 17:57
pyrokin30-Aug-09 17:57 
GeneralRe: XBee Camera Pin
dktran31-Aug-09 9:32
dktran31-Aug-09 9:32 
GeneralRe: XBee Camera Pin
funkotron7631-Aug-09 10:23
funkotron7631-Aug-09 10:23 
GeneralRe: XBee Camera Pin
dktran31-Aug-09 10:52
dktran31-Aug-09 10:52 
GeneralUsing the same setup. Pin
pyrokin3-Jul-09 17:58
pyrokin3-Jul-09 17:58 
GeneralCool stuff!! Pin
Mubi | www.mrmubi.com17-Jun-09 8:55
professionalMubi | www.mrmubi.com17-Jun-09 8:55 
GeneralMy vote of 1 Pin
Sacha Barber5-Apr-09 4:56
Sacha Barber5-Apr-09 4:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.