国产性一乱一性一伧的解决方法,国产一区影视,日韩欧美国产亚洲,日韩av在线播放不卡,国产69精品久久久久孕妇大杂乱 ,亚洲国产一,97国产精品视频,波多野结无码高清中文
君億道科技聯系電話:0755-26830682

公司新聞

最全面及時的公司資訊、企業動態

適用于 Windows 的 Python 示例以 100 Hz 收集熱電偶數據

來源君億道

下面的代碼清單使用 daq_in_scan 函數來讀取熱電偶輸入(本文底部附有模塊)。此功能通常用于同時讀取USB-1616HS和USB-2523等設備上的設備子系統(模擬、數字). 但是,如果您需要以更快的速度掃描多個熱電偶,則還必須使用它來將通道與其 CJC 傳感器配對。在此示例中,我們使用它以每秒 100 個樣本讀取 8 個熱電偶輸入(以及相關的 CJC 通道)。緩沖區中返回的二進制數據包含 CJC 和通道數據。它被安排為 CJC、Channel0、CJC Channel1 等。必須注意在每個通道之前放置正確的 CJC。GetTCValues 函數用于將 CJC 和通道數據轉換為溫度值。使用該功能的關鍵是輸入第一個熱電偶/CJC 的位置和要轉換的樣本數。

 

下面附上 32 位代碼文件。要運行該示例,您必須安裝適用于 Windows InstaCal mcculw Python。由于選項卡縮進問題,不建議使用附加模塊復制/粘貼 Python 代碼。

 

免責聲明:

隨附的代碼或示例按原樣提供。它尚未作為產品進行測試或驗證,用于已部署的應用程序或系統,或用于危險環境。您承擔使用代碼或示例的所有風險。

文件:daq_in_scan_usb_1800.py

庫調用演示:mcculw.ul.daq_in_scan()                           

用途:同步掃描8個熱電偶通道

演示:如何將原始數據轉換為溫度

其他庫調用:mcculw.ul.daq_in_scan()

                            mcculw.ul.get_tc_values()

                            mcculw.ul.win_buf_free()

                            mcculw.ul.release_daq_device()

 

特殊要求:此示例過濾 USB-1808 系列。

__future__ 導入 absolute_import,除法,print_function

from builtins import * # @UnusedWildImport

從時間導入睡眠

# 1616HS 2500 系列不支持 ScaleData

# from ctypes import cast, POINTER, c_double

ctypes 導入 cast、POINTER、c_ushortc_float

 

mcculw 進口 ul

mcculw.enums 導入 ScanOptions、ChannelTypeULRange、TempScaleDigitalPortType

mcculw.device_info 導入 DaqDeviceInfo

mcculw.ul 導入 ULError

mcculw.enums 導入 FunctionType,狀態

 

 

嘗試:

    console_examples_util 導入 config_first_detected_device

導入錯誤除外:

    .console_examples_util 導入 config_first_detected_device


