Digital I/O

Showing results for 
Search instead for 
Did you mean: 

drive relay coil with transistor powered by usb-6009?

I'm a little rusty with this, so bear with me.


I have a USB-6009 which I would like to drive a 2N2222A transistor with to energize the coild of a SPDT relay.  The coil with draw ~ 30mA.


I believe I can accomplish this by:

  • sourcing 5V collector voltage from the USB-6009
  • driving the base with one of the DIO lines on the USB-6009
  • suppling 5V from the emitter of my transistor to the relay coil
  • biasing the transistor with a 5K emitter resistor


Something like this:


Figure 1: Basic NPN common-collector circuit (neglecting biasing details).


This will result in the 30mA required by my relay coil coming from the 5V supply on the USB-6009, and not damage the DIO line.  Correct?

0 Kudos
Message 1 of 8

Hi Optimus,


I would suggest something like this. Don't forget the diode across the relay.


Relay Driver

Message Edited by K C on 10-16-2008 08:32 AM
Message 2 of 8

Thanks KC.  Yes...the diode.


I'm a little confused on how the transistor is biased in this configuration.  the 10k resistor is in parallel with the emitter?  Would you mind elaborating?



0 Kudos
Message 3 of 8



It is just a switching transistor is this case. The voltage divides over the resistor and leaves a base voltage of about 3V. That is more then enough to open the transistor. The 5k6 (or 10k or whatever) is limiting the current. The 10k is there to prevent that the transistor opens when there is nothing connected to the input.

Any other resistor value will do as long as the voltage is enough to open the resistor.

Message 4 of 8

Sorry to bump an ancient thread but this is eaxctly what I am looking to do to drive a pair of relays.


I have a question though.


As I understand the 0v is the ground and the 0-5v is the digital output.


Where is the 5v energizing the relay coming from? An external power supply?


I was thinking of using the daqs built in 5v 200mA power supply for that.



0 Kudos
Message 5 of 8

Inrternal supply or external supply....either will work. The internal supply is more convenient but limited in capacity. For one relay it is fine.

Message 6 of 8

Thanks I will be using solid state relays so I should only need about 60mA between both.

0 Kudos
Message 7 of 8

Solid state relays require even less power than a mechanical relay.  Look at the spec sheet for your SSR's, you may be able to drive them right off the DO line.  Analog outputs have a little more juice if the DO's are borderline; I've driven SSR's right off the AO's in some of my equipment. 


One thing to keep in mind when designing the system is that when the DAQ initializes, the digital lines are pulled high.  If there's a combination of outputs that could be potentially hazardous or exceed the duty cycle of some device attached to it, make sure the system is designed to handle a condition where all digital lines are pulled high for an extended period of time.  This may require some additional hardware logic to prevent two outputs from being driven high simultaneously.

0 Kudos
Message 8 of 8