Home Page |
Network Schematic |
Communication Protocol |
Circuit Diagrams |
Software to download |
PICNET is a home or office automation project designed to connect a network of up to 99 MICROCHIP PIC microcontrollers (12C508A, 16F84 and 16C71) together to provide a simple low-cost automation system. All the PICs are connected by only 3 wires and the I/O pins can be read or set using a simple ASCII protocol sent from a personal computer serial port and used to control lighting, open doors, operate air conditioning etc. The communication protocol is simple and commands can be sent from a terminal program or a high level programming language like Visual Basic. The DDE server program also supports NETDDE access across Windows networks and Dial Up Networking giving you the facility to turn household or office appliances on or off remotely. The One Time Programmable versions of the PIC devices cost between £1 and £2 to buy keeping the cost of the PICNET well within the Hobbyist budget. Please note, this is not a commercial product.
The communication input pin on the PIC microcontrollers is normally in the high impedance input state waiting for characters to be sent from the PC. When a complete command has been received the PIC will respond by changing the communication pin to an output and driving the line low to transmit characters back to the PC. After the PIC has finished the communication pin is returned to the input state to wait for further commands. The LED is used to indicate network activity and is designed to draw 10mA of current when the communication line is pulled low.
Read command: (05/28) This command is a request for node 5 to return the value of its register 28. The PIC at node 5 responds with (085) the value of register 28. The response is always 3 digits long.
Write command: (08/34/100) This command sets register 34 on node 8 to 100. The pic at node 8 responds with (100) to confirm the command.
If the node address in the command is 0 e.g. (00/24) all the nodes respond with the value of register 24 which is the node address. This command will get a response from all the PICs on the network confirming they are working correctly. A special software routine in the PIC ensures that the responses from the PICs will not clash.
These commands can be sent to the PICNET using the Windows program TERMINAL.EXE. The default PC comm port settings for the PICNET are 9600 baud , 8 bits, 1 stop bit, no handshaking. Once you have set up the communication parameters then just type the commands. As you type the LED should flicker to indicate everything working okay. The best command to type in first is (00/24) which will command each PIC on the network to return its node address.
The circuit diagrams and example programs together with the PIC software are all free to download. The PIC circuit boards are all built on vero board and the circuits have been kept as simple as possible using the minimum of components.
The communication line is pulled low through the LED. Approximately 10mA is required to pull the line low. This part of the circuit is required somewhere on the PICNET. The 5V supply is taken from the keyboard cable on the prototype using a 6 pin small din plug and socket fitted inline with the keyboard.
The 12C508A needs no additional components and can be connected directly to the PICNET. The internal RC clock has proved stable and accurate enough to work at baud rates up to 9600.
The MAX233 converts the RS232 voltage levels from the PC comm port into TTL levels suitable for the PICNET. The diode connected to pin 3 is required because the output of the MAX233 cannot be switched into a high impedance mode when not being used. The MAX233 was chosen as it needs no additional components unlike the MAX232 which requires 4 capacitors.
The 16F84 is an excellent device for prototyping due to its EEPROM program memory. I have used this device and the 16C84 to control high speed machinery in the packaging industry and it is very robust. The only additional component required is a ceramic resonator (4Mhtz). Use the new 3 pin type which saves fitting de-coupling capacitors. The EEPROM memory area is mapped to address 64-99. Use the command (07/64/150) to write to EEPROM register 0, (07/65/075) for EEPROM register 1 etc. (where the 16f84 is at node 7).
The 16C71 is very similar to the 16F84 and has four 0-5V analogue inputs. The A/D registers are mapped to registers 64-67, just read any of these registers with the command (03/64). The conversion will be completed and then the results returned as usual (200) for example. ANIN 3 is set up in voltage reference mode.
Parts List |
|
PIC 16F84 18 Pin DIL Flash Re-Programmable |
328-3775 |
PIC 12C508A 8 Pin OTP |
234-0300 |
PIC 16C71 18 pin DIL |
831-450 |
+5v 100mA Voltage regulator |
268-0147 |
Ceramic Resonator 4Mhtz |
274-346 |
The ASM file containing the software for the PICs is PICNET.ASM
Thanks to Carlos for developing the software further. Here is a copy of His new software PICNET1.ASM. Carlos has added the facility for the PIC to send a message across the PICNET when it detects an input pin change state. The original concept of the PICNET projects was for the PIC's on the PICNET to communicate with each other in a peer to peer mode and not just as a server/client with a PC. Carlos can be contacted at carlosmgr@eresmas.com for more information.
Visual basic 3 program PICSERV.EXE and the source code, is a DDE server program which simplifies reading and writing to the PICNET. PICSERV.ZIP
Visual basic 3 program PIC_COM.EXE and source code demonstrates how to communicate with the PICNET using VB3. It contains two library files, PICDDE.FRM and PICDDE.BAS. PICCOM.ZIP
If you have any questions or comments, please contact alec@bystronic-lenhardt.co.uk