Phone:
1-800-346-3119

DAQ FAQ: Part 2 - Digital Inputs with Counters and Digital Outputs

Digital Inputs - Why Counters are Needed! 

There is a limit to how many times a second a digital input can be read.  The digital input will be either a 1 
or 0, reporting the value at the time the input is read.  The problem is; to catch every high and low cycle, a 
sampling rate needs to be around 2.4 times the frequency of the pulses or high & low cycles will be missed.  
With a counter, you can read the counter value, and then read the next value, subtract the former value 
from the new value, so the count difference and sampling interval can determine what the speed is. 
 
Counters are used for water flow or other metering systems. A pulse is generated for each measured unit of 
flow.  This type of counter is used in our Wireless Modular I/O on the digital inputs, and the count can be 
read using ModBus polling through a radio modem of the counter register.  Some counters can be reset to 
zero, others for metering purposes accumulate a count until they roll over back to zero.  A counter register 
is usually two bytes to handle counts up to 65535 counts. 
 
Some counters are able to read the interval between pulses directly or the frequency. This is useful for 
controlling the speed of conveyer belts or for reading the length of materials. 
 
Useful counter specs are the  maximum frequency of the pulses, may be up to 100Hz on some, much 
higher on others, and duration of the pulse.  One ADAM-4000 series model supports up to 3Hz 32 bit 
counter, plus 1 bit of overflow.  The counter model supports a 32 bit counter, at 5Hz to 50KHz, selectable 
gate time, noise filter, a minimum pulse width of >10msec and 2 alarm outputs. 

Digital Outputs 

Digital outputs come in two DC output types, Voltage/Current Sourcing, Voltage/Current Sinking.  

Simplified Diagram - Sourcing vs Sinking

Either type can be used to drive a electromechanical relay, relays provide isolation between the DC output, 
and the voltage being switched On/Off.  Some digital outputs already have relays, Form A Relays are 
Normally Open Contacts (SPST), Form C Relays are 3 contact type, COM (Common), which connects to 
the NC (Normally Closed) or NO (Normally Open) contacts. Solid state relays for AC or DC generally have 
a DC rated coil of 3-32 VDC less than 3 volts for Off, or more than 3 up to 32 VDC for On.  A digital output 
that can source the voltage and current is recommended for solid state relays 
 
Relay Outputs have voltage ratings for AC or DC voltages they can safely handle, and current ratings for 
DC or AC voltages, and ratings for resistive loads or for inductive loads such as motors, transformers, or 
similar devices.

If we look at specifications for a digital output, on the B&B Electronics model, 232SDD16 or 485SDD16, the 
digital outputs have a low voltage rating of 0.6 VDC of 8.3 mA (sinking), and rating of 4.3 VDC at 3.1 mA 
(sourcing).  To prevent loads from damaging the output, current must be limited to around 2 mA in either 
case.  These are TTL level outputs, 0 to 5 VDC.  If we want to connect a red or green LED, we must use a 
resistor that will limit the current.  LEDs and optical isolators have a DC voltage that when the LED is 
lighted, the voltage will be relatively constant, usually between 1.9 volts and 2.4 volts. Let’s examine the 
current limiting resistor in each case.  
 
TTL level max is 5 volts, minus 1.9 volts = 3.1 volts. 
 
3.1 volts divided by 0.002 mA = 1550 ohms limiting resistor.  Safe Value is larger. For 1 mA 3K ohms can 
be used.  1 mA will usually light a small LED  
 
If LED has 2.4 volt drop when lighted, 2.6 volts are remaining to drop.  Resistor value is then 1300 ohms 
(about 1.5K) for 2 mA, for 1 mA the closest standard value is 2.7K ohms. 

Figure 1: Current Sourcing

In the next figure (Fig. 2), External +5 volts is connected to a resistor to limit the current, and the Digital 
Output starts to Conduct when the output is pulled down to 0.6 volts, and the voltage across the LED is 
about 1.9 volts. 
 
The return line for the 5 volts must be connected to the GND or Common line for the outputs. 

Figure 2: Current Sinking

Figure 2: Current Sinking

What if we need to source or sink more current than the device can provide? 
 
To the current sinking output above we can add a NPN transistor.  We still need to limit the current sourced 
by the digital output so it does not exceed the rated output, but the transistor inverts the output so we need 
to use a high to get a low output and a low to get a high output.

Figure 3: Using a Transistor to Drive a 24 VDC Relay

The opposite of sinking is sourcing, typically referred to as PNP output, but may be a FET instead of 
transistor.

Figure 4

In either of the above cases, the relay and D1 diode could be replaced with a load resistor or active device.  
Then we would need to know how much current Q1 could source or sink.  Typical coil resistance for “Ice 
Cube” type SPST 24VCD relay is 750 ohms. 
 
Next section will be on analog A/D inputs and D/A analog outputs, and bits of resolution.