def run_example():

    use_device_detection = False

    board_num = 0

    # USB-1808 系列支持的 PID

    = 100

    points_per_channel = 64

    memhandle =

 

    嘗試:

 

        # 使用 InstaCal 的零板

        daq_dev_info = DaqDeviceInfo(board_num)

        print('\n活動數據采集設備:', daq_dev_info.product_name, ' (',

              daq_dev_info.unique_id, ')\n', sep='')

 

        scan_options = ScanOptions.FOREGROUND

 

        # 創建 daq_in_scan 通道配置列表

        chan_list = []

        chan_type_list = []

        增益列表 = []

 

        # 模擬頻道必須在列表的第一位

        chan_list.append(0)

        chan_type_list.append(ChannelType.CJC)

        gain_list.append(ULRange.BIP10VOLTS)

 

        chan_list.append(0)

        chan_type_list.append(ChannelType.TC)

        gain_list.append(ULRange.BIP10VOLTS)

 

        chan_list.append(1)

        chan_type_list.append(ChannelType.CJC)

        gain_list.append(ULRange.BIP10VOLTS)

 

        chan_list.append(1)

        chan_type_list.append(ChannelType.TC)

        gain_list.append(ULRange.BIP10VOLTS)

 

        chan_list.append(1)

        chan_type_list.append(ChannelType.CJC)

        gain_list.append(ULRange.BIP10VOLTS)

 

        chan_list.append(2)

        chan_type_list.append(ChannelType.TC)

        gain_list.append(ULRange.BIP10VOLTS)

 

        chan_list.append(2)

        chan_type_list.append(ChannelType.CJC)

        gain_list.append(ULRange.BIP10VOLTS)

 

        chan_list.append(3)

        chan_type_list.append(ChannelType.TC)

        gain_list.append(ULRange.BIP10VOLTS)

 

        chan_list.append(3)

        chan_type_list.append(ChannelType.CJC)

        gain_list.append(ULRange.BIP10VOLTS)

 

        chan_list.append(4)

        chan_type_list.append(ChannelType.TC)

        gain_list.append(ULRange.BIP10VOLTS)

 

        chan_list.append(4)

        chan_type_list.append(ChannelType.CJC)

        gain_list.append(ULRange.BIP10VOLTS)

 

        chan_list.append(5)

        chan_type_list.append(ChannelType.TC)

        gain_list.append(ULRange.BIP10VOLTS)

 

        chan_list.append(4)

        chan_type_list.append(ChannelType.CJC)

        gain_list.append(ULRange.BIP10VOLTS)

 

        chan_list.append(6)

        chan_type_list.append(ChannelType.TC)

        gain_list.append(ULRange.BIP10VOLTS)

 

        chan_list.append(5)

        chan_type_list.append(ChannelType.CJC)

        gain_list.append(ULRange.BIP10VOLTS)

 

        chan_list.append(7)

        chan_type_list.append(ChannelType.TC)

        gain_list.append(ULRange.BIP10VOLTS)

        num_chans = len(chan_list)

 

        total_count = num_chans * points_per_channel

        half_count = total_count / 2

 

        # 為掃描分配內存并將其轉換為 ctypes 數組指針

        memhandle = ul.scaled_win_buf_alloc(total_count)

 

        # 1616HS 2500 系列不支持 ScaleData

        # ctypes_array = cast(memhandle, POINTER(c_double))

        ctypes_array = cast(memhandle, POINTER(c_ushort))

 

        # 檢查緩沖區是否分配成功

        如果不是內存句柄:

            raise Exception('錯誤:分配內存失敗')

 

        scan_options = ScanOptions.CONTINUOUS | 掃描選項.背景

 

        # 開始掃描

        actRate, preCount, postCount = ul.daq_in_scan(

            board_num, chan_list, chan_type_list, gain_list, num_chans,

            rate, 0, total_count, memhandle, scan_options)

 

        狀態,curr_count,curr_index = ul.get_status(

            board_num, FunctionType.DAQIFUNCTION)

 

        # 用于切換讀取上下緩沖區的布爾標志

        read_lower =

 

        # 獲取 640 個樣本

        獲取 = points_per_channel * num_chans * 10

        而狀態!=狀態。空閑:

 

            狀態,curr_countcurr_index = ul.get_status(

                board_num, FunctionType.DAQIFUNCTION)

 

            如果(curr_index > half_count)和(read_lower == True):

                # 如果您也有電壓或數字輸入,請使用

                ul.win_buf_to_array(memhandle, ctypes_array, 0, int(half_count))

 

                # 每個通道的點數是 64,所以有 32 個要轉換,從零開始

                e, temps = ul.get_tc_values(

                    board_num, chan_list, chan_type_list,

                    num_chans, memhandle, 0, int(points_per_channel/2), TempScale.CELSIUS)

 

                對于范圍內的 j (256)

                    如果 j % 8 == 0

                        打?。ǎ?/p>

                    print('{:2.2f}\t'.format(temps[j]), end ='')

 

                read_lower =

 

            elif (curr_index < half_count) (read_lower == False)

                # 如果您也有電壓或數字輸入,請使用

                ul.win_buf_to_array(memhandle, ctypes_array, int(half_count), int(half_count))

 

                # 每個通道的點數是 64,所以有 32 個要轉換,從中間點開始

                e, temps = ul.get_tc_values(

                    board_num, chan_list, chan_type_list,

                    num_chans,memhandleintpoints_per_channel/2),intpoints_per_channel/2),TempScale.CELSIUS

 

                對于范圍內的 j (256)

                    如果 j % 8 == 0

                        打?。ǎ?/p>

                    print('{:2.2f}\t'.format(temps[j]), end='')

 

                read_lower =

 

            如果 curr_count > 獲?。?/p>

                print('\n獲取的掃描次數 = {:d}'.format(int(curr_count / num_chans)))

                休息

 

        ul.stop_background(board_num, FunctionType.DAQIFUNCTION)

        print("\n掃描成功完成。")

    除了 ULError e

        打印('\n', e)

    最后:

        如果內存處理:

            # finally 塊中釋放緩沖區以防止內存泄漏。

            ul.win_buf_free(內存句柄)

        如果使用_device_detection

            ul.release_daq_device(board_num)


如果 __name__ == '__main__'

    運行示例()


主營:電流探頭,電壓探頭,羅氏線圈,電流傳感器,高壓探頭,電流互感器,功率電子測量產品
粵ICP備14003389號深圳君億道科技有限公司 © http://www.fengshengzhitongche.com
主站蜘蛛池模板: 东平县| 安溪县| 赤城县| 娄底市| 汝州市| 济源市| 大庆市| 保康县| 根河市| 泗阳县| 沛县| 大渡口区| 江安县| 响水县| 阳春市| 苏州市| 宜丰县| 琼结县| 区。| 马边| 香格里拉县| 中方县| 远安县| 上饶市| 老河口市| 合江县| 汤阴县| 阿图什市| 新建县| 大石桥市| 卓资县| 楚雄市| 潞城市| 皋兰县| 左权县| 巫山县| 油尖旺区| 根河市| 驻马店市| 钦州市| 客服| 石河子市| 平顺县| 涿州市| 海晏县| 德令哈市| 岑溪市| 临汾市| 黎平县| 花莲市| 容城县| 邛崃市| 沂南县| 肃北| 潮州市| 三都| 呼玛县| 九台市| 招远市| 贵德县| 瓦房店市| 天全县| 北川| 洛隆县| 祁连县| 西和县| 怀集县| 广州市| 孙吴县| 靖宇县| 武胜县| 淳安县| 玛沁县| 淮南市| 同德县| 襄城县| 房山区| 福清市| 台前县| 苗栗市| 伊吾县| 花莲县|