Recently,. I wrote an Instructable called, "Connect your projects to the Internet".
In that Instructable, I demonstrated the use of Microchip's ENC28J60 chip to connect your Propeller micro-controller to the Internet. This time, I want to carry things to the next step with an easy way to control the "real world" from your project.
We'll be looking at a method to safely connect 110v devices to the Propeller through the use of the x10 firecracker, a device which accepts "serial" data to wirelessly control up to 256 different devices. Later in this instructable, I'll tie the project together with the Microchip ENC28J60 project, propelling it to an Internet controllable system.
1 - Propeller Platform board (or equivalent Propeller based board)
1 - E-Net Module (or equivalent ENC28J60 circuit)
1 - A breadboard or PCB. I'll talk about methods for both.
1 - An x10 firecracker kit (Ebay), (X10.com)
1 - A "TC4427CPA" chip (Digikey)
1 - 9pin male dsub connector (Radio Shack)
2 - 10k resistors (Radio Shack)
Some hookup wire and a few basic tools.
Step 1: The "Firecracker" Circuit
The circuit for controlling the x10 Firecracker is surprisingly very simple.
This is the perfect project for a beginner, as it involves a single chip and a couple "pull down" resistors.
The x10 firecracker isn't actually a "serial communication" device like a modem, but rather accepts data from the micro-controller by reading bit sequences from the DTR/RTS lines. The Propeller can easily send data on these lines using a TC4427 level-shifter.
Jon McPhalen (Parallax forums) came up with this amazing circuit.
There are a couple different demonstration programs which allow the firecracker module to be controlled by the Propeller using a serial terminal:
Jon McPhalen's: JM_Firecracker_Demo
Ron Czapala's: FC_Demo
Both of these simple demonstration programs are excellent examples of what is possible with a few lines of Propeller Spin code.
Step 2: Building Your Own Firecracker Circuit.
While solderless breadboards are an excellent method for troubleshooting a circuit, they can also lead to the creation of various problems with loose/broken wires, and miss pinned as well as loose connections. I'd recommend the use of a solder together PCB version. If you are pinning the unit to sit on the Propeller Platform, it's a straightforward build.
I've used the Gadget Gangster mini-PCB, but any similar PCB will work just as well.
Here are the step-by-step instructions for the attached image.
- Place 8pin socket at J5-J8
- Red wire from N2 to H2
- Red wire from F2 to F7
- Small jumper wire from N4 to M4
- Small Jumper wire from M7 to L7
- Purple wire from N6 to L6
- Purple wire from N8 to L8
- 10k resistor from M5 to K6
- 10k resistor from M9 to K8
- Wire from M1 to 9pin-5
- Wire from F6 to 9pin-4
- Wire from F8 to 9pin-7
- Solder row of 4 male pins P1-P4
- Solder row of 4 (or more) male pins P6-P9
- Insert TC4427 facing left
I've added the use of male pin headers to make the board plug into my Gadget Gangster Propeller Platform, as well as a socket for the TC4427 chip.
Step 3: Testing Your Firecracker Circuit
Using the two test programs I provided links to in the first thread, you'll need to adjust the DTR/RTS lines to match your own.
Opening the programs in Propeller Tool, look for the following two lines in the first page of the program and adjust them to:
DTR = 1
RTS = 3
Once you've done that use F10 to send to them to your Propeller and load the Parallax Serial Terminal (Packaged with Propeller Tool.) Jon's test program uses typed commands like, a1on, a2on, a1off, a_bright, and so on. Ron's test program is a bit more interactive, containing both an automated demo as well as step-by-step command ability.
Step 4: The Next Step.. Internet Control..
If you read my "Connecting your project to the Internet" Instructable, then you've got a little idea of where I'm going next...
Combine two great projects for Internet control:
The magic behind making this an Internet control project is Harrison Pham's PropTCP which is an MIT licensed object. While you can certainly build your own ENC28J60 circuit, the Open Source E-Net Module is a slick way to get things up and running easily.
You'll also want a copy of Harrison's webserver, modified for use with the x10 firecracker by including Jon McPhalen's object code.
This version of the ENC28J60 webserver runs entirely on the Propeller/E-net/Firecracker combined circuit. I've included code for up to 10 devices on the "A" channel, but can easily be modified to include many, many more.
Step 5: Setting Up the Firecracker E-Net Server
Once you've downloaded and extracted the webserver code, adjust the DTR/RTS lines to match your circuit. (Lines 35,36)
Then adjust the IP address, subnet, gateway, and dns lines to your network. (Lines 48-51)
(You can obtain the subnet, gateway, and dns using "Command Prompt" and "IPCONFIG /ALL" on any Windows station.)
Optionally, you can change the device names by changing the text in the next DAT section. (Lines 56-65)
Once you've made the adjustment, connect the circuit to your network and access it by http://THE_IP_ADDRESS/x10control.html from your web browser. You should have the ability to turn on/off any of the 10 devices on x10 "A".
Step 6: What's Next?
In this Instructable, I've combined a couple great Propeller projects and created something awesome.
What can be done from here?
1. By creating a port forwarding rule in your router, you can add the ability to control devices in your home/office from the Internet, or quite frankly any Internet capable device.
2. You could easily combine this project with the use of a web camera to stream security footage from your home/office along with the x10 controls. The web server software has a built-in HTML page which could have both additional controls, and camera footage included. (See lines 234-287)
3. You could take this entire project another step further.. Include the use of a sensor to provide temperature data and even thermostat controls. The Propeller spin code for the DS1620 temperature sensor is nearly drop-in with only four connecting wires back to the Propeller.
Hopefully, I've inspired you to some great high-voltage control, safe for both you and your microcontroller!
Special Thanks to:
Jon McPhalen (Parallax forums)
Ron Czapala (Parallax forums)
Harrison Pham (Parallax forums)
Without fantastic coders like these, this project simply would not have been possible.