LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Square wave average voltage data acquisition

Hi,

I would like to measure a voltage of a 50 Hz square wave every 15 seconds or so (and write this to a file). I don't really care if it's an average voltage or peak voltage although average would probably be more accurate. The problem is that if I acquire a single sample, I often hit a part of the period where the voltage is 0. I can't use continuous sampling because I'm using the same analog input to measure several voltages and I'm using a digital out card and relays as a multiplex. I'm thinking about taking 20 ms of samples every time, making average of those samples and writing the average value to the measurement file or ideally having the program detect the period and write it's average value or even synchronize the data acquisition with the square wave which is being generated in labview with several oscilators in a sequence - I'm changing the amplitude for each step of the sequence through the front panel. The problem is that I don't know how to do any of that.

I'd really appreciate any help.

0 Kudos
Message 1 of 4
(3,397 Views)

Ok.  You seem to have several problems. Let's try to separate them so that they can be addressed individually.

 

1. You need to measure the amplitude of a 50 Hz square wave ~ every 15 seconds.

2. You are aware of some of the issues with trying to get a quick measurement of a periodic signal.

3. You are using an external relay-based multiplexer to select a signal to be measured.

4. You are also controlling multiple signal sources or changing the parameters in a single source at various times in the same program.

5. You have limited experience at such programs.

6. Probably several others which are not obvious from your post.

 

Possible approaches to solutions: (note they are in different order from above but use the same numbering)

3. Even with mercury-wetted reed relays, reliable multiplexing on a 20 ms time scale is not easy. Actuation time and bounce on both opening and closing can be ~ 1 ms for fast reed relays and 10s of ms or longer for most other types.  If you actually switched the relays every 20 ms continuously, you would wear them out in a few hours to a few weeks, depending on the type of relay.

2. and 3. You should have at least one full cycle of the square wave to make a meaningful measurement unless you are absolutely sure the amplitude will not vary during one cycle and the signal and measurement system have no noise.

1. and 2. Neither peak nor average is liekly the best measurement of your square wave. Consider a stable, noise-free square wave with 50% duty cycle. If the high part is at 1 V and the low part is at 0.04 V, the average will be 0.48 V, the peak will be 1 V but the actual amplitude is 0.96 V peak to peak.  The Pulse Measurements.vi (signal Processing >> Waveform Measurements palette) is a good starting point for measuring your square wave. With square waves it is not too difficult to find the transitions and do you own calculations if the existing VIs do no do exactly what you need.

4. and 5. Look at the State Machine templates or Design Patterns which come with LabVIEW. A state machine architecture is versatile, robust, easily modified or extended, and well suited to the type of program you are developing.

 

Lynn

 

 

Message 2 of 4
(3,371 Views)

Thank you for the reply.

Just to make it clear. I'm not multiplexing at 20 ms, but 500 ms. The period between the samples is actually going to be at least 1 minute when I finish the testing, so there is no need for speed.

I have tried to use the VIs from the Waveform Measurements palette, but if I recall correctly, there were as many values written to the file as there were samples taken, but I want only one value. Maybe I've missed something, will check on Monday.

The state machine looks promising, thanks!

0 Kudos
Message 3 of 4
(3,359 Views)

Now we are out of the realm of theory and into impementation. If you do not figure it out on Monday, please post your VI.

 

Lynn

0 Kudos
Message 4 of 4
(3,354 Views)