CURRENT ISSUE

Contests

bottom corner

Feature Article



Issue #202 May 2007
The Wittness Camera
Build a Self-Recording Surveillance Camera
Grand Prize Atmel AVR Design Contest 2006
by Alberto Ricci Bitti

Start | Solid-State Recording | Full Interaction | Complete Picture | Basic Instinct | Filled To Capacity | Speech Preparation | Circuit Implementation | Concept To Prototype | Picture Inspection |Design Evolution | Sources & PDF

BASIC INSTINCT
The most peculiar aspect of this design is that the firmware is written in BASIC. I’m a strong advocate of using C for embedded systems, and I routinely use the excellent GNU compiler collection (GCC) for AVR development on PC and Linux platforms. But, while I was waiting for the samples of the camera to arrive, I was asked to select a BASIC compiler and IDE for the educational board my company was developing. The BASCOM-AVR from MCS Electronics is a stable, popular product with a rock-solid user base and a syntax similar to Visual Basic. The IDE installs a lot of examples. You don’t need anything else to make your application. Actually, the IDE integrates all sorts of accessories, including a simulator, a chip programmer, and a serial terminal (nice touch).

While browsing the online help section, the AVR-DOS library supplied with the package grabbed my attention. AVR-DOS makes the job of writing a disk file trivial:

open “README.TXT” for output as #1
print #1, “HALLO FILE!”
close #1

This is all it takes to write a text file to the SD card with BASCOM and the AVR-DOS library. The library also provides a default pin-configuration file and system set-up functions to include in your application. Online help even includes a schematic for wiring an SD or MMC card to the SPI.

I couldn’t resist trying it. I grabbed an SD card from the nearest photo camera, Atmel’s STK300 evaluation board, and a soldering iron. A few minutes later, Windows Notepad (running on a 32-bit, 3-GHz machine) was opening a file written by an 8-bit, 8-MHz AVR microcontroller. I was hooked.

BASCOM is good at simplifying hardware access. For small applications, it’s a time saver. Do you need a real-time clock? Just tell the compiler, and it will do the hard work of making timer-interrupt code specific to the AVR flavor you selected. Do you need a buffered serial I/O? Just select the buffer size and data rate. The list of supported features is long: an RC5 IR remote control, an ADC readout, timers, and a PWM setup (to name only a few that were useful for this project). You could also use a graphic and text LCD, 1-Wire devices, SPI and I2C buses, PS2 mice, AT keyboards, and even a TCP/IP stack!

On the other extreme, as the complexity of your application increases, you will miss C-type checking, aggregate types, and support for modularity. Also, BASCOM error messages are obscure if not misleading, and the compiler’s lack of automatic-type conversions and true expression handling is an unnecessary pain. My advice is to stay with C if you expect to develop more than 64 KB of code. For smaller designs like this one, it makes sense to use BASIC if you are exploiting most of the built-in features it offers. However, BASCOM does support structured programming. With a bit of discipline, you can write code that’s as organized as you can in C. Refer to the source code on the Circuit Cellar FTP site for my best attempt at doing it!

 

Previous | Next

 


bottom corner