Test and Measurement Forum

Pico TC-08, Reading Data

Post your .Net discussions here

Pico TC-08, Reading Data

Postby Solarity » Thu Dec 15, 2016 8:05 am

Hello there =)

Currently I'm working on a project and I bought the TC-08 Data logger for it.
What I am trying to achieve is that I connect 8 Thermocouples type-K to the TC-08 and read the temperature data from each one using a c# application.

I was looking inside the example code that is provided with the installation of the drivers and found the USBTC08CSConsole application. This is working perfectly only I want the code to be running inside a Form instead of a Console application, so I started making a form layout, and copied some code from the Console Application.
I managed to connect to the TC-08 but I can't seem to figure out how to extract the temperature data from each channel.

Form Layout:
Image

Code:
Connecting to the TC-08
Code: Select all
        private void button1_Click(object sender, EventArgs e)
        {
            //connect tc-08
            short handle = Imports.TC08OpenUnit();

            if (handle == 0)
            {
                Imports.TC08CloseUnit(1);
                textBox1.AppendText("Device is disconnected ");
                button1.Text = "Connect";
                textBox2.AppendText(Convert.ToString(handle));
            }

            else
            {
                Imports.TC08OpenUnit();
                textBox1.AppendText("Device opened successfully " );
                button1.Text = "Disconnect";
                textBox2.AppendText(Convert.ToString(handle));
            }

        }



What I would like to know is what code do I need to read the temperature from sensor 1 (Channel 1) and paste this temperature inside a Textbox. if I know how to do that I should be able to write the rest myself.

Thanks for your help in advance =)
Greetings, Solarity
User avatar
Solarity
User
User
 
Posts: 2
Joined: Thu Dec 15, 2016 7:13 am

Re: Pico TC-08, Reading Data

Postby Hitesh » Thu Dec 15, 2016 11:24 am

Hi Solarity,

You will need to use the usb_tc08_set_channel() (TC08SetChannel() in the USBTC08Imports.cs file) function to enable the channel and set the thermocouple type.

In order to get the current reading for the channel you can call the usb_tc08_get_single() (TC08GetSingle() in the USBTC08Imports.cs file) function.

Hope this helps,
Hitesh

Technical Support Engineer
Hitesh
Site Admin
Site Admin
 
Posts: 2387
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: Pico TC-08, Reading Data

Postby Solarity » Thu Dec 15, 2016 1:10 pm

Hello there Hitesh,

I am trying to figure out how to apply those functions,
Small preview of what the program is doing now:

Connecting to TC-08:
Button 1
Code: Select all
        private void button1_Click(object sender, EventArgs e)
        {
            //connect tc-08
            short handle = Imports.TC08OpenUnit(); //Code to open the device

            if (handle == 0)
            {
                Imports.TC08CloseUnit(1);
                textBox1.AppendText("Device is disconnected ");
                button1.Text = "Connect";
                textBox2.AppendText(Convert.ToString(handle));
            }

            else
            {
                Imports.TC08OpenUnit();
                textBox1.AppendText("Device opened successfully ");
                button1.Text = "Disconnect";
                textBox2.AppendText(Convert.ToString(handle));
            }
        }



Button 2
Code: Select all
        private void button2_Click(object sender, EventArgs e)
        {
            SetChannels();
            GetValues();
        }


SetChannels()
Code: Select all
        void SetChannels()
        {
            short channel;
            short ok;

            for (channel = 0; channel <= USBTC08_MAX_CHANNELS; channel++)
            {
                ok = Imports.TC08SetChannel(_handle, channel, TC_TYPE_K);

            }
        }


GetValues() I think something is going wrong here but I have no clue how to fix this.
Code: Select all
        unsafe void GetValues()
        {
            short status;
            short chan;
            float[] tempbuffer = new float[9];
            short overflow;

            // label the columns
            for (chan = 1; chan <= USBTC08_MAX_CHANNELS; chan++)
            {
                textBox6.AppendText("Chan{" + chan + "}: " );
            }

                status = Imports.TC08GetSingle(_handle, tempbuffer, &overflow, Imports.TempUnit.USBTC08_UNITS_CENTIGRADE);
                textBox7.AppendText(Convert.ToString(status)); // checking the value
                if (status == PICO_OK)
                {
                    for (chan = 1; chan <= USBTC08_MAX_CHANNELS; chan++)
                    {
                        textBox5.AppendText("{0:0.0000}   " + tempbuffer[chan]);
                    }
                    Thread.Sleep(1000);
                }
            status = Imports.TC08Stop(_handle);
        }

