Silicon ChipPICAXE Net Server, Pt.4 - December 2006 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Cheap battery drills are very wasteful
  4. Feature: The Holden Lightship & Its 2321cm Video Screen by Ross Tester
  5. Feature: What’s Happened To Electronic Advances In Cars? by Julian Edgar
  6. Feature: Excellence In Education Technology Awards by Silicon Chip
  7. Feature: Bringing A Dead Cordless Drill Back To Life by Ross Tester
  8. Project: Cordless Power Tool Charger Controller by John Clarke
  9. Project: Build A Radar Speed Gun, Pt.2 by Jim Rowe
  10. Project: A Heartbeat CPR Training Beeper by Jim Rowe & Ross Tester
  11. Project: Super Speedo Corrector by John Clarke & Julian Edgar
  12. Project: 12/24V Auxiliary Battery Controller by Branko Justic & Ross Tester
  13. Project: PICAXE Net Server, Pt.4 by Clive Seager
  14. Salvage It: The good bits in microwave ovens by Julian Edgar
  15. Vintage Radio: The AWA 976A Hybrid Car Radio by Rodney Champness
  16. Book Store
  17. Advertising Index
  18. Outer Back Cover

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

You can view 37 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.

Items relevant to "Cordless Power Tool Charger Controller":
  • Cordless Power Tool Charger Controller PCB [14112061] (AUD $10.00)
  • PIC16F88-I/P programmed for the Cordless Power Tool Charge Controller [CHRGCONT.ASM] (Programmed Microcontroller, AUD $15.00)
  • PIC16F88 firmware and source code for the Cordless Power Tool Charge Controller [CHRGCONT.ASM] (Software, Free)
  • PCB pattern for the Cordless Power Tool Charge Controller (PDF download) [14112061] (Free)
  • Cordless Power Tool Charger Controller front panel artwork (PDF download) (Free)
Items relevant to "Build A Radar Speed Gun, Pt.2":
  • PCB patterns for the Radar Speed Gun (PDF download) [DOPPLR1A/DOPPLR1B] (Free)
  • Radar Speed Gun front panel artwork (PDF download) (Free)
Articles in this series:
  • Build A Radar Speed Gun, Pt.1 (November 2006)
  • Build A Radar Speed Gun, Pt.1 (November 2006)
  • Build A Radar Speed Gun, Pt.2 (December 2006)
  • Build A Radar Speed Gun, Pt.2 (December 2006)
Items relevant to "A Heartbeat CPR Training Beeper":
  • CPR Trainer PCB [04112061] (AUD $5.00)
  • PIC16F628A-I/P programmed for the Heartbeat CPR Training Beeper [CPRTRAIN.HEX] (Programmed Microcontroller, AUD $10.00)
  • PIC16F628A firmware for the Heartbeat CPR Training Beeper [CPRTRAIN.HEX] (Software, Free)
  • PCB pattern for the Heartbeat CPR Training Beeper (PDF download) [04112061] (Free)
  • Heartbeat CPR Training Beeper front panel artwork (PDF download) (Free)
Items relevant to "Super Speedo Corrector":
  • PIC16F628A-I/P programmed for the Super Speedo Corrector [speedcor.hex] (Programmed Microcontroller, AUD $10.00)
  • PIC16F628A firmware for the Super Speedo Corrector [speedcor.hex] (Software, Free)
  • PCB pattern for the Super Speedo Corrector (PDF download) [05112061] (Free)
Items relevant to "PICAXE Net Server, Pt.4":
  • PICAXE-28X BASIC source code for the PICAXE Net Server temperature controller example (Software, Free)
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)

Purchase a printed copy of this issue for $10.00.

