Silicon ChipPICAXE Net Server, Pt.1 - September 2006 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Australia's energy policies should rely heavily on natural gas
  4. Project: Turn an Old Xbox Into A $200 Multimedia Player by Julian Edgar
  5. Feature: Thomas Alva Edison – Genius; Pt.1 by Kevin Poulter
  6. Feature: Transferring Your LPs to CDs & MP3s by John Clarke
  7. Project: PICAXE Net Server, Pt.1 by Clive Seager
  8. Review: “Wachit” – It Turns A VCR Into A Security Recorder by Murray Downes
  9. Project: The Galactic Voice by John Clarke
  10. Project: Aquarium Temperature Alarm by Peter Smith
  11. Project: S-Video To Composite Video Converter by Jim Rowe
  12. Salvage It: The good bits in old receivers by Julian Edgar
  13. Vintage Radio: The Admiral 5BW mantel receiver by Rodney Champness
  14. Book Store
  15. Advertising Index
  16. Outer Back Cover

This is only a preview of the September 2006 issue of Silicon Chip.

You can view 36 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:
  • Thomas Alva Edison – Genius; Pt.1 (September 2006)
  • Thomas Alva Edison – Genius; Pt.1 (September 2006)
  • Thomas Alva Edison – Genius, Pt.2 (October 2006)
  • Thomas Alva Edison – Genius, Pt.2 (October 2006)
Articles in this series:
  • PICAXE Net Server, Pt.1 (September 2006)
  • PICAXE Net Server, Pt.1 (September 2006)
  • PICAXE Net Server, Pt.2 (October 2006)
  • PICAXE Net Server, Pt.2 (October 2006)
  • PICAXE Net Server, Pt.3 (November 2006)
  • PICAXE Net Server, Pt.3 (November 2006)
  • PICAXE Net Server, Pt.4 (December 2006)
  • PICAXE Net Server, Pt.4 (December 2006)
Items relevant to "The Galactic Voice":
  • PCB patterns for the Galactic Voice (PDF download) [08109061/2] (Free)
  • Galactic Voice control panel artwork (PDF download) (Free)
Items relevant to "Aquarium Temperature Alarm":
  • PICAXE-08M software for the Aquarium Temperature Alarm (Free)
  • PCB pattern for the Aquarium Temperature Alarm (PDF download) [03109061] (Free)
  • Aquarium Temperature Alarm front panel artwork (PDF download) (Free)
Items relevant to "S-Video To Composite Video Converter":
  • PCB pattern for the S-Video to Composite Video Converter (PDF download) [02109061] (Free)
  • S-Video to Composite Video Converter front panel artwork (PDF download) (Free)

Purchase a printed copy of this issue for $10.00.

