PDA

View Full Version : [Question(s)] How do I switch a 5v supply on/off with a logic 3v?



Connor
01-05-2009, 12:24 AM
I need to make a small circuit that can switch on/off a 5v supply, (low current draw, only 6 LV-MaxSonars which pull 3mA each) using a 3v logic. I need to be able to reboot my sonars, but, I want to run them at my new stable 5v supply, and use the Phidgets 8/8/8 digitial output to toggle them on/off.

Thanks, Connor

Adrenalynn
01-05-2009, 02:16 AM
How about just an op-amp?

Quantum
01-05-2009, 08:43 AM
Transistor would work here as well. There tons of circuits on the web. Nothing to complicated either.

Paul

jes1510
01-05-2009, 09:31 AM
Keep in mind if you use a transistor you will need to account for the voltage drop across the collector-emitter junction (typically around .7v but varies per transistor). For example, if you put the transistor in series with the 5v rail and use it to switch your load then your output will be 5v-0.7v=4.3v to the load. If the transistor is on the reference leg of the regulator then it will add to the output voltage (5v + 0.7v = 5.7v). You can probably use a diode to account for the drop. If you put the transistor on the reference leg of the regulator then you can put a diode in series with the output to "drop" the additional voltage. Also keep in mind that the junction drops in a diode and transistor will vary with the current so pay attention to the datasheets.

If you need a solid 5v then a rail to rail op-amp will work fine as well. Lots of options here.

I vote AND gates.

Connor
01-05-2009, 09:36 AM
I was thinking op-amp/transistor.. I just didn't know which one, nor the specific value for said componant.. This is for my Sonar ring, and that being said, this may be a mute point now, as I'm now seiresly considering converting it from analog output to Serial (based on this thread) http://forums.trossenrobotics.com/showthread.php?t=885&page=3 just because it'll free up 6 analog inputs on my 8/8/8, I don't have to use a digital output to trigger (I can use TX pin from the serial), and then I wouldn't be "sensitive" to the voltage needed to drive the ring, and I see no distinct advantage using the analog at this point. I also didn't know you could use the sonars in that way untill just a few days ago. Anyway, I would just send out a single character on the serial port and get back the follow...

*example*
R006
R018
R127
R023
R014
R032

Easy enough to use this data, since I know how many sensors I have, and since I will trigger them each time.. I'll trigger them every .35 to .4 seconds and be done with it.. Oh, I do have a free serial port, as I have one I'm using with my X10 Firecracker, which uses RTS/CTS which I don't care about with regard to sonars, All I need are the TX and RX pins. I just hope I don't have a conflict trying to open/close the comport between the two applications.. I'll have to sort that out.

Thanks, Connor

Connor
01-06-2009, 06:41 PM
How about just an op-amp?

Did you mean Op-Amp or Optocoupler?

Thanks, Connor

Adrenalynn
01-06-2009, 07:03 PM
Sorry - I've been meaning to pop back in here and clarify. Optoisolator aka OptoCoupler aka PhotoCoupler (http://www1.jaycar.com.au/images_uploaded/optocoup.pdf).

Sorry - my bad. My brain is in OpAmp mode right now since I'm building a nice stable/repeatable circuit for these flex resistors - something just slapping a voltage divider on won't yield [Pokes at Dave's tutorial]...

Jes' AND gates or transistor switch will also work just fine - and the AND gates would probably be a few microseconds "snappier" (rise-time) - but Optoisolators would be sooo dirt-simple for what you're suggesting, imho.

Edit: How about a 4N25? +5v goes through a pull-up resistor (80mA max into the LED), ground to K. When the 5v hits the LED, it switches the +3v going through C through a small resistor and then on to the load, E to ground.

$0.34 from Digikey (probably a couple bucks at RadioShack...), plus a few cents into two resistors (or a couple more bucks at RadioShack ;) )

Connor
01-06-2009, 08:09 PM
Sorry - I've been meaning to pop back in here and clarify. Optoisolator aka OptoCoupler aka PhotoCoupler (http://www1.jaycar.com.au/images_uploaded/optocoup.pdf).