Con t r o l y ou r n ex t el ec t r on i c s p r ojec t f r om v i r t u a l l y a n y w h er e on t h e p l a n e t ! PICAXE Net Server – Pt.4 By CLIVE SEAGER The PICAXE Protoboard plugs directly into the PNS I/O connector and is a useful learning tool. It could even form the basis of an experimental control system that is accessible over the Internet! Last month, we showed you how to use the PICAXE Net Server (PNS) to control a motor and monitor a switch in a pet feeder via the Internet. As promised, this month we look at a more sophisticated monitoring system. A S DESCRIBED last month, basic applications requiring simple on/ off control can be driven directly from the PNS with only a few extra parts. However, more complex applications often call for a dedicated controller, perhaps based on a PICAXE chip. Fortunately, a PICAXE chip in such a system can be programmed to inter88  Silicon Chip act with the PNS by sharing information (such as sensor data) in a common area of memory. These variables can then be displayed within web pages or even manipulated by the PNS to alter system behaviour. Temperature controller Environmental temperature con- trol is one example of a process that demands a dedicated control system. A temperature controller might be used to regulate the temperature in a dwelling, greenhouse, fish tank or even home-brew storage tank – to name a few examples! An outline of a rudimentary controller that could be used to maintain room temperature (in a cold-weather climate) within a specific range is shown in Fig.1. It is based around a PICAXE-28X chip, which controls a heater and fan via transistor switches and relays. A DS18B20 sensor provides temperature feedback. If the PNS were not connected to the temperature controller, then the siliconchip.com.au BASIC program in Listing 1 would be all that’s required. The program waits until the temperature drops below a minimum of 16°C, at which point the heater (on output 2) is switched on. When the temperature subsequently rises above 22°C, the fan (on output 5) is switched on. In this example, the purpose of introducing the PNS into the system is to be able to remotely monitor the room temperature. To do this, the PICAXE chip needs to copy the temperature value into the PNS shared memory space every time the DS18B20 sensor is read. Shared memory The PNS includes an area of memory that can be accessed by both itself and a connected PICAXE chip. This shared memory is located within the DS1307 chip on the PNS circuit board and is accessible via the I2C serial bus (see Fig.2). Handshaking is employed to ensure that both the PNS and PICAXE chip do not access the shared memory simultaneously. In normal operation, the PNS has control of the I2C bus and the PICAXE chip simply ignores I2C communications. However, when the PICAXE is ready to update the shared memory, it sets the RTS signal (output0) high. Once the PNS is ready to release the I2C bus, it responds by taking the CTS signal (input 5) high. At this point, the PICAXE chip is free to use the I2C bus. Once communication is complete, the PICAXE lowers the RTS signal. The PNS responds by lowering CTS and retaking control of the bus. The modifications required to the PICAXE program to enable shared memory access are shown in Listing 2. As you can see, memory location 50 is used to store the temperature variable (temp). Of course, this application shares only one PICAXE variable but more variables can be shared if desired. In addition, it’s possible to reverse the process, allowing a value entered on a web page to be transferred back to a PICAXE variable. Refer to the PNS data sheet for details on how this can be achieved. Hardware setup The PICAXE Net Starter Pack includes a PICAXE Protoboard (part no. AXE022) which comes fitted with a siliconchip.com.au Fig.1: here’s the basic outline of what would be required for the rudimen­ tary temperature controller described in the text. It uses a PICAXE micro to control a fan and heater via two transistors, which in turn switch two relays. A DS18B20 sensor provides temperature feedback. Fig.2: external PICAXE micros can communicate with the PNS via an area of shared memory. This memory is physically located in the DS1307 clock chip on the PNS circuit board and is accessed over the I2C bus, as depicted here. Only the PICAXE-18X, -28X and -40X micros support I2C communications. A PICAXE Protoboard is included in the Net Starter Pack and it comes preassembled with a PICAXE-28X chip. Rows of pads around the board provide easy access to all of the micro’s port pins. When jumpers J1 & J2 are positioned as shown (the default), the PICAXE chip is programmed via the on-board stereo socket. For remote programming over the Internet, move J1 & J2 to the righthand position. December 2006  89 90  Silicon Chip siliconchip.com.au Fig.3 (left): here’s the circuit for most of the PICAXE Protoboard (only the optional oscillator circuit consisting of X2, C5, C6 , J4 & J5 has been omitted). Note the area enclosed within the grey box – this is not part of the Protoboard circuit. Its purpose is to demonstrate what would be required to convert the Protoboard into a rudimentary temperature controller, as outlined in Fig.1. PICAXE-28X chip. This board can be connected directly to the PNS via the supplied ribbon cable, which connects the I2C bus (SDA & SCL) and handshaking (RTS & CTS) signals. The PNS also provides power (+5V) to the Protoboard over this connection, so no separate power source is required for most experiments. Before powering up, make sure that jumpers J1–J3 are positioned as shown in the accompanying photograph. Fig.3 shows the majority of the circuit for the Protoboard. Also included (within the grey box) is the additional circuitry needed for the temperature controller function we described earlier. If you want to build your own temperature controller, then this additional circuitry (comprising Q1, Q2, RLY1, RLY2, etc) can be constructed on Veroboard or similar and connected to the PICAXE-28X port pins via the empty rows of pads on the board. Warning: the two 5V relays (RLY1 & RLY2) must not be used to switch 240VAC mains voltages. If mains appliance switching is required, then the relay contacts can be wired to appropriately rated external switching devices, such as the “Remote Relay” (DSE Cat. K-3041) published in the May 2006 edition of SILICON CHIP. Note that it’s not necessary to construct the entire add-on circuit (within the grey box) to experiment with shared memory and the PNS web pages presented here. Instead, you may wish to connect just the DS18B20 temperature sensor and it’s 4.7kW pull-up resistor; this will at least allow remote monitoring of ambient temperature. PNS web page Our web page for this month is very simple, as all it needs to do is display the temperature value. Again, the code is split between two files, temp.cgi (Listing 3) and index.htm (Listing 4). The file temp.cgi retrieves the temperature value every three seconds by siliconchip.com.au Listing 1: tempcontrol.bas Listing 2: tempmonitor.bas symbol temp = b1 symbol temp = b1 main: pause 3000 readtemp 0,temp if temp < 16 then heater_on if temp > 22 then fan_on init: i2cslave %11010000, i2cslow, i2cbyte main: pause 3000 readtemp 0,temp gosub PNS_write if temp < 16 then heater_on if temp > 22 then fan_on all_off: low 2 low 5 goto main all_off: low 2 low 5 goto main heater_on: high 2 goto main fan_on: high 5 goto main heater_on: high 2 goto main fan_on: high 5 goto main ' Sub to update PNS memory PNS_write: high 0 CTS_loop: if pin5 = 0 then CTS_loop writei2c 50,(temp) low 0 return 'set RTS 'wait for CTS 'write temp to byte 50 'clear RTS Fig.4: the circuit in Fig.3 uses abbreviated labels for the PICAXE28X pins. Here’s a more comprehensive pinout diagram. reading the value from shared memory address 50. As usual, index.htm uses frames and temp.cgi to build the home page. Refer to Pt.3 last month to learn how the code works and how to download it into the PNS. Remote PICAXE programming So what happens if you want to December 2006  91 Listing 3: temp.cgi Fig.5: once the compiled PICAXE code has been successfully transferred to the PNS, all you need to do is click on “Program PICAXE” to remotely reprogram the PICAXE chip on the Protoboard! be able to change the temperature threshold values of the PICAXE program remotely? One way to achieve this would be to expand the BASIC program and html code so that you can alter these values on a web page. Another way would be to download a new BASIC program into the PICAXE chip over the Internet! To enable the PNS to download new programs into the PICAXE chip <html> <meta http-equiv=”refresh” content=”3”> <head> <title>Temperature Monitor</title> </head> <body> <center> The temperature value is ?50 &deg; Celsius </body> </html> remotely, you must first move jumpers J1 & J2 on the Protoboard to the righthand side (see photos). This connects the PICAXE chip download pins to the PNS serial port via signal lines “TX” and “RX” on the PNS I/O connector. Important: you must first disconnect the Protoboard (or move J1 & J2 back to their default lefthand positions) before connecting the PNS to your PC via the RS232 cable. We suggest that you place <html> <head> <title>Temperature Monitor</title> </head> <frameset cols=”100%” frameborder=1> <frame name=”temp” src=”temp.cgi” marginheight=2 marginwidth=2 frameborder=1> </frameset> </html> Looking for real performance? • • • • Summary This is the final instalment of our 4-part series on the PICAXE Net Server. We hope that our examples have aptly demonstrated how this versatile unit could be used to bring low-cost remote Internet access to many different types of projects. For more information, check out the complete PNS datasheet (NET001. pdf), available for download from SC www.picaxe.co.uk. Listing 4: index.htm Completely NEW projects – the result of two years research masking tape or similar over the 9-pin “D” connector on the PNS to prevent accidental dual connection. To initiate the download process, first open the desired BASIC program in the Programming Editor and then select PICAXE->Wizards->PICAXE Net Server->PICAXE Download from the menu. The program is first compiled and if this is successful, the “FTP Transfer…” dialog appears (Fig.5). Now click on the “Connect” and “Transfer” buttons in turn. Once the “File sent successfully” message is displayed, the PNS can be issued with a “Program PICAXE” command. This can be achieved manually via a web page form or by clicking the “Program PICAXE” button. 2 160 PAGES 3 CHAPTER Learn how engine management systems work S Build projects to control nitrous, fuel injection and turbo boost systems Switch devices on and off on the basis of signal frequency, temperature and voltage Build test instruments to check fuel injector duty cycle, fuel mixture and brake and coolant temperatures Mail order prices: Aust. $A22.50 (incl. GST & P&P); Overseas $A26.00 via airmail. Order by phoning (02) 9939 3295 & quoting your credit card number; or fax the details to (02) 9939 2648; or mail your order with cheque or credit card details to Silicon Chip Publications, PO Box 139, Collaroy, NSW 2097. 92  Silicon Chip From the publ isher s of Intelligent turbo timer I SBN 09585 2294 9 780958 5229 -4 46 $19.80 (inc GST) NZ $22.00 (inc GST) TURBO BOOS T & nitrous fue l controllers How engin e management works siliconchip.com.au