ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

6602, .NET, concepts, documentation....

Wow. I'm really confused here. I've spent the last few days messing around with DAQmx and .NET, just doing a few basic tests. I can make a pulse train, and I can make a finite train (when I use the correct channels), but there are many functions that I don't know how to perform or don't completely understand. Part of this could be my relative inexperience in programming the 6602 and the Microsoft lingo (COM, ActiveX, etc.) The documentation that I have been referring seems pretty shoddy.

First, a bit about my application: I use the 6602 to generate pulses to synchronize dual head Nd:YAG lasers (4 pulses each) to a camera (for PIV-type stuff). We have a really decrepid program written in C with the traditional NI-DAQ to do this kind of stuff, and, well, I'm sick of trying to fool it into doing what I wanted it to do, so I decided to rewrite one from scratch. The main functionality I would like to add is the ability to synchronize to an experimental device such as a stepper motor or whatever. Since I need one pulse for the camera and four for the laser, I believe that leaves me with three counters to play with (I believe our current program uses 6 for some reason).

Here's the details of the computer system:
  • Windows XP on Intel Xeon processors
  • NI-DAQmx 8.0 - I don't know the specific version; I downloaded it on 12/15/2005 and the MeasurementStudioVS2003\DotNET\Assemblies directory contains the following directories: 8.0.11.12, 8.0.11.194, and Current. I installed it with .NET support.
  • Microsoft Visual Studio 2005 Standard Edition version 8.0.50727.42
  • PCI-6602 card.
The test programs I've been writing in Visual Basic

I will split my questions because this is too long for one post.


0 Kudos
Message 1 of 30
(7,950 Views)

First, some software issues:

  1. I previously had NI-DAQ 7.4 installed. I did not uninstall it before installing NI-DAQmx. Was I supposed to?
  2. I also use Video Savant 4.0 from IO Industries which uses a Sentinel parallel port dongle. After installing NI-DAQmx, the Sentinel Server, spnsrvnt.exe, causes some sort of buffer overrun and crashes during the XP login screen. I don't know exactly what this service does, as when I run it manually Windows says it ran and stopped itself and may be a one-time service instead of a continuous one. Either way, Video Savant doesn't seem to have any problems. At the same time, Windows complained that it could no longer verify the status of Norton Antivirus 8 (I installed 10 and that seems to be working now). So far these are not a problem, but I figured I'd put it up just in case.
  3. I saw the link on the forums for the Visual Studio 2005 patch and downloaded it but it says that I already have the newest version, so the patch does nothing. This page [broken link removed] tells me how to add the Measurement Studio controls to a project, yet the DLLs it points to just below step 5 are not installed on my system - I only have NationalInstruments.DAQmx.dll and NationalInstruments.Common.dll. I reran DAQmx setup and verified that I had installed everything that says .NET on it.
  4. If I don't do things properly (so that the NI-DAQmx API throws an exception) and I don't have code to handle the exception, it will crash all of Visual Studio. Am I just trying to combine things that are way too new here?
  5. I was a bit annoyed that I had to reboot after the DAQ-mx installation and then reboot again after running Measurement Explorer for the first time....

Second, some programming issues:

I can't seem to get things straight as to how to perform simple tasks with the card. I'm sure some of it is my general ignorance, so I would appreciate it if I could get pointed to the correct documentation.

Here's a list of the documentation I've been referring to:

  1. NI-DAQmx .NET framework 1.1 Help - The page on "Using the Measurement Studio NI-DAQmx .NET Library" was a handy starting point to get some of the concepts. However I found the reference section to be disappointing. You have written an API with long, descriptive function names and it seems like the description is nothing more than the same words with spaces in between them - I found the help file no more useful than Visual Studio's object browser or the pop-up hints. It would be nice to see some examples of how the functions all work together.
  2. NI-DAQmx Help - to reference the line names for my 6602. Pretty handy, except I'm confused. Under NI-DAQmx Key Concepts/Terminals/Terminal Names, "Counter Accessory Terminal Names" shows "Revised Terminal Names" - what are these? Are these the strings I use on channel.PulseTerminal? Because in NI-DAQmx Device Terminals, "Terminal Name Equivalents" states the the equivalent of GPCTR1_GATE is CTR 1 GATE, which doesn't work (it seems the correct string to use is CTR1GATE). In a quick test program I created a  frequency  channel on counter 0 at 10 Hz, and another on counter 1 at 100 Hz (both with .5 duty cycle), and then I set the PulseTerminal of counter 0 to "CTR1GATE" (which does not throw an exception, but does not give a signal off of counter 1 being intermittent .05 second bursts of 100 Hz pulses as I expected - more on this later), but if I try to set it to "PFI34" I get an exception that the "hardware does not support it". Aren't these the same line in the 6602? What names should I use?
  3. 6601/6602 User Manual, January 1999 Edition - is there a new version out? There is a whole section on "Functionality" on chapter 3 that describes "Counter Applications" like frequency division and the like, which, as far as I can tell (though I have never programmed it myself) could be directly set with the GPCTR_Set_Application function in the Traditional NI-DAQ. Is there an equivalent way of doing these things with NI-DAQmx through .NET? Have these "applications" been renamed, or obsoleted? I'm lost here.
 
