Silicon ChipArduino-Compatible I/O Controller - April 2010 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: The Federal Government's insulation scheme is a tragedy
  4. Feature: 3D TV Is Here At Last! by Kevin Poulter
  5. Feature: FAQs On The Web Server In A Box (WIB) by Mauro Grassi
  6. Project: Capacitor Leakage Adaptor For DMMs by Jim Rowe
  7. Book Store
  8. Project: A 1000:1 EHT Probe by Jim Rowe
  9. Project: Arduino-Compatible I/O Controller by Greg Radion and Ross Tester
  10. Review: PICOTEST M3510A 6½-Digit Multimeter by Nicholas Vinen
  11. Project: Digital Audio Signal Generator, Pt.2 by Nicholas Vinen
  12. Vintage Radio: The spark era: the beginning of radio by Rodney Champness
  13. Advertising Index
  14. Outer Back Cover

This is only a preview of the April 2010 issue of Silicon Chip.

You can view 32 of the 104 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.

Items relevant to "FAQs On The Web Server In A Box (WIB)":
  • dsPIC33FJ64GP802-I/SP programmed for the Webserver in a Box (WIB) [0711109A.HEX] (Programmed Microcontroller, AUD $25.00)
  • Webserver in-a-Box (WIB) Programming Tables (PDF download) (Software, Free)
  • dsPIC33 firmware (HEX file) and website files for the Webserver in-a-Box project (Software, Free)
  • Webserver in-a-Box (WIB) PCB pattern (PDF download) [07111092] (Free)
  • Webserver in-a-Box (WIB) front panel artwork (PDF download) (Free)
Articles in this series:
  • WIB: Web Server In A Box, Pt.1 (November 2009)
  • WIB: Web Server In A Box, Pt.2 (December 2009)
  • Web Server In a Box, Pt.3 (January 2010)
  • Internet Time Display Module For The WIB (February 2010)
  • FAQs On The Web Server In A Box (WIB) (April 2010)
Items relevant to "Capacitor Leakage Adaptor For DMMs":
  • Capacitor Leakage Adaptor PCB [04204101] (AUD $15.00)
  • Capacitor Leakage Adaptor PCB pattern (PDF download) [04201401] (Free)
  • Capacitor Leakage Adaptor panel artwork (PDF download) (Free)
Items relevant to "A 1000:1 EHT Probe":
  • 1000:1 EHT Probe PCB [04104101] (AUD $25.00)
  • 1000:1 EHT Probe PCB pattern (PDF download) [04104101] (Free)
Items relevant to "Digital Audio Signal Generator, Pt.2":
  • Digital Audio Signal Generator main PCB (to suit Jaycar case - 04203101] (AUD $10.00)
  • Digital Audio Signal Generator main PCB (to suit Altronics case - 04203103] (AUD $10.00)
  • Digital Audio Signal Generator control PCB [04203102] (AUD $7.50)
  • dsPIC33FJ64GP802-I/SP programmed for the Digital Audio Signal Generator [0420310C.HEX] (Programmed Microcontroller, AUD $25.00)
  • dsPIC33 firmware and source code for the S/PDIF Digital Audio Signal Generator [0420310C.HEX] (Software, Free)
  • S/PDIF Digital Audio Signal Generator main PCB pattern for Jaycar case (PDF download) [04203101] (Free)
  • S/PDIF Digital Audio Signal Generator main PCB pattern for Altronics case (PDF download) [04203103] (Free)
  • S/PDIF Digital Audio Signal Generator display/control PCB pattern (PDF download) [04203102] (Free)
  • S/PDIF Digital Audio Signal Generator front panel label artwork (PDF download) (Panel Artwork, Free)
  • S/PDIF Digital Audio Signal Generator top panel label artwork for Jaycar case (PDF download) (Panel Artwork, Free)
  • S/PDIF Digital Audio Signal Generator top panel label artwork for Altronics case (PDF download) (Panel Artwork, Free)
Articles in this series:
  • Digital Audio Signal Generator, Pt.1 (March 2010)
  • Digital Audio Signal Generator, Pt.2 (April 2010)
  • Digital Audio Signal Generator, Pt.3 (May 2010)

Purchase a printed copy of this issue for $10.00.

