Introduction: Remotely Controlled VGA Camera - Overview
The idea behind this project was very straightforward: design an inexpensive remotely controlled system capable of taking still pictures and uploading them to a remote file storage with a camera to be activated by either remote commands or sensor events. And after numerous brain storms the following solution has been found.
In base configuration the system comprises of at least two parts: main (MCU) and transport modules. Main module is driven by ATMega1280 chip with four hardware serial ports, dedicated I2C realtime clock and thermometer/thermostat, primary and backup stabilized power supplies, microSD card, parallel interface for 2 lines x 16 chars alphabetical LCD display, speaker output, four independent digital inputs for sensors, one input line for tamper detection, two 10A 240 VAC relay outputs, JTAG and ISP interfaces for programming/debugging and numerous extension connectors. The module also has USB-to-Serial interface allowing to reprogram, reconfigure and debug the system by connecting it to a desktop PC/notebook via USB port.
Interaction with the outer world is achieved by using unified interchangeable transport modules to make the system independent from any communication interface. For example, if the system is to be deployed at a remote location then the most appropriate way of communication would be GSM network accessed through GPRS modem. Potentially, transport module could provide just about any interface, for example, Ethernet, Zigbee, Bluetooth or something else. In this instructable we will be using GSM transport module.
In this particular application the project used as a security system with a picture triggered by PIR sensor and immediate uploading to a remote storage. The system could be set to active/inactive mode by either a RC from broken TV/DVD or by sending SMS. Apart from sensors picture may also be requested by sending SMS.
Step 1: Remotely Controlled VGA Camera - Circuit Diagram
Let's start from designing schematics. As an electronic design automation tool called gEDA is chosen (http://www.geda-project.org). Despite its enormous popularity Eagle system was eventually rejected as the dimensions of main PCB are not covered by Eagle's free license and the cost of license of substantial. At the same time, gEDA has enough capabilities to allow us design this project.
Two circuit diagrams need to be designed - one for main module and one for GSM transport module.
Step 2: Remotely Controlled VGA Camera - PCB Design
After submitting Gerber files for both PCBs in two weeks our boards are finally delivered. At the same time ordering electronic components in accordance with BOM files so that upon PCBs arrival we will be able to start soldering straight away.
Step 3: Remotely Controlled VGA Camera - Soldering
Not just saying that soldering of those small SMD components is possible, it is actually easy. It is fun. The most difficult component to be soldered is ATMega1280. But all we need to accomplish our mission is:
- A clamp tool with magnifier (available at http://cpc.farnell.com/duratool/d00269/clamp-tool-with-magnifier/dp/TL10478),
- A soldering station. We used old Duratech TS1560 and were pretty happy with the results,
- Soldering paste in syringe packaging (we used SMD291SNL available at http://www.digikey.com/product-detail/en/SMD291SNL/SMD291SNL-ND/1160001?cur=USD
That is it. That is all we need. Believe us, you can do it.
When soldering is completed, clean your PCBs and do visual check. If it is all good, time to flash bootloader.
Step 4: Remotely Controlled VGA Camera - Flashing Bootloader
A bootloader is a compact executable code often flashed in upper program memory area implementing basic transfer protocol and facilitating self-programming function, making possible firmware updates without need to have an external programmer.
Next we need an ISP programmer, let’s take as an example USBtinyISP AVR ISP Atmel Programmer (for example, this one: http://www.ladyada.net/make/usbtinyisp). It costs around $15USD, supplied with two flat cables (for 10 and 6 pin connectors) and is capable of providing a flashing board with +5V. Download USB drivers required for the programmer, they are available at http://blog.arduino.cn/wp-content/uploads/2009/05/usbtinyisp-w32-driver-v112.zip. Connect the programmer to a PC over a USB cable, Windows should report about newly found device and will ask for drivers. Unzip and install just downloaded archive. Now in Device Manager a new device called USBtinyISP AVR Programmer should appear in LibUSB-Win32 Devices group.
Donwload and install WinAVR from http://winavr.sourceforge.net. Open Command Prompt and type ‘avrdude’ - you should get list of options as a result.
Connect main module and the programmer with 10-wire flat cable but before make sure that programmer’s ‘PWR’ jumper is closed – in this case the module will be powered by USBtiny.
Donwload latest firmware from http://sourceforge.net/projects/defendline2/files/latest/download. Already compiled bootloader could be found at CPP\BootLoader\ATmegaBOOT_168_atmega1280.hex. Now it could be flashed to the board, type the following line in Command Prompt:
avrdude -p m1280 -c usbtiny -U flash:w:ATmegaBOOT_168_atmega1280.hex
When programming is done, set FUSE bits with the follwoing consecutive commands:
avrdude -p m1280 -c usbtiny -U hfuse:w:0x98:m
avrdude -p m1280 -c usbtiny -U lfuse:w:0xD7:m
avrdude -p m1280 -c usbtiny -U efuse:w:0xFF:m
Disconnect USBtiny from your PC and main module. Now the main module may be programmed without USBtiny.
Step 5: Remotely Controlled VGA Camera - Flashing Firmware
Connect the main module to external power supply and to PC via USB, Windows should report about newly found virtual COM port and will install the drivers automatically. Alternatively, VCP drivers could be downloaded from http://www.ftdichip.com/Drivers/VCP.htm and installed manually. When it is done, in Device Manager a new device called USB Serial Port should appear in Ports (COM&LPT) group.
To activate bootloader hold SB1 button while the module is being powered up and until red LED starts blinking. Without releasing SB1 enter the following command (substitute 'com4' with appropriate COM port):
avrdude -p m1280 -c avrisp -P com4 -b 57600 -U flash:w:DefendLineII.hex
Note, that this time we use ‘avrisp’programmer type and explicitly defined COM port and baud rate.
When the flashing process is completed the module automatically restarts and it is ready for configuration process.
The good news is that the firmware comes with source code - you are free to modify it to meet your own needs!
Step 6: Remotely Controlled VGA Camera - Server Side
Server-side application is implemented as a set of PHP scripts using MySQL database as data storage. If you want your scripts to be easy accessible from GSM network it would be very reasonable to install them at a host provided by a webhoster. The following applications should be available on a hosting site: PHP5, PHPMyAdmin, MySQL.
Using create_struct.sql from the archive attached here, create a new DB structure by means of PHPMyAdmin. Grant full privileges to a DB user that will be used to access the database.
Copy the whole structure PHP/dl/*.* to your remote host. Make sure that *.php files have permissions for execution and upload and mixed folders have write permissions.
Now a few modifications in /dl/include/config.inc.php must be done. Redefine db_user and db_pass by filling them with database credentials. Fill web_user_MD5 and web_pwd_MD5 with MD5 sums, calculated for web username and web password appropriately.
You should be able to login to access DefendLine data http://yourhost/dl/dlRep.php. There should be an empty list.
Imitate some data submitted by a remote security system. Open the following link: http://localhost/dl/dlLog.html, fill the fields appeared then submit the form. Check http://localhost/dl/dlRep.php again. There should be one record. Setting up procedure complete.
The picture attached shows our web interface with some pictures uploaded.
Step 7: Remotely Controlled VGA Camera - Assembling
Speaking of camera - it is uCAM-TTL from http://www.4dsystems.com.au
Step 8: Remotely Controlled VGA Camera - Intial Testing and Configuring
Connect main module via USB cable to your PC. Make sure that virtual serial port appeared (as it did in the previous step). Run terminal program, choose the appropriate port and set the baud rate to 115200. Power up the main module and try to interrogate the device as it is done on the video.
Settings are stored in NV flash memory. There are many settings to be set, including timezone, sensor descriptions, device name etc but there are at least two of them most important: GSM APN and URL. The first one allows to open GPRS connection and depends on your mobile provider. The second one actually points to a web server with PHP scripts installed.
Step 9: Remotely Controlled VGA Camera - Putting Everything Together
As a result - the system may be controlled from distance by a RC from TV/DVD. LCD plays significant role in diagnostics when you don't have PC/notebook connected to USB port.
Step 10: Remotely Controlled VGA Camera - Whole System in Action
Step 11: Remotely Controlled VGA Camera - Example of Pictures Taken
And finally, here are examples of pictures taken by the system. Some of them really funny!