0 Kudos
Message 2 of 30
(7,943 Views)
.NET and DAQmx concepts

To use my 6602 through Visual Basic .NET, I create a new VB project and then add references to NationalInstruments.Common.dll and NationalInstruments.DAQmx.dll in the \MeasurementStudioVS2003\DotNET\Assemblies\Current directory. I must manually browse for these as they do not apper under .NET in Visual Studio.

6602 Counter Concepts

Let me describe to you conceptually how the card works - if I don't get this right, then that could be part of the problem, so if I missed something, let me know.

The 6602 has 8 counters. Each counter is connected to four terminals or lines. These are:

Source - this is where the base timing signal goes in. By default this is routed to one of the three internal clocks of the 6602 (which one I'm not sure of), although I can manually plug something in via a break-out board or BNC2121 (but if I do this I have to base my program on ticks not frequency). I see there are functions to tell the card what the external timebase is (CounterTimebaseRate and CounterTimebaseSource). The description of the latter says "Use this property to specify an external timebase and produce custom pulse widths that are not possible using the internal timebases". I see now how to use it with an external source, but how do I specify one of the tree internal clocks? Is this done automatically?

Aux - I have no idea what this is for.

Gate - this is like a logic gate. If it is high, the counter will do what it is set to do. If not, it stays inactive. This is how the Timing.ConfigureImplicit(SampleQuantityMode.FiniteSamples, n) function gets executed. From what I have read, gate connectivity is limited: you can only use a counter's output as another's gate in specific pairs - counters 0 and 1, 2 and 3, etc. Is this correct? The FiniteSamples configuration fails, for example, if you crate channels on both counters 0 and 1. Is the connection of the gates bidirectional, meaning out 0 can go into gate 1 and out 1 can go into gate 0? And any other gate connections must be done by wires on the break-out board or equivalent?

Out - this is the default output line. To redirect output you use PulseTerminal.



0 Kudos
Message 3 of 30
(7,946 Views)
Actual code examples:

Here are a few specific situations in which some of the above questions are arising.

Triggered Burst

I would like to create a retrigerable burst at a set frequency. Thus, if a photo-interruptor or whatever sends a signal to the card, I can tell the card to send out pulses to the camera and lasers to record say 50 frames. As a demo, I just wanted to get one counter to do a 5 pulses at 1000 Hz every time my DG535 sent the card a pulse through the gate of counter 1.

After declaring my task t, I create a channel on counter 1 with:

            t.COChannels.CreatePulseChannelFrequency("Dev1/ctr1", _
                                                     "Camera", _
                                                      COPulseFrequencyUnits.Hertz, _
                                                      COPulseIdleState.Low, 0, 1000, 0.5)

Now to create 5 pulses every time,

            t.Timing.ConfigureImplicit(SampleQuantityMode.FiniteSamples, 5)

But to do the trigger I need all this:

            t.Triggers.StartTrigger.Type = StartTriggerType.DigitalEdge
      t.Triggers.StartTrigger.DigitalEdge.Source = "PFI34"
      t.Triggers.StartTrigger.Retriggerable = True
      t.Triggers.StartTrigger.ConfigureDigitalEdgeTrigger("PFI34", DigitalEdgeStartTriggerEdge.Rising)


Is this correct? It sounds like I'm telling the thing what type of trigger it is more than once. Is there a way to do the same thing just with ConfigureDigitalEdgeTrigger? When I was testing this, removing any line prevented the program from functioning.

Then of course,

      t.Start()

This does what I want, but is the triggering supposed to be that convoluted?


0 Kudos
Message 4 of 30
(7,941 Views)
Triggered Burst 2

This has to do with the definition of a gate: If both my trigger and my output signal come from the card, then I should be able to just gate a counter to get a series of pulses, since they will automatically be synchronized (as long as the frequencies are integer multiples). Imagine I want the same 1000 Hz counter to output for 5 pulses on, then 5 pulses off. So I write this:

            t.COChannels.CreatePulseChannelFrequency("Dev1/ctr0", _
                                                     "Internal", _
                                                      COPulseFrequencyUnits.Hertz, _
                                                      COPulseIdleState.Low, 0, 100, 0.5)
            Internal = t.COChannels.Item("Internal")
            Internal.PulseTerminal = "CTR1GATE"
            t.COChannels.CreatePulseChannelFrequency("Dev1/ctr1", _
                                                     "Camera", _
                                                      COPulseFrequencyUnits.Hertz, _
                                                      COPulseIdleState.Low, 0, 1000, 0.5)
            t.Timing.ConfigureImplicit(SampleQuantityMode.ContinuousSamples)
            t.Start()

Yet the output of counter 1 is a continus stream at 1000 Hz. Why is there no gating going on?

ConfigureImplicit

Many of your examples that use continuous pulse trains use this:

            t.Timing.ConfigureImplicit(SampleQuantityMode.ContinuousSamples, 1000)

What is this 1000 doing? The tooltip for the function is missing the word to describe what it does.



0 Kudos
Message 5 of 30
(7,940 Views)
Conclusion

As you can see there are a lot of issues here that are confusing me. My aim is to create a general purpose camera/laser/experiment/custom synchronization program, but I cannot get the card to perform even some simple tasks.

Eventually, I would like to have a pulse train for camera/laser (5 counters running at no faster than 15 Hz - the laser limit) to
  • Run on its own, based on the card's internal clock.
  • Run phase locked to an external clock between ~1 and <15 Hz.
  • Run "triggered burst" so that a series of frames can be acquired by the camera after an external trigger is sent to the card (like the retrigerable burst above but with all 5 counters).
  • Run "frequency divided" so that if an experiment running at higher than 15Hz must be synchronized, the card can take this trigger, divide it, and send out the pulse train based on this new rate.
  • Run "custom" - meaning the camera/laser stuff remains intact but the user can actually use any remaining counters for other signals.
  • I want these things to be possible with minimum wiring - I want to leave my research group with something easy to use.
Also I would like to know: is the external I/O connector the only way to get to the signals? I would like to use a drive bay on the computer as the "BNC connector block" for the signals.  But it doesn't look to me like I can do that without using the external I/O connector and driving that massive cable back into the computer case to connect to the break-out....

Anyone's insights would be greatly appreciated.

Thanks,
Emilio
0 Kudos
Message 6 of 30
(7,937 Views)
Hello Emilio,
 
It does sound like you've been working on this for a while! 
 
What version of the NI-DAQmx Help are you referring to?  The September 2005 version seems to have the correct Revised Terminal Names.  You'll want to use the counter number such as DevX/ctrY where X is your device number and Y is your counter number when you create the Counter channel.
 
It looks like  your triggered burst code is correct  For the Triggered Burst 2, it sounds like what you want to do can be done using a pause trigger.  You can use the shipping example GenDigPulseTrainContinuous_Pause Trigger.  There are two ways to connect signals, you can use an external connection, or you can connect any routed signal using the
Public Sub ConnectTerminals( _ 
            ByVal 
sourceTerminal As 
Micaela N
National Instruments
0 Kudos
Message 7 of 30
(7,905 Views)
What version of the NI-DAQmx Help are you referring to?  The September 2005 version seems to have the correct Revised Terminal Names.  You'll want to use the counter number such as DevX/ctrY where X is your device number and Y is your counter number when you create the Counter channel.

I downloaded DAQmx in December, so I must have the right one. I just have to be careful about where I'm looking and try to stay straight on all the lingo.

As for the second parameter (samplesPerChannel) in the ConfigureImplicit method...

I see now what you mean. The tooltip inside Visual Studio seems to have a bug where it does not show words that are linked in the help file, so instead of seeing "...NI-DAQmx uses this value to determine the buffer size.", I see "...NI-DAQmx uses this value to ."


*****

Thanks for all the helpful pointers! I will explore what you've suggested and will get back to you if I have any other problems.

0 Kudos
Message 8 of 30
(7,902 Views)
Emilio,
 
I can understand the confusion, there is quite a bit of documentation for DAQmx in .NET and as you start out it can be difficult to sort through.
 
Good luck and let me know if you run into anything else!
Micaela N
National Instruments
0 Kudos
Message 9 of 30
(7,889 Views)
Hmmm... what documentation do you mean?

The help file is nice, I guess, but I would have never found this ConnectTerminals method unless I had browsed one by one through the reference.

One thing is having the information, the other is having it arranged so one can find it. I read through the "getting started" type stuff to understand what a task was, and what a channel was, etc., but it would be useful to have a list of functions by category or something similar - otherwise, as a complete novice, I find myself reading the dictionary to learn a language.

So if there is such documentation, let me know. The links you have shown me are great. Even if it's a book I have to buy.

Thanks!
Emilio
0 Kudos
Message 10 of 30
(7,885 Views)