Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

I need tips on programming a 6602 counter/timer

I am new to Labview but have been a command line programmer for some time.  I have a 6602 card in a PXI system.  I would like to use the internal clock of the 6602 to control the delivery of triggers to various instruments.  These triggers need to be both user inputted and optionally scanned in time.  Eventually, I will trigger the 5112 NI scope board to recieve signal and plot to the screen. 
0 Kudos
Message 1 of 14
(5,561 Views)
Darrin,
There are a lot of terrific LabVIEW examples that ship with the NI-DAQmx driver that are compatible with the PXI-6602.  These include counter examples as well as pulse train generation examples.  For example, some of these that would be great to looks at can be found by opening the NI Example Finder (Help >> NI Example Finder).  Under the Browse tab, navigate to Hardware Input and Output >> DAQmx >> Generate Digital Pulses.

There are also shipping examples that show how to use a common signal between boards.  Most of these examples share clocks, but you could also apply this to triggering.  These are found in: Hardware Input and Output >> DAQmx >> Synchronization >> Multi-Device and Hardware Input and Output >> DAQmx >> Synchronization >> Multi-Function

There are also a lot of great examples, DevZone posts, and tutoirals that you can find on our website by searching for various keywords like 6602, synchronization, triggering. etc.

One example that shows how to export a digital signal from one board and use it on another board via the RTSI lines that are built into the backplane of the PXI chassis can be seen here.

Hopefully this gives you a good place to start!

Regards,
Doug Mumford
Applications Engineer
National Instruments
Doug M
Applications Engineer
National Instruments
For those unfamiliar with NBC's The Office, my icon is NOT a picture of me 🙂
0 Kudos
Message 2 of 14
(5,542 Views)
Doug, thanks for the fast response.  This is certainly a good place to start.  I do have a few more questions, however.  I can run some of the sample VI's like Gen Dig Pulse.vi and others, however, I can only get the siganl to output on ch0 and ch1 (out0 and out1 of the BNC-2121).  Is it possible to configure the output onto the PFI lines?  Doing so (if I'm not mistaken) will give me 25 different TTL triggers. 
 
I am working my way through the examples and sample vi's and certainly appreciate your assistance.
-Darrin
 
0 Kudos
Message 3 of 14
(5,533 Views)
Darrin,
The PXI-6602 has 40 PFI lines.  Most of these can be used either as traditional DIO lines or configured to export signals from the 8 counters on the 6602.  For example, you could specify 16 of the PFI lines to be digital output lines, and you could additionally set up a few counters and send out their output, gate and source lines onto PFI lines.  Each counter has specific PFI lines for its gate, source, and output -- check the pinout of the 6602 to see what lines correspond to which counter.

Now, to use these PFI lines as input to another board you have two options.  The first is to physically wire the PFI line from your BNC-2121 to a terminal block connected to your second device.  By doing this you can use as many of the PFI lines on your 6602 as you want.  The second way is to use the built in RTSI bus that is part of the backplane of the PXI chassis.  This way actually routes the signals internally in the PXI chassis, and you don't have to physically connect the wires -- you just specify the source of your trigger on one device as PFIx on your 6602.  The caveat with this method is that there are only 8 RTSI lines to work with.

I hope this info helps.

Doug M
Applications Engineer
National Instruments

Doug M
Applications Engineer
National Instruments
For those unfamiliar with NBC's The Office, my icon is NOT a picture of me 🙂
0 Kudos
Message 4 of 14
(5,523 Views)

Doug,

I have sucessfully programed the 6602 counter/timer to provide a series of TTL trigger pulses at 10Hz.  I have used the CO-pulse-generation-frequency.vi  to control the timing and delivery of the pulses.   Using this vi, however, only gives me microsecond control of the pulse delivery.  I was under the assumption that the 80 MHz internal clock of the 6602 would be capable of 12.5 ns resolution.  Are there other vi's which would allow me to attain such resolution or is this the best I can do with the 6602?

-Darrin

 

0 Kudos
Message 5 of 14
(5,500 Views)
Darrin,

