DefendLineII has a native support of JPEG Colour Camera (C328 compatible). Such type of camera is capable of delivering VGA quality still pictures, it is equipped with hardware JPEG compressor and serial interface making integration with embedded devices quick and easy. This camera requires two wires (RX and TX) for serial communication, ground and positive power wires. Peak power consumption reaches 60mA at 3.3V but most of the time camera stays in stand-by mode making it quite attractive for security, monitoring, medical embedded applications and designing of robot-kits of any kind, this description perfectly fits to our needs. The camera looks like that:
Potentially DefendLineII is capable of supporting for up to three serial cameras (in this case USB port won’t be available) but in this example we are going to demonstrate how to handle only one camera connection. Check carefully camera header pinouts before connect it to CONN3 serial header located on our board. Pin interconnection table is given below:
Signal name | Wire color | C328 camera J1 header | DefendLineII CONN3 header |
---|---|---|---|
Vcc (3.3V) | Red | 1 | 6 |
Camera Tx | Yellow | 2 | 1 |
Camera Rx | Green | 3 | 3 |
GND | Black | 4 | 2,4 |
Software support is provided by a class implemented in SerialCamera.c
file. The class exploits all camera’s features described in great detail in C328 User Manual. In order to take a picture five basic steps should be performed: synchronization procedure (series of specific byte sequence to wake up the camera), initial camera settings (JPEG or RAW mode, picture resolution), setting up of a package size (pictures are split into packages when being sent to the host controller), making a snapshot itself (issuing a command to read raw data from sensor and store it in internal camera RAM) and finally reading of a stored picture in a loop package by package until the whole picture is received.
On the very top level the interactions with a camera are encapsulated in DefendLineII.c
in just two methods: uint8_t takePicture(char* fileName, uint16_t resCode)
and volatile void onPicturePacketReceived(uint8_t* buf, uint16_t len, struct fat_file_struct* fd)
. The first one initiates camera and MicroSD filesystem, requests a snapshot and the second method handles data portion every time when next package arrives. When the operation is successfully completed a JPEG file will be stored in current directory on MicroSD card.
The process of taking pictures might be triggered manually in terminal. Insert MicroSD into its slot, connect the camera to CONN3 header, connect board to your PC via USB cable, power up the board and launch terminal application. Type test
and the device should report that MicroSD and Serial camera are detected and initialized (please refer to DefendLineII. Terminal commands for more information). If this step was successful you can take a picture. Point your camera to a desirable object and type takephoto [filename]
. Orange LED will start repeatedly blinking as indication of data transfer and in a few seconds a new captured image will be stored on a flash card in JPEG format.
Files stored on a flash might be transferred to PC in two ways – by sticking MicroSD directly into computer with help of a card reader or by means of cat [filename]
command in terminal which outputs the content of binary files as dump of hex data. Later this dump could be converted into binary file so that the file will be viewable. In the nearest future it is planned to employ lightweight ZModem protocol to facilitate file transfers between the board and PC.
Leave a Reply
You must be logged in to post a comment.