Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

CompactDaq AI with Visual Basic .NET

Michael,

You should be able to use the CJC normally, just consider that it requires an additional 70 ms to sample.  That should be fine for this app, since 2.8 Hz is still > 1 Hz.  If you don't measure it every sample, you can also measure it once at the beginning of the task, or use a constant temperature.  If your cDAQ chassis is in a constant temperature environment for the duration of the test, those shouldn't affect your data quality much.

That sounds like the right software structure, but the terminology is different in the LabVIEW environment (which I'm familiar with), so I'll let the experts analyze your code.

100 C/s is certainly more than most users!

Regards,
Kyle
0 Kudos
Message 21 of 115
(2,478 Views)
Kyle,

How would I go about measuring it once per task rather than once per channel?  That seems like a much more efficient method.  The chassis is in a climate controlled area, but we all know that climate control is subject to many parameters.
Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
0 Kudos
Message 22 of 115
(2,473 Views)
Hi Michael,

We are still having trouble running your code with all of the Excel references.  I tried what you suggested, following the directions at the forum you referenced, but it was to no avail.  The path for the library is undefined and even after locating it and defining it, the Excel objects are still not found.

However, Kyle had the idea that you may not be starting your task before your loop with the reads in it.

According to the NI Measurement Studio .NET Class Library, you should use the Public Sub Start() method to start a DAQmx task.  I could not find this method in your code.

If you do not use this method, a measurement task starts automatically when you call a read method.  If you do not use Start and Stop when you use a read or write method multiple times, the task starts and stops repeatedly, which reduces the performance of the application.

Is this a possiblility?

Thanks!
Erik
0 Kudos
Message 23 of 115
(2,474 Views)
Michael,

I'm confusing the autozero settings (none, once, every sample) with CJC a bit.  You can read the CJC for each module manually and then use that value to compensate your acquisition, but enabling the built-in CJC support in the driver will read the CJC once per sample.  Look for the "CJC Source" property in your DAQmx function reference for the settings you would use to turn off the automatic CJC use.

Since the CJC is only read once per module, not once per channel, it's only a 25% sample period penalty -- from 280 ms to 350 ms.  If you can afford this, it's certainly easiest (and most accurate) to leave it.  For that matter, you should consider turning on autozero, at least to once per task, to improve accuracy a bit.  You're already setting that in your code.

It sounds like we may be on to something with the task starting issue.  Hope that gets everything working.

Regards,
Kyle
0 Kudos
Message 24 of 115
(2,463 Views)
Erik, have you tried to delete the reference completely and then go to the Project Menu -> Add Reference -> COM Tab -> Microsoft Excel 11.0 Object Library -> OK

This would completely remove any previous reference and then reference the file from your machine where your machine knows it is located.

Can you be more specific on CJC Source?  The only reference I found to "cjc" was AIThermocoupleCjcSource, and that doesn't have any information on reading once per task/module/channel.

Message Edited by SCXI and MS 2k3-VB.NET on 01-03-2007 09:13 AM

Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
0 Kudos
Message 25 of 115
(2,454 Views)
Kyle,

Does NI recommend using autozero at least once per channel for thermocouple readings? for voltage readings?

I don't understand what you are trying to say about the CJC.  Does it already read once per channel or once per module?  Do I need to set it to any configuration other than that which it is already programmed for?  Does the CJC count as one of the samples in the 14 S/s rate? 

Here is the code I have for setting up the task.  I'm sure you will able to understand this regardless of your knowlege of VB.NET.  NOTE: I just added task.start.  I haven't tested this yet.

            While ChannelCount < numChannels
                While AIChannels(ChannelCount).Device = Device
                    TasksChannelCount(TaskCount) += 1

                    With AIChannels(ChannelCount)
                        Select Case AIChannels(ChannelCount).Type
                            Case Is = "Temperature"
                                Tasks(TaskCount).AIChannels.CreateThermocoupleChannel(.Device & "/" & _
                                                .Channel, Trim(.Name), .Min, .Max, AIThermocoupleType.K, _
                                                AITemperatureUnits.DegreesC)
                                If Not .Device.Contains("cDAQ") Then
                                    Tasks(TaskCount).AIChannels(.Name).AutoZeroMode = AIAutoZeroMode.None
                                    Tasks(TaskCount).AIChannels(.Name).LowpassEnable = True
                                    Tasks(TaskCount).AIChannels(.Name).LowpassCutoffFrequency = 4
                                End If
                            Case Is = "Voltage"
                               'deleted for space
                            Case Else
                                'deleted for space
                        End Select
                    End With
                    ChannelCount += 1
                    If ChannelCount = numChannels + 1 Then Exit While
                    If AIChannels(0).Device.Contains("cDAQ") Then
                        Device = AIChannels(ChannelCount).Device
                    End If
                End While

                Tasks(TaskCount).Timing.ConfigureSampleClock("", frm.numSampleRate.Value, SampleClockActiveEdge.Rising, _
                                                             SampleQuantityMode.FiniteSamples, frm.numSamples.Value)
                Tasks(TaskCount).Control(TaskAction.Verify)
                Tasks(TaskCount).Control(TaskAction.Unreserve)
                reader(TaskCount) = New AnalogMultiChannelReader(Tasks(TaskCount).Stream)
                Tasks(TaskCount).Start()

                TaskCount += 1
                TasksChannelCount(TaskCount) = 0
                Device = AIChannels(ChannelCount).Device
            End While
Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
0 Kudos
Message 26 of 115
(2,445 Views)
Michael,

NI officially recommends that you use autozero on the 9211 when the 9211 is outside the "room temperature" range of 15-35 degC.  The manual has a pretty good assessment of the effect on the measurement for different types of thermocouples.  If you were to use it, once per task would be sufficient for most applications, or at most once per module.  The 9211 only has one autozero channel (and CJC channel) per module, not per channel.

I'm not sure what the default setting is for CJCs.  Your best bet is to read the property, or just set it to built in.  Here's the corresponding C function I've found reference to:
DAQmxGetAIThrmcplCJCSrc.  The property is Analog Input >> Temperature >> Thermocouple >> CJC Source.  Set it to built-in, and it will read once per module, which counts as one channel in your 14 S/s rate.

Your code looks reasonable to me, with the addition of Start().

9211 manual link:
http://www.ni.com/pdf/manuals/373466c.pdf

Kyle
0 Kudos
Message 27 of 115
(2,438 Views)
I tried the code with task.start and it still takes 2 seconds per reading.  Have you guys figured out how to automate excel yet?
Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
0 Kudos
Message 28 of 115
(2,430 Views)
Hi Michael,

Your new code looks good, as long as right now there is only one total task running (TaskCount has only one value).  I should have mentioned this before - make sure that at the end of your code, after all of the reads have executed, you have a Tasks(TaskCount).Stop() in the same way you have a Tasks(TaskCount).Start()If your task is starting and stopping on each iteration of the loop, the Stop() method should return an error that there are no tasks running.

I tried your suggestion of removing the Microsoft Office 11.0 Object Library adding the \obj\Debug\Interop.Microsoft.Office.Core.dll file that you provided me as the new object library, but the Excel objects were still undefined because the Microsoft.Office.Interop.Excel reference is still undefined.  In order for us to properly analyze the code, we will need a stripped-down version of your code that simply starts a task, reads in a loop, and stops the task.

We have a shipping example that does continuous acquisition on thermocouples.  Have you confirmed that the slow acquisition rate occurs in this example as well?  (The example can be found at C:\Program Files\National Instruments\MeasurementStudioVS2005\DotNET\Examples\DAQmx\Analog In\Measure Temperature\ContAcqThermocoupleSamples_IntClk\Vb).

I hope that using the Stop() method works!

Regards,
Erik
0 Kudos
Message 29 of 115
(2,425 Views)
I will work on changing the loadchannelconfiguration function to a tab delimited text file, but what I needed you to do was find your own Excel Object Library, not the one included with my project.  That is the whole problem.  My reference will not work.  When you go to the project menu in the menu bar and then go to references to add the excel 11.0 object library, Visual Studio is going to find the library on your machine which has nothing to do with any libraries I provided.

Because that is a simple step, can you try it while I change this program, just for both of our benefit.  I need to know that it will work on another machine without having to send it as an installer and it would probably help you to know how to automate Excel at some point or another.  If you feel like it's a waste of time, then don't bother because I will be sending an updated version.

Thank you for your persistence.
Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
0 Kudos
Message 30 of 115
(2,417 Views)