Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Hardware Timed Interrupt

Solved!
Go to solution

Where can I find sample code for a CTR/TMR channel interrupt so I can create a hardware timed interrupt?

 

ex. Clock frequency = 1 MHz.  Loop period = 100 ms. 

 

1. Start counting.

2. Trigger interrupt when counter = 10000.

3. Reset counter.

4. Execute interrupt code.

5. Repeat steps 2-5.

 

Thanks!

Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
0 Kudos
Message 1 of 39
(6,782 Views)

Hi Michael.

 

I wasn't able to find a direct example to your request but the following should be a good reference

  COunter Operations with Measurement Studio DAQ ActiveX Controls

  Hardware Reset of a TIO (NI 660x) Counter in Measurement Studio  

  Count Digital Events with Option to ResetCounter

 

Keep in mind that some of the above makes references using the T-DAQ driver, and the last example uses LabVIEW with DAQmx, so you would need to reference the vi's to the functions in the DAQmx C Reference Help.


Regards,
Glenn
0 Kudos
Message 2 of 39
(6,762 Views)
I found an example.  Unfortunately, I need to be installing support for .NET framework 1, 2, and 3.5 in order to get all of the examples.  I would rather have all the examples install with .NET framework 3.5 since that is the one I use...
Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
0 Kudos
Message 3 of 39
(6,724 Views)
Can you point to the example you are referencing?

Regards,
Glenn
0 Kudos
Message 4 of 39
(6,706 Views)

C:\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples\DotNET2.0\Counter\Count Digital Events\CountDigEventsBuffContinuous_ExtClk

 

You specify the number of counts before it calls the callback function.  It is not a accurate as I've seen on microcontrollers, but it may be OK.  It seems to get more accurate the faster I run the clock, but I might have overrun a variable somewhere because when I try to run the clock at 1,000,000 (I believe) on a PCI 6713 (24 bit counters) and count 100,000 counts it gives me an error stating that I need to divide the signal...  I wish I could use the 20 MHzTimeBase rather than having to use another counter to provide the clock.  I'll post the exact error tomorrow.

 

 

Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
0 Kudos
Message 5 of 39
(6,703 Views)

The following attachements show the code to configure the tasks to generate a clock signal, count pulses, and toggle a digital channel in order to click the frequency of the interrupt as well as an error that I get when I try to run at 1 MHz or higher using a PCI-6713.  If I need a 10 Hz interrupt using a 1 MHz clock, I have to count 100 kPulses.  It does not like this for some reason. 

 

I'm running a test right now to count the interrupts over a known period of time to determine the error in the system.  The frequency of the interrupt bounces between 9.992 and probably 10.008 (actually half of that due to the fact that each interrupt toggles the digital channel so the frequency is cut in half).  I can handle small errors.  Our tests can be anywhere from 20 minutes to 4 days.  I just need to determine how many extra seconds I end up running if the frequency is slightly less than 10 Hz.

 

Thoughts on the whole idea?

 

 

Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
Download All
0 Kudos
Message 6 of 39
(6,692 Views)

I ran it for around 2.5 hours and these are my results:

 

Incrementing a counter each time the interrupt is called:

 

Start time: 11:09:26

End time: 13:49:58

 

Elapsed seconds: 9512

Counter value / 10 = 9511.9

 

I will run 16+ hours next Monday and see what I get, but I can live with these results!

Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
0 Kudos
Message 7 of 39
(6,687 Views)

Why would I get that error if I disconnect the clock from the input pin?  I'm trying to put some checks into the code just in case the loop stops firing, but when I disconnect the wire that jumps from the counter output to the counter input I immediately get an error.  It is the same error I posted above.

 

Thanks.

Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
0 Kudos
Message 8 of 39
(6,630 Views)
Hi Michael,

From your above post it sounds like you are using one of the counters as your clock source. By disconnecting that jumper the line may be reading noise that could be misinterpreting it as rising clock edges thus resulting the aforementioned error.

Regards,
Glenn
0 Kudos
Message 9 of 39
(6,612 Views)
I just figured out that I missed the ability to use the internal clock.  I've changed that now so I don't have to use two counter channels.
Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
0 Kudos
Message 10 of 39
(6,610 Views)