1

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

user1068636
  • 1,871
  • 7
  • 33
  • 57
  • you are not running the program in a while loop? are you running continuously?. actually by duty cycles is how a square wave will be defined. math is simple here right? – Koushik Shetty Mar 30 '13 at 10:08
  • You don't need the 'Selected Frequency' and 'Selected width' indicators, right click on the knobs and select 'Visible Items\Digital display' to add a numeric control. – Ton Plomp Mar 30 '13 at 12:27
  • To remove the seperate output indicator, look at http://stackoverflow.com/a/1733681/47860 option B – Ton Plomp Mar 31 '13 at 14:56

1 Answers1

1

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%.

Ton Plomp
  • 3,020
  • 1
  • 18
  • 35
  • Hi Ton - I have updated my original question with a new diagram following your recommendation. Is the new diagram what you were referring to? If so, how do I make my waveform actually look like square pulse waves instead of the triangular shape? Is it possible to display the Time Axis in milliseconds as opposed to seconds? – user1068636 Mar 30 '13 at 18:03
  • You can change the interpolation style to only have horizontal and vertical lines, to change the line style click in the Palette on the white line and choose the option you prefer from the interpolation field. – Ton Plomp Mar 31 '13 at 14:54