Skip to content

Commit 8b5888b

Browse files
author
neil.hamilton
committed
create initial example setup
1 parent b22d1f0 commit 8b5888b

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

pt104Examples/pt104Example.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#
2+
# Copyright (C) 2022 Pico Technology Ltd. See LICENSE file for terms.
3+
#
4+
# PT104 Example
5+
# This example opens a pt104, sets up a single channel and collects data before closing the pt104
6+
7+
import ctypes
8+
from picosdk.usbPT104 import usbPt104 as pt104
9+
import numpy as np
10+
from picosdk.functions import assert_pico_ok
11+
from time import sleep
12+
13+
# Create chandle and status ready for use
14+
status = {}
15+
chandle = ctypes.c_int16()
16+
17+
# Open the device
18+
status["openUnit"] = pt104.UsbPt104OpenUnit(ctypes.byref(chandle),0)
19+
assert_pico_ok(status["openUnit"])
20+
21+
# Set mains noise filtering
22+
sixty_hertz = 0 #50 Hz
23+
status["setMains"] = pt104.UsbPt104SetMains(chandle, sixty_hertz)
24+
assert_pico_ok(status["setMains"])
25+
26+
# Setup channel 1
27+
channel = pt104.PT104_CHANNELS["USBPT104_CHANNEL_1"] #channel 1
28+
datatype = pt104.PT104_DATA_TYPE["USBPT104_PT100"] #pt100
29+
noOfWires = 4 #wires
30+
31+
status["setChannel1"] = pt104.UsbPt104SetChannel(chandle, channel, datatype, noOfWires)
32+
assert_pico_ok(status["setChannel1"])
33+
34+
print(status)
35+
36+
#pause
37+
sleep(2)
38+
39+
# Get values
40+
value = ctypes.c_int32()
41+
filtered = 1 # true
42+
status["getValue"] = pt104.UsbPt104GetValue(chandle, channel, ctypes.byref(value), filtered)
43+
assert_pico_ok(status["getValue"])
44+
45+
# Close the device
46+
status["closeUnit"] = pt104.UsbPt104CloseUnit(chandle)
47+
assert_pico_ok(status["closeUnit"])
48+
49+
print(status)

0 commit comments

Comments
 (0)