Sorry - my bad. My brain is in OpAmp mode right now since I'm building a nice stable/repeatable circuit for these flex resistors - something just slapping a voltage divider on won't yield [Pokes at Dave's tutorial]...

Jes' AND gates or transistor switch will also work just fine - and the AND gates would probably be a few microseconds "snappier" (rise-time) - but Optoisolators would be sooo dirt-simple for what you're suggesting, imho.

Edit: How about a 4N25? +5v goes through a pull-up resistor (80mA max into the LED), ground to K. When the 5v hits the LED, it switches the +3v going through C through a small resistor and then on to the load, E to ground.

$0.34 from Digikey (probably a couple bucks at RadioShack...), plus a few cents into two resistors (or a couple more bucks at RadioShack ;) )

No problem.. I went and picked up a Op-Amp the other day.. and then got to looking and went, this isn't right.. :happy:

As for the component, I need to the other way.. 3 or so volts from the digital output, switching a 5v source for the sonars.

Thanks, Connor

Adrenalynn
01-06-2009, 08:16 PM
Sorry about that!

Ok - no big. The source and the load can be swapped - it's just an LED and a photo cell. For a 4N25, depending upon which model, the output needs to be <7v, <15v, <25v. But the isolation will be 2500+v, and you can find 'em that will switch up to thousands of volts DC.

Connor
01-17-2009, 05:07 PM
Hey guys, I'm needing some help with a OptoCoupler I got today, It's a NET3040 which is = 4N25. I'm trying to drive a 5v relay with it from the digital output of the Phidgets 8/8/8 and having some problems. I get around 4.87v accross the outputs when I wire it up, however, it doesn't trip the relay..Any idea what I'm doing wrong? The relay I'm using is a Sanyou SRD-S-105D, 5v SPDT.

Thanks, Connor

Adrenalynn
01-17-2009, 05:16 PM
How much current is the relay pulling?

jes1510
01-17-2009, 06:50 PM
What are the outputs? Do you have a complete schematic?

Connor
01-17-2009, 07:30 PM
How much current is the relay pulling?

According to this document. 72.46 mA for this relay @5v.

http://www.sanyourelay.ca/public/products/pdf/srd.pdf

Connor
01-17-2009, 07:43 PM
What are the outputs? Do you have a complete schematic?

No schematic. Going into pin 1 on the 4N25 from the phidgets 8/8/8 output (with a 330 ohm resister in series) pin 2 to ground.

Pin 4 to the relay coil, pin 5 to 5v supply, other pin on coil to ground.

2nd variation was putting 47k ohm resister in series with the supply to pin 5, hooked the supply to the coil, hooked pin 4 to ground.. This looked to invert the input, but, still didn't trigger the coil.

Thanks, Connor

jes1510
01-17-2009, 08:30 PM
The transistor in the 4N25 is an NPN. Hook it up like this:

From Phidgets through 330 Ohm resistor to Pin 1
Pin 2 to GNd
Pin 4 to GNd
Pin 5 to Relay coil
Other side of relay coil to Vcc

Don't forget the protection diode.

Connor
01-17-2009, 08:40 PM
The transistor in the 4N25 is an NPN. Hook it up like this:

From Phidgets through 330 Ohm resistor to Pin 1
Pin 2 to GNd
Pin 4 to GNd
Pin 5 to Relay coil
Other side of relay coil to Vcc

Don't forget the protection diode.

Tried this, didn't work.. Getting around 4.97v on the output when toggled.. I checked the relay with the 5v supply directly, and it trips.. so.. I'm confused.

jes1510
01-17-2009, 09:01 PM
Leave it hooked up the way I suggested. With the Opto "activated" measure the voltage across the relay coil. Do the same with it "unactivated". Post results here.

Connor
01-17-2009, 09:11 PM
Leave it hooked up the way I suggested. With the Opto "activated" measure the voltage across the relay coil. Do the same with it "unactivated". Post results here.

.717v with the relay in place and opto activated, 4.98 or so without the relay.
-.003v with the relay in place and opto unactivated.

I don't have the diode in place yet, but that wouldn't be the problem.. I can put it in place.. but, I though I would wait till I get this debugged.

