How to Use Sine Wave Source in Simulink: Step-by-Step Guide
In Simulink, use the
Sine Wave block from the Sources library to generate sinusoidal signals. Configure its parameters like amplitude, frequency, and phase to customize the wave. Connect it to other blocks to simulate systems with sine wave inputs.Syntax
The Sine Wave block in Simulink has key parameters you set to define the sine wave:
- Amplitude: The peak value of the wave.
- Frequency: How fast the wave oscillates (in radians per second).
- Phase: The starting angle of the wave (in radians).
- Sample time: Time interval between output samples (0 for continuous).
You use the block by dragging it into your model and setting these parameters in its dialog box.
text
Sine Wave block parameters: - Amplitude: 1 - Frequency: 2*pi (for 1 Hz) - Phase: 0 - Sample time: 0 (continuous)
Example
This example shows how to add a Sine Wave block, set its parameters, and connect it to a Scope block to visualize the sine wave output.
text
1. Open Simulink and create a new model. 2. From the Library Browser, drag the <code>Sine Wave</code> block (under Sources) into the model. 3. Double-click the <code>Sine Wave</code> block and set: - Amplitude: 2 - Frequency: 2*pi*5 (for 5 Hz) - Phase: 0 - Sample time: 0 4. Drag a <code>Scope</code> block (under Sinks) into the model. 5. Connect the output of the <code>Sine Wave</code> block to the input of the <code>Scope</code> block. 6. Click the <code>Run</code> button to simulate. 7. Double-click the <code>Scope</code> block to see the sine wave plot.
Output
A plot window opens showing a smooth sine wave oscillating with amplitude 2 and frequency 5 Hz.
Common Pitfalls
Some common mistakes when using the Sine Wave block include:
- Setting frequency in Hz instead of radians per second. Remember, frequency = 2 * pi * Hz.
- Using a non-zero sample time for continuous simulation, which can cause unexpected behavior.
- Forgetting to connect the output to a sink block like
Scopeto visualize the signal. - Not setting the phase correctly, which shifts the wave start point.
Always double-check parameter units and connections.
text
Wrong frequency setting example: - Frequency: 5 (incorrect, means 5 rad/s) Correct frequency setting: - Frequency: 2*pi*5 (correct for 5 Hz)
Quick Reference
| Parameter | Description | Typical Value |
|---|---|---|
| Amplitude | Peak value of sine wave | 1 or as needed |
| Frequency | Oscillation speed in rad/s | 2*pi*frequency_in_Hz |
| Phase | Starting angle in radians | 0 |
| Sample time | Time between samples (0 for continuous) | 0 |
Key Takeaways
Use the Sine Wave block from the Sources library to generate sinusoidal signals.
Set frequency in radians per second: frequency = 2 * pi * Hz.
Keep sample time zero for continuous simulation unless discrete sampling is needed.
Connect the sine wave output to a Scope block to visualize the signal.
Double-check amplitude, frequency, and phase parameters for correct wave shape.