MoonNote

반응형
     

 

 

 

실습 구성

◾ NI Data Acquisition Device : USB-6212

◾ DAQmx Driver, numpy

 

 

실습 방법

◾ NI DAQ 장비를 이용한 Digital Input Continuous Sampling 예제

◾ 서로 다른 Digital Port의 0~2번 line을 물리적으로 연결

◾ UI 툴은 따로 사용하지 않아 NI MAX에서 디지털 출력을 하고 명령창에서 Input 값 출력해서 확인

 

'''
Copyleft © MoonNote

작성자 : MoonNote
블로그 주소 : MoonNote.tistory.com
'''

import nidaqmx
import time
import numpy as np

from ast import Break
from nidaqmx.constants import LineGrouping

data = np.zeros(4)

with nidaqmx.Task() as task :

    task.di_channels.add_di_chan("Dev1/port0/line0:3", "", line_grouping=LineGrouping.CHAN_PER_LINE)
    task.start()
    try:
        while True:
            data = task.read(1, timeout=10)
            print('port0/line0:3 data =', data)
            time.sleep(0.5)
    except KeyboardInterrupt:
        Break
        print('close the program')
    task.stop()

 

테스트 영상

 

 

 

 

 

 

 

 

※ 이 글이 도움이 되었다면 "🤍공감" 버튼을 클릭해주세요. 클릭 한번이 글 쓰는데 큰 힘이 됩니다.

공유하기

facebook twitter kakaoTalk kakaostory naver band