What was that? A Whats-a-Maja-Thimagig?
Yep - One of those! This Instructable extends my Arduino Ethernet controller to control a set of up to 6 relays, but that's not the neat bit. The neat bit is that there is a web based state machine in the AtMega chip so that the relays will operate in whatever sequence with whatever timing you want - all by themselves.
This allows you to have a set of relays connected to the end of a piece of Ethernet cable that can be accessed from a web browser anywhere from your house.
I needed a system to sequence a set of relays to control some Christmas lights around my house this Christmas, as well as to turn on and off a water fountain, so I thought that a simple controller for it would be an AtMega328 chip. Then I thought about how cool it would be to allow these things to be controlled from a web interface. A little bit of tinkering later, and this project was born. I really only needed 4 relays, but as I was doing the layout, I decided that here was enough space for 6!
This project is an autonomous controller, operating a set of 6 relays according to a pre-programmed pattern, over and over again. If you are impatient, jump to the section on programing the board to see how it is programmed.
In my case, I wanted to control a fountain and some Christmas lights, so my pre-programmed pattern is as follows:
Relay 1 - Front fairy lights
Relay 2 - Fountain Blue Light
Relay 3 - Fountain Green Light
Relay 4 - Fountain Pump
On startup, do the following forever until it is switched off:
Turn on the Fairy lights, the Blue light and run the pump. After 3 minutes, turn off the blue light, and turn on the Green light. After 3 more minutes, turn off the fountain and the fountain lights.
This would be defined in the controller as:-
State0; Relay 1, Relay 2, Relay 4 - time 3 minutes - jump to state 1
State1; Relay 1, Relay 3, Relay 4 - time 3 minutes - jump to state 2
State2; Relay 1 - time 3 minutes - jump to state 0
Relay 1 would be connected to the Fairy lights.
Relay 2 would be connected to the Blue light
Relay 3 would be connected to the Green light
Relay 4 would be connected to the pump.
You can have a completely different program, say for running a gardening facility, where the relays drive various pumps and lights for watering and heating. Whatever you like! The uses are limitless! And the hacking potential is limited only by your imagination.
Remove these ads by
Signing UpStep 1How does the programming work - or What is a state machine?
I am glad that you asked that!
The controller implements a wonderful tool called a state machine. A state machine is one of the simplest controllers that just knows two things; What the current state is, and what will the next state be?
State machines are driven by a table called a state table. Essentially what the controller does, is cycle through the state table one state at a time. Our state table documents the current output settings, and what the next state will be. In our case, it also specifies the amount of time we wait in the current state. Here is an example of a state table that toggles the first 4 relay outputs in sequence, waiting for 3 minutes between cycles;
State 0: 1 on, 2 off, 3 off, 4 off, 5 off, 6 off, Wait 3 minutes - goto State 1
State 1: 1 off, 2 on, 3 off, 4 off, 5 off, 6 off, Wait 3 minutes - goto State 2
State 2: 1 off, 2 off, 3 on, 4 off, 5 off, 6 off, Wait 3 minutes - goto State 3
State 3: 1 off, 2 off, 3 off, 4 on, 5 off, 6 off, Wait 3 minutes - goto State 0
The controller runs in an infinite loop, where it knows what the current state is, waits the required time, and then jumps to the next state as dictated by the table.
You will find state machines in things ranging from traffic lights, through washing machines, through to Industrial controllers.
| « Previous Step | Download PDFView All Steps | Next Step » |










































I have a New Arduino Uno - R3 board .
Can i program with this board the atmega IC?
Is it possible to add a port like ' 7000 ' in case i want forward the ip- port to router?
Thanks
George
As far as changing ports, the ethernet library that I used is very limited - it can only allow ports from 1 - 255 (8 bits). It is able to be changed in software though.
Please do not use the project over an external ethernet connection without some extra security. THE LIBRARY USES QUITE A FEW SHORTCUTS THAT ARE VERY INSECURE AND OPEN TO HACKING. Even if you add a login screen, then there is no guarantee that you can mahe it unhackable :-)
All of my projects have a 6 pin header that is designed to use this cable to program the chip.
Doug
i am new to ethernet, i want to control devices in lan. please can you help me.please send me your project details.
my mail ID: hardships_143@yahoo.co.in
Thanks & Regards.
http://www.chipoteka.hr/?module=moduli%2Fshop&moduleS=index&moduleLinkID=22&search=atmega&traziField=atmega
It's Arduino compatible microcontroler, unfortunately, they don't have Atmega328 which has double amount of flash memory.
Or you can always buy Atmega328 from ebay.
If anybody does need some 328 chips, email me (doug@doughq.com) and I can post one out to you.
Doug
can you send me the pcb board artwork for top and bottom . i did print out the pcb layout but the size it too big. Please send me the actual size in pdf or bmp format.
Thanks,
Jimmy
jason.bouroutis@gmail.com
Kind regards
drj113,
my email address is jimmy_wong2001@yahoo.com
thanks and Best Regards,
Jimmy
So I use "Arduino Dumemilanove or Nano w/ ATmega328"
It can be programmed using RS232 if you change the voltages.
Mantux100,
The actual size of the board is 10mm x 11mm. i use the Foxit reader software to print out the pcb artwork and the scale set it to 100%.
drj113,
Thanks for everything, i finaly get the print pcb right size.
Thanks,
Jimmy
can i use 51ohm resistor insted i cant find 50ohm resistor?
thanks Ami
can i ask about the ferrite bid is the fx18 the packing? i have dificults to find
can i use this :http://cgi.ebay.com/50-Ni-Zn-Ferrite-Bead-Core-Lead-3-5x6-0mm-Taiwan-/140329107881?pt=LH_DefaultDomain_0&hash=item20ac4441a9#ht_1504wt_905
i have to say again that I loved our instructable.
I would like to ask you, since I know very little about programing the arduino, how could I make it possible to have distinct ON/OFF commands, instead of just toggle.
I ask your help because I would like to be able to control better the relays.
I email last year asking you about your board and I let that idea go, now I decide to start again, got my relays, arduino and ethernet board running, teste your code and everything looks awesome. I am still trying to figureout how to remove the programs without damage the rest of the code but I got stuck with toggle issue.
could you help me out with this matter???
thank you in advance
PC
This is what I have been looking for :)
I am intending on using these for a community art project, where 1 will be installed in up to 50 apartments of a single block of apartments. Through the internet/local wan I will control a single light source in the apartment and in the evening create a giant pixel display using the building. How can I keep the cost down? I am not sure I can get static ip addresses for the ports in each apartment, will this matter? Any help greatly appreciated. As an arts project dealing with very limited funding.
Thanks
greg
It is here
http://kicad.sourceforge.net/wiki/index.php/Main_Page
Were you successful in getting Kicad installed?
Give this link a go.
http://kicad.sourceforge.net/wiki/index.php/Download
Don't click on the windows logo - click on the text below it - that will take you to a download page with both linux and windows versions.
Here is a direct link - savethe file and run it on your machine - that will install the program.
http://iut-tice.ujf-grenoble.fr/cao/KiCad-2010-05-05-BZR2356-final-WinXP_full_with_components_doc_autoinstall.exe