Need help with an electronic circuit

Meaningful discussion outside of the potato gun realm. Projects, theories, current events. Non-productive discussion will be locked.
User avatar
potatoflinger
Sergeant 2
Sergeant 2
Posts: 1136
Joined: Thu Nov 02, 2006 3:26 pm
Location: Maryland

Sun Feb 24, 2013 11:26 pm

Well, I am really new to making electronic stuff, and I am running into an issue with a project I am working on. The project is a chicken coop door that opens and closes automatically based on the amount of sunlight it receives. The door works by having an old drill wind up a rope to open and close the door. I programmed an ATtiny 85 to read the amount of light through a photocell, and then I wanted to use two relays to control the motor. (one for forwards, one for backwards)

The problem I am running into is that I know the ATtiny can't supply enough power to activate the relay, which requires 5vdc, but it needs more amperage than the ATtiny can supply. I know the best thing to use is probably a transistor of some sort, but I have no experience with them.

My question is: can anyone point me in the right direction for using a transistor to trigger the relay? I really just need to know what type of transistor to use and how I should connect it so that one of the digital outputs on the ATtiny will activate a relay.

Any help is very much appreciated.
It's hard to soar with eagles when you're working with turkeys.
User avatar
Zeus
Staff Sergeant
Staff Sergeant
Posts: 1505
Joined: Tue Oct 27, 2009 7:34 pm
Location: 'Straya, C*nt

Sun Feb 24, 2013 11:30 pm

You can use a reed relay, they take some 20-50mA, and can switch 1A. Or just a 2N2222 to switch it.
/sarcasm, /hyperbole
User avatar
dewey-1
Sergeant 3
Sergeant 3
Posts: 1298
Joined: Wed Mar 28, 2007 10:24 am
Location: NE Wisconsin USA

Mon Feb 25, 2013 1:36 am

I will do a schematic for you tomorrow.

What is the voltage and current of the drill motor? What is the power source?
Hopefully it is a DC motor.

Use a ULN2803 (sink driver) or UDN2981 (source driver) IC with one relay SPST for power on/off and a DPDT relay for polarity reversal.
User avatar
Technician1002
Captain
Captain
Posts: 5189
Joined: Sat Apr 04, 2009 11:10 am

Mon Feb 25, 2013 3:37 am

A robotics RC servo amp/motor speed control and do the job. Direction and speed is simply defined by pulse width sent to the speed control. A positon feedback pot on the door can make it a full servo, so the uController can simply send a desired positon pulse width, and the servo will simply tend itself to drive to the desired position.

Look up info on driving RC servos for further reading.
User avatar
Zeus
Staff Sergeant
Staff Sergeant
Posts: 1505
Joined: Tue Oct 27, 2009 7:34 pm
Location: 'Straya, C*nt

Mon Feb 25, 2013 6:02 am

Bear in mind though, servos aren't too cheap, and while I've used them, and love them, for this sort of application, they might not be worth the investment. Locally I'd pay $40-60 for a 5kg servo, which would be marginal for a coop door, whereas a windscreen wiper motor is about $5-15.

And personally, while micros are nifty, I'd just be inclined to make a simple light/dark sensor from $5 of parts, and not have to worry about voltage regulation and driving relays from different levels. The dependance on micros is getting concerning for the users of analogue circuitry, it's almost a dying art...
/sarcasm, /hyperbole
User avatar
POLAND_SPUD
Captain
Captain
Posts: 5402
Joined: Sat Oct 13, 2007 4:43 pm
Been thanked: 1 time

Mon Feb 25, 2013 10:14 am

Personally I'd use an H bridge - either as an IC or just build one out of transistors.


This part would make things a lot easier though I assume that the motor uses more than just 1 A ?
https://www.sparkfun.com/products/315

Does anyone know anything rated to more than 1A that has inbuilt diodes and is fairly inexpensive ?
Children are the future

unless we stop them now
User avatar
Technician1002
Captain
Captain
Posts: 5189
Joined: Sat Apr 04, 2009 11:10 am

Mon Feb 25, 2013 11:07 am

I some full mechanical servos are expensive as they are engineered to not fail when pulling high g forces on that 1/4 scale jet.. you don't need that level or expense.

The robotics guys pick up motor speed controls that are just fine for driving higher voltage (not 5 volts) with the H bridge built in. Some have a place to add a feedback pot to make the door a servo. To control it, only a single uP pin is needed with pulse width modulation.

If you want to roll your own, adding an H bridge to a very cheap servo (sub $10) to the servo amp is relatively trivial. A crash tested servo that has a good amp, but broken case or gears is a good source of a servo amp. It can drive a power amplifier to drive a drill motor.

http://www.seattlerobotics.org/encoder/ ... ontrol.htm
A commercial solution adds spike suppression, noise isolation, and even opto isoloation so brush noise doesn't swamp your logic and cause glitches or full failure. In that regard they are relatively cheap.

http://compare.ebay.com/like/3805754977 ... s&var=sbar#
User avatar
dewey-1
Sergeant 3
Sergeant 3
Posts: 1298
Joined: Wed Mar 28, 2007 10:24 am
Location: NE Wisconsin USA

Mon Feb 25, 2013 2:56 pm

Here is a simple schematic for your reversing motor control.
Note that inductive loads have about a 30% of maximum resistive current in relay contact ratings.
Attachments
PF-Motor-Ckt.jpg
User avatar
potatoflinger
Sergeant 2
Sergeant 2
Posts: 1136
Joined: Thu Nov 02, 2006 3:26 pm
Location: Maryland

Mon Feb 25, 2013 5:54 pm

Thanks for all the great info. That schematic seems like it should work well.

To answer a few questions, the power source is going to be a wheelchair battery, which is just a 12v deep cycle lead acid battery. The drill is a dc motor that runs at 9.6v. With no load on the motor, I measured a draw of between 3 and 4 amps, but under a load it would be higher.

There will be a set of normally closed sail switches (one at the upper limit of the door and one at the lower) that will cut the power to the relays that drive the motor when they are pressed, so that the door will stop in the right places.

I will post a video of it in action after I get it working. It will be at least a few days from now though, because I am going to be busy with other stuff for a little while.
It's hard to soar with eagles when you're working with turkeys.
Post Reply