Kontaktaufnahme

Live-Chat mit Tektronix-Vertretern. Verfügbar von 9 bis 17 Uhr CET Geschäftstage.

Anrufen

Kontaktieren Sie uns telefonisch unter

Verfügbar von 9 bis 17 Uhr CET Geschäftstage.

Download

Laden Sie Handbücher, Datenblätter, Software und vieles mehr herunter:

DOWNLOADTYP
MODELL ODER SCHLÜSSELWORT

Feedback

How do I monitor the state of a contact switch using a digital I/O board?

Frage:

How do I monitor the state of a contact switch using a digital I/O board?

Antwort:

The digital inputs on the digital I/O board monitor digital high or low states. The input can be connected to +5 volts through a resistor of approximately 10kOhms, making the digital input high. If a contact switch is connected between digital ground and the input, the input will read high until the switch is closed, pulling the input low, as shown in Figure 1.


Figure 1

Most digital inputs on the digital I/O board come in groups of 8 lines. When these groups are read in software, the states of the 8 input lines are represented by an 8-bit decimal number from 0 to 255. This value is equal to the sum of the decimal weightings of each bit that is high. A value of 0 means that all lines are low, while a value of 255 means that all 8 lines are high. The states of individual lines can be determined by performing a bitwise AND with the value corresponding to that bit shown in Figure 2.


Figure 2

For example, if a value of 139 is read in the software and this value is ANDed with 128 (bit8), the answer would be 128, which means that bit8 is high. If 139 is also ANDed with 8 (bit4), we get 8, which means that bit4 is also high. Now, if we AND 139 with 16 (bit5), we get 0, which means that bit5 is low.

The sum of 139 corresponds to 128+8+2+1, so we can determine that bits 1, 2, 4, and 8 are all high.


Diese FAQs beziehen sich auf:

Keine Produktreihe

Produkt:

FAQ-ID 70581

Alle FAQs ansehen »