LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get specific pulse train

Solved!
Go to solution

Hi, friends:

 

I'm using NI BNC2110 to collect a pulse train from a hardware, which looks like Capture2. As you see, every trigger signal is composed by two pulses, which has the time interval of 40 ms, and every trigger signal has time interval of 1 s. At the beginning, I used DAQmax counter input edge to catch the pulses. Definitely, I got the number just doubled what I need (for one of my trigger signal has two pulses). After than, I tried to use a division by 2 for getting my desire signal; well, it works, but not perfect.

 

So, presently, I'm looking for some method to directly measure the signal. I tried to use DAQmax CO pulse tick to get my signal (shown as capture 1), but I don't know how to read it.

 

Would you please give me some help?

 

Thanks a lot.

 

 

Download All
0 Kudos
Message 1 of 20
(3,485 Views)

We'll need a better and clearer description of what you're looking to do.  "Collecting" a pulse train does not tell us much.   You also made an attempt to approach this by generating a counter *output*, which doesn't make any sense to me.

 

- are you trying to measure the incoming "trigger" pulse pair?  What characteristics are you measuring?

- do you need to react to this signal or do you only need to characterize it?

- what's the purpose of the CO task you tried?

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 2 of 20
(3,471 Views)

Sorry for not describing my point clearly.

 

This pulse train is generated from a hardware (ECU). Every time, the hardware will generate a pair of pulses (40ms interval). What I want to do is to use these two pulses as one signal pulse, after that, I want to use "counter" to calculate how many pulses that the hardware have generated. So, theoretically, my desire number of reading of the pulses is exactly half of the total pulses.

 

At the beginning, I just used the "count input edge" vi to read the number of pulses, and as you know, the number is double of what I need. So I used a "division" vi to divide my reading by 2. This way can work, but when it's not perfect.

 

Following, I tried to use "counter output" vi, with the purpose to make the pulse-pair as one signal pulse and generate a new pulse train, but I don't know how to fulfill it.

 

Hopefully I make my points clear this time.

 

Thank you for your reply.

0 Kudos
Message 3 of 20
(3,465 Views)

Sorry, but most of the same stuff still seems unclear to me.  Here are 3 specific excerpts.

 

1. What I want to do is to use these two pulses as one signal pulse

 

2. I used a "division" vi to divide my reading by 2. This way can work, but when it's not perfect.

 

3. I tried to use "counter output" vi, with the purpose to make the pulse-pair as one signal pulse and generate a new pulse train


1. You say you want to *USE* the pulse pair as a single pulse.  Use it how?  For what purpose?  Is there an important timing relationship to maintain to the original pulse pair?  Do you need to generate a signal?  Do you need to characterize a measurement related to the pulse pair?  Etc.

 

2. I don't understand the "when it's not perfect" part.  Do you mean that *usually* you get pairs of pulses but not *always*?

 

3. Is this merely a troubleshooting step or is it an actual desired goal for your code?

 

Generally, what's the big picture here?  Why is it important to count the pulse pairs and in what way do you want to treat them as though they were a single pulse?  Do you need to generate an actual single pulse for every pair coming in?  If so, what are the timing requirements for the output pulse relative to the input pulses?

 

*Those* are some of the details I don't understand enough to be able to give specific advice.  I know a lot about NI counters, but I don't understand what you're trying to do nor whether what you're trying is actually what you *ought* to be doing.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 4 of 20
(3,448 Views)

Thanks Kevin.

 

The hardware calls ECU, which is used to control the movement of another 2D hardware of "Galvo". At one time, The ECU will generate a pair of pulses, which are used to trigger the x-y direction movement of Galvo. So, when one pair of pulses were generated, it means the Galvo will move a step. This is why I want to "use the pulse pair as one single pulse". Finally, I will count how many pulse pairs I have received, which means how many steps the Galvo has moved. In other words, what I want to get is the number of pulse pairs, not the number of all the pulses.

 

I can use "counter" vi to get the number of pulses I received, but as you know, this number will be double than the real number I need. The term "not perfect" means, the number I got by "counter" vi is exact twice of the number I need. So I used "divide" vi to divide the number by 2, the result is what I need. But, by this way, when the reading loop is fast, the output might be wrong.

 

