PDA

View Full Version : NPN Open Collector



guiguibud
11-14-2012, 10:24 AM
Hey guys,

Quick question here... I'm using Teensy2 and would like to have an input from a IR sensor that outputs a NPN Open Collector signal (PEM7D, http://www.vellemanusa.com/products/view/?country=us&lang=enu&id=521375)... I know that those are usually seen as basic switches, so I could use this directly as an input, but I've read in different places that there might be a bit of voltage going through... As I don't want to fry my Teensy2, do you think it would be best to use an external Pullup resistor (like 10k) or the one inside the Teensy2 is sufficient?

Thanks a lot for your answers!

JBeale
11-14-2012, 06:34 PM
The normal procedure with an open collector signal is to use a pullup resistor, for example 10k to your 5V supply, as you suggest. With no pullup resistor, there will be no signal. I don't know the value of the Teensy 2 internal pullup resistor (does it even have one?) but if it is very large, it will limit your data rate due to stray capacitance forming an RC time constant.

guiguibud
11-15-2012, 09:03 AM
The normal procedure with an open collector signal is to use a pullup resistor, for example 10k to your 5V supply, as you suggest. With no pullup resistor, there will be no signal. I don't know the value of the Teensy 2 internal pullup resistor (does it even have one?) but if it is very large, it will limit your data rate due to stray capacitance forming an RC time constant.

Exactly my point... teensy has one according to this http://www.pjrc.com/teensy/tutorial3.html

It states examples of connecting a push button through a 10k resistor first, then directly using pinMode(8, INPUT_PULLUP)...

Anyway, not going to take my chances on this one... So 10k it is!

Thanks a lot

PaulStoffregen
11-15-2012, 11:09 AM
Either the internal pullup (every digital pin has one built in) or a real 10K resistor should work fine.

The nice thing about using a real resistor is you can easily test if the voltage changes without running any software, or without even connecting to a pin.

John's point about the RC delay is correct, but the speed limitation is on the scale of microseconds (or less). For signals like serial data at many thousands of bits per second, such delays can become important. But for an IR security sensor detecting human movement, microsecond or even millisecond delays are not important. Nobody moves that fast.

guiguibud
11-15-2012, 03:18 PM
Brilliant!

Thanks a lot for your answer!