Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Can't get data from a USB6009 device (Edge Counter) using Measurement Stud. 2009

HI.

 

INTRODUCTION

------------------------

 

My name is Gerardo Diaz from MainRoads Application Support. We do have a Developer License from National Instruments and we are kind of stuck with a problem here.

 

 

OVERVIEW

--------------------

We have an old Labview Application that needs to be migrated to .NET (front end) and using MEasurement Studio 2009 to handle the connectivity to the Daq device (USB-6009)

The USB 6009 receives data from the car (speed) and reports it back to the application.

 

PROBLEM

----------------

 

We have already put together a sample application that creates a Task on the fly via code similar to the one that already exist inside MEasurement Explorer but no data comes through to the application. If the task is created via Measurement Explorer it works fine and the speed is retrieved via an Edge Counter task however the .NET code doesn't get anything.

 

 

ADDITIONAL INFO

---------------------------

 

Here is the code used.

 

 

 protected override void InternalStart()
        {
            _task = new Task();
            //this.Device = "/Dev2/ctr0"
            //this.InitialCount = 0
            //this.Direction = "Up"
            //this.Edge = "Falling"

            CIChannel MyCounterChannel = _task.CIChannels.CreateCountEdgesChannel(this.Device,"", this.Edge, this.InitialCount, this.Direction);
            _counterReader = new CounterReader(_task.Stream);

            Status = "Starting...";

            _taskThread = new Thread(ReadSingleSampleUInt32);
            _taskThread.Start();
        }


 private void ReadSingleSampleUInt32()
        {
            this.Status = "Started";

            while (true)
            {
                DateTime start = DateTime.Now;
                this.CounterValue = _counterReader.ReadSingleSampleUInt32();


                double waitMilliseconds = (1000f / this.MaxReadsPerSecond) - (DateTime.Now - start).TotalMilliseconds;
                if (waitMilliseconds > 0)
                {
                    Thread.Sleep(Convert.ToInt32(waitMilliseconds));
                }
            }
        }

 

 

 

_counterReader.ReadSingleSampleUInt32() always returns zero. As I said before if I create the Edge Counter task manually inside Measurement Explorer with the same values as above it does get the data when the car moves.

 

Hope someone could get us on this one.

 

Cheers

 

Gerardo DIaz

MainRoads Application Support

0061432962491

 

0 Kudos
Message 1 of 3
(3,105 Views)

Hey Gerardo,

 

We have a .NET Edge Counting example that ships with DAQmx, did you try that out and see if you get any data?

 

It's located in a different place depending on your version of windows:

 

Windows XP and Prior: C:\Documents and Settings\All Users\Shared Documents\National Instruments\NI-DAQ\Examples\DotNETx.x\Counter\Count Digital Events\CountDigEvents
or
Windows Vista or 7: C:\Users\Public\Public Documents\National Instruments\NI-DAQ\Examples\DotNETx.x\Counter\Count Digital Events\CountDigEvents

 

 

 

 

Kristen
National Instruments
0 Kudos
Message 2 of 3
(3,061 Views)

Howdy Gerardo!

 

I do not see anywhere in your code where you are actually starting the acquisition task by calling "_task.Start()".  It appears that you are starting the thread by calling "_taskThread.Start()", but that is not necessarily starting the counter input task.

 

If you are new to programming for DAQmx using C# I would recommend looking over the DAQmx .NET examples that can be included with the installation of the driver.  You can find them by going to Start>>All Programs>>National Instruments>>NI-DAQ>>Text-Based Code Support>>.NET Examples.

 

Regards,

Barron
Applications Engineering
National Instruments
0 Kudos
Message 3 of 3
(3,061 Views)