From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

count leading and falling edges

Hello, I have a PCI-6711 DAQ board and I am using VB2008 to control it with Vista x64. I have used the .Net 3.5 examples successfully to count leading edge pulses and I have modified the example so on every third pulse, it sends out a TTL pulse on Output channel #0. What I'd like to do now is to send a output pulse out that is High on the leading edge of the third input pulse counted and send an output pulse out that is Low on the Falling edge of the third input pulse counted.

 

         I tried to run two Tasks simulaneously, one counting the rising edges and one counting the falling edges. This did not work, I got an error message when I told the second task to Start. I am looking for some suggestions on how to do this. I looked at some of the "measure Pulse width" examples but didn't understand them. The input pulses will be in the range of 60Hz to 1 Hz. and I'd like to run this function for 4 hours or more if that makes any difference.

 

thank you in advance for your suggestions.

 

GeorgeDeb4

 

0 Kudos
Message 1 of 40
(7,501 Views)

Hi George,

 

On thing that you can take a look at is using a digital input and read change detection events.  The change detection will detect both rising and falling  edges.  From what you are describing, it sounds like you just want to output the same pulse that you are reading in - if you output a high value on a rising edge and change it to a low value on a falling edge, you will be copying the input wave.  Is this what you are wanting to do?

Regards,
Jim Schwartz
0 Kudos
Message 2 of 40
(7,467 Views)

Hello Jim,

       Yes, that is what I am looking to do except I'd like to copy 3 of 4 pulses but the fourth pulse, I'd like to send out a second output port. Thank you very much, I'll check out the change detection events. I had thought of it as reading in a pulse on one channel and sending out pulses on two other channels at the ratio of 3 to one but "copying" one of the pulses sounds easier and quicker.

 

Thank you.

 

George

0 Kudos
Message 3 of 40
(7,456 Views)

I have tried to run the Net 3.5 sample program using change Detections Events and am getting an error message with my PCI-6711 board. Can you tell me what might be the cause of this? The line it fails on is:

          

myTask.Timing.ConfigureChangeDetection(risingEdgeLinesComboBox.Text, fallingEdgeLinesComboBox.Text, sampleQuantityMode.ContinuousSamples, 1000)

 

The error message says the sample timing type of "Change detection" is not allowed. it suggests the "On Demand" type.

 

Is this a hardware thing?

 

Thank you.

 

George

0 Kudos
Message 4 of 40
(7,409 Views)

Unfortunately the PCI-6711 does not support change detection, which is why you see this error.  I recommend using 1 counter to count the rising edges and 1 for the falling edges in Pulse mode versus Toggle mode.  You will need to use CO Ticks (Counter Out Ticks) channel configuration for each counter so that a pulse is output after 3 high ticks and 3 low ticks.  The source of your ticks for your channel configuration will be your input signal.  Wire each counter output into an external OR gate.

Regards,


h_baker
National Instruments
Applications Engineer
0 Kudos
Message 5 of 40
(7,379 Views)

Hello h_baker,

        Thank you for your help. I have been able to use the two counters as you suggested to do exactly what I wanted. I am getting pulses at the rate of 30 Hz. I have a timer in VB2008 set to 1 msec to watch for changes in the pulse signal. It works perfectly for about 60-70 cycles and then seems to be a little bit slow to react to a rising signal. It then goes another 50 cycles and misses a beat again. Over the course of 15 seconds, it will be late on about 6 pulses out of 450. The only thing I could think of that would cause this is, that VISTA x64 is not letting the VB2008 timer be accurate enough by randomly doing other things instead of firing the timer event in VB every 1 millesecond.

        If you think this might be correct, would a DAC board with Event Triggers be a good solution for this? I wouldn't have to rely on VB to fire a timer event to check the pulse signal, it would come from the DAC board itself. If yes, could you recommend a DAC board I could use, preferably PCI format. Another idea is that once I get my first pulse detected, all of the following pulses should be very consistent in frequency, I could possibly use an internal timer after I get my first external pulse as a more involved solution.

 

thank you.

 

George

 

 

 

 

0 Kudos
Message 6 of 40
(7,234 Views)

Hi Geoge,

 

I'd like to clarify what you're trying to do.  From your earlier statement:

I'd like to copy 3 of 4 pulses but the fourth pulse, I'd like to send out a second output port.

 

Does the following graph represent what you need?

 

Signals.png

If so, the best way would be to use a board that supports Clocked digital I/O (I would look into the PCIe 6230 if you have a PCI Express slot available in your PC, if not the PCI 6220 is a good alternative).  There isn't going to be a way to get exactly the above signals using your 6711 (which does not support change detection nor does it support clocked digital I/O--the above solution requires the use of both).

 

 

Having said this, you can perform the following on your 6711 using a Counter Output task set to Pulse Mode:

 

Signals.png

 

Let us know which one of the above you'd like to go with (or if it's something else entirely) and we can provide more details about how to set up the task.

 

 

Best Regards,

John Passiak
0 Kudos
Message 7 of 40
(7,221 Views)

Hello John,

          Thank you for the suggestion, the link went to a  PCIe 6320 board. The link below said PCIe 6230, is this just a typo(flipped the 2 + 3 around)? I'll order the PCIe 6320 and check it out. I am trying to do the first scenario you listed. In the future, I think I'll get PCIe 6321 boards as we might need some analog outs too for other applications and it would be best to standardize on a single board so we can inventory it. Does this sound OK?

 

         Sometime in the next week or so could you point me in the right direction to implement the change detection and clocked digital I/O functions in VB2008?

 

Thank you.

 

George

0 Kudos
Message 8 of 40
(7,186 Views)

Hi George,

 

Sorry, I meant to say 6320--thanks for bringing it up.  The 6321 is essentially the same board but with the analog outputs (you could do the same thing on any 63xx board, I initially chose the 6320 since it is the lowest cost--the other X Series boards have different channel counts and different AI and AO specs).

 

 

In any regard, the configuration is going to look like this:

 

Signals2.png

 

 

You would configure a Digital Input Task for a single line using Change Detection timing (set the change detection to occur on both rising and falling edges of this single input line).  This generates an internal signal called "ChangeDetectionEvent" every time the line switches from high to low or from low to high.  You would then use this internal signal as a sample clock for a Digital Output task which would consist of the two output channels (with the necessary data to be generated).

 

Port 0 is the only port that supports change detection and clocked digital I/O on our X Series and M Series boards (but you can configure each line as an input or an output individually).  So, after using one of the lines for your change detection input signal, you could have up to 7 outputs (on boards like the 6320 or 6321) or up to 31 outputs (on boards like the 6323).

 

 

To get started, I would look at the following shipping examples:

ReadDigChan_ChangeDetection

ContWriteDigPort_ExtClk

 

 

Best Regards,

John Passiak
Message 9 of 40
(7,180 Views)

Hello John,

 

    I have received the 6320 board but I am not sure which ports to use for the Change Detection routine. I have it wired to use Port 2.0 or PFI 8 on pin 37, using ground pin 36. when I run the example code for change Detection Events with VB2008, I am not sure which parameters to enter to get it looking at the pins I have wired it to. If I select Port 2 line 0, I get an error message that I am not using a buffered line. If I use Port 0 line 1, I do not get a signal detected. Sorry for the basic questions, I am just not sure what the example program is looking for. I have also tried Port 0 line 1 and wired to pin out # 17 with ground to 50. This did not work either.

 

thank you.

 

George

 

 

0 Kudos
Message 10 of 40
(7,094 Views)