Pages: [1]   Go Down
Author Topic: Timer project. Can this happen easily?  (Read 2342 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I know nothing about programming whatsoever- except a painstakingly small about of Visual Basic.

I was wondering is someone knowledgeable would help me out. I need to make a timer switch for a power outlet, cheap. I need it to switch every minute, and then every five minutes, over and over.

I was thinking I could do it the stupid way and just build a rig attached to a power strip with a little servo. On start it would run for a minute, then rotate the servo once, then after five minutes, it would rotate it the other way, and again, infinitely. I could easily use that to build something that would turn the power strip on and off as I please.

How easy would this be to program? Comparable devices run for upwards of 75$! Not to mention the skills I could learn in tinkering with the code myself.

Thanks much!


Logged

0
Offline Offline
God Member
*****
Karma: 0
Posts: 731
skcor oniudrA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Very easy, and quite a good way to start with Arduino if you haven't already got one.

You wouldn't need much of a sketch(code) to do that job with Arduino. Check out Spiff's iDuino (http://spiffie.org/kits/iduino/) all for under 20 bucks and more than enough for what your wanting.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I would probably pick one of those up, because they look cheap and I could use the soldering practice. But ultimately I want to support the original creators buy buying a real arduino, besides- I want one for personal use to tinker with with the best functionality/ build quality I can get, you know.

Funny thing, I can fix just about and hardware or software related issue on any computer, including resoldering jacks, components; what have you- but I know NOTHING about programming!

What program do you use to start making code, or what language do you write the code in? I assume you flash it via the USB. Hell, I think I could actually use visual basic.

EDIT:

I'm using a power strip because I'll want lots of sockets anyway and there's a physical switch there- I don't feel like wiring or learning to wire up high voltage required to make a wall-outlet timer right now. I'm sure sometime in the future I can make a stand-alone enclosed plug in unit; but right now a servo moving a physical switch seems easy.

http://arduino.cc/en/Tutorial/Sweep

That tutorial looks like it could be edited without much effort to add timing.  The code reminds me a lot of Visual B; and I can understand what it's saying. It's just a matter of learning some syntax I think.

Do you think a servo will handle moving once  a minute all day like that and last long or would they wear out fast?
« Last Edit: December 02, 2008, 04:37:16 pm by blujay42 » Logged

London, Ontario, Canada
Offline Offline
Jr. Member
**
Karma: 0
Posts: 90
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I want to start my reply by saying I am not sure exactly what you want to do but...

If you want to power-off a power-strip via CPU control, I would not use a servo.  I think the mechanical linkage problem would be a chore to sort out.  

Instead I would use an arduino to drive a small relay via a single transistor.  Use a 5volt relay with 120vac contacts.  Wire the relay contacts across the existing power on/off switch of the strip.  Leave the existing switch off at all times.  When the arduino pin goes high, it turns on the transistor which has enough kick to pull in the relay contacts which are switching 120vac.  Put 2 push buttons on the arduino.  One button is marked "ON" and causes the relay to turn on, the other button is marked "OFF" and causes the pin to go low/off.  

From that point onward, you would use the 2 buttons to turn on/off the power-strip power knowing that it also turns off/on under CPU timings.  If the strip is large enough, you can put the entire circuit inside the strip and drill 2 small holes for the push buttons.

note: link says 12volts but simply replace with 5volt relay:

http://terpconnect.umd.edu/~toh/ElectroSim/relay.html
http://forum.allaboutcircuits.com/showthread.php?t=13312

ps: I did the same thing last week with a relay.

Does my suggestion make sense?  If yes, write a small sketch to turn on and off an LED via push buttons.  Once that works, replace the LED with a transistor/relay and your done.

Example (missing many lines but I hope it expresses the idea)

setup()
{
#define LED1 5 // make PIN 5 our LED pin
#define RELAY1 6 // our transistor input for the relay
pinMode(LED1, OUTPUT);
pinMode(RELAY1, OUTPUT);
}

loop()
{

if (button1 == high)
{
digitalWrite(LED1, HIGH); // ON button
digitalWrite(RELAY1, HIGH);
}

if (button2 == HIGH)
{
digitalWrite(LED1, LOW); // OFF button
digitalWrite(RELAY1, LOW);
}

....add timer code here....

}
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I sortof understand your concept! Sorta :/

heh

The code makes sense at least. This would be a much more sophisticated way of doing it. Perhaps it is appropriate.

Basically, it needs to switch a power strip on and off- one for one minute, then off for five- for an infinite amount of time. Just loop.

So... you really think it's safe to bust open a power strip? Maybe if I look at it's insides i'll better understand how a switch is used to control so much power. I guess I never understood that.

You're also saving me money by not having to use a servo... and I get to learn more about what transistors and stuff actually do... so... yeah... smiley-razz


Thanks for the help.


If you're curious, I'm building and automated hydroponic system; and I want it to be more personal, smaller/ more contained than what you can buy in component form.

EDIT :  wow! it actually looks quite simple! I had no idea it was that simple!

Sorry, a bit of history. I work at a local place called Tech Junkies; we build and repair computers. I do the hardware work- replacing DC jacks, motherboards, cpus; desktops, laptops, whatever. It all requires an amazingly low electritian-esque knowledge. I also do advanced registry work and clean computers up that way... help protect data, set up raids for customer companies, monitor computers... a bit of everything!

So naturally I sit there all day and read wired. Well there was this great wired article about the arduino, and I had heard of it before- it just never seemed like something I could do. I mean sure, I peruse hackaday like an addict, but it never seemed doable as a noobie before.


« Last Edit: December 03, 2008, 12:02:31 am by blujay42 » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Where the bloody hell do I find a relay with 5v switch and 120v AC though? I can find big ones for automotive use that run 30 amps...
Logged

London, Ontario, Canada
Offline Offline
Jr. Member
**
Karma: 0
Posts: 90
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

A few comments....

adding timer code will be easy, maybe less than a dozen lines of code.
To keep it simple, wait 10th/sec with each pass of the loop, that way our push buttons still work fairly quickly (arduino will seem to sleep during the delays so keep them short).  

example:  delay(100);  // delay 10th/sec  1000=1 second

Keep a counter and when it hits 1 minute, do your thing....
counter = counter + 1;
if (counter == 600) // 600 10ths = 60 seconds = 1 minute
{
digitalWrite(LED1, HIGH); // turn on LED
digitalWrite(RELAY1, HIGH); // click on relay
counter = 0;  // restart our counter
}

maybe a we bit more detail to determine if we are at 1 min or 5 mins with this time through the loop.

I would say turn on at 1 min, off at 2 mins, on at 7 mins, off and reset counter at 12 mins.  Does that sound right? (I recommend only waiting a few seconds until you get it counting properly and then bump it up to minutes - to keep you sane!)


Comment #2:  Cut a power cord in half if you can not open the strip.  The relay is controlling the power cord which is plugged into the strip.  Make sure you have something solid to store this whole mess in.

Comment #3:  Relays?  Look around.  They are in a lot of stuff.  any old phone equipment lying around.  I stole one out of some tossed PBX trash. It had roughly 32 of them inside and a paint-stripper/blow-dryer heated the back-side all of them fell out perfectly desoldered.

Comment#4:  You could use a 12 volt relay.  The transistor can be powered by the same 12volts that powers the arduino.  The control pin of the transistor is 5 volts from the arduino but it can switch 12v (exactly like those 2 web links suggest).  

Comment#5:  A 24vac relay will probably pull in at 12vdc.

The transistor+resistor+diode will fit on a circuit board the size of a dime (even using full sized parts).  The relay is the only large part.
Any cheap 50-cent transistor will work.  Steal one off the LED speed indicator from an old PC case. The resistor can be anything from 5k to 15k, exact values not required.  You can test this stuff without the arduino.  Wire up the relay electronics and hit the input with a 3volt battery from a PC motherboard.  If it goes click, the 5v from an arduino will also work.

Once you have a controllable relay circuit, the arduino is simply the timed 5volt control signal.

One last comment...  most arduino boards have an LED already connected to pin13.  If you change the code to #define LED 13, you do not need to add an LED.
Logged

0
Offline Offline
Faraday Member
**
Karma: 7
Posts: 2526
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Where the bloody hell do I find a relay with 5v switch and 120v AC though? I can find big ones for automotive use that run 30 amps...
Seeing as you're putting this on a power strip on a standard 120VAC outlet which is 20A, 30A isn't all that big...

Here's one, and another and another.

There are also solid state relays like this and this and this, which are typically bit easier to deal with than mechanical relays (no back-EMF garbage, etc), although you may still need a transistor to get enough current to turn them on.

Warning: only 2 of the 6 devices I listed are capable of handling the current that a standard wall outlet will feed it.  If you put a 2A relay in a circuit that has a 15A breaker and a 10A load, very bad things will happen - this is the sort of circuit that results in your house burning to the ground.  Make sure there is a fuse or breaker that will open at or below the current rating of the relay you choose.

If you are building a hydroponics system, I would use some standard 24VAC sprinkler valves and power supply from the local home center and switch the 24VAC instead of 120VAC.  A bonus is you could (with a bit of effort) rectify the 24VAC and use the resulting DC to feed the arduino.

-j

Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I thought about that, but using sprinkler valves would oust the pump I already have (and don't want running all the time) because I have a unit built with it's volume and pressure all figured out.

http://www.allelectronics.com/make-a-store/item/SSRLY-42/40-AMP-SOLID-STATE-RELAY/1.html

That one looks perfect... i'm going to hammer around the shop today and see if I can find one laying around. I know where to look- I bet you anything there's one that can handle way more than I need in an old computer power supply somewhere...
« Last Edit: December 03, 2008, 09:34:54 am by blujay42 » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Th relay fuses I scavenged appear to be rated at 12A 120AC. I have 3;

Is this safe? It seems too low.

I also have a butt-ton of transistors. Should I use a really big one?
« Last Edit: December 04, 2008, 04:53:55 pm by blujay42 » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks to this great article on hackaday I have this project working flawlessly. However I have one question still, how ca I power the Iduino through USB-B without a computer?
Logged

0
Offline Offline
God Member
*****
Karma: 0
Posts: 572
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://www.adafruit.com/index.php?main_page=index&cPath=10&sessid=df9a5feff4fb420c8f84e02ab2761d70

plus your normal usb cable
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 12
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Please share the link for the article you used.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the ada link. I'll need one of those.

Right now it's still on a breadboard, but it works for low voltage, so building it into a socket shouldn't be too hard.

http://hackaday.com/2008/12/05/working-with-relays/

^that^ page taught me to use relays. I found one that can handle the current inside a washing machine, when you think about it, that's a place you pretty much expect them (high volt relays) to be.

Following is the spec sheet for the relay I found. What I did was I went around and        ized broken appliances, stealing everything that looked like a relay and anything else I wanted. I must have scored a cool dozen switches and at least 30 green led's too.

I brought back like 10, but only 2 of them were good. 277 VAC, 30 A, and a ma - 5V DC switching tolerance: perfect.

http://pewa.panasonic.com/pcsd/product/auto/pdf_cat/jtnjt.pdf


this is fun.
« Last Edit: January 04, 2009, 12:41:17 pm by blujay42 » Logged

Pages: [1]   Go Up
Jump to: