Test and Measurement Forum

Reading from PT-104 in C#

Post your .Net discussions here

Reading from PT-104 in C#

Postby dle » Wed Jan 10, 2007 7:20 pm

I am attempting to read temperature values from a PT-104 with attached PT100 in C#. Interfacing with the driver seems to work fine up until I attempt to get the temperature values, which always fails. No error messages are given so I can't tell what is going wrong.

Code: Select all
[DllImport("PT10432.DLL")]
        private static extern short pt104_open_unit(ushort port);

        [DllImport("PT10432.DLL")]
        private static extern void pt104_close_unit(ushort port);

        [DllImport("PT10432.DLL")]
        private static extern short pt104_set_channel(ushort port, ushort channel, ushort dataType, ushort numWires);

        [DllImport("PT10432.DLL")]
        private static extern short pt104_get_value(long[] data, ushort port, ushort channel, ushort filtered);

...


long[] data = new long[256];

short result = pt104_open_unit(1); // returns 1 (true)
result = pt104_set_channel(1, 4, 1, 4); // returns 1
result = pt104_get_value(data, 1, 4, 0); // returns 0 (error!)


The probe works on this channel (tested using PicoScope), so I am sure its not the hardware. The only other thing that I have noticed is that the array 'data' returns with the first value equal to '1' and the remainder are left as 0.

Any help would be appreciated. Thanks.

Dave
dle
User
User
 
Posts: 4
Joined: Wed Jan 10, 2007 6:50 pm

Postby Erik » Tue Jan 23, 2007 9:31 am

See the following paragraph in the documentation for the driver about the return value of pt104_get_value()

Returns:
TRUE - if a reading is available
FALSE - if any of the inputs are out of range. It will normally return FALSE for a few seconds after you open the driver, until the driver has taken a reading from the specified channel

Could this be your problem?
Erik
PICO STAFF
PICO STAFF
 
Posts: 52
Joined: Mon Oct 23, 2006 8:16 am
Location: Cambridgeshire, UK

Postby dle » Tue Jan 23, 2007 5:41 pm

I am sure this is not the case, since I've tried taking readings very shortly after taking a successful reading from PicoScope (indicating that a reading is available). I've queried the device minutes after initializing the driver, which should be enough time for any "startup", yet no results.

Any other ideas would be appreciated. Thanks.
dle
User
User
 
Posts: 4
Joined: Wed Jan 10, 2007 6:50 pm


Return to .Net Languages (C#, VB.Net, .)

Who is online

Users browsing this forum: No registered users and 0 guests