Discussion:
2 measurements from one signal using PWM and Labview 5
(too old to reply)
Electramotive
2005-08-07 23:40:35 UTC
Permalink
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


pump7.vi:
http://forums.ni.com/attachments/ni/170/136040/1/pump7.vi
Electramotive
2005-08-08 19:10:47 UTC
Permalink
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
Ryan V
2005-08-08 23:10:50 UTC
Permalink
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
Electramotive
2005-08-09 05:10:40 UTC
Permalink
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
Ryan V
2005-08-09 19:10:53 UTC
Permalink
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
Kevin Price
2005-08-09 21:10:42 UTC
Permalink
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.

Loading...