Somehow the "status" is not equal to "PICO_OK",
If I change
Code: Select all
if (status == PICO_OK)
to
Code: Select all
if (status == 0)

It does show me something but it are only zero's so there is no temperature being measured somehow.

Any tips =)
Thanks for your Time & Help
User avatar
Solarity
User
User
 
Posts: 2
Joined: Thu Dec 15, 2016 7:13 am

Re: Pico TC-08, Reading Data

Postby Solarity » Fri Dec 16, 2016 10:35 am

Any help.. ?
User avatar
Solarity
User
User
 
Posts: 2
Joined: Thu Dec 15, 2016 7:13 am

Re: Pico TC-08, Reading Data

Postby Hitesh » Fri Dec 16, 2016 11:29 am

Hi Solarity,

When the status is equal to 0, try calling the dll's usb_tc08_get_last_error() function and let me know what that function returns.

Does the device work ok with the PicoLog software?

Regards,
Hitesh

Technical Support Engineer
Hitesh
Site Admin
Site Admin
 
Posts: 2387
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: Pico TC-08, Reading Data

Postby Solarity » Fri Dec 16, 2016 1:36 pm

Hitesh wrote:Hi Solarity,

When the status is equal to 0, try calling the dll's usb_tc08_get_last_error() function and let me know what that function returns.

Does the device work ok with the PicoLog software?

Regards,



Hello there Hitesh,

Thank you for your time =), the device is working perfectly with the Console program which came with the installation of the driver. So there is no error with the device or the console program. There has to be something which I am not seeing. spend alot of hours trying to figure out what, Monday I'll let one of my teachers look into it. In the meantime I'll see what " Get_last_error" will teach me.

I'll notify you shortly =)

Greetings,
Solarity
User avatar
Solarity
User
User
 
Posts: 2
Joined: Thu Dec 15, 2016 7:13 am

Re: Pico TC-08, Reading Data

Postby Solarity » Fri Dec 16, 2016 2:19 pm

Omg I was testing some things, and I fixed it! Whoooo. I can finally read temperatures now with the click of a button

I'll make a guide + upload the program soon so more people can enjoy the code in c# :D
User avatar
Solarity
User
User
 
Posts: 2
Joined: Thu Dec 15, 2016 7:13 am

Re: Pico TC-08, Reading Data

Postby Hitesh » Fri Dec 16, 2016 5:23 pm

Good to hear you fixed it! :D

Look forward to seeing the guide and program - you can submit it via the PicoApps page on our website.

Regards,
Hitesh

Technical Support Engineer
Hitesh
Site Admin
Site Admin
 
Posts: 2387
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: Pico TC-08, Reading Data

Postby Solarity » Mon Dec 19, 2016 8:45 am

Hitesh wrote:Good to hear you fixed it! :D

Look forward to seeing the guide and program - you can submit it via the PicoApps page on our website.

Regards,


Hello there Hitesh =)

I have uploaded the program I made to PicoApps page on your website.

Inside the program I made a lot of note's that describe the functions of different buttons etc.
Someone with a little understanding of c# should be able to understand what the program is doing.

Greetings,
Solarity
User avatar
Solarity
User
User
 
Posts: 2
Joined: Thu Dec 15, 2016 7:13 am

Re: Pico TC-08, Reading Data

Postby Hitesh » Tue Dec 20, 2016 9:20 am

Hi Solarity,

Thank you - we have received your completed form so an entry should appear on the PicoApps page in due course.

Regards,
Hitesh

Technical Support Engineer
Hitesh
Site Admin
Site Admin
 
Posts: 2387
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: Pico TC-08, Reading Data

Postby Solarity » Tue Dec 20, 2016 9:36 am

Hitesh wrote:Hi Solarity,

Thank you - we have received your completed form so an entry should appear on the PicoApps page in due course.

Regards,


Hi there Hitesh,

It's a very basic program for now, but when I find the time I'll update it with a bit more functions.
First I have to complete my own project where I am using this code.


Greetings =)
User avatar
Solarity
User
User
 
Posts: 2
Joined: Thu Dec 15, 2016 7:13 am


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

Who is online

Users browsing this forum: No registered users and 0 guests