There seems to be a problem with the 'mydll.usb_tc08_set_channel command'
It will accept 0 but not 1 - 8. This is why I only get the cold junction temperature.
Looking at your programming calls, it would be helpful if you can call usb_tc08_get_last_error after each call to set the channel and send in the error codes returned by the function.
Alternatively, just try setting the cold junction and channels 1 and 2, and send in the error codes.
Have you got thermocouples in all of the ports?
Unfortunately I have not programmed using Python before.
import ctypes as C
tc08=C.CDLL("libusbtc08.2.dylib")
temp_array_obj=C.c_float*9
overflow_obj=C.c_int16
chan_obj=C.c_int16
tc_obj=C.c_char
units_obj=C.c_int16
temp_array=temp_array_obj()
overflow=overflow_obj()
chan=chan_obj()
tc=tc_obj()
units=units_obj()
# Plug a type J thermocouple into channel 4 on the tc08
chan.value=4
tc.value='J'
units.value=0
# Find the tc08
handle=tc08.usb_tc08_open_unit()
# Initialize the channel
tc08.usb_tc08_set_channel(handle,chan,tc)
# Make a single measurement
tc08.usb_tc08_get_single(handle,temp_array,overflow,units)
print temp_array[4] # temp_array[0] is the cold junction temperature
Hello,
I have tried using the code as supplied by Martyn to control a TC-08 temperature logger, but am getting the following error
mydll.usb_tc08_get_single(device, temp.ctypes.data, overflow_flags.ctypes.data, 0)
ctypes.ArgumentError: argument 2: : int too long to convert
I am using Python 3.5.2 | Anaconda 4.2.0 (64-bit) on a windows 10 PC with 64 bit architecture, and the driver I am using is the 64 bit driver usbtc08.dll provided by the SDK PicoSDK 10.6.12 (64-bit)
I have also received the same error when using the code supplied by scls19fr
Any ideas what could be going wrong?
Many thanks for your help
Colin
The temp buffer should be an array of 9 floating point numbers. Please check the data type used for this array.
If you are still having trouble, please post your code here. You may also wish to refer to some of the Customer examples that we have linked to from our GitHub repository.
import ctypes
import numpy as np
from ctypes import *
mydll = ctypes.windll.LoadLibrary('usbtc08.dll')
device = mydll.usb_tc08_open_unit()
mydll.usb_tc08_set_mains(device,50)
temp = np.zeros( (9,), dtype=np.float32)
overflow_flags = np.zeros( (1,), dtype=np.int16)
mydll.usb_tc08_set_channel(device, 0, 0 )
tc_type=ord('K')
for i in range(1,3):
mydll.usb_tc08_set_channel(device,i,tc_type)
print(temp.ctypes.data)
mydll.usb_tc08_get_single( device, temp.ctypes.data, overflow_flags.ctypes.data, 0)
mydll.usb_tc08_close_unit(device)
print(temp[0],temp[1],temp[2])
The datatype used for the temp buffer is indeed an array of of 9 floating point numbers. And if I ask to print temp i get [ 0. 0. 0. 0. 0. 0. 0. 0. 0.].
However if I probe the query temp.ctypes.data, the the repsonse I get is 30910073648. I suspect this may be the issue but do not know what to do about it.
Best regards,
Colin
Hello Hitesh,
Thank you for your reply.
When I run with the 32 bit driver (and the picolog application installed) I get the following error
Traceback (most recent call last):
File "temp.py", line 4, in
mydll = ctypes.windll.LoadLibrary('usbtc08.dll')
File "C:\Users\colinb\AppData\Local\Continuum\Anaconda3\lib\ctypes\__init__.py", line 425, in LoadLibrary
return self._dlltype(name)
File "C:\Users\colinb\AppData\Local\Continuum\Anaconda3\lib\ctypes\__init__.py", line 347, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 application