Digital Input Guide: Difference between revisions

From Phidgets Support
No edit summary
(10 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<metadesc>Digital Inputs are used to read the state of devices such as buttons or switches. You can find digital input interfaces at Phidgets.com.</metadesc>
[[Category: Primer]]
[[Category: Primer]]


==Introduction==
==Introduction==
[[File:DAQ1300_0.jpg|link=|right|400px]]
Digital Inputs can be used to convey the state of various devices such as push buttons, limit switches, relays, or logic level outputs. They have two states: high and low. Any signal that is expected to interact with more than just these 2 states is inappropriate for this type of input. 


Digital Inputs can be used to convey the state of various devices such as push buttons, limit switches, relays, or logic level outputs.
Digital inputs are one of the easiest components to work with, since all that is required is a simple check to see which state they are in when an event triggers. A digital input can either be ''Active High'' or ''Active Low'':
They have two states: Low and High.
*'''Active Low''' digital inputs consider their state to be TRUE when the voltage is low (closer to 0V), and FALSE when high (closer to 5V).
Any signal that is expected to interact with more than just these 2 states is inappropriate for this type of input.
*'''Active High''' digital inputs are the opposite- TRUE when the voltage is high, and FALSE when the voltage is low.


Digital inputs are one of the easiest components to work with, since all that is required is a simple check to see which state they are in when an event triggers.


A digital input can either be '''Active High''' or '''Active Low'''.
The exact voltage values at which a digital input switches varies from device to device. See the specification table for your Phidget for more details.
 
'''Active Low''' digital inputs consider their state to be TRUE when the voltage is low (closer to 0V), and FALSE when high (closer to 5V).
 
'''Active High''' digital inputs are the opposite- TRUE when the voltage is high, and FALSE when the voltage is low.


The exact voltage values at which a digital input switches varies from device to device. See the specification table for your Phidget for more details.


Below is a table of Phidgets with digital inputs, and their type of digital input:
Below is a table of Phidgets with digital inputs, and their type of digital input:
 
{|class="wikitable" style="text-align: center; margin:auto;"
{| style="border:1px solid darkgray;" cellpadding="7px;"
|-style="background: #f0f0f0"
|-style="background: #f0f0f0" align=center
|'''Product #''' || '''Name''' || '''Digital Input Type'''
! Product # || Name || Digital Input Type
|-
|-
|style="background: #f0f0ff" align=center| 1010
|1010
|style="background: #f0f0ff" align=center| [{{SERVER}}/products.php?product_id=1010 PhidgetInterfaceKit 8/8/8 Mini-Format]
| [{{SERVER}}/products.php?product_id=1010 PhidgetInterfaceKit 8/8/8 Mini-Format]
|style="background: #f0f0ff" align=center| Active Low
| Active Low
|-
|-
|style="background: #f0f0ff" align=center| 1011
| 1011
|style="background: #f0f0ff" align=center| [{{SERVER}}/products.php?product_id=1011 PhidgetInterfaceKit 2/2/2]
| [{{SERVER}}/products.php?product_id=1011 PhidgetInterfaceKit 2/2/2]
|style="background: #f0f0ff" align=center| Active Low
| Active Low
|-
|-
|style="background: #f0f0ff" align=center| 1012
| 1012
|style="background: #f0f0ff" align=center| [{{SERVER}}/products.php?product_id=1012 PhidgetInterfaceKit 0/16/16]
| [{{SERVER}}/products.php?product_id=1012 PhidgetInterfaceKit 0/16/16]
|style="background: #f0f0ff" align=center| Active High
| Active High
|-
|-
|style="background: #f0f0ff" align=center| 1018
| 1018
|style="background: #f0f0ff" align=center| [{{SERVER}}/products.php?product_id=1018 PhidgetInterfaceKit 8/8/8]
| [{{SERVER}}/products.php?product_id=1018 PhidgetInterfaceKit 8/8/8]
|style="background: #f0f0ff" align=center| Active Low
| Active Low
|-
|-
|style="background: #f0f0ff" align=center| 1019
| 1019
|style="background: #f0f0ff" align=center| [{{SERVER}}/products.php?product_id=1019 PhidgetInterfaceKit 8/8/8 w/6 Port Hub]
| [{{SERVER}}/products.php?product_id=1019 PhidgetInterfaceKit 8/8/8 w/6 Port Hub]
|style="background: #f0f0ff" align=center| Active Low
| Active Low
|-
|-
|style="background: #f0f0ff" align=center| 1073
| 1073
|style="background: #f0f0ff" align=center| [{{SERVER}}/products.php?product_id=1073 PhidgetSBC3]
| [{{SERVER}}/products.php?product_id=1073 PhidgetSBC3]
|style="background: #f0f0ff" align=center| Active Low
| Active Low
|-
|-
|style="background: #f0f0ff" align=center| 1203
| 1203
|style="background: #f0f0ff" align=center| [{{SERVER}}/products.php?product_id=1203 PhidgetTextLCD]
| [{{SERVER}}/products.php?product_id=1203 PhidgetTextLCD]
|style="background: #f0f0ff" align=center| Active Low
| Active Low
|-
|-
|style="background: #f0f0ff" align=center| DAQ1200
| DAQ1200
|style="background: #f0f0ff" align=center| [{{SERVER}}/products.php?product_id=DAQ1200 4x Digital Input Phidget]
| [{{SERVER}}/products.php?product_id=DAQ1200 4x Digital Input Phidget]
|style="background: #f0f0ff" align=center| Active Low
| Active Low
|-
|-
|style="background: #f0f0ff" align=center| DAQ1300
| DAQ1300
|style="background: #f0f0ff" align=center| [{{SERVER}}/products.php?product_id=DAQ1300 4x Isolated Digital Input Phidget]
| [{{SERVER}}/products.php?product_id=DAQ1300 4x Isolated Digital Input Phidget]
|style="background: #f0f0ff" align=center| Active High
| Active High
|-
|-
|style="background: #f0f0ff" align=center| DAQ1301
| DAQ1301
|style="background: #f0f0ff" align=center| [{{SERVER}}/products.php?product_id=DAQ1301 16x Isolated Digital Input Phidget]
| [{{SERVER}}/products.php?product_id=DAQ1301 16x Isolated Digital Input Phidget]
|style="background: #f0f0ff" align=center| Active High
| Active High
|-
|-
|style="background: #f0f0ff" align=center| HUB0000
| HUB0000
|style="background: #f0f0ff" align=center| [{{SERVER}}/products.php?product_id=HUB0000 VINT Hub Phidget]
| [{{SERVER}}/products.php?product_id=HUB0000 VINT Hub Phidget]
|style="background: #f0f0ff" align=center| Active Low
| Active Low
|}
|}


==Specifications==
==Specifications==
===Digital Input Hardware Filter===
===Digital Input Hardware Filter===
There is built-in filtering on the digital input, to eliminate false triggering from electrical noise.
There is built-in filtering on the digital input, to eliminate false triggering from electrical noise.
Line 90: Line 85:
[[Image:digital_input.jpg|right|300px|link=|thumb|Schematic for a Phidgets digital input.]]
[[Image:digital_input.jpg|right|300px|link=|thumb|Schematic for a Phidgets digital input.]]


The digital inputs have a built in 15K pull-up resistor.   
The digital inputs have a built in pull-up resistor. (It may be a 10 kOhm or 15 kOhm resistor depending on the Phidget).   
By connecting external circuitry, and forcing the input to Ground, the Digital Input in software will read as TRUE.   
By connecting external circuitry, and forcing the input to Ground, the Digital Input in software will read as TRUE.   
The default state is FALSE - when you have nothing connected, or your circuitry (switch, etc) is not pulling the input to ground.
The default state is FALSE - when you have nothing connected, or your circuitry (switch, etc) is not pulling the input to ground.
Line 103: Line 98:
[[Image:switch_digital_input.jpg|right|300px|link=|thumb|Schematic for connecting a switch to a digital input.]]
[[Image:switch_digital_input.jpg|right|300px|link=|thumb|Schematic for connecting a switch to a digital input.]]


Closing the switch causes the digital input to report TRUE.
Closing or opening the switch causes the digital input to change state.


<br clear="all">
<br clear="all">
===Monitoring the Position of a Relay===
===Monitoring the Position of a Relay===


Line 111: Line 107:


The relay contact can be treated as a switch, and wired up similarly.   
The relay contact can be treated as a switch, and wired up similarly.   
When the relay contact is closed, the Digital Input will report TRUE.
When the relay contact is opened or closed, the Digital Input's state will change.


<br clear="all">
<br clear="all">
===Detecting an External Voltage with an N-Channel MOSFET===
===Detecting an External Voltage with an N-Channel MOSFET===


Line 120: Line 117:
A MOSFET can be used to detect the presence of an external voltage.   
A MOSFET can be used to detect the presence of an external voltage.   
The external voltage will turn on the MOSFET, causing it to short the Digital Input to Ground.   
The external voltage will turn on the MOSFET, causing it to short the Digital Input to Ground.   
If the MOSFET is conducting > 270uA, the Digital Input is guaranteed to report TRUE. 
If the MOSFET is conducting < 67uA, the Digital Input is guaranteed to report FALSE.
The voltage level required to turn on the MOSFET depends on the make of of MOSFET you are using. Typical values are 2V-6V.
The voltage level required to turn on the MOSFET depends on the make of of MOSFET you are using. Typical values are 2V-6V.


<br clear="all">
<br clear="all">
===Isolating a Digital Input with an Optocoupler===
===Isolating a Digital Input with an Optocoupler===


[[Image:isolating_digital_input_optocoupler.jpg|right|300px|link=|thumb|Schematic showing isolation of a digital input with an optocoupler.]]
[[Image:isolating_digital_input_optocoupler.jpg|right|300px|link=|thumb|Schematic showing isolation of a digital input with an optocoupler.]]


When driving current through the LED, the Digital Input will report TRUE.
You can use an optocoupler to isolate a digital input from the device it's reading, which is useful for avoiding [[Electricity Primer#Shared Grounds|ground loops]] in some systems.  
The amount of current required will depend on the optocoupler used.   
The amount of current required will depend on the optocoupler used.   
Design to sink at least 270uA to cause the digital input to report TRUE, and less than 67uA to report FALSE.


<br clear="all">
<br clear="all">
===Detecting an External Voltage with an NPN Transistor===
===Detecting an External Voltage with an NPN Transistor===


Line 139: Line 135:


This circuit can be used to measure if a battery is connected, or if 12V (for example) is on a wire.
This circuit can be used to measure if a battery is connected, or if 12V (for example) is on a wire.
By designing to have Collector-Emitter current > 270uA, the digital input will report TRUE.


<br clear="all">
<br clear="all">
===Using a Capacitive or Inductive Proximity Switch===
===Using a Capacitive or Inductive Proximity Switch===


Line 151: Line 147:
Similar capacitive or inductive proximity switches from other manufacturers should work just as well.
Similar capacitive or inductive proximity switches from other manufacturers should work just as well.


{|border=1
{|class="wikitable" style="text-align: center; margin:auto;"
|+'''Switches'''
|+'''Switches'''
|-
|-
! Manufacturer  
|style="background:#f0f0f0;" |'''Manufacturer'''
! Web Page  
|style="background:#f0f0f0;" |'''Web Page '''
! Capacitive Part No.  
|style="background:#f0f0f0;" |'''Capacitive Part No.'''
! Inductive Part No.
|style="background:#f0f0f0;" |'''Inductive Part No.'''
|-
|-
| Automation Direct  
| Automation Direct  
| www.automationdirect.com  
| [https://www.automationdirect.com Automated Direct]
| CT1 Series  
| CT1 Series  
| AM1 Series
| AM1 Series
Line 171: Line 167:


The digital inputs can be easily wired to use many variable resistors as switches.
The digital inputs can be easily wired to use many variable resistors as switches.
If the resistance falls below 3.75k Ohms, the Digital Input will go TRUE.
The digital input will activate either when the FSR is pressed, or when it is not pressed, depending on whether your digital input is active high or active low. You can adjust the sensitivity of the FSR by adding other resistors in series or parallel.
If the resistance rises above 75k Ohms, the Digital Input will go FALSE.

Revision as of 16:49, 29 November 2017


Introduction

DAQ1300 0.jpg

Digital Inputs can be used to convey the state of various devices such as push buttons, limit switches, relays, or logic level outputs. They have two states: high and low. Any signal that is expected to interact with more than just these 2 states is inappropriate for this type of input.

Digital inputs are one of the easiest components to work with, since all that is required is a simple check to see which state they are in when an event triggers. A digital input can either be Active High or Active Low:

  • Active Low digital inputs consider their state to be TRUE when the voltage is low (closer to 0V), and FALSE when high (closer to 5V).
  • Active High digital inputs are the opposite- TRUE when the voltage is high, and FALSE when the voltage is low.


The exact voltage values at which a digital input switches varies from device to device. See the specification table for your Phidget for more details.


Below is a table of Phidgets with digital inputs, and their type of digital input:

Product # Name Digital Input Type
1010 PhidgetInterfaceKit 8/8/8 Mini-Format Active Low
1011 PhidgetInterfaceKit 2/2/2 Active Low
1012 PhidgetInterfaceKit 0/16/16 Active High
1018 PhidgetInterfaceKit 8/8/8 Active Low
1019 PhidgetInterfaceKit 8/8/8 w/6 Port Hub Active Low
1073 PhidgetSBC3 Active Low
1203 PhidgetTextLCD Active Low
DAQ1200 4x Digital Input Phidget Active Low
DAQ1300 4x Isolated Digital Input Phidget Active High
DAQ1301 16x Isolated Digital Input Phidget Active High
HUB0000 VINT Hub Phidget Active Low

Specifications

Digital Input Hardware Filter

There is built-in filtering on the digital input, to eliminate false triggering from electrical noise. The digital input is first RC filtered by a 15K/100nF node, which will reject noise of higher frequency than 1kHz. This filter generally eliminates the need to shield the digital input from inductive and capacitive coupling likely to occur in wiring harnesses. You can further reduce noise by externally filtering the input signal, but you will lose sensitivity in the process.

Digital Input Hysteresis

The digital input has hysteresis - that is, it will hold its current state (false or true), unless a large change occurs. To guarantee FALSE, the digital input must be at least 3.75V, and to guarantee TRUE, the digital input must be less than 1.25V.

Digital Input Sampling Characteristics

The state of the digital inputs are reported back to the PC periodically. During this sampling period, if a digital input was true for greater than 4.0ms, the digital input is guaranteed to be reported as true in software. This makes the digital input much more sensitive to reporting TRUE state, and makes it useful to watch for short events. Any Digital Input True events of less than 1.5ms are never reported.

Electrical Specifications

Schematic for a Phidgets digital input.

The digital inputs have a built in pull-up resistor. (It may be a 10 kOhm or 15 kOhm resistor depending on the Phidget). By connecting external circuitry, and forcing the input to Ground, the Digital Input in software will read as TRUE. The default state is FALSE - when you have nothing connected, or your circuitry (switch, etc) is not pulling the input to ground.


Using the Digital Inputs

Here are some circuit diagrams that illustrate how to connect various devices to the digital inputs on your Phidget.

Wiring a switch to a Digital Input

Schematic for connecting a switch to a digital input.

Closing or opening the switch causes the digital input to change state.


Monitoring the Position of a Relay

Schematic for connecting to a relay.

The relay contact can be treated as a switch, and wired up similarly. When the relay contact is opened or closed, the Digital Input's state will change.


Detecting an External Voltage with an N-Channel MOSFET

Schematic for detecting voltage with a NMOS transistor.

A MOSFET can be used to detect the presence of an external voltage. The external voltage will turn on the MOSFET, causing it to short the Digital Input to Ground. The voltage level required to turn on the MOSFET depends on the make of of MOSFET you are using. Typical values are 2V-6V.


Isolating a Digital Input with an Optocoupler

Schematic showing isolation of a digital input with an optocoupler.

You can use an optocoupler to isolate a digital input from the device it's reading, which is useful for avoiding ground loops in some systems. The amount of current required will depend on the optocoupler used.


Detecting an External Voltage with an NPN Transistor

Schematic for detecting voltage with an NPN transistor.

This circuit can be used to measure if a battery is connected, or if 12V (for example) is on a wire.


Using a Capacitive or Inductive Proximity Switch

Schematic for connecting to a proximity switch.

Capacitive proximity switches can detect the presence of nearby non-metallic objects, whereas inductive proximity switches can detect only the presence of metallic objects. To properly interface one of these proximity switches to the digital inputs, a 3-wire proximity switch is required, as well as an external power supply. We have checked the following switch from Automation Direct to verify that it works with the Digital Inputs. Similar capacitive or inductive proximity switches from other manufacturers should work just as well.

Switches
Manufacturer Web Page Capacitive Part No. Inductive Part No.
Automation Direct Automated Direct CT1 Series AM1 Series


Using an FSR or Variable Resistor as a Switch

Schematic for using an FSR as a switch.

The digital inputs can be easily wired to use many variable resistors as switches. The digital input will activate either when the FSR is pressed, or when it is not pressed, depending on whether your digital input is active high or active low. You can adjust the sensitivity of the FSR by adding other resistors in series or parallel.