Pt-104 Data logger problem

Post your Linux discussions here
Post Reply
bubamara
Newbie
Posts: 0
Joined: Wed Apr 20, 2016 8:17 am

Pt-104 Data logger problem

Post by bubamara » Wed Apr 20, 2016 9:08 am

Dear all,

I am using two channels of the Pt-104 Data logger and RPi/Python in order to obtain the temperatures for the PID temperature control:
I am using the following code:

Code: Select all

handlePointer=c_short()
temp=np.zeros((9,),dtype=np.int64)
temp_1=np.zeros((9,),dtype=np.int64)
temperature_1=np.int64
temperature_2=np.int64
mydll=cdll.LoadLibrary('/opt/picoscope/lib/libusbpt104.so.2')
status_unit=mydll.UsbPt104OpenUnitViaIp(byref(handlePointer),'CO778/099','140.181.66.19:1')
Then I chek if the status_unit==0 and if so proceed with the setting of the channels:

Code: Select all

status_channel=mydll.UsbPt104SetChannel(handlePointer,2,1,2)
status_channel_1=mydll.UsbPt104SetChannel(handlePointer,1,1,2)
Check if they are zeros, as well, and obtain the temperatures in a while loop) as:

Code: Select all

mydll.UsbPt104GetValue(handlePointer,2,temp.ctypes.data)
mydll.UsbPt104GetValue(handlePointer,1,temp_1.ctypes.data)
temperature_1=temp[0]/1000.0
temperature_2=temp_1[0]/1000.0
The problem arised when I noticed that sometimes, after a few hours of working, Pt-104 Data logger stops sending the data. (It cannot be because of Ethernet connection since I am also using the other device on the same network for reading some voltages simultaneously and it is working fine). I taught that the problem can be solved then by closing the pico device and then closing the driver as:

Code: Select all

status_close=mydll.UsbPt104CloseUnit(handlePointer)
handle=mydll._handle
del mydll
cdll.LoadLibrary('libdl.so').dlclose(handle)
However when I try to reopen it with the same procedure:

Code: Select all

mydll=cdll.LoadLibrary('/opt/picoscope/lib/libusbpt104.so.2')
status_unit=mydll.UsbPt104OpenUnitViaIp(byref(handlePointer),'CO778/099','140.181.66.19:1')
status_channel=mydll.UsbPt104SetChannel(handlePointer,1,1,2)
status_channel_1=mydll.UsbPt104SetChannel(handlePointer,1,1,2)
mydll.UsbPt104GetValue(handlePointer,2,temp.ctypes.data)
mydll.UsbPt104GetValue(handlePointer,1,temp_1.ctypes.data)
I do not get any temperature readings. The problem is solved only when the python script is restarted. However since i have to have the continuous temperature readings that are related to the the controls of the other devices in the same script the restarting of script is not the solution.
Is there any way to reset/restart the driver properly or some other solution to fix the problem?
Thank you very much in advance! :)

Hitesh
Site Admin
Site Admin
Posts: 2829
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: Pt-104 Data logger problem

Post by Hitesh » Mon Apr 25, 2016 12:47 pm

Hi,

For the UsbPt104GetValue() function, the value parameter should be a 32-bit signed integer as opposed to a 64-bit integer.

You do not need to specify the serial number when connecting via Ethernet as you can use just the IP address and port number.

When the connection is lost, are you able to send a ping command to the IP address successfully? Rather than using port 1, which perhaps is a reserved port, I would suggest using a larger number e.g. 6500.

Regards,
Hitesh

Technical Support Engineer

bubamara
Newbie
Posts: 0
Joined: Wed Apr 20, 2016 8:17 am

Re: Pt-104 Data logger problem

Post by bubamara » Thu Apr 28, 2016 2:07 pm

Dear Hitesh,

First of all, thank you for your suggestions. I have set port to 6500, however the probem remained unsolved. Concerning ping, I run it in the background while the script was running, and I noticed that every time that Datalogger stopped working, the ping time went from about 1ms to 200-300 ms. Afterwards, the ping time was fine, however I was not able to obtain the temperatures again until I have restarted the script. Also I noticed something strange. I am able to open the unit just using both serial number and IP address:

Code: Select all

status_unit=mydll.UsbPt104OpenUnitViaIp(byref(handlePointer),'CO778/099','140.181.66.19:6500')
If I try to open it using just IP adress:

Code: Select all

status_unit=mydll.UsbPt104OpenUnitViaIp(byref(handlePointer),'140.181.66.19:6500')
the unit cannot be opened.

If you have some suggestions, I would really appreciate them.
Thanks a lot.
Regards

Hitesh
Site Admin
Site Admin
Posts: 2829
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: Pt-104 Data logger problem

Post by Hitesh » Thu Apr 28, 2016 2:19 pm

Hi,

How is the USB PT-104 connected to the ethernet port on the Raspberry Pi? Is it via a Power over Ethernet Switch, through just a normal switch/hub or directly?

If you are opening the device without using the serial number, you still need to pass a value for the serial parameter but set it to the Python equivalent for NULL.

Regards,
Hitesh

Technical Support Engineer

bubamara
Newbie
Posts: 0
Joined: Wed Apr 20, 2016 8:17 am

Re: Pt-104 Data logger problem

Post by bubamara » Fri Apr 29, 2016 7:54 am

Dear Hitesh,

Thanks a lot, None for serial number works.
DataLogger is connected to a normal Ethernet switch (which is then connected to the Ethernet network and not to RPi) and is powered via USB cable which is connected to a computer.

Regards.

Hitesh
Site Admin
Site Admin
Posts: 2829
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: Pt-104 Data logger problem

Post by Hitesh » Fri Apr 29, 2016 9:42 am

Hi Bubamara,

Are you able to try the USB PT-104 connected directly to the Ethernet port on the Raspberry Pi using a crossover cable?

Regards,
Hitesh

Technical Support Engineer

bubamara
Newbie
Posts: 0
Joined: Wed Apr 20, 2016 8:17 am

Re: Pt-104 Data logger problem

Post by bubamara » Tue May 03, 2016 11:24 am

Dear Hitesh,

Unfortunately I have to use the etharnet port of RPi for etharnet connection (I have to have remote access to RPi). However I have connected both Rpi and Pt-104 to the same network switch and I am still seeing the same problem. Is there any way to close and restart Pt-104 without killing the process?

Thanks a lot,
Regards,
Bubamara

Hitesh
Site Admin
Site Admin
Posts: 2829
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: Pt-104 Data logger problem

Post by Hitesh » Wed May 04, 2016 4:23 pm

Hi Bubamara,

You could try calling the UsbPt104CloseUnit() function if the UsbPt104GetValue() function returns a status code that is not PICO_OK or not a repeat value, then try opening the connection to the device again.

Have you tried using a Windows PC with the PicoLog Recorder software to see if that works with the Ethernet connection?

Regards,
Hitesh

Technical Support Engineer

Post Reply