Question

How do I generate a square wave that takes the frequency(in Hz) and pulse width (in milliseconds) as input in Lab View?

I have looked through this:

http://zone.ni.com/reference/en-XX/help/371361H-01/lvexpress/simulate_signal/

and so far developed a diagram that looks like this:

enter image description here

However, the problem I am running into is the duty cycle input to the square wave is specified in percentage of period, whereas I need it to be in specified in milliseconds.

How can I feed in the pulse width (in milliseconds) to the square wave's input? Do I need to perform some math on it?

For example, if the selected pulse width is 2ms and the period is 5000ms then 100 * 2/5000 = 0.04% ? But that seems a bit ridiculous to be doing a simple square wave that way.

EDIT:

per suggestion from Ton, here is a new diagram:

I don't mean to be picky, but why do my pulses look triangular ? How do I get them to actually look like square wave pulses? How do I change the time access to display in milliseconds instead of seconds?

enter image description here

Was it helpful?

Solution

Your math is off, you should calculate the 2 ms as a percentage of the pulse frequency. So with 50 Hz (or 20 ms) your duty cycle is 10%.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top