LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2 measurements from one signal using PWM and Labview 5

Hello,
I am attempting to take two measurements from PWM signal - the high pulse width and the rising edge to rising edge time.  Using Labview 5 and the attached code, I have been able to fulfill each task separately.  But I have not been able to both simultaneously using the same counter.  Basically I just attempted to copy the same diagram twice over but that did not work, and I have a feeling that it has something to do with synching the counter but do not have the programming skills to understand what I have done wrong.  If anyone knows how this can be done or even if it can be done with Labview 5, I would be happy to hear any suggestions.
Thanks,
Nick
0 Kudos
Message 1 of 7
(2,590 Views)
Nick,

I do not see how you could do both simultaneously with the same counter. Both counts start at the rising edge. One stops on the falling edge and the other stops on the next rising edge. It seems to me that you need two counters. You did not specify your hardware, so I do not know if you have two counters. If you try to re-configure a single counter between the full period and high pulse width modes, you will likely miss one or more period, maybe many periods, between successive measurements.

With two counters you should be able to get what you want in LV 5, unless your PWM frequency is high enough that you cannot transfer the data from two counters fast enough.

Lynn
0 Kudos
Message 2 of 7
(2,581 Views)
Lynn-
I am using a NI PCI 6040E daq board which does have 2-24 bit counters.  But I want to perform close looped control using a separate encoder with the second counter.  One option that I have heard to take two measurements with one counter is using the "measured buffered semi period" example vi.  Supposedly you can measure low width and high width of a signal using the same counter.  In this way I could add the two to get the period, but I am not familiar with this buffering routine.  Do you know if this option will work for continuous measurements or does it only last for a fixed amount of measurements?  Any help would be great.
Thanks,
-Nick
0 Kudos
Message 3 of 7
(2,573 Views)
Nick,

You are correct. Buffered semi-period measurement will provide the data you desire. In order to make this a continuous measurement, simply select "continuous" as the Buffer Mode. The data will be output in array with alternating entries for high ticks and low ticks. This should allow you to calculate the pulse width and period.

Hope this helps,
Ryan V.
National Instruments
Ryan Verret
Product Marketing Engineer
Signal Generators
National Instruments
0 Kudos
Message 4 of 7
(2,568 Views)
Thanks Ryan,
The buffered measurements were exactly what I needed to extract two signals, but I am having one difficulty - the high ticks and low ticks of the pulses aren't coming extracted exactly on a one to one ratio.  I split the signal into two and while watching the output with an indicator I noticed that after a certain number of counts that the output would actually flip between the high and low pulse width.  My guess is that a lost pulse occurs every so often and the signal is stored as the wrong type.  Let me know if you know a way around this.
-Nick
0 Kudos
Message 5 of 7
(2,567 Views)
Nick,

You are correct in that the most likely cause is a missed pulse. Is this a 5V TTL signal? Our counters are designed to accept TTL signals only. Perhaps the signal is heavily loaded (by something other than the DAQ card) and does not have the integrity to be reliably measured. Can you take a look at it with one of your analog inputs? If this is PWM, the frequency should be fixed. Would it be possible to check (in software) for suspiciously long high/low times?

Ryan V.
National Instruments
Ryan Verret
Product Marketing Engineer
Signal Generators
National Instruments
0 Kudos
Message 6 of 7
(2,554 Views)

Nick,

I don't have LV on my network PC so I can't look at the code you posted now.  Here's a couple thoughts anyhow:

Re: "flipping" between high pulse time and low pulse time.  Are you sure you are reading ALL the buffered data, and always in chunks that are a multiple of 2?  Exactly how are you "splitting the signal in two?".   Once the task starts, the values should alternate properly until/unless you get an error.

Warning: back a few years ago, there wasn't any good way to specify whether to start measuring with the high time or the low time when doing buffered semi-period measurement on E-series boards.  It was just random chance for whichever was present when the task was started.  If you're still in LV 5, you must also be using the standard "traditional" NI-DAQ driver rather than the newer DAQmx, right?  If so, I'm pretty sure you'll be stuck with this indeterminacy. 

Note that this is a different effect than the "flipping" which sounded like it occurred part way through a continuous acquisition.  This other indeterminacy will make it impossible to predict whether the very first value buffered represents a high time or low time -- unless you can figure it out using other knowledge about your signal's duty cycle.

-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 7 of 7
(2,547 Views)