Wave Generator (Square) (G Dataflow)

Generates a signal containing a square wave.

offset

DC offset of the signal.

Default: 0

reset phase

A Boolean that determines the initial phase of the wave.

 True Sets the initial phase to phase in and sets the initial time to t0 if you configure this node to return a waveform. Sets the initial phase to phase in if you configure this node to return a double-precision, floating-point number or an array of double-precision, floating-point numbers. False Uses the values of phase out and t0 from when the node last executed as the initial phase and time of the wave if you configure this node to return a waveform. Uses the values of phase out from when the node last executed as the initial phase of the wave if you configure this node to return a double-precision, floating-point number or an array of double-precision, floating-point numbers.

Default: False

amplitude

Amplitude of the signal.

Default: 1

frequency

Frequency of the signal.

Default: 10

phase in

Initial phase in degrees of the signal when reset phase is True.

Default: 0

duty cycle

Percentage of time a square wave remains high versus low over one period.

Default: 50

error in

Error conditions that occur before this node runs.

The node responds to this input according to standard error behavior.

Standard Error Behavior

Many nodes provide an error in input and an error out output so that the node can respond to and communicate errors that occur while code is running. The value of error in specifies whether an error occurred before the node runs. Most nodes respond to values of error in in a standard, predictable way.

error in does not contain an error error in contains an error
If no error occurred before the node runs, the node begins execution normally.

If no error occurs while the node runs, it returns no error. If an error does occur while the node runs, it returns that error information as error out.

If an error occurred before the node runs, the node does not execute. Instead, it returns the error in value as error out.

Default: No error

sample rate

Sample rate in samples per second.

Default: 1000

samples

Number of samples in the signal.

samples must be greater than 0. Otherwise, this node returns an error.

This input is available when you configure this node to return a waveform or an array of double-precision, floating-point numbers.

Default: 1000

t0

Timestamp of the output signal. If this input is unwired, this node uses the current time as the timestamp of the output signal.

This input is available only if you configure this node to return a waveform.

square wave

Output square signal.

This output can return the following data types:

• Waveform
• Double-precision, floating-point number
• 1D array of double-precision, floating-point numbers

phase out

Phase, in degrees, of the next sample of the output signal.

error out

Error information.

The node produces this output according to standard error behavior.

Standard Error Behavior

Many nodes provide an error in input and an error out output so that the node can respond to and communicate errors that occur while code is running. The value of error in specifies whether an error occurred before the node runs. Most nodes respond to values of error in in a standard, predictable way.

error in does not contain an error error in contains an error
If no error occurred before the node runs, the node begins execution normally.

If no error occurs while the node runs, it returns no error. If an error does occur while the node runs, it returns that error information as error out.

If an error occurred before the node runs, the node does not execute. Instead, it returns the error in value as error out.

Algorithm for Simulating a Square Wave

If sequence Y represents a square wave, this node generates the pattern according to the following equation.

$y [ i ] = amplitude × square ( phase [ i ] ) , f o r ⁢ i = 0 , 1 , 2 , ... , n − 1$

where n is the number of samples. The node calculates $\text{square}\left(\text{phase}\left[i\right]\right)$ according to the following table.

$p\text{mod}\left[i\right]$ $\text{square}\left(\text{phase}\left[i\right]\right)$
$0 ≤ p m o d [ i ] < ( 0.01 ⁢ × d u t y ⁢ c y c l e ) × 360$ 1
$( 0.01 ⁢ × d u t y ⁢ c y c l e ) × 360 ≤ p m o d [ i ] ≤ 360$ -1

where $p\text{mod}\left[i\right]$ is $\text{phase}\left[i\right]$ modulo 360, and $\text{phase}\left[i\right]$ is:

$initial_phase + frequency × 360 × i samples per second$

where initial_phase is the initial phase of the wave.

Where This Node Can Run:

Desktop OS: Windows

FPGA: Not supported

Web Server: Not supported in VIs that run in a web application