jes1510
01-17-2009, 09:19 PM
Wait, How much current can the Phigets board source?

Connor
01-17-2009, 09:21 PM
Try changing the resistor to 100 Ohms and perform the same test as above.

Will that not blow the LED in the opto ?

jes1510
01-17-2009, 09:39 PM
Well according to the datasheet I found here:
http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=160-1300-5-ND

The maximum forward current for the LED is 80mA.

Pull out the relay and replace it with a 10k resistor. Redo the measurements above. I suspect the LED isn't turning on. Either that or you don't have it hooked up the way that you think it's hooked up.

Connor
01-17-2009, 09:42 PM
Well according to the datasheet I found here:
http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=160-1300-5-ND

The maximum forward current for the LED is 80mA.

Pull out the relay and replace it with a 10k resistor. Redo the measurements above. I suspect the LED isn't turning on. Either that or you don't have it hooked up the way that you think it's hooked up.

Here is the datasheet on the exact component I'm using..

http://www.nteinc.com/specs/3000to3099/pdf/nte3040.pdf

Connor
01-17-2009, 10:07 PM
Well according to the datasheet I found here:
http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=160-1300-5-ND

The maximum forward current for the LED is 80mA.

Pull out the relay and replace it with a 10k resistor. Redo the measurements above. I suspect the LED isn't turning on. Either that or you don't have it hooked up the way that you think it's hooked up.

I'm about to scream.. I've not done the 10k trick yet, but, I put a 100ohm and 22ohm resisters inline with the pin 1 and the phidgets.. Toggle it on and off, and I can see the voltage from pin 4 and 5 go from 0 to 5v. I hooked up the relay. (BTW, I've now switched to a independent 5v supply for the relay side) and I now read around 1.1v when across the coils.. I just don't get it.. it's like not enough current is getting through to drive the relay or something...

Quantum
01-17-2009, 10:40 PM
Take a picture and post.

If you have independent power sources they do need to have a common ground.

Do you have any common transistor laying around? Just asking to see what you have available.

Connor
01-17-2009, 11:11 PM
Take a picture and post.

Done



If you have independent power sources they do need to have a common ground.


Not with a opto, would defeat the purpose of isolation then.



Do you have any common transistor laying around? Just asking to see what you have available.


Not at the moment..

Quantum
01-17-2009, 11:24 PM
Yea no need for common grounds forget about that.

You need a protection diode across the coil.

The opto is still a transitor and it needs to be protected when the coil trips on and off.

When the coil loses power the magnetic field cause a brief surge and this will damage transistors. The diode will allow this to fade with out damage to transistors or ic.

It could be that the ISO crapped out on you.

Connor
01-17-2009, 11:27 PM
Yea no need for common grounds forget about that.

You need a protection diode across the coil.

The opto is still a transitor and it needs to be protected when the coil trips on and off.

When the coil loses power the magnetic field cause a brief surge and this will damage transistors. The diode will allow this to fade with out damage to transistors or ic.

It could be that the ISO crapped out on you.

Well, I did the diode thing.. early on.. pulled it while testing because nothing was working. Why do I get a voltage of 5v when I test it with my multimeter without the relay in place when the opto is toggled on?

Connor
01-17-2009, 11:34 PM
Am I using a Opto that can handle driving this relay?

Quantum
01-17-2009, 11:51 PM
Yea it should work take a look at this schematic.

Still need the 330 on pin one.

You can find the 3904 at radios shack. Usually comes indivisually or in the npn pnp package.

lnxfergy
01-17-2009, 11:55 PM
Am I using a Opto that can handle driving this relay?

Me thinks: NO (EDIT: without additional components), based on


.717v with the relay in place and opto activated, 4.98 or so without the relay.
-.003v with the relay in place and opto unactivated.

I don't have the diode in place yet, but that wouldn't be the problem.. I can put it in place.. but, I though I would wait till I get this debugged.

It would appear that your optocoupler is passing the signal, but can't generate enough current to drive the relay. I don't see a "on" current spec'd in the datasheet. I'm not entirely sure - but I think that the "DC CURRENT TRANSFER" of 20&#37; at If=10mA, Vce = 10V means you don't have enough juice to drive the relay. In theory, that limits the output to 20% of 100mA (or 80 as quoted elsewhere), well below 77 for the relay.

-Fergs

lnxfergy
01-17-2009, 11:59 PM
Yea it should work take a look at this schematic.

Still need the 330 on pin one

BadaBING! Nail hit on head. Need a second Transistor! +rep

Connor, if we denote the current through the LED as A, you need a minimum gain of 77mA/(A *.2) to account for the lose in the coupler...

-Fergs

Quantum
01-18-2009, 12:04 AM
In your picture everything looks good but you dont have wires going from the contacts of the relay. The one throw side and either of the pole sides. Can you check this instead of the coil.

Besides looking at it in person I have no clue.

Adrenalynn
01-18-2009, 12:19 AM
Sorry - I haven't popped back into the thread. My initial guess was such, hence my asking for the current requirement. I agree from the spec-sheet, Fergs, I don't think you're getting enough current, but you could measure that with your meter, I'm sure. It's tiny current...

Connor
01-18-2009, 12:53 AM
Sorry - I haven't popped back into the thread. My initial guess was such, hence my asking for the current requirement. I agree from the spec-sheet, Fergs, I don't think you're getting enough current, but you could measure that with your meter, I'm sure. It's tiny current...

Okay, So, I need another transister, or a bigger opto. at this point, would it not just be easier to use a single transister?

I'm also thinking I need to re-evaluate me relay.. It's rated at 10 @ 28Vdc. This is the relay to switch from charging to power.. and if I add in my servos later on like I'm planning, which pull 5.2amps at 7.2v, (I'll have 2 of those) then this one may not be able to handle it...