My goal is to get the number of pulse pairs. This is the movement info of Galvo. Furthermore, I can calculate the moving track by using that number.

 

I attached a demo vi, hope it can make my point more clear 🙂

 

Thanks again.

0 Kudos
Message 5 of 20
(3,445 Views)

What hardware device are you using? The BNC-2110 is a terminal block- what is that block connected to?

 

I'm with Kevin in that I'm not sure what you're trying to do with the "single pulse" train- do you need to actually output something, or are you just looking to monitor the pulse lines?

 

Anyway, to solve your pulse counting problem, here's how I'm understanding it- you can successfully count edges, but if you happen to read in the middle of a pulse pair you will get an uneven number of samples. Is this right? If so, that should always be an odd number, right? Can you divide by 2 then round down?

 

If you actually DO need a separate pulse generated, you could create a digital task and use your pulse train as its clock source. Tell it to output a "1 0" pulse train. The first rising edge of the pulse will get you a 1 on the output, and the second will get you a 0 on the output. You didn't mention how long the single pulse needed to be, but this will get you a pulse that's the same width as the rising edge of the first pulse to the rising edge of the second pulse.

 

Yet another option would be to have your digital output set up with an internal sample clock (doable on X series directly, and on M series with an AI dummy task) that outputs your "long pulse" on a trigger. Use the input double-pulse line as your trigger source for that task. I think you should be able to make it retriggerable, but you may need to filter errors if it complains when you give it a second trigger before it's done with the first. I haven't tried that so I don't know if it'll ignore the second trigger if it's still outputting the waveform or if it'll start the waveform over (I bet it'll ignore the second trigger but throw an error, which you can ignore.)

0 Kudos
Message 6 of 20
(3,431 Views)

Thanks for reply. 

My daq device is PCIe 6321, and I have put it in the block diagram of my demo vi.

My goal is quite straightforward, which is to get the number of pulse pairs. I can use counter vi get accurate number of pulses, which is exact two times of the number of pulse pairs. 

I realize I can do by using "internal sample clock " and I also tried it. But I can't get it . 

Would you please give me some details on this method? 

 

Thanks 😀 

0 Kudos
Message 7 of 20
(3,426 Views)

If all you care about is counting pulse pairs, it seems pretty obvious on this end that you should just divide the raw edge count by 2 and round to an integer.  When that result changes, pass it along.   Nothing more than that.  I wrongly assumed I must be missing some other more complicated requirement.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 8 of 20
(3,374 Views)

Yes, dividing the reading from counter by 2 can work most of the case, but sometimes it will bring malfunction, so I call it imperfect. 

 

For example, if every one second, the ECU will generate a pulse-pair and I use the divider to realize my purpose. Meanwhile, I put a "read" vi inside a while loop to read the data from counter. If I set the looping time (by "wait") close to 1 second, the reading is sort of right (most of the time, but not every time). But if I set the looping time much shorter than 1 second, 0.1s for example, then the reading will be wrong all the time; it will repeat in some steps.

 

That's why I want to find a direct way to get the number of pulse-pair. I just want to use the counter the catch the first pulse in one pulse-pair, and then ignore the second one of the pulse pair. I know some concept as "gate" or "two counters" can sort of solve my problem, but I just don't know how to realize it in real.

 

Thanks.

0 Kudos
Message 9 of 20
(3,362 Views)

I'm sorry, I'm still not sure why the data will be wrong. If you read the number of pulses every 0.1 seconds, it'll indicate immediately when there was a new pulse, then be the same value for the next 9 or so cycles, then show again. Why is this wrong?

 

Use some actual values- "it should read 8 pulses but it's showing 17". You say the reading will be wrong or repeat... the counter keeps track of the total number of edges, NOT your code, so it doesn't matter at all how frequently you poll it. You'll still just see the total number of pulses.

 

Maybe you're assuming the counter resets each time you poll for edges? If so this is not the case, it keeps track of cumulative pulses since you started the task.

0 Kudos
Message 10 of 20
(3,357 Views)