PICA XE Net Ser ver – Pt.1 By CLIVE SEAGER Control your next electronics project from virtually anywhere on the planet using the Internet and a tiny web server – the PICAXE Net Server! M OST READERS WILL already be aware that it’s possible to control just about anything over the Internet. Unfortunately, the complexities involved in doing so mean that simple do-it-yourself projects are locked out of this extremely useful technology – until now, that is! The PICAXE Net Server (PNS) described here is a microcontrollerbased web server, designed to operate either by itself or in partnership with a PICAXE chip. This small (112 x 76mm) board acts as a complete stand-alone web server, without the need for a computer, making it ideal for building into electronics projects. Because the PNS is microcontroller based and reads its web pages from a small memory chip (EEPROM), it obviously cannot act as a conventional web server, serving thousands of pages to hundreds of users. However, when used appropriately as an Internet 40  Silicon Chip interface for electronics projects, it is an extremely versatile and powerful piece of equipment. Over the coming months, we’ll look at using the PICAXE Net Server in a couple of simple projects. This month, we’ll look at the basics of the PNS and then construct a simple demo board to connect to its input/output port. The remainder of the article focuses on setting up the PNS and culminates in the use of the demo board for testing. What you need It is recommended that first-time users of this system purchase the PICAXE Net Starter Pack. The pack includes the PNS itself, the Net Demo board and a Protoboard with a PICAXE-28X chip installed (see “Obtaining Kits & Software” elsewhere in this article). Also included are the required serial download and network cables. The PNS and Protoboard are supplied fully assembled, whereas the Net Demo board is supplied as a kit for user assembly. You will also need to purchase a 9V DC 1A power supply separately (eg, a plugpack) if you don’t have one. Note that although it’s possible to set up and test the PNS without a network, you can’t do much more than that unless you have (at minimum) a fully functioning small home network with an Internet connection. Future instalments will describe the network setup in some detail, including how to make the PNS visible on the Internet. However, due to the huge variation in networking products, we cannot hope to cover all possible configurations. You should therefore have at least a basic knowledge of Microsoft Windows networking or be able to obtain assistance from someone who has if necessary. Before continuing, make sure you have upgraded your PICAXE Programming Editor software to version 4.1.16 (or later). The software updates are available to download free of charge from www.picaxe.co.uk. The PNS circuit A block diagram of the PICAXE siliconchip.com.au Table 1: PNS Input/Output Port Pin Special Function P7 input P6 P4 output - PWM output input - DS18B20 digital temperature sensor interface output - LED tick output P3 input - ADC3 P2 input - ADC2 P1 input - ADC1 P0 input - ADC0 I/O port The PNS has an 8-bit general-purpose input/output (I/O) port, accessed via a 16-pin IDC header (CONN5). Under software control, each pin is individually configurable as a digital input or output. Each pin also has an associated special function, as listed in Table 1. siliconchip.com.au Fig.1: the PICAXE Net Server is based around a PIC18F452 microcontroller from Microchip. Compressed web pages are stored in a tiny 64kbyte EEPROM, while a 2-line, 16-character LCD conveys status information and can display user-programmed messages. The network connection is handled by a Realtek RTL8019 Ethernet controller chip. 9-PIN SERIAL CONNECTOR STATUS LEDS NETWORK STATUS LEDS RJ45 NETWORK CONNECTOR RESET SWITCH MODE SWITCH 2.1MM DC POWER SOCKET INPUT/OUTPUT PORT CONNECTOR Net Server appears in Fig.1. At the heart of the system is a PIC18F452 microcontroller, programmed with the PNS firmware. The micro connects to the network via an RTL8019 Ethernet controller chip. Time and date are maintained by a battery-backed DS1307 real time clock (RTC) chip, while the web pages are stored in a 24LC512 EEPROM. The PNS also includes a serial interface, a general-purpose input/output port and a 2-line, 16-character LCD. A photograph of the PNS appears in Fig.2, highlighting the positions of the various connectors, LEDs and switches. Note that the LEDs between the serial and network connectors are stacked two high to maximise on real estate. The LEDs next to the network connector indicate network status, the top LED lighting when the PNS is correctly connected to a network. The bottom LED is also normally illuminated but flickers while network communications are in progress. Of the other two LEDs, the upper device connects to the RTC chip and flashes once per second. The lower LED connects to the output port (P4) and can be used within a program as a status indicator. Alternatively, it can be configured as a “heartbeat” signal, flashing every second to show that the PNS firmware is operating normally. ICD CONNECTOR (DO NOT USE) P5 - mode switch Fig.2: the PNS is supplied fully assembled. Most of the electronics is hidden beneath the LCD module, which sits atop 12mm standoffs. All connectors are positioned along the extremities of the PC board for easy access. The ICD (in-circuit debugging) connector is for factory programming, so don’t connect anything to it! When configured as outputs, all pins have a maximum sink or source current of 20mA. An exception to this is output 4, which is open collector and so can only sink current. In operation, the I/O pins are controlled via two 8-bit registers in the PNS named “TRIS” and “SF”. A zero in any bit of the TRIS register causes the corresponding pin to act as an output, whereas a one causes it to act as an input. Setting an SF bit to one enables the corresponding pin’s special function, while a zero disables that function. Demo board assembly The PICAXE Net Demo board is designed to allow initial testing of the PNS input/output port. It’s supSeptember 2006  41 the 16-pin IDC connector is oriented correctly. If you follow Fig.4 and the markings on the PC board, you can’t go wrong! Once assembled, set trimpot VR1 to about mid-position and connect the board to the PNS using the 16way ribbon cable assembly supplied in the starter pack. Note that a row of holes (currently unused) is provided for the connection of experimental test circuits, if desired. The TRIS and SF registers in the PNS must now be set up to suit the input/output devices present on the board. Using the information in Table 2, we can deduce that the registers should be set as follows: Fig.3: the Net Demo board provides a means of connecting a group of peripheral devices (a switch, LDR, temperature sensor and two LEDs) to the PNS input/output port for testing. TRIS = %10101011 = 171 SF = %11110011 = 243 This month, we will set these register values automatically via a default web page already programmed in the PNS. In future articles, we’ll look at other ways to set these values and create our own custom web pages for the PNS. In the meantime, let’s continue with the initial PNS setup procedure. Setting up the PNS Fig.4: follow this diagram when assembling your Net Demo board. Take care with the orientation of the DS18B20, the LEDs and the I/O connector (CT1). The view at right shows the full-assembled board. The PNS setup procedure varies slightly depending on how your home network is configured. Generally, it’s a 4-step process, so let’s examine each step in turn. STEP 1: Connect The Network Cable plied as a kit of parts and shouldn’t take you more than about 10 minutes to assemble. The circuit diagram for the demo board appears in Fig.3. As you can see, pins P0, P1 & P5 of the PNS port connect to a variable voltage (VR1), a light sensor (LDR) and a temperature sensor (DS18B20), respectively. In ad- dition, P3 connects to a switch, while P2 & P6 drive red & green LEDs (P4 is not used). Refer to the overlay diagram in Fig.4 for component placement. In particular, ensure that the flat (cathode) sides of the two LEDs and the DS18B20 temperature sensor are oriented as shown. Also, ensure that the notched side of Table 2: PNS Setup For Net Demo Board Pin TRIS SF Demo Board Use P7 Input PNS mode switch not connected P6 Output PWM output LED P5 Input Temperature DS18B20 temperature sensor P4 Output PNS ‘tick’ LED not connected P3 Input -- push switch P2 Output -- LED P1 Input ADC1 Light Dependant Resistor P0 Input ADC0 Preset Resistor 42  Silicon Chip There are two possible ways to connect the PNS to your computer to perform the initial setup and testing: (a) Connection via a hub/switch/router (recommended) If your computer is part of a home network, it will probably be connected to a small hub, switch or router. In this case, use an ordinary (“straightthrough”) network cable (coloured blue in the Starter Pack) to connect the PNS directly to a spare port on your network hub/switch/router. Make sure that the device supports “10-BASE T” connections; devices marked as “10/100” are compatible. (b) Direct connection If your computer is not connected to a network, then it can be connected directly to the PNS. Of course, this assumes that your computer includes a “10-BASE T” compatible networking socket. To make the connection, simply use the “crossover” cable (coloured grey in siliconchip.com.au Parts List: Net Demo Board Fig.5: if your network uses fixed IP addresses, then you need to manually assign an IP address to the PNS before use. This is achieved via the Programming Editor’s “PICAXE Net Setup” wizard, as depicted here. 1 PC board 1 16-way IDC connector (CT1) 1 miniature tactile pushbutton switch (S1) 1 miniature 10kW trimpot (VR1) 1 miniature LDR Semiconductors 1 DS18B20 1-wire digital temperature sensor 1 5mm red LED (LED1) 1 5mm green LED (LED2) Resistors (0.25W 5%) 2 10kW 1 4.7kW 2 330W Obtaining kits and software Fig.6: a “ping” test is a quick way of verifying that the PNS is contactable over the network. You’ll note that we’ve used an address of 192.168.0.21 for the PNS in these examples, rather than 192.168.0.11 as described in the text. Either should work on a small home network! the Starter Pack) to connect the PNS to your computer’s network connector. STEP 2: Connect A 9V DC Plugpack Connect a 9V DC plugpack (2.1mm tip, centre positive) to the DC input socket. When power is applied, the LCD should display “PICAXE NET v1.00”. If you don’t see this message or it is very faint, try adjusting the LCD contrast setting using the vertical trimpot at the front of the PNS. When the PNS has a working network connection, the top LED (next to the network connector) will light. STEP 3: Set The PNS IP Address All devices connected to a network, including the PNS, require a unique IP address for identification. As supplied, the PNS is configured to automatically receive an IP address from the network. In this mode, the DHCP server (eg, your router) allosiliconchip.com.au cates the PNS an IP address as soon as it connects to the network. If your network supports DHCP, the IP address (eg, something like 192.168.0.5) will appear on the PNS LCD screen a few seconds after a successful network connection is established. In this case, you can skip directly to Step 4! If you have connected the PNS directly to the computer via the crossover cable or if no IP address automatically appears on your PNS LCD, then your network is using fixed IP addresses. In this case, you must manually assign a fixed IP address to the PNS. At this point, it is useful to know the IP address of your computer. To discover the address, run the Programming Editor software and then choose the PICAXE -> Wizards -> PICAXE Net Server -> Ping Test menu. The computer’s IP address will be displayed The PC board copyright for this project is owned by Revolution Education Ltd. A complete NET001 Starter Pack is available from authorised PICAXE distributors – see www.microzed. com.au or phone MicroZed on 1300 735 420. Each Starter Pack contains: 1 NET002 PICAXE Net Server 1 NET006 PICAXE Net Demo Board kit (as listed above) 1 CAB010 RS232 serial cable 1 CAB005 CAT5 patch cable (blue) 1 CAB006 CAT5 crossover cable (grey) 1 AXE022P PICAXE-28X Protoboard 1 AXE010X PICAXE-28X microcontroller (preinstalled on above Protoboard) 1 NET004 16-way IDC ribbon cable assembly Also required (not in Starter Pack) 1 9V DC plugpack with 2.1mm plug, centre positive Optional items 1 USB010 USB to serial adapter 1 HUB001 5-port 10/100 Ethernet switch 1 CAB005 CAT5 patch cable (for use with switch) Optional add-ons SPE020 Speech synthesizer MIC052 PCF8570P RAM September 2006  43 Jargon Buster DHCP (Dynamic Host Configuration Protocol): A networking protocol that allows a DHCP server to assign temporary IP addresses to network computers by “leasing” IP addresses to users for a limited amount of time. Dynamic IP Address: A temporary IP address assigned by a DHCP server. Ethernet: A networking protocol that specifies how data is placed on and retrieved from a common transmission medium. IP (Internet Protocol): A protocol used to send data over a network. IP Address: The address used to identify a computer or device on a network. The address can be static (fixed) or dynamic (changing). Ping (Packet INternet Groper): An Internet utility used to determine whether a particular IP address is online. PNS: PICAXE Net Server Port: The connection point on a computer or networking device used for plugging in cables or adapters. RJ-45 (Registered Jack-45): An Ethernet connector that holds up to eight wires. RTC (Real Time Clock): an integrated circuit that allows the PNS to maintain the current time and date. Server: Any computer whose function in a network is to provide user access to files, printing, communications and other services. Static IP Address: A fixed address assigned to a computer or device that is connected to a network. Subnet Mask: An address code that determines the size of the network. TCP (Transmission Control Protocol): A network protocol for transmitting data that requires acknowledgement from the recipient of data sent. TCP/IP (Transmission Control Protocol/Internet Protocol): A set of instructions PCs use to communicate over a network. in the Starter Pack) between your PC’s 9-pin serial port and the serial port connector on the PNS. If your computer lacks a serial port, you’ll need a USB-to-serial adapter. (b) Make sure that the Programming Editor software is set up to use the correct serial port via the View -> Options -> Serial port menu. (c) From the PICAXE -> Wizards -> PICAXE Net Server -> Setup menu, select the “Fixed IP” option and enter the desired IP address (see Fig.5). For testing purposes, make sure the subnet mask is set to 255.255.255.0 and the gateway is set to the same as the IP address. For example, if you have selected 192.168.0.11 as the PNS IP address, the correct settings would be: IP: 192.168.0.11 Subnet Mask: 255.255.255.0 Gateway: 192.168.0.11 (d) Click on “Download” and a dialog box will appear with further instructions. Briefly, you must now press and hold the “Mode” switch while pressing the “Reset” switch. A “Setup. . .” message will then appear on the LCD, after which you can click on the “OK” button to initiate the download. After programming, the PNS should immediately display your selected IP address on the bottom line of the LCD. The serial cable can now be disconnected, as it is only required for the above steps. STEP 4: The Ping Test. at the bottom of the “Ping Test” window. If the number is 0.0.0.0 then no IP address is currently set up on your computer. Next, you need to select an IP address for the PNS. If you are familiar with IP addresses, you have probably already nominated a suitable number and so can proceed directly. Alternatively, a good rule of thumb for home networks is to select an address that is about 10 larger than your computer’s current address. For example, if the computer’s IP reads 192.168.0.1, then try 192.168.0.11 for the PNS. The important point here is that no two devices on the network must be using the same address! Now that you’ve selected an IP address, it must be programmed into the PNS, as follows: (a) Connect the serial cable (supplied Fig.7: some Internet security/firewall packages may prevent the PICAXE Programming Editor (progedit.exe) from accessing the Internet. Here’s the warning message given by one popular package. In this case, choose “Permit” and “Always use this action” to allow access. 44  Silicon Chip Your PNS should now be displaying an IP address (eg, 192.68.0.11). In the Programming Editor, select the PICAXE -> Wizards -> PICAXE Net Server -> Ping Test menu. Enter the IP address (as shown on the LCD) and then click “Ping”. If the system is set up correctly, you should see a series of four replies on the screen almost instantly - similar to the example shown in Fig.6. This proves that your computer can “talk” to the PNS over the network. Note: the first time you use the Programming Editor software with the PNS you may get a warning message if you are running an Internet security/firewall application. This is completely normal. You simply need to ensure that your firewall software allows the Programming Editor executable file (progedit.exe) to communicate on ports 80 (HTTP) and 21 (FTP). In the case of the Norton Internet Security (see Fig.7), choose “Permit” and “Always use this action” to prevent siliconchip.com.au the message appearing again in the future. Note that if you do not correctly configure firewall/security access, the Programming Editor software will be prevented from communicating with the PNS. STEP 5: View The PNS Web Pages Using A Browser Open your web browser and enter the IP address shown on the PNS screen as the website address (eg, http://192.168.0.11). The default home page of the PNS should then be displayed - see Fig.8. A click on the netdemo.cgi link should then take you to the demo page for the PNS Net Demo board (Fig.9). Make sure the demo board is connected to the PNS and then click the “Setup SF/TRIS” button at the top of the page. This configures the TRIS and SF registers of the PNS to match the demo board layout, as described earlier. Now click the “Switch LED on” button. If all is well, the LED on the demo board should light up! So there, you have it – control of devices over a network from an Internet browser! OK, so the PNS is probably sitting on the desk in front of you at the moment but in theory you can control it from anywhere in the world! The web page will refresh every three seconds with the PNS input variables. Try holding down the pushbutton switch on the demo board or heating up the temperature sensor by holding it; you will see the corresponding values change on the page. Note that because the PNS is a microcontroller-based device, it may occasionally not serve a web page within your browser’s timeout period. This will cause a “page not available” error (or similar) to be displayed. In these instances, simply clicking the “refresh” button on your browser should bring up the desired page. Fig.8: once you can access the default page of the PICAXE Net Server, you’re ready to test the I/O port. Click on the netdemo.cgi link to get to the tests. Mission complete You have now completed the PIC­ AXE Net Server setup and can access its web pages and perform simple control functions over the network. Over the coming months, we will describe how to build a more complex PICAXE project and include details on how to make the PNS visible over the Internet. As promised, this will allow you to control your projects over the Internet from anywhere in SC the world! siliconchip.com.au Fig.9: the page allows you to test the PNS input/output port and at the same time demonstrates the remote control capabilities of the system. Click on the “Setup SF/TRIS” button first, then have fun experimenting with the other parameters! September 2006  45