03-21-2006 11:37 PM - edited 03-21-2006 11:37 PM
Message Edited by leek2 on 03-21-2006 11:39 PM
03-22-2006 06:11 PM
Hi Leek2,
The dual_ttl-count_test.vi program isn't working because you are trying to generate a pulse AND count pulses using the same counter. The single_ttl-count.vi ran fine because it generates the pulses on one counter and reads them in on another.
I'm a little confused about what exactly you are trying to do. Do you want to do edge counting with two different counters at the same time? Do you also want to generate pulses, or was that just for testing purposes? I'd highly suggest taking a look at some of the counter examples that come with the DAQmx drivers. You can find them through Labview by going to Help -> Find Examples... to open the NI Example Finder. Browse to the examples by clicking Hardware Input and Output -> DAQmx -> Counter Measurements -> Count Digital Events. There are also some basic pulse generation examples in Hardware Input and Output -> DAQmx -> Generating Digital Pulses.
Good luck!
-Justin
03-23-2006 12:09 AM
Dear Justin,
I really appreciate to your comments and suggestions. Now I am a little understanding why dual TTL vi didn't work. As you ask me, I want to simultaneously count TTL pulses using edge counting with two different counters for integration time (i.e., gate time, (e.g., 1 sec, 30sec, or 1min)). I'd like to explain what I am doing.
I have two TTL pulse sources under the condition that TTL pulses are produced, if incoming analog voltage is bigger than threshold voltage determined by user. I want to count TTL pulses using buffered edge counting. For a single TTL vi case, when I used DAQ assistant vi, the counter clock source was PFI 0 and the input of Sample Clock Source was PFI 13 so I connected PFI 0 with PFI 13. And I've controlled gate time (e.g. 1 sec) by setting high time (0.5 sec) and low time(0.5 sec) in signal output range of Sample Clock Source vi.
I also tried to use example, Count Digital Events-Buffered -Continuous-Ext Clk, to count TTL pulses, but for single TTL measurement, it was working. In this case when I produce TTL pulses through function generator, the result is different with single_ttl_count.vi. That is, single_ttl_count.vi is more accurate than example mentioned. (to be continued)
03-23-2006 12:12 AM
I have three questions.
1. There are many sample clock sources if I use example. or Could you explain how to select Sample Clock Source to approriately set gate time? ( I am still not sure how I do accurately choose Sample Clock Source). 2. How do I use two counters to count TTL pulses through buffered edge counting? 3. For single_ttl_count vi, if I used 1K TTL pulses, I've got cumulative count without gate time like table below (raw data format)
0 1000
0 2000
0 3000
but I'd like to write as following
0 1000
1 1000
2 1000
which function do I have to use to correctly rewrite raw data like table above?
Thank you.
Leek2
03-24-2006 11:56 AM
Leek2,
Let me make sure I know exactly what you are doing...
You have already set up 2 analog level triggers, which will each produce a pulse (or trigger) whenever your analog signal reaches a certain threshold. You want to be able to count these pulses separately, using the 2 counters on your board, correct? I'm assuming this means that the analog signals will be crossing the thresholds repeatedly, and you want to count the number of times that it does.
You also mentioned controlling the gate time of your counters. What function will this serve in your overall application? Are you using it to "turn on" the counter when your analog signal goes above the threshold? For example, you might be trying to only count the number of pulses that occur while the analog signal is above the threshold, which would allow you to calculate the time that the analog signal was out of a specified range. Are you trying to do this in your application, or am I minunderstanding you?
Finally, where did you get the data in your last post? Is that being output from your VI? If it is, can you also post the VI that gave you that data? I think it would be a big help if I could see the code you are using.
-Justin
03-24-2006 12:58 PM - edited 03-24-2006 12:58 PM
Justin, thank you.
The TTL pulses were produced by Single Channel Analyzer(SCA). My counter input is always TTL pulse. You are correct. I only want to count TTL pulses with respect to time (so called, gate time). The gate time was controlled by high time and low time in Sample Clock Source vi of single_ttl_count.vi(I posted vi file). For example, if I want to set gate time 1 sec, I set high time (0.5 sec) and low time (0.5 sec). In this case I also change sample rate(1Hz)) and read sample(1) in TTL counting DAQ assistant vi. If 1min, I set high (30 sec) and low (30sec) and sample rate(60Hz) and read sample (1). If my setting is not correct, could you tell me?
You exactly understood what I am doing. When you run single_ttl_count.vi, you've got the data that is cumulative count without writing gate time, but I know what is the gate time. Because I set high and low time in clock source. If I incorrectly use clock soure, could you tell me how to select clock source?
In other word, I really want to count TTL pulses using buffered edge count under external clock source. So I tried to modified Count Digital Events-Buffered Continuous Ext Clk. vi example (attached), but output data (TTL count) is not consistent even I give input 1K TTL pulses. In this case I can solve cumulative count, but am still having a problem that I cannot write gate time, that is, I cannot write count # with respect to time like 0sec 1000, 1 sec 1000, 2 sec 1000, etc. Also in this program the setting up of gate time is exactly same as single_ttl_count.vi [when you open the file attached and run the vi, please change counter (Dev2/ctr0 -> Dev1/ctr0) and also change sample clock source from Dev2/PFI0 to Dev1/PFI 0]
Could you give me help? Thank you. Leek2
Message Edited by leek2 on 03-24-2006 12:58 PM
Message Edited by leek2 on 03-24-2006 12:59 PM
03-27-2006 11:50 PM
Leek2,
Take a look at the attached VI. I've edited a few things: First, I moved the Start Task VI and Stop Task VI to the outside of the while loop. This will make the code run much faster, and will probably improve that performance issue you had mentioned. I replace the Write to Measurement File VI with the Write to Spreadsheet File VI, and I used the increment of the while loop to create the file format that you wanted. I also replaced the waveform graph with a chart, so it will keep a history of the data from previous iterations of the while loop.
This VI will continue to do buffered counting of the input pulse train, until it receives the control pulse on PFI0. Then it will latch and return the current count in the count buffer. Let me know if this is closer to what you want.
-Justin