Interface your PC to the real world with this eight- Arduino-compatible Want to control something – anything – with commands from your PC? Perhaps turn sprinklers on and off to water your garden? Maybe read some sensors? Or even sequencing Christmas tree lights in time with music? (OK, so we’re getting in early!) Making the computer output the correct information is one thing. Interfacing that data to control realword devices is another. That’s what this nifty little relay box is all about. T he project, developed by Ocean “sketch” (also see panel!) that receives or responds with the status of inputs. Controls, is based on the hard- simple commands over the USB or This sketch is available on the Ocean ware of the Arduino physical RS485 serial port and switches relays Controls website as an example of Arduino programming for the computing controllers. It controller. can be programmed as a Multiple controllers can be stand-alone controller usFeatures connected to one or more PCs ing the free, open source • 8 Relay outputs 5A 250VAC in an RS485 network. Each Arduino environment. • 4 Opto-isolated inputs 5-30VDC controller can be assigned They’ve called it the • 3 Analog inputs (10-bit) an address and will respond “Relayduino”, for obvious • Connections via pluggable screw terminals to commands addressed to reasons. • 0-5V or 0-20mA analog inputs, jumper selectable them. Internally, the controller • Power indicator LED A simple ASCII protocol is “shield compatible”, • Arduino compatible allows control from Winallowing the use of many • Accepts Arduino shields (Ethernet/XBee) dows/Mac/Linux using either extension boards designed USB Virtual COM drivers or for the Arduino Deumilan• USB virtual COM or RS485 input RS485. ove (see the panel later in • Suits Windows/Mac/Linux/etc Additionally, multiple dethis article). • Easily connect multiple units far apart by RS485 vices can be connected to one As shipped, the con• All enclosed in professional-looking plastic case RS485 bus, allowing control troller is loaded with a 66  Silicon Chip siliconchip.com.au -channel, USB/RS485 Design by Greg Radion# Article by Greg Radion and Ross Tester I/O Controller of many devices from one USB port. The relays are capable of switching up to 5A at 250VAC, 10A at 120VAC and 10A at 24VDC but the PC board tracks will only handle up to about 5A. But what can you do with it? That, of course, is the $64,000 question – but in this case, the answer is simple: whatever you want! The project described is simply a means of taking inputs, whether digital or analog and using those to switch relays under the software which you drive it with. We’re not going to go into a lot of detail here nor describe any of the software you’ll need to perform the tasks required. Quite simply, that would be a near-infinite list, dependent entirely on exactly what it was that you wanted to control/sample/read/etc. However, on the Ocean Controls website you’ll find a few sample programs, including one which will flash your Christmas Tree lights! A fair degree of experience is assumed in building this project. Perhaps it’s even better to assume that by building and using this project, you’ll gain a lot of experience! Because it is operated from low siliconchip.com.au # Ocean Controls Specifications Power Supply: Analog Input ANx: 0-5V: 0-20mA: Opto-isolated input: Relay outputs: 5V auxiliary supply: 9-16V DC (12V Nominal) ~200mA + external 5V drain ~500keffective resistance with no jumper installed ~250effective resistance with jumper installed 0-30V, ~1keffective resistance SPDT contacts rated to 5A (resistive), 250VAC / 30VDC 200mA power (nominally 12V DC) it’s very safe to experiment with. However, the relays are rated to switch mains voltages so we must be quite specific in our warnings regarding working with mains: if in doubt, don’t! Via closest to “5” on ANALOGS header R8 solder pad closest to “R8” label If the PC board version is marked as KTA-223v1 then an insulated wire link needs to be soldered between the points shown here. Other PC board versions do not need this link. April 2010  67 12V INPUT T17 + D10 A REG1 7805 +12V K 220 F – OUT IN GND 100nF T16 + 10 F 100nF – 19 VBUS D– D+ GND K5 100nF 1.5k +5V A +5V 5V OUTPUT USB 100nF 10 F 16 15 20 Vcc 2 DTR 4 VccIO RST USBD– CTS USBD+ IC3 RxD 100nF 10k 10k LK4 18 4 AVcc Vcc 29 RST 100nF Vcc S1 5 MOSI RxIFTD FT232RL 1 TxD +3.3V 17 3.3V 13 OUT TxDEN 26 25 TEST AGND GND GND GND 7 18 21 MISO TxOFTD SCK A D4 K K A D1 K 5 MOSI 16 SDA 4 ICSP 17 SCL GND D2 4.7k RO 6 7 A B IC4 DI LTC485S RE DE 4.7k A 10k D8 4 A RxImax 2 TxEN K A D7 3 GND 5 K A D9 D6 K T9 PB1 PB0 30 PD0 RxIAVR PD7 31 PD1 TxDAVR PD6 28 PC5 TxEAVR PD5 IC1 PD4 ATMEGA328 10k 1k K OPTO ISOLATED INPUT1 D11 A – (OPTO ISOLATED INPUTS 2 & 3 NOT SHOWN) + T12 CURR INPUT1 CURR INPUT2  3 PD3 PD2 6 D14 A 7 8 1C 18 12 2 2B 2C 17 11 3 3B 3C 16 10 4 4B 4C 15 9 5 5B 5C 14 2 6 6B 6C 13 1 7 7B 7C 12 32 8 8B NC COM NO (RELAYS 2-7 & CONS T2-T7 NOT SHOWN) RLY1 8C 11 T1 E 9 PC1/ADC1 A1 25 PC2/ADC2 A2 26 PC3/ADC3 A3 27 PC4/ADC4 A4 NC COM 13 NOTE: While the eight relay contacts are each rated at 5A/250V (AC) and 10A/12V (DC), the PC board tracks may not be. Therefore, we strongly urge that if you are going to control this magnitude of current (or greater), the relay contacts be used only to switch higher-rated external relays, with due care taken for electrical safety. AREF 11 20 100nF 10  T8 NO 15 D10-D14 9 K A T13 3x 4.7k T14 LK1 CURR INPUT3 1 1B 24 16 12  RLY8 10 13 4x 4.7k 14  5 1k – 2 4 K OPTO ISOLATED INPUT4 1 IC5 TLP283-4 6 COM +5V + 3 +12V A D5 K K TxOmax 1 1 CONN A IC2 ULN2803 8 Vcc 2 15 10k +5V RS485 IN/OUT K6 RESET +5V T15 K 6 Vcc RESET 11 POWER  LED1 240 LK2 240 LK3 240 19 ADC6 A6 22 ADC7 A7 23 PC0/ADC0 A0 D1-D9 XTAL1 XTAL2 7 8 K A X1 LED AGND GND GND 5 3 21 K A 7805 SC  2010 USB RELAY CONTROLLER (OCEAN CONTROLS KTA-223) GND IN GND OUT Fig.1: The controller is based on the ATMEGA328 and is compatible with the Arduino platform. 68  Silicon Chip siliconchip.com.au You know that old adage “a little knowledge is a dangerous thing”? Nothing is truer when it comes to working with mains. Note also the warning later on the limitations not only of the relay contacts but also of the current-carrying capacity of the PC board tracks. PC board assembly The Relayduino kit comes partially assembled – all surface-mount components have already been placed, with the exception of three resistors that are not needed (R4, R5 and R7). Board assembly involves the addition of the through-hole components. The PC board supplied in the kit may be one of two versions, depending on production. If yours is marked as KTA-223v1, then a wire link needs to be added. It is soldered between the via (the link between the top and bottom layers of the board) closest to the numeral “5” of the “Analogs” Header and the edge of the surfacemount resistor R8, closest to the text “R8” (see photo overleaf). If the board is marked KTA-223v2 or higher then no link is required. However, check before adding the link to the v1 board, as Ocean Controls may well have already added the link for you! Next, add the header pins for the jumpers (or shunts). First cut the 8x1 header pin strip to make four lots of two pins each, then solder each twopin set in place for J1, J2, J3 and J4. The matching jumper shunts (or shorting pin sets) can now be installed if the auto reset feature and 0-20mA signals are to be used. There are quite a few right angle terminal sockets to solder in. Two 12-way connectors make up T1-T8 and one each of 12-way, 5-way and 2-way make up T9-T17, as shown in the component overlay and PC board silk screen. The sockets should be installed so that they overhang the edge of the PC board, as shown in the photo. Next comes the 7805 regulator. Before soldering it in, the regulator legs should be bent 90° down with a pair You can increase the current-carrying capacity of the PC board tracks by filling the vias (the plated holes which pass from the bottom layer to the top layer of the board) with solder, as seen here. The tracks themselves (at the top of the board) are wider to carry the extra current but the copper within the vias is very thin. Filling with solder helps overcome this problem. of pliers so that when it is soldered to the board, its mounting hole lines up with the hole in the board. Then it can be fastened to the heat- sink (between the regulator and the board) using an M3 screw and nut. It may be easiest to do this by pushing the screw through the regulator, The bottom of the case needs to be modified as shown – the four inner PC board pillars need to be removed. This can be done with a pair of sharp sidecutters or the pillars can be carefully drilled away with a large drill bit. siliconchip.com.au April 2010  69 AN1 AN2 COM COM AN3 D– D+ +5V COM +12V 1k D11 1k 1k D12 1k (RTC MODULE) 4.7k 4.7k 4.7k 4.7k ICSP 100nF ATMEGA328 70  Silicon Chip D13 D14 4.7k 4.7k 2.0k 2.0k 4.7k 100nF 2.0k D8 D9 IC3 FT232RL 100nF 100nF 4.7k COM ANALOG INPUTS RS485 POWER USB OPTO-ISOLATED INPUTS heatsink and PC board and 4 3 2 1 determining the right “bend” POWER position that way. Once sure T17 T11 T15 T13 T12 T10 T9 T14 T16 you have got the position cor(K5) LED1 rect, solder the regulator in and trim the legs if they stick D10 4 3 1.5k out too far beneath the board. 1 2 4.7k The USB socket and the 10 F IC4 220 F relays are next to be soldered D4 LK2 LK3 LK1 10k 10k 1 in. The USB socket shouldn’t 10k IC5 D1 cause any drama but the relays TLP283-4 D7 D5 10k LK4 need some explanation. D6 D2 IC1 1k The PC board has been de100nF 1k REG1 1k signed to accept two different RESET 7805 X1 relay types – a longer, skinnier 10 F type and a squat, squarer modIC2 el. While the first type will fit ULN2803 the PC board, it is too tall to 100nF 100nF (EXPANSION fit into the case. Therefore the MODULES) supplied relays are the type that fit into the squarer of the RLY2 two rectangles marked on the RLY1 RLY8 RLY4 RLY6 PC board surface. RLY3 RLY5 RLY7 When installing the eight relays it’s best to solder them in one-at-a-time. They have the undesirable habit of dropping out when you flip the board over to solder the pins, so may want to hold them against a bit of card to T1 T2 T3 T4 T5 T6 T7 T8 prevent this. Another way of achieving NO C NC NO C NC NO C NC NO C NC NO C NC NO C NC NO C NC NO C NC this is to use a very tiny piece 1 2 3 4 5 6 7 8 of Blu-tak (about the size of a RELAY OUTPUTS grain of rice) to hold the relay Fig.2: full-size PC board component overlay, with matching photograph at right. The in place. It’s non-conductive front panel labels are described in the table below left. so doesn’t matter if it stays under the relay once soldered. Either way, ensure each of the maximum current, fill each of these pair of sidecutters – but be careful as relays is flush with the board before holes with solder once the relays are the bits can shoot off! You could also soldering. use a large drill bit to remove them. in place. (See Fig 2). There will be several unused holes Put the front and rear panels over The final component to be fitted in the PC board tracks below the re- is the LED. Its legs should be bent to each end, with the terminal blocks lays. To ensure the tracks can carry the 90° and mounted so that the flat side poking through. Insert the assembly of the body matches the flat side on into the bottom section of the case the overlay/silkscreen. So that it can – you should find the front and rear Front Panel Connections poke through the hole in the panel, panels will slide into the side guides Label Description it should be mounted approximately and channels quite easily. + Opto-isolated input positive Screw the main PC board to the case 8mm (to the centre of the LED) above Opto-isolated input negative using the screws supplied. If you find the PC board surface. 5VO 5V output for sensors Now that it’s complete, before the one of the screws is difficult (or imposCOM Common connection (ground) PC board is screwed into the case sible) to fit, simply use only three of V+ 12V power supply positive input check your soldering and ensure you the screws. To complete assembly, marry the top haven’t missed any joints or misplaced COM Common connection (ground) of the case to the bottom. It only goes components. ANx Analog input x one way, because there is an orientaUSB USB B-type connection to PC Fitting into the case tion lip on one side. The front and D+ RS485 data+ rear panels should easily fit into the The case needs slight modification DRS485 datathe inner four screw mounting pillars channels on the lid. Screw it in place C Relay common contact need to be removed as they interfere using the long countersunk screws. NO Relay normally open contact with the mounting of the board (See NC Relay normally closed contact photo overleaf). This is easiest with a Jumper settings siliconchip.com.au Parts List – Relayduino Controller 1 KTA-223 PC board, partly assembled with SMD devices 1 5mm LED 1 7805 5V regulator (TO220) 1 TO-220 heatsink 1 USB “B” female socket 8 12V relays 3 12-way right-angle terminal sockets 1 5-way right-angle terminal sockets 1 8x1 Header pin set 1 2-way right-angle terminal socket 4 Jumper shunts 8 2-way plug-in terminal blocks 9 3-way plug-In terminal Blocks 1 ABS instrument case 1 Front panel 1 Rear panel 5 6mm M3 screws 1 M3 nut The above parts will be supplied in the Ocean Controls KTA-223 kit. Visit www.oceancontrols.com. au for more details and pricing. The analog inputs can be set for 0-5V or 0-20mA operation. Inserting jumper shunts in the positions J1, J2 or J3 will set the associated analog inputs to 0-20mA operation. Removing the shunts will set the analog inputs to 0-5V operation. The analog inputs are protected with 4.7k inline resistors. These will protect the microcontroller from damage for accidental input voltages up to 30V. When the jumper labelled AUTO RESET is installed the board will reset each time a serial connection is made to the USB COM port. This should only be installed when reprogramming via the Arduino Environment, or the device will reset each time a serial connection is made to the unit. is connected to V+ and COM. The controller has screw terminals for the connection of power. Plugpack power supplies often come with a plug on the end of the lead. The plug can be cut off and bare wires exposed for the screw terminals on the controller. Connect the power supply positive to the V+ terminal and negative to the COM terminal next to it. The POWER LED should light. A series diode (D1) protects the controller by preventing it from operating with power connected in reverse polarity. If the LED does not light, ensure your supply is delivering sufficient voltage and is connected the right way around. Connections Using the controller The controller requires a nominal 12VDC to operate. This can come from a plugpack, bench top power supply or battery and siliconchip.com.au The test software downloadable from www.oceancontrols.com.au Connect the controller to a computer using a USB-A male to USB-B male cable. When the power is turned on your computer may prompt you to install drivers. The drivers required are the FTDI Virtual April 2010  71 Here’s the completed unit mounted inside the case, looking from rear to front. Connection is made to the input and output sockets by means of plug-in terminal blocks, not shown in this photo. COM Port Drivers the latest versions for all systems are available from www. ftdichip.com/Drivers/VCP.htm The Ocean Controls website also has a number of possible input and output configurations for you to experiment with. Test Utility The main window of the Windows test utility is shown overleaf. If the Address of the unit you wish to control is known put it in the “Address” text box, if not, use 0 for the address and any unit will respond. Enter the COM Port number in the “Port” text box, if this is not known it can be found in the device manager under ports. The quickest way to run device manager is by clicking Start->Run and then typing “devmgmt.msc”. Once the device is communicating, relays can be turned on or off by clicking the buttons in the Relays group and the status of the Digital and Analog Inputs are shown in their 72  Silicon Chip relevant groups. The source code for this program is available from Ocean Controls and is written in Visual Basic Express 2008 which is available free from Microsoft. Ocean Controls can also supply a similar example program with source code for Visual Basic 6. Communicating with the controller The Address and Baud Rate of the unit can be set and are stored in the controller’s memory. By default the controller is listening for serial data at 9600 baud, and has address 00. The controller will always use 1 Stop Bit, 8 Data Bits and No Parity. The commands the controller uses are in the form <at>AA CC X<CR> The <at> symbol is used to define the start of a command. AA is the address of the unit from 00 to 99. CC is a two-letter command used to determine the command type. X is a one or more characters which determines the parameter for the command. <CR> is the carriage return character. This is ASCII character 13, or 0x0d. Each time a valid command is received the unit will respond with #AA followed by any values that are requested from the unit. See the panel overleaf for a list of commands. Note that 00 is the Wildcard Address. If a command has 00 as the address, all devices will respond as if they have been individually addressed. Where from, how much? You’ll find much more information, including current pricing, instructions and software downloads, etc, on the www.oceancontrols.com.au website. siliconchip.com.au Using the controller as an Arduino device The unit as supplied is an Arduino- operation of other modules or shield compatible board with Arduino bootloader that rely on these pins (for example, the and a custom sketch loaded that responds Ethernet shield cannot be used with the to the serial commands listed overleaf. RTC module). The source code of this is available from The RS485 transceiver is connected in Ocean Controls and can be modified in the parallel with the FTDI USB to Serial conArduino environment to suit your purpose. verter and ATMega328 UART pins. The Arduino programming environment This transceiver allows half-duplex secan be downloaded for Windows, Mac OS rial communication over 2 or 3 wires. The X and Linux from www.arduino.cc transceiver requires a TX Control signal to When using the Relay Controller with enable the transmit or receive line driver. the Arduino Environment select “Arduino When transmitting, the TX Control line Duemilanove w/ ATmega328” from the must be asserted (driven high). To receive, “Tools->Board” menu, and install the the line must be left low. “AUTO RESET” jumper on the PC board The FT232RL USB to Serial converter for ease of programming. provides a TXEN signal for RS485 TransThe hardware has been designed to ceivers. When data is received from the accept the Arduino compatible Shields. USB port by the FT232RL, it asserts the TX The cover may not be able to be installed Control line, putting the RS485 transceiver when using larger shields. Some shields in Transmit mode. may require removal or modification of the The serial data is then transmitted to the back panel to fit overhanging components ATMega328 and onto the RS485 network. (the Libelium XBee shield fits with XBee Using the RS485 transceiver from modules using chip antennae but SMA custom Arduino code requires that your antenna connections conflict with the code drive the TX Control line high at the back panel). beginning of data transmission and returns The V1 controller PC board does not it low at the end of the transmission. The locate the 6-pin ICSP in the same position TX Control line is connected to Digital 19. as the Arduino Deumilanove. Some shields The Ocean Controls sketch provides an (notably the Libelium XBee shield) take 5V example of how to do this. power, ground or other signals from the The table below shows the mapping of ICSP header. These shields must be sup- Arduino pins to the inputs and outputs of plied power or signals from the standard the controller. Arduino header rows, or extended from the Arduino Pin Mapping ICSP connection on the KTA-223 IO Arduino Pin AVR Port.Pin controller to the shield. The Libelium XBee Relay 1 Digital 2 PORTD.2 shield must be supplied Relay 2 Digital 3 PORTD.3 with 5V power by conRelay 3 Digital 4 PORTD.4 necting 5V on the shield Relay 4 Digital 5 PORTD.5 to K6 Pin 2 and GND on Relay 5 Digital 6 PORTD.6 the shield to K6 Pin 6. Relay 6 Digital 7 PORTD.7 Space is provided on Relay 7 Digital 8 PORTB.0 the PC board to install Relay 8 Digital 9 PORTB.1 the SparkFun Real Time Opto-In 1 Digital 15 / Analog 1 PORTC.1 Clock module (SparkOpto-In 2 Digital 16 / Analog 2 PORTC.2 Fun part: BOB-00099). Opto-In 3 Digital 17 / Analog 3 PORTC.3 The intention is to allow the controller to Opto-In 4 Digital 18 / Analog 4 PORTC.4 operate in stand alone Analog In 1 Analog 6 ADC6 situations that require Analog In 2 Analog 7 ADC7 more timing flexibility Analog In 3 Analog 0 PORTC.0 than the stock controlRX Data Digital 0 PORTD.0 ler can provide. The TX Data Digital 1 PORTD.1 PC board connects the RS485 TX Control Digital 19 / Analog 5 PORTC.5 RTC module SDA to Ethernet Shield Digital 10 PORTB.2 Arduino Digital 12 and Ethernet Shield Digital 11 PORTB.3 SCL to Arduino Digital Ethernet Shield / RTC SDA Digital 12 PORTB.4 13. Installing this unit Ethernet Shield / RTC SCL Digital 13 PORTB.5 may prevent proper siliconchip.com.au What is Arduino? Arduino is an open-source microcontroller development environment consisting of hardware in the form of an AVR development board, software for Windows, Mac and Linux and firmware in the form of a bootloader programmed in to the AVR microcontroller on the development board. Arduino is similar to PICAXE or the BasicStamp but open source, for the Atmel AVR and cross platform. Arduino was developed to enable virtually anyone, from artists to engineers, to get up-and-running with microcontroller programming and real world interaction, without the need to dig through data sheets, design PC boards or have an engineering degree. The hardware is cheap (less than $40) for the basic Arduino Duemilenove. No further tools are needed: just plug it into a USB port, download the software to your PC and you can program it straight away. Speaking of programming the Arduino, it is done using “C”. The program is called a “sketch” and is broken into initialisation and main program sections. Many examples for all sorts of sensors and interfaces are supplied. The expansion boards for the Arduino are called “shields” and are designed to plug in to the top of the main board. Multiple shields can be stacked on top of each other. The Ocean Controls KTA-223 Relay Controller has been loaded with the Arduino bootloader and a sketch which interprets the serial commands and operates the Relays. If someone wishes to alter the protocol, or reprogram the unit, they can do so without the need of a programmer. For more details on Arduino, take a look at www.arduino.cc April 2010  73 Command Set Letter Command Parameters ON Turn relay On 1-8: Turn Relay 1-8 On Individually 0: Turn All Relays On at Once Notes This command is used to turn a single relay on. Eg, <at>44 ON 1 will turn relay 1 on for the unit with address 44. It can also be used to turn all the relays on, this occurs when the parameter value is 0. OF Turn relay Off 1-8: Turn Relay 1-8 Off Individually Similar to the on command this command will turn relays off in 0: Turn All Relays Off at Once the same manner. Eg, <at>44 OF 1 will turn relay 1 off for the unit with address 44; <at>44 OF 0 will turn all relays off. WR Write to all relays The parameter is a number which The write relays command is used when more than one relay is determines which of the relays to be turned on or off at once. The parameter is a decimal number should be turned on or off. which, in binary, represents the on and off status of the 8 relays. The least significant bit of this value controls relay 1. The most significant bit of the parameter value controls relay 8. A set bit (1) turns the relay on, a cleared bit (0) turns the relay off. Example: To turn relays 1, 2 and 6 on (and others off) the binary value required is 00100011. In decimal this is 35. (2^(1-1) + 2^(2-1) + 2^(6-1) = 35). To issue this to a controller with address 44, the required command is <at>44 WR 35 IS Status of inputs 1-4: Returns Status of Inputs    1-4 Individually 0: Returns Status of All Inputs This command will return the status of the inputs. If the parameter is between 1 and 4 then the controller will return a 0 or 1 corresponding to that input. Eg, <at>44 IS 1 will return #44 1 if the input is on, or #44 0 if the input is off. If the parameter is 0 then the unit will respond with the status of all the inputs, in similar form as the Write Relays command. Eg, if inputs 1 and 2 for the unit are on then <at>44 IS 0 will return #44 3. 3 is 0011 in binary, and each bit represents each input from 4 down to 1. RS Much the same as the input status command, this command will return the status of the relays. If the parameter is between 1 and 8 then the unit will return with a 0 or 1 corresponding to that relay. Eg, <at>44 RS 1 will return #44 1 if the relay is on, or #44 0 if the relay is off. If the parameter to this command is 0 then the unit will respond the same way as the input status command, but return the status of the relays. Status of relays 1-8: Returns Status of Relays    1-8 Individually 0: Returns Status of All Relays AI Read analog input 1-3: Read Value of Analog Input The analog input command will read the status of the analog    1, 2 or 3 input defined by the parameter and return it as a value between 0: Returns Value of All Analog 0 and 1023. Eg, <at>44 AI 1 will return #44 512 if the analog input    Inputs is reading 50%. SA Set address 01-99: Sets the Address of the Addresses are valid from 01-99. A unit will only respond if its    unit in Memory address in memory is the same as that of the command sent, or if the address of the command sent is 00. The address is saved to non-volatile memory inside the controller, meaning it will be preserved even after power is disconnect from the controller. SB Set baud rate 1-10: Sets the Baud Rate 1: 1200 baud 6: 19200 baud The baud rate is saved to non-volatile memory inside the controller, 2: 2400 baud 7: 28800 baud meaning it will be preserved even after power is disconnected 3: 4800 baud 8: 38400 baud from the controller. 4: 9600 baud# 9: 57600 baud 5: 14400 baud 10: 115200 baud (# default) SC 74  Silicon Chip siliconchip.com.au