Quantum
01-18-2009, 12:54 AM
Try this

lnxfergy
01-18-2009, 01:05 AM
Okay, So, I need another transister, or a bigger opto. at this point, would it not just be easier to use a single transister?

I'm also thinking I need to re-evaluate me relay.. It's rated at 10 @ 28Vdc. This is the relay to switch from charging to power.. and if I add in my servos later on like I'm planning, which pull 5.2amps at 7.2v, (I'll have 2 of those) then this one may not be able to handle it...

Why do you need to turn off the servos?

Further, why would you tie the sonars and servos to the same power supply! If you thought you had issues before with noise on the power supply - just wait until you add a servo!

-Fergs

Connor
01-18-2009, 01:12 AM
Why do you need to turn off the servos?

Further, why would you tie the sonars and servos to the same power supply! If you thought you had issues before with noise on the power supply - just wait until you add a servo!

-Fergs

Sorry, I kinda changed subjects in the middle of my thread.. This opto circuit is for my charging system / power distribution, completely separate from turning the sonar's on/off.. I just thought since we were talking about opto's this would be a good place. The sonars just didn't behave correctly when being powered via 3.5v from the phidgets because they're talking to 5v serial on the PC, at least, that's my believe anyway. As for noise, I dunno, I think it might just be cheap a$$ speakers or something... Jess is bringing me a different set to try out at our local club meeting this coming Tuesday.

Thanks, Connor

Connor
01-18-2009, 01:22 AM
Try this

I didn't have a 2N2222 but, I pulled a S8050 from a Roomba main board (dead) and tried it.. That worked..

http://electronics.se-ed.com/magic/s8050.pdf

Quantum
01-18-2009, 02:03 AM
So you have it working great.

8050 is a little beefier that the 2222 but it works it works. Could use a mosfet if you start to draw large currents this will help to make it more hardy.
as you can pull more from them. The circuit is a little different but the idea is the same. The only difference is there is an added resistor between two legs.
you look this up on goggle. if I remember correctly it's going to be something in the range of 100K's. Eliminates the diode.

But remember put that diode in there. Seems useless but its needed because of emf from the coil. the transistor can go and for a couple of pennies saves alot of trouble.

Connor
01-18-2009, 02:05 AM
So you have it working now?

Would appear to have it working with just the single S8050 transitor. I'm putting the circuit together on a prototype board now.. but it worked on the bread board.

Thanks, Connor