I have a problem reading the temperature from a PicoLog TC08. I access the unit with Java Native Access (http://jna.java.net/), because there is no original dll-file for Java. I can see that Java can communicate with the TC08, but I can't read any temperature. Can you help me, so I can use the TC08 in my Java application?
Below is the code for connection to TC08
Initaite via JNA
-------------------------
public FloatByReference fbr = new FloatByReference();
public LongByReference lbr = new LongByReference();
public ShortByReference sbr = new ShortByReference();
-------------------------
Run this code:
PicoLog picolog = (PicoLog) Native.loadLibrary(System.getProperty("user.dir") + "\\usbtc08.dll", PicoLog.class);//initiate via JNA
short handle = picolog.usb_tc08_open_unit();
short channel = 0;
short measureUnit = 0; // 0=celcius
short fillMissing = 1; // 1=previous good reading
The minimum interval being returned doesn't look right - what happens if you try to call it before the run function? Also, set the time interval to the minimum 100ms instead of 50.
Also, are you passing arrays for the temp_buffer and times_ms_buffer in the usb_tc08_get_temp() function call?
There may be an issue with the way parameters are being passed. Does your PicoLog class show the specification for each of the methods it has available?
Now I pass the temp_buffer and the times_ms_buffer as arrays with the length of 9. I did not do that before. But still, it is as if the TC08 does not write any values in the buffer-array. It just passes through the function without changing the value in the array.
I have changed the data types to something that should match the Native data types. (I got help from the Java Native Access user group)
I do not use the Picotech SDK. I use only Java and Java Native Access.I have an interface in wich I declare only the functions I use in the .dll file.
The Minimum interval is now looking more correct after I changed the data types, but I can't get any readings on the temperature.
Any suggestions?? Hope that we can solve this, as I need the temperature readings for an application.
FloatByReference[] ArrayFBR = new FloatByReference[9];
NativeLongByReference[] ArrayNLBR = new NativeLongByReference[9];
I am not familiar with JNA but I have used the JNI interface with the SDK for one or two of our oscilloscope ranges. Have you tried using JNI as well to communicate with the device? I have written an example in the Java forum:
Please note that for the times_ms_buffer argument to usb_tc08_get_temp() (ArrayNLBR in your case), it only needs to be set to a 1 by x array where x is the number of samples per channel you are capturing. This is because it records the time that it captures the reading for channel 1 for each sample set.
Also, have you tried calling the usb_tc08_get_single() function to get a single reading - you can call this instead of the usb_tc08_run() and usb_tc08_get_temp() functions to try getting a reading on channel 1.
I've pasted in some code from the console example that might help:
long interval;
float temp_buffer [9][BUFFER_SIZE];
long times_ms_buffer[BUFFER_SIZE];
short overflows[9];
long numberOfReadings;
long buffer_length;
short channel;
long i;
// Get minimum interval
min_interval_ms = usb_tc08_get_minimum_interval_ms(handle);
buffer_length = BUFFER_SIZE;
printf("Min. interval (ms): %d\n", min_interval_ms);
//Interval
interval = usb_tc08_run(handle, min_interval_ms);
printf("Interval: %d\n", interval);
printf("Press any key to start\n");
_getch();
//Loop
while (!_kbhit())
{
// Obtain a set of readings
for (channel = 0; channel <= USBTC08_MAX_CHANNELS; channel++)
{
numberOfReadings = usb_tc08_get_temp( handle, temp_buffer[channel], ×_ms_buffer[channel],
buffer_length, &overflows[channel], channel, 0, // degrees Celsius units
0); // do not fill missing readings
}
}
Please note that when capturing streaming data, you need to read data from the buffer periodically, and also call the usb_tc08_stop() function when you have finished collecting data.
Hope this helps.
Last edited by Hitesh on Mon Oct 15, 2012 11:34 am, edited 2 times in total.
Reason:Updating message.
I only use one array, but I put a value in the array before handing it over. Se the examples below.
I have seen ypu example, but I am not familiar with writing the wrapper.dll in C og C++, so thats why I chose JNA, as their code works fine with other dll-files I use for my application.
I have tried many differetn things now to make this work, and I still don't get the temperature. I think the problem lies in the datatype Float * temp_buffer vs FloatByReference[], and likewise between the long * times_ms_buffer and NativeLongByReference[]
------------------------------------------
The following cod gives me a java.lang.NullPointerException:
//make the array with space for 9 numbers and hand it over to the TC-08 in the function
FloatByReference[] ArrayFBR = new FloatByReference[9];