Skip to content

Commit 36348ed

Browse files
author
neil.hamilton
committed
Add tc08Examples/tc08StreamingModeExample.py
1 parent 12a40c6 commit 36348ed

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#
2+
# Copyright (C) 2019 Pico Technology Ltd. See LICENSE file for terms.
3+
#
4+
# TC-08 SINGLE MODE EXAMPLE
5+
6+
7+
import ctypes
8+
import numpy as np
9+
import time
10+
from picosdk.usbtc08 import usbtc08 as tc08
11+
from picosdk.functions import assert_pico2000_ok
12+
13+
# Create chandle and status ready for use
14+
chandle = ctypes.c_int16()
15+
status = {}
16+
17+
# open unit
18+
status["open_unit"] = tc08.usb_tc08_open_unit()
19+
assert_pico2000_ok(status["open_unit"])
20+
chandle = status["open_unit"]
21+
22+
# set mains rejection to 50 Hz
23+
status["set_mains"] = tc08.usb_tc08_set_mains(chandle,0)
24+
assert_pico2000_ok(status["set_mains"])
25+
26+
# set up channel
27+
# therocouples types and int8 equivalent
28+
# B=66 , E=69 , J=74 , K=75 , N=78 , R=82 , S=83 , T=84 , ' '=32 , X=88
29+
typeK = ctypes.c_int8(75)
30+
status["set_channel"] = tc08.usb_tc08_set_channel(chandle, 1, typeK)
31+
assert_pico2000_ok(status["set_channel"])
32+
33+
# get minimum sampling interval in ms
34+
status["get_minimum_interval_ms"] = tc08.usb_tc08_get_minimum_interval_ms(chandle)
35+
assert_pico2000_ok(status["get_minimum_interval_ms"])
36+
37+
# set tc-08 running
38+
status["run"] = tc08.usb_tc08_run(chandle, status["get_minimum_interval_ms"])
39+
assert_pico2000_ok(status["run"])
40+
41+
time.sleep(2)
42+
43+
# collect data
44+
temp_buffer = (ctypes.c_float * 2 * 15)()
45+
times_ms_buffer = (ctypes.c_int32 * 15)()
46+
overflow = ctypes.c_int16()
47+
status["get_temp"] = tc08.usb_tc08_get_temp(chandle, ctypes.byref(temp_buffer), ctypes.byref(times_ms_buffer), 15, ctypes.byref(overflow), 1, 0, 1)
48+
assert_pico2000_ok(status["get_temp"])
49+
50+
# stop unit
51+
status["stop"] = tc08.usb_tc08_stop(chandle)
52+
assert_pico2000_ok(status["stop"])
53+
54+
# close unit
55+
status["close_unit"] = tc08.usb_tc08_close_unit(chandle)
56+
assert_pico2000_ok(status["close_unit"])
57+
58+
# display status returns
59+
print(status)

0 commit comments

Comments
 (0)