The 6602 has an 80 MHz timebase, however, the fastest pulse train you can generate with a counter is to use two timeticks as the high portion, and two time ticks as the low portion, giving a max pulse train frequency of 20 MHz.  This should be exportable over the PXI backplane, however, at these high frequencies digital signals are going to be susceptible to signal degradation, nevertheless you should be able to achieve this rate.  This would give a resolution of 50 ns. If you are transmitting the signal over wires from a terminal block, how high of frequency you can transmit will be determined in large part by the quality of the wiring.

--Doug
Doug M
Applications Engineer
National Instruments
For those unfamiliar with NBC's The Office, my icon is NOT a picture of me 🙂
0 Kudos
Message 6 of 14
(5,492 Views)
Thanks Doug,
I do have a few more questions...
1)  Are PXI_Trig-n (where n = 0-7) RTSI lines? 
 
2) I have created a task where all 8 counter channels export signals to various timed instruments.  I was hoping to use one of the channels to trigger my NI-5112 scope by exporting the signal to an RTSI line (as we discussed previously) but I think this is impossible since my task contains more than one counter channel.  Is this true or is there another way? 
 
3) Since I could not trigger my NI-5112 scope via a RTSI line, I tried it the old fashioned way.  I simply took a RG-58 cable and connected a counter channel with the external trigger input on the 5112.  I then made calls to the "Analog edge ref trigger" vi and indicated that the trigger source was external.  This failed for some reason???   However, switching the trigger source call to Ch 0 (the input channel on the 5112) successfully triggered the scope.  Do I need to configure the external trigger before calling it in the "analog edge ref trigger" vi or am I completely screwed up here?
 
-Darrin
 
0 Kudos
Message 7 of 14
(5,477 Views)
Hello Darrin,
 
1. Yes, the PXI Trigger lines do act the same as RTSI lines.
 
2. You can use your PXI 6602 and DAQmx to send a trigger across a RTSI line. A task can contain multiple counter output channels so this will work. To connect the trigger you created to a RTSI line, use DAQmx Connect Terminals.vi.
 
3. RTSI Triggering is definitely the way to go. In order to test the triggering, you can use the NI-SCOPE Soft Front Panel. Switch the trigger mode to digital, and you can choose the RTSI line on which you'd like to trigger.
 
Please let me know if you have any questions. Have a great day!
 
Sincerely,
Marni S.
0 Kudos
Message 8 of 14
(5,440 Views)

Gentlemen, I have a new problem.  I can create a task which will output TTL trigger pulses on two of the counters of a PXI-6602.  I can program one of the counters to output 4 microseconds after the first finishes.  I can monitor both pulses on an oscilloscope and there are dead solid in time (essentially no timing jitter).  Now here's the problem:  after I stop the vi and restart, the pulses are no longer separated by 4 microseconds.  The pulses still have no jitter but the relative timing has changed by an unpredictable +/- 2 microseconds.  Nothing has changed other than to stop and restart the pulse train.  This is a particularly vexing problem for me since my application requires that I stop and restart the pulse train multiple times during my application.  Is there anything I can do to get reproducible control over these counters?

-Darrin

 

0 Kudos
Message 9 of 14
(5,380 Views)
Darrin,
How are you programming the 2nd counter to start 4 microseconds after the 1st counter? In a retriggerable pulse train generation, the start delay parameter is only used for the first generation, so if you are using that parameter for your 2nd counter, and it is retriggering off an output from the 1st counter, you will only see the delay on the first generation.  See this Knowledge Base.

However, if you are clearing the task completely, then rerunning the setup of the counters everytime, the initial delay parameter should be the same.  Note that the only way to really get accurate and consistent delays between two counters is two synchronize them by some hardware signal, either a trigger that both are started on or by having one trigger off the output of the other.  Simply calling Start Task on both tasks right after each other will not guarantee they will start together with the resolution you are looking for (4 microseconds).

Doug M
Doug M
Applications Engineer
National Instruments
For those unfamiliar with NBC's The Office, my icon is NOT a picture of me 🙂
0 Kudos
Message 10 of 14
(5,359 Views)