Reading from PT-104 in C#

Post your .Net discussions here
Post Reply
dle
User
User
Posts: 4
Joined: Wed Jan 10, 2007 6:50 pm

Reading from PT-104 in C#

Post by dle »

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

Erik
PICO STAFF
PICO STAFF
Posts: 53
Joined: Mon Oct 23, 2006 8:16 am
Location: Cambridgeshire, UK

Post by Erik »

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?

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

Post by dle »

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.

Post Reply