Pages: [1]   Go Down
Author Topic: Protecting Digital Input pin  (Read 692 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 0
Posts: 141
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

My sensor outputs 7.5v 100/150mA when its high.

Currently I tie this line to ground with a 10k resistor, and regulate it to 3.3v with a TS2950CT-3.3, before connecting to a digital pin on the arduino. Is this a correct way of doing things? Do I need to add or change anything?

thanks.
Logged

0
Offline Offline
Shannon Member
****
Karma: 215
Posts: 12486
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Its not a sensible approach IMO, a resistive divider might be sufficient.

What does it output when low?  How fast does it switch between high and low?
Logged

[ I won't respond to messages, use the forum please ]

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 634
Posts: 34559
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Is this a correct way of doing things?
No. Do not use a voltage regulator for signal level shifting.

Quote
My sensor outputs 7.5v 100/150mA when its high.
No it outputs 7.5V and is capable of supplying up to 100mA if the load demands it.

The simplest way to do this is to drive the output of your sensor through a potential divider to cut down the maximum voltage to about 4.5V to feed into the digital input pin of an arduino.
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 141
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Its not a sensible approach IMO, a resistive divider might be sufficient.

What does it output when low?  How fast does it switch between high and low?


It outputs 0 when low. Its a non latching touch sensor so not that fast.

Quote
Is this a correct way of doing things?
No. Do not use a voltage regulator for signal level shifting.

Why not?
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 634
Posts: 34559
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Why not?
Because it is not designed to do such a thing. It will not be stable and will not respond fast.

It is like saying hey I want to use a food blender to chop up my Christmas tree for the compost.
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 141
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It will not be stable and will not respond fast.

That's all the reasoning I need!

So in theory a voltage divider using r1 = 15k, r2 = 12k, will give me the same output of 3.33v. What is the advantage of taking it higher to 4.5v? I always thought Id keep things lower to offer more protection.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 634
Posts: 34559
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Are we talking about an arduino that runs on 5V, you haven't said.
Basically you want the signal as close to the supply as possible and in any case not more than 0.5V above it.
While a 5V arduino will respond to a 3V3 signal as a logic high it is more susceptible to noise and interference.
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 141
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry yes Arduino Uno.

The sensor actually outputs 0.3v when it is LOW, do I need to account for this in any way?

So changing r1 to 10k, r2 to 15k now gives me ~4.5v, when the sensor is HIGH.


* divider.JPG (13.89 KB, 323x436 - viewed 27 times.)
Logged

0
Offline Offline
Shannon Member
****
Karma: 215
Posts: 12486
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The 0.3V will be divided down to something like 0.2V, well within spec for a logic LOW  smiley

To explain slightly more about logic thresholds:

Every logic family (this includes ATmega series of microcontrollers which are a family) standardizes on the voltages that represent logic HIGH and logic LOW.  But there are two specifications each for HIGH and LOW.

Any device _outputing_ a LOW is _required_ to generate a voltage below VOL.  Any device _reading_ a logic LOW is required to accept any voltage from 0 to VIL as "LOW".

For instance for the ATmega running at 5V supply, VOL = 0.9V and VIL = 1.5V.  This means upto 0.6V of noise can be injected onto the signal line between the devices and a LOW will still always be recognised correctly.   In digital circuits there is always noise being injected via stray inductance and capacitance, so this "noise immunity" can be very important.

On the high side VOH = 4.2V and VIH = 3.0V.   Thus you want your resistive divider to output between 4.2V and 5.0V for a HIGH and between 0.0 and 0.9V for a LOW.

At a pinch you will get away with the ranges 3.0V..5.0V and 0.0V..1.5V, but this means you lose "noise immunity" - there is a risk of noise interfering with the correct recognition of the logic signal.  4.5V for HIGH and 0.2V for LOW are fine of course.

One conseqeuence of the VIL=3.0V means that most 3.3V logic devices can drive the Arduino inputs (but with lower than normal noise immunity).
Logged

[ I won't respond to messages, use the forum please ]

Pages: [1]   Go Up
Jump to: