Silicon ChipAVR200 Single Board Computer, Pt.1 - June 2005 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Photocopying is a huge cost to Silicon Chip
  4. Feature: Looking At Laptops by Ross Tester
  5. Feature: Getting Into WiFi, Pt.2 by Ross Tester
  6. Project: The Mesmeriser: A LED Clock With A Difference by Scott Melling
  7. Project: The Coolmaster Fridge/Freezer Temperature Controller by Jim Rowe
  8. Salvage It: A voltmeter for almost nothing by Julian Edgar
  9. Project: Alternative Power Regulator by Ross Tester
  10. Project: PICAXE Colour Recognition System by Clive Seager
  11. Feature: PICAXE In Schools, Pt.2 by Clive Seager
  12. Project: AVR200 Single Board Computer, Pt.1 by Ed Schoell
  13. Vintage Radio: Signal Generators: what they are and how to fix them by Rodney Champness
  14. Book Store
  15. Advertising Index
  16. Outer Back Cover

This is only a preview of the June 2005 issue of Silicon Chip.

You can view 39 of the 112 pages in the full issue, including the advertisments.

For full access, purchase the issue for $10.00 or subscribe for access to the latest issues.

Articles in this series:
  • Getting into Wi-Fi (May 2005)
  • Getting into Wi-Fi (May 2005)
  • Getting Into WiFi, Pt.2 (June 2005)
  • Getting Into WiFi, Pt.2 (June 2005)
  • Getting Into WiFi, Pt.3 (July 2005)
  • Getting Into WiFi, Pt.3 (July 2005)
Items relevant to "The Coolmaster Fridge/Freezer Temperature Controller":
  • Coolmaster PCB pattern (PDF download) [10108051] (Free)
  • Coolmaster front panel artwork (PDF download) (Free)
Items relevant to "PICAXE Colour Recognition System":
  • PICAXE-08M BASIC source code for the PICAXE Colour Recognition System (Software, Free)
Items relevant to "PICAXE In Schools, Pt.2":
  • PICAXE-08M BASIC source code for "PICAXE in Schools", part 2 (Software, Free)
Articles in this series:
  • What’s this? Free PC Boards for Schools? (May 2005)
  • What’s this? Free PC Boards for Schools? (May 2005)
  • PICAXE In Schools, Pt.2 (June 2005)
  • PICAXE In Schools, Pt.2 (June 2005)
  • PICAXE In Schools, Pt.3 (July 2005)
  • PICAXE In Schools, Pt.3 (July 2005)
  • PICAXE In Schools, Pt.4 (September 2005)
  • PICAXE In Schools, Pt.4 (September 2005)
  • PICAXE In Schools; Pt.5 (November 2005)
  • PICAXE In Schools; Pt.5 (November 2005)
Articles in this series:
  • AVR200 Single Board Computer, Pt.1 (June 2005)
  • AVR200 Single Board Computer, Pt.1 (June 2005)
  • AVR200 Single Board Computer, Pt.2 (July 2005)
  • AVR200 Single Board Computer, Pt.2 (July 2005)

Purchase a printed copy of this issue for $10.00.

Pt.1: By ED SCHOELL* Managing Director, JED Microprocessors Pty Ltd. AVR200 Single Board Computer Professional engineers, students and hobbyists alike will appreciate this lowcost, high-performance development board from JED Microprocessors. J ED MICROPROCESSORS are an Australian company situated in Boronia, Victoria. Over their 25-year history, JED has produced a wide range of boards for the industrial and scientific sectors. Thousands of their single board computers are in use in applications as diverse as traffic monitoring in Victoria to penguin weighing in the Antarctica. Although relatively low in cost, this new design boasts high performance and ease-of-use that will prove adaptable to an endless variety of applications. It is based on the Atmel ATmega32 microcontroller which features an 8-bit RISC architecture 84  Silicon Chip that’s designed for efficient programming in high-level languages such as C and BASIC. What’s on the board As mentioned, an ATmega32 microcontroller forms the heart of the AVR200 design. JED has chosen the 40-pin dual-in-line packaged device rather than the 44-pin surface-mounted variant. In fact, all parts on the board are through-hole mounting, so that the board is easy to assemble. The board’s architecture is very simple, with the majority of the micro’s four 8-bit ports available for external interfacing. A handful of more complex functions such as serial I/O and I2C are supported by dedicated hardware. A screw terminal block at one end of the board accepts DC power (6-18V) for the on-board +5V regulator. Adjacent to this is a reset switch for the micro, while on the opposite side of the board are the serial communications connectors, comprising a D9 socket for the RS232 interface and a 10-way header for the I2C bus. Rows of screw terminal blocks along the top and bottom edges of the board provide easy access to the microcontroller’s ports. In the standard configuration, eight lines function as analog inputs or digital inputs/outputs. A further 11 lines act as digital inputs, while nine drive power Mosfets to provide open-drain outputs. All port pins used as inputs include over-voltage protection. If the standard configuration is not suitable for your application, then in most cases, ports can be swapped from siliconchip.com.au inputs to outputs or vice versa with only minor component changes. Atmel AVR micro The ATmega32 is a mid-level microcontroller in the AVR range and has 131 instructions, most executing in just one clock cycle. The board is normally supplied with a 3.6864MHz crystal but frequencies of up to 16MHz are supported. The RF energy radiated from the board is comparatively low, due mainly to the on-board filtering components and the lack of external high-speed buses. There are 32 user registers as well as 2Kb of user RAM. Six of these registers can be combined to form three 16-bit pointers, all supporting autoincrement/decrement with indirect and indexed addressing modes (the advantages of the AVR over architectures like the 8051 and PIC are immediately apparent when looking at this internal structure). Included on the chip are 32Kb of FLASH (program) memory and 1Kb of EEPROM. The FLASH memory can be loaded from a programming adapter (such as the AVR-ISP) or via the serial port of a PC using a boot loader. This will be described in more detail later. Major peripherals included in the ATmega32 are as follows: • UART for serial communications (RS232, RS485 or TTL level); (TWI), identical • Two Wire Interface to the Philips I2C system; • Serial Peripheral Interface (SPI), which allows two-way clocked data transfer; • Two 8-bit and one 16-bit counter with prescalers, capture/compare functions and PWM outputs; • Four 8-bit multifunction input/ output ports; • Watchdog timer. Note: the operation of the Atmega32 microcontroller is far too complex to be described in any detail in this short article. Readers not already conversant with this device can download the datasheets from www.atmel.com Let’s examine each of the I/O ports in detail and look at the various options available for the AVR200 hardware. The accompanying circuit diagrams are split into three sections due to size constraints. Fig.1 shows ports A & B as well as the voltage regulator, line filters and the optional high-resolution voltage reference. Fig.2 shows port C, siliconchip.com.au Basic Specifications • • • • • • • • • High performance ATmega32 AVR RISC microcontroller Easy-to-assemble design (no surface mounted devices) Four 8-bit input/output (I/O) ports, configured as follows: - 8 analog inputs or digital inputs/outputs - 11 digital inputs - 9 Mosfet (open drain) outputs - RS232 serial port - optional RS485 port - buffered I2C port - battery-backed real-time clock Highly customisable (ports can be reconfigured) Screw terminal connections High quality, plated-through PC board with solder mask Over-voltage protection for all inputs Small size (only 110 x 90mm) Supports “upstairs” expansion/prototyping boards the real-time clock and the buffered I2C interface. Finally, Fig.3 shows port D and the RS232 serial interface. Port A – analog inputs The ATmega32 has a powerful analog input system, incorporating an 8-channel, 10-bit resolution analog-todigital converter (ADC). Each channel is brought out to screw terminal blocks (J2 & J3), one of which also provides a +5V connection for external interface circuits, where required. Each channel incorporates a 7-way socket strip (L4-L11) that’s positioned between the micro’s inputs and the terminal blocks. The strips can be loaded with various components to perform a range of basic signal-conditioning functions. These include over-voltage protection, voltage scaling, high-pass filtering, etc. The various possibilities are shown in Fig.4. In summary, these are: • A simple series resistor (Rs, usually 10kW) for protecting a port input (Fig.4a); • A pull-up resistor (Rpu) to Vcc, used with resistive transducers to ground (Rs is still required) (Fig.4b); • A termination resistor to ground (Rpd) for a current loop input (eg, a 200W resistor converts a 4-20mA current loop to a 4V signal). Note that resistor Rs is still required (Fig.4c); • A series resistor (Rs) and a filter capacitor (Cf) to ground for signal smoothing (Fig.4d); or • A voltage divider configuration using Rs and Rd (Fig.4e). All port A inputs are protected against over-voltage conditions using Texas Instruments TL7726 hex clamping devices (U5 & U6). These devices limit the voltage range on the port pins to between Vcc and ground (± 200mV when sinking 25mA). ADC reference The full-scale voltage range of the ADC depends on the chosen reference voltage. This can be +5V (Vcc), an internal +2.56V reference or an external +4.096V adjustable reference. The latter is provided by an optional MAX874CPA precision voltage reference (U4). VR1 allows this to be set accurately using a digital voltmeter. The typical temperature coefficient for the MAX874CPA is 20ppm/°C, which is less than 1 LSB of conversion error over a 40°C range. This degree of precision is not possible with the internal reference, which can vary from 2.3-2.7V and has no quoted temperature coefficient. When using +5V as a reference, be aware that its absolute value can vary between 4.75V and 5.25V. Although large, this variation can be acceptable in certain applications (eg, when making ratiometric measurements). Port A – digital I/O The Atmega32 supports both analog inputs and digital I/O on port A. The June 2005  85 86  Silicon Chip siliconchip.com.au desired mode of operation is selected under program control. Therefore, the same connectors (J2 & J3) can provide analog inputs, digital inputs or digital outputs. Again, components must be installed in the 7-way socket strips to suit the chosen mode. If the port is used as digital inputs, resistors similar to the analog modes above can be installed, as follows: • A series resistor (R s, usually 10kW) for protecting a port input – see Fig.4a; • A switch or (external) optoisolator input with pull-up resistor (Rpu) to +5V (Fig.4b). • A pull-down resistor to ground (Rpd). This allows voltage inputs of 5 -12V to be sensed, with over-voltage protection limited by the dissipation of Rpd (Fig.4c); and • A voltage-divider configuration with Rs and Rd. Peak over-voltage protection of hundreds of volts is provided in this way (dissipation is limited by Rs) – see Fig.4e; If Port A is to be used as digital out- Where To Buy A Kit Kits and options for this project will be available from JED Microprocessors Pty Ltd, 173 Boronia Rd, Boronia, Vic, 3155. Ph (03) 9762 3588. Or visit their website at: www.jedmicro.com.au puts, all that’s required is a low value series resistor (Rs) of 100W or less to limit the short-circuit current. The output voltage swing is 0-5V, with several milliamps of drive current. Note that LEDs can easily be driven using Rs as a current-limiting resistor. If more current is needed from Port A, then the socket strips can be omitted during assembly and eight 4.7kW resistors and MDT3055 N-channel power Mosfets installed in their place, as shown in Fig.4(f). Port B – SPI interface The Serial Peripheral Interface (SPI) Fig.1: the ATmega32 microcontroller features four 8-bit ports for external interfacing tasks. Ports ‘A’ & ‘B’ are shown here, with ‘C’ and ‘D’ on following pages. Port A can support analog inputs or digital I/O and is highly configurable via 7-way socket strips (L4 – L11). Port B is typically configured for digital inputs. siliconchip.com.au June 2005  87 Fig.2: six bits of port C (PC2 – PC7) drive power Mosfets to provide high-current open-drain outputs. The lower two bits (PC0 & PC2) are used by the TWI (I2C) interface for peripheral expansion. 88  Silicon Chip siliconchip.com.au is a 3-wire interface that enables synchronous data transfer between the ATmega32 (in “master” mode) and any number of peripheral devices. It can also be used for micro-to-micro communications, where one operates in master mode and the other in slave mode. The SPI supports all industrystandard modes as well as variable bit rates, MSB or LSB first transfers and interrupt generation on transfer complete. Three pins on port B are used for the SPI: PB5 is “MOSI” (Master Out Slave In), PB6 is “MISO” (Master In Slave Out) and PB7 is “SCK” (Serial Clock). These signals are made available on connector J13. This connector also brings out port pins PB1-PB4, which can be used as “enable” signals for peripherals. A secondary function of the SPI port comes into play when the micro’s RESET line is active. In the reset state, the SPI operates as a serial programming interface, allowing direct programming of the micro’s FLASH memory (from a PC, for example). To this end, connector J13 has been specially modified to allow connection of a 6-pin Atmel STK500/AVR-ISP programming cable. A gap of four missing pins allows the 6-pin cable header to fit onto the first six pins of the connector. Connector J13 is also intended to allow connection of a prototype or project board with SPI-interfaced peripherals or direct port-driven I/O. Add-ons like this can be connected via a ribbon cable or mounted “upstairs” on a satellite board such as the AVR202. Port B – digital I/O As an alternative to the SPI functions mentioned above, all bits of Port B are also available for generalpurpose I/O. In the standard configuration, all eight bits are digital inputs but bits 0-3 (PB0-PB3) can also be configured as power Mosfet outputs using optional components. If PB0-PB3 are to be used as inputs, a 6-way socket strip is installed in the RP5 position to accept a 4 x 4.7kW 5-pin resistor pack. The end pins of the socket are at +5V and ground, so depending on the orientation of the resistor pack, the four port lines may be pulled down to ground or pulled up to +5V. In addition, a 4 x 4.7kW 8-pin resistor pack must be installed in locasiliconchip.com.au tion RP15. These series resistors are designed to provide current limiting for the TL7726 hex clamping devices (U5 & U6) during over-voltage conditions. Note that configuring bits 0-3 as inputs also enables the use of several special on-chip functions. Refer to the ATmega32 datasheets for detailed information. On the AVR200, bit 2 (INT2) can be linked via jumper L12 to the programmable square-wave output from the real-time clock. Alternatively, if PB0-PB3 are to be used as outputs, Mosfets F1-F4 are installed together with four gate pull-down resistors. The resistors go into location RP1 as a 4 x 4.7kW 5-pin resistor pack. Note that this configuration is optional and therefore the Mosfets and the resistor pack are not supplied in the standard kit. Any optional items can be ordered separately from JED. If PB4-PB7 are to be used as inputs, resistor packs RP6 (4 x 4.7kW 5-pin) and RP7 (4 x 4.7kW 8-pin) are installed, along with four zener diodes (Z6-Z9) for over-voltage protection. As described previously for the lower port lines, resistor pack RP6 provides either a pull-up or pull-down function, depending on how it is oriented in its socket strip. Port C – TWI (I2C) The Two-Wire Serial Interface (TWI) is used for peripheral expansion, both on the AVR200 board (eg, the real-time clock), “upstairs” to add-on boards via connector J14 and off-board via connector J6. The hardware for this interface is contained within the micro and is fully programmable. Two pins on port C are used for the TWI: PC0 is “SCL” (the clock line) and PC1 is “SDA” (the bi-directional data line). Both the CodeVision C and BASCOM BASIC compilers support this interface. Peripherals on the AVR200 and upstairs boards connect directly to the micro’s TWI lines. Both lines are pulled up to +5V with 1.5kW resistors, while zener diodes (Z1 & Z2) protect the internal bus and the micro from over-voltage transients. Normally, off-board TWI communications are buffered with U11, a PCF82B715 “times-10” current multiplier. This allows the TWI bus to extend some distance from the board via header J6 and low-cost 10-way ribbon Pin Function Pin Function 1 3 5 7 9 +5V Buffered SCL Buffered SDA INT0 INT1 2 4 6 8 10 +5V ground ground ground ground Table 1: pin-outs for the TWI (I2C) bus header (J6). The internal header (J14) has the pin-outs but note that it is non-buffered. cable. EMC filters with transient voltage suppressors (LC4 & LC5) protect these off-board connections. The TWI bus appears on header J6 along with two +5V power lines, four ground lines and two interrupt lines (INT0 & INT1). The pinouts for J6 are shown in Table 1. If it is necessary to communicate with non-buffered external devices, the buffer chip (U11) is simply omitted and links L24 & L25 are bridged to connect the SDA and SCL signals to the outside world. In addition, R9 & R10 are omitted and R11 & R12 should be 100W rather than 10W. Port C – real-time clock A Dallas DS1307 real-time clock chip (U7) provides time and date information over the TWI bus. This chip fits underneath the microcontroller and operates with a 32kHz watch crystal. A small lithium cell provides back-up when the power is off. With link L12 installed, the clock chip can provide a square wave signal of 1Hz, 4kHz, 8kHz or 32kHz on INT2 (PB2). The DS1307 includes 56 bytes of non-volatile RAM, also accessible over the TWI bus. Port C – digital I/O The standard configuration for port C bits PC2-PC7 is as outputs. Six MTD3055VL power Mosfets (F5-F10) provide high-current opendrain outputs on terminal blocks J4 & J5. Resistor packs RP8 & RP9 pull the Mosfets’ gates low to ensure that they’re off when not being driven by the port pins. An option is to configure PC2-PC7 as inputs. In this mode, the RP8 & RP9 positions are fitted with six zener diodes instead (not shown on circuit), providing over-voltage protection for the micro’s inputs. Also, two 3 x 4.7kW 6-pin resistor packs are installed in locations RP13 & RP14, and 5-way June 2005  89 Fig.3: the standard configuration for Port D uses three bits (PD4, PD5 & PD7) to drive power Mosfets and three bits (PD2, PD3 & PD6) as digital inputs. The lower two bits (PD0 & PD1) are used for an RS232 serial interface. socket strips are installed in locations RP2 & RP3. The socket strips accept 3 x 4.7kW 4-pin resistor packs, which can be used to pull up or pull down the inputs depending on how the packs are oriented in their sockets. Port D – RS232 serial port The ATmega32 hardware UART is a powerful device with receive buffers, 90  Silicon Chip its own baud rate generator, digital filters for noise reduction, multiple modes and three independent interrupts. The standard configuration for AVR200 serial communications is a minimum-component RS232 interface. This requires only two pins from port D: PD0 for “RXD” (receive data) and PD1 for “TXD” (transmit data). In this simple, no-handshake mode, links L20 & L21 are bridged, connecting PD0 & PD1 to the RS232 transceiver IC (U8). The other (line) side of the transceiver is connected to the RS232 D9 connector (J8) via link L13. Link L13 has two possible positions, allowing changeover of the TX and RX pins on the D9 connector to facilitate either DTE (Data Terminal Equipment) siliconchip.com.au or DCE (Data Communications Equipment) modes. For example, if talking to a modem, the AVR200 needs to appear as a DTE. Alternatively, if talking to a PC, the AVR200 should be linked as a DCE. If hardware handshaking is needed (using the RTS/CTS pair), then it can be incorporated by bridging link L22 and installing a jumper on L17 pins 2-3. This provides an RTS line driver and CTS receiver in U9, utilising port pins PD6 & PD7. L14 allows changeover of the RTS & CTS pins on the D9 connector to swap between DTE and DCE modes. Linking L14 pins 5 and 6 simply loops back RTS to CTS on the interface. Port D – RS485 or TTL serial ports (optional) The AVR200 also includes support for an RS485 communications port. In this case, links L20, L21 & L22 are left open and a multiplexer IC (U9) is installed, along with an RS485 transceiver (U10), two filters (LC2 & LC5) and a screw terminal block (J7). The multiplexer allows switching between the RS232 and RS485 serial interfaces, either manually via L19 or under program control via port pin PD4. By omitting the RS485 transceiver (but including the multiplexer) and installing a 4-pin strip header (J7B), it is possible to connect to TTL/CMOS compatible serial ports such as might be used on radios or GPS receivers, for example. Important: the RS485/TTL interface is optional and parts for it are not included in the standard kit, nor does it appear on the circuit diagram shown here. Information on these features is available from the JED website at www. jedmicro.com.au. Port D – digital inputs Port bits PD2, PD3 & PD6 are always digital inputs, normally accessible via screw terminal block J9. Alternatively, these inputs can be rerouted to perform other functions by moving links L15L17 from their normal positions (pins 1-2) to their secondary positions (pins 2-3). The alternate functions can be summarised as follows: • PD2 – interrupt (INT0) from the TWI bus (link L15); • PD3 – interrupt (INT1) from the TWI bus (link L16); • PD6 – CTS input from the RS232 port (link L17). Also, this port bit siliconchip.com.au can be pulled up (to +5V) or down to ground via link L18. Port D – digital I/O The standard configuration for port bits PD4, PD5 & PD7 are as outputs. Three MTD3055VL power Mosfets (F11-F13) provide high-current opendrain outputs on terminal block J10. A resistor pack (RP10) pulls the Mosfet gates low to ensure that they’re off when not being driven. Optionally, PD4, PD5 & PD7 may be configured as inputs. In this mode, the RP10 position is fitted with three zener diodes (not shown on the circuit) instead of the resistor pack to provide over-voltage protection. Also, a 3 x 4.7kW 6-pin resistor pack is installed in location RP16 and a 5-way socket strip is installed in location RP4. As described previously, the socket strip accepts a 3 x 4.7kW 4-pin resistor pack, which can be used to pull up or pull down the inputs. Note: PD7 is used as the RTS source if needed by the RS232 interface and as the TX-ON source in RS485 mode. PD4 is used as the multiplexer control bit if the optional programmable RS232/ RS485 interface is installed. Power supply DC power is applied to the board on terminal block J1. The rail is filtered with LC8, a combination ferrite inductor, capacitor and varistor. This removes much of the EMC entering or leaving the system via the power leads. An LM2940T-5 3-terminal voltage regulator provides on-board power conditioning. It’s a low-dropout design, which means that it can operate with DC inputs as low as 5.5V and still produce a regulated +5V output. Maximum continuous input is +18V, although it can withstand short transients to +60V and it includes reverse polarity protection. Separation of the analog and digital supply rails prior to the microcontroller inputs is effected with L1 & L2 and their associated 22mF and 100nF capacitors. This arrangement also prevents radiation of digital noise on the supply rails. That’s all we have space for this month. Next month, we’ll describe the assembly and give the various options available for programming the Atmega32 micro. We’ll also give the SC full pricing details for the kit. Fig.4: these diagrams show the various signal conditioning options for the port A 7-way socket strips. June 2005  91