Notice: This page contains information for the legacy Phidget21 Library. Phidget21 is out of support. Bugfixes may be considered on a case by case basis. Phidget21 does not support VINT Phidgets, or new USB Phidgets released after 2020. We maintain a selection of legacy devices for sale that are supported in Phidget21. We recommend that new projects be developed against the Phidget22 Library.
|
Digital Output Primer: Difference between revisions
(Created page with " Digital Outputs can be used to drive LEDs, solid state relays, and transistors (or anything that will accept a CMOS signal). Digital outputs can be used to control devices that ...") |
|||
(13 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
[[Category: Primer]] | |||
{{HiddenNeeds|This should eventually include open collector digital outputs, and their differences}} | |||
==Introduction== | |||
Digital Outputs can be used to drive LEDs, solid state relays, and transistors (or anything that will accept a CMOS signal). | Digital Outputs can be used to drive LEDs, solid state relays, and transistors (or anything that will accept a CMOS signal). | ||
Line 6: | Line 9: | ||
==Specifications and Features== | ==Specifications and Features== | ||
[[Image:digital_output.jpg|right|thumb|A Phidgets digital output.]] | [[Image:digital_output.jpg|right|thumb|300px|link=|A Phidgets digital output.]] | ||
The 250 ohm resistance is internal to the PhidgetInterfaceKit 8/8/8, and limits the current that can flow through the output. | The 250 ohm resistance is internal to the PhidgetInterfaceKit 8/8/8, and limits the current that can flow through the output. | ||
This is intended to protect the device from being damaged if there is a short to ground or if an LED is used. | This is intended to protect the device from being damaged if there is a short to ground or if an LED is used. | ||
Ultimately this means the maximum current output of the digital outputs is 16mA. In practice you should not try to draw 16mA from the outputs for extended periods of time though as this can lead to damaged components. You should try to limit your current draw to less than 5mA though up to 10 would not cause any immediate concerns. | |||
The output is intended to drive TTL or CMOS inputs; it is not designed to provide power to an external circuit. | The output is intended to drive TTL or CMOS inputs; it is not designed to provide power to an external circuit. | ||
In practice the frequency at which these outputs can be switched is highly dependent on system properties such as OS, USB hardware, and cabling. However, it is a good bet that the majority of systems will be able to achieve 1kHz. | |||
<br clear="all"> | <br clear="all"> | ||
Line 20: | Line 26: | ||
===5 Volt Terminal Block=== | ===5 Volt Terminal Block=== | ||
For users who need it, we provide 5V on the terminal block next to Digital Output 7. | For users who need it, we provide 5V on the terminal block next to Digital Output 7 on most InterfaceKit boards. | ||
==Using the Digital Outputs== | ==Using the Digital Outputs== | ||
Line 27: | Line 33: | ||
===Driving an LED with the Digital Output=== | ===Driving an LED with the Digital Output=== | ||
[[Image:LED_digital_output.jpg|right|thumb|Schematic for connecting to an LED.]] | [[Image:LED_digital_output.jpg|link=|300px|right|thumb|Schematic for connecting to an LED.]] | ||
Connecting an LED to a digital output is simple. Wire the anode to a digital output labeled 0 to 7 on the Interface Kit, and the cathode to a supplied ground, labeled G. | Connecting an LED to a digital output is simple. Wire the anode to a digital output labeled 0 to 7 on the Interface Kit, and the cathode to a supplied ground, labeled G. | ||
Line 34: | Line 40: | ||
===Using a 3052 SSR Board with a Digital Output=== | ===Using a 3052 SSR Board with a Digital Output=== | ||
[[Image:3052_digital_output.jpg|right|thumb|Schematic for connecting a 3052 board.]] | [[Image:3052_digital_output.jpg|right|link=|300px|thumb|Schematic for connecting a 3052 board.]] | ||
Setting the digital output to true causes the output of the 3052 to turn on. | Setting the digital output to true causes the output of the 3052 to turn on. | ||
This can be used to control AC or DC devices. | This can be used to control AC or DC devices. The 3053 and 3054 relay boards can be connected in the same way. | ||
The load can also be switched with the 3052 on the high side. | The load can also be switched with the 3052 on the high side. | ||
Line 43: | Line 49: | ||
<br clear="all"> | <br clear="all"> | ||
===Isolating a Digital Output with a MOSFET based SSR=== | ===Isolating a Digital Output with a MOSFET based SSR=== | ||
[[Image:isolating_digital_output_ssr.jpg|right|thumb|Schematic for isolating a digital input with an SSR.]] | [[Image:isolating_digital_output_ssr.jpg|link=|300px|right|thumb|Schematic for isolating a digital input with an SSR.]] | ||
It’s possible to wire up your own Solid State Relay to the digital output. | It’s possible to wire up your own Solid State Relay to the digital output. | ||
Line 55: | Line 62: | ||
===Isolating a Digital Output with an Optocoupler=== | ===Isolating a Digital Output with an Optocoupler=== | ||
[[Image:isolating_digital_output_optocoupler.jpg|right|thumb|Schematic for isolating a digital input with an optocoupler.]] | [[Image:isolating_digital_output_optocoupler.jpg|link=|300px|right|thumb|Schematic for isolating a digital input with an optocoupler.]] | ||
In some applications, particularly where there is a lot of electrical noise (automotive), or where you want maximum protection of the circuitry (interactive installations, kiosks), electrical isolation buys you a huge margin of protection. | In some applications, particularly where there is a lot of electrical noise (automotive), or where you want maximum protection of the circuitry (interactive installations, kiosks), electrical isolation buys you a huge margin of protection. | ||
Line 65: | Line 72: | ||
===Controlling a Relay with a N-Channel MOSFET=== | ===Controlling a Relay with a N-Channel MOSFET=== | ||
[[Image:relay_nmos.jpg|right|thumb|Schematic for using a relay with an NMOS transistor.]] | [[Image:relay_nmos.jpg|right|thumb|link=|300px|Schematic for using a relay with an NMOS transistor.]] | ||
A inexpensive mosfet and flyback diode can be used to control larger loads - relays for example - directly from the digital output. | A inexpensive mosfet and flyback diode can be used to control larger loads - relays for example - directly from the digital output. | ||
Line 73: | Line 80: | ||
===Controlling a Relay with a NPN Transistor=== | ===Controlling a Relay with a NPN Transistor=== | ||
[[Image:relay_npn.jpg|right|thumb|Schematic for using a relay with an NPN transistor.]] | [[Image:relay_npn.jpg|right|thumb|link=|300px|Schematic for using a relay with an NPN transistor.]] | ||
This circuit is very similar to the N-channel mosfet - but you may already have NPN transistors on hand. | This circuit is very similar to the N-channel mosfet - but you may already have NPN transistors on hand. | ||
Line 80: | Line 87: | ||
===Using a 3051 Dual Relay Board with one or two Digital Outputs=== | ===Using a 3051 Dual Relay Board with one or two Digital Outputs=== | ||
[[Image:3051_digital_outputs.jpg|right|thumb|Schematic for using a 3051 board.]] | [[Image:3051_digital_outputs.jpg|right|link=|300px|thumb|Schematic for using a 3051 board.]] | ||
The 3051 Dual Relay Board is designed to be used with the PhidgetInterfaceKit 8/8/8. | The 3051 Dual Relay Board is designed to be used with the PhidgetInterfaceKit 8/8/8. | ||
An Analog Input can be used to supply power to the relays, and one or two digital outputs used to control the relays. | An Analog Input can be used to supply power to the relays, and one or two digital outputs used to control the relays. | ||
The 3051 is a good option if you need a couple relays in your project. | The 3051 is a good option if you need a couple relays in your project. | ||
<br clear="all"> | |||
===Remembering Output States Through Reboot=== | |||
When your computer reboots, the interface kit object will disconnect in software, which will cause you to lose your output states, even if the interface kit is connected to a powered USB hub. If you need to remember the output states, you could program your application to save the states to a file when a disconnect event occurs, and load the states when it connects again. |
Latest revision as of 19:21, 17 January 2013
Introduction
Digital Outputs can be used to drive LEDs, solid state relays, and transistors (or anything that will accept a CMOS signal). Digital outputs can be used to control devices that accept a +5V control signal. With transistors and some electronics experience, other devices can be controlled, such as buzzers, lights, larger LEDs, relays.
Specifications and Features
The 250 ohm resistance is internal to the PhidgetInterfaceKit 8/8/8, and limits the current that can flow through the output. This is intended to protect the device from being damaged if there is a short to ground or if an LED is used. Ultimately this means the maximum current output of the digital outputs is 16mA. In practice you should not try to draw 16mA from the outputs for extended periods of time though as this can lead to damaged components. You should try to limit your current draw to less than 5mA though up to 10 would not cause any immediate concerns. The output is intended to drive TTL or CMOS inputs; it is not designed to provide power to an external circuit.
In practice the frequency at which these outputs can be switched is highly dependent on system properties such as OS, USB hardware, and cabling. However, it is a good bet that the majority of systems will be able to achieve 1kHz.
Ground Protection
Ground terminals on the InterfaceKit share a common ground with USB ground. Because they are not internally isolated, these terminals will expose the USB ground potential of the PC to which they are connected. Be sure you are completely familiar with any circuit you intend to connect to the InterfaceKit before it is connected. If a reverse voltage or dangerously high voltage is applied to the input or output terminals, damage to the Phidget or the PC may result.
5 Volt Terminal Block
For users who need it, we provide 5V on the terminal block next to Digital Output 7 on most InterfaceKit boards.
Using the Digital Outputs
Here are some circuit diagrams that illustrate how to connect various devices to the digital outputs on your Phidget.
Driving an LED with the Digital Output
Connecting an LED to a digital output is simple. Wire the anode to a digital output labeled 0 to 7 on the Interface Kit, and the cathode to a supplied ground, labeled G.
Using a 3052 SSR Board with a Digital Output
Setting the digital output to true causes the output of the 3052 to turn on. This can be used to control AC or DC devices. The 3053 and 3054 relay boards can be connected in the same way.
The load can also be switched with the 3052 on the high side. High side switching is helpful for powering more complicated circuitry that cannot tolerate having multiple grounds.
Isolating a Digital Output with a MOSFET based SSR
It’s possible to wire up your own Solid State Relay to the digital output. MOSFET based SSRs have the advantage that they can be understood as being a simple switch.
There are many other types of SSRs that are more suitable for controlling higher power, higher voltage AC devices that can also be controlled in the same fashion.
Isolating a Digital Output with an Optocoupler
In some applications, particularly where there is a lot of electrical noise (automotive), or where you want maximum protection of the circuitry (interactive installations, kiosks), electrical isolation buys you a huge margin of protection. Driving the LED causes the output transistor to sink current.
The maximum current through the transistor will depend in part on the characteristics of the optocoupler.
Controlling a Relay with a N-Channel MOSFET
A inexpensive mosfet and flyback diode can be used to control larger loads - relays for example - directly from the digital output. Be sure to use a Logic-Level MOSFET so that the +5V Digital Output is able to turn it on.
Controlling a Relay with a NPN Transistor
This circuit is very similar to the N-channel mosfet - but you may already have NPN transistors on hand.
Using a 3051 Dual Relay Board with one or two Digital Outputs
The 3051 Dual Relay Board is designed to be used with the PhidgetInterfaceKit 8/8/8.
An Analog Input can be used to supply power to the relays, and one or two digital outputs used to control the relays.
The 3051 is a good option if you need a couple relays in your project.
Remembering Output States Through Reboot
When your computer reboots, the interface kit object will disconnect in software, which will cause you to lose your output states, even if the interface kit is connected to a powered USB hub. If you need to remember the output states, you could program your application to save the states to a file when a disconnect event occurs, and load the states when it connects again.