연락처

텍트로닉스 담당자와 실시간 상담 6:00am-4:30pm PST에 이용 가능

전화

전화 문의

9:00am-6:00PM KST에 이용 가능

다운로드

매뉴얼, 데이터 시트, 소프트웨어 등을 다운로드할 수 있습니다.

다운로드 유형
모델 또는 키워드

피드백

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

질문:

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

답변:

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.


이 FAQ는 다음에 적용 됩니다:

제품 시리즈 없음

제품:

FAQ ID 70581

모든 FAQ 보기 »