Main Content

Active Noise Control with Simulink Real-Time

Design a real-time active noise control system using a Speedgoat® Simulink® Real-Time™ target.

Active Noise Control (ANC)

The goal of active noise control is to reduce unwanted sound by producing an “anti-noise” signal that cancels the undesired sound wave. This principle has been applied successfully to a wide variety of applications, such as noise-cancelling headphones, active sound design in car interiors, and noise reduction in ventilation conduits and ventilated enclosures.

In this example, we apply the principles of model-based design. First, we design the ANC without any hardware by using a simple acoustic model in our simulation. Then, we complete our prototype by replacing the simulated acoustic path by the Speedgoat Target Computers and Speedgoat Support (Simulink Real-Time) and its IO104 analog module. The Speedgoat is an external Real-Time target for Simulink, which allows us to execute our model in real time and observe any data of interest, such as the adaptive filter coefficients, in real time.

This example has a companion video: Active Noise Control – From Modeling to Real-Time Prototyping.

ANC Feedforward Model

The following figure illustrates a classic example of feedforward ANC. A noise source at the entrance of a duct, such as a fan, is “cancelled” by a loudspeaker. The noise source b(n) is measured with a reference microphone, and the signal present at the output of the system is monitored with an error microphone, e(n). Note that the smaller the distance between the reference microphone and the loudspeaker, the faster the ANC must be able to compute and play back the “anti-noise”.

The primary path is the transfer function between the two microphones, W(z) is the adaptive filter computed from the last available error signal e(n), and the secondary path S(z) is the transfer function between the ANC output and the error microphone. The secondary path estimate S'(z) is used to filter the input of the NLMS update function. Also, the acoustic feedback F(z) from the ANC loudspeaker to the reference microphone can be estimated (F'(z)) and removed from the reference signal b(n).

To implement a successful ANC system, we must estimate both the primary and the secondary paths. In this example, we estimate the secondary path and the acoustic feedback first and then keep it constant while the ANC system adapts the primary path.

Filtered-X ANC Model

With Simulink and model-based design, you can start with a basic model of the desired system and a simulated environment. Then, you can improve the realism of that model or replace the simulated environment by the real one. You can also iterate by refining your simulated environment when you learn more about the challenges of the real-world system. For example, you could add acoustic feedback or measurement noise to the simulated environment if those are elements that limit the performance of the real-world system.

Start with a model of a Filtered-X NLMS ANC system, including both the ANC controller and the duct’s acoustic environment. Assume that we already have an estimate of the secondary path, since we will design a system to measure that later. Simulate the signal at the error microphone as the sum of the noise source filtered by the primary acoustic path and the ANC output filtered by the secondary acoustic path. Use an “LMS Update” block in a configuration that minimizes the signal captured by the error microphone. In a Filtered-X system, the NLMS update’s input is the noise source filtered by the estimate of the secondary path. To avoid an algebraic loop, there is a delay of one sample between the computation of the new filter coefficients and their use by the LMS filter.

Set the secondary path to s(n) = [0.5 0.5 -.3 -.3 -.2 -.2] and the primary path to conv(s(n), f(n)), where f(n) = [.1 -.1 .2 -.2 .3 -.3 .15 -.15]. Verify that the adaptive filter properly converges to f(n), in which case it matches the primary path in our model once convolved with the secondary path. Note that s(n) and f(n) were set arbitrarily, but we could try any FIR transfer functions, such as an actual impulse response measurement.

Secondary Path Estimation Model

Design a model to estimate the secondary path. Use an adaptive filter in a configuration appropriate for the identification of an unknown system. We can then verify that it converges to f(n).

Real-Time Implementation with Speedgoat

To experiment with ANC in a real-time environment, we built the classic duct example. In the following image, from right to left, we have a loudspeaker playing the noise source, the reference microphone, the ANC loudspeaker, and the error microphone.

Latency is critical: the system must record the reference microphone, compute the response and play it back on the ANC loudspeaker in the time it takes for sound to travel between these points. In this example, the distance between the reference microphone and the beginning of the “Y” section is 34 cm. The speed of sound is 343 m/s, thus our maximum latency is 1 ms, or 16 samples at the 16 kHz sampling rate used in this example.

We will be using the Speedgoat real-time target in Simulink, with the IO104 analog I/O interface card. The Speedgoat allows us to achieve a latency as low as one or two samples.

To realize our real-time model, we use the building blocks that we tested earlier, and simply replace the acoustic models by the Speedgoat I/O blocks. We also included the measurement of the acoustic feedback from the ANC loudspeaker to the reference microphone, and we added some logic to automatically measure the secondary path for 15 seconds before switching to the actual ANC mode. During the first 15 seconds, white noise is played back on the ANC loudspeaker and two NLMS filters are enabled, one per microphone. Then, a “noise source” is played back by the model for convenience, but the actual input of the ANC system is the reference microphone (this playback could be replaced by a real noise source, such as a fan at the right end of the duct). The system records the reference microphone, adapts the ANC NLMS filter and computes a signal for the ANC loudspeaker. To access the model’s folder, open the example by clicking the “Open Script” button. The model’s file name is “Speedgoat_FXLMS_ANC_model.slx”.

Noise Reduction Performance

We have measured the performance of this ANC prototype with both dual tones and the actual recording of a washing machine. Tonal or repetitive noises are easier because the adaptive filter will work even if it is adapting to an earlier or later cycle. With the washing machine, there is a mix of tones and noise. In this case, we require the Speedgoat's low latency processing so that we can adapt the ANC filter and produce the anti-noise so that it reaches the error mic in time to correct the noise signal. We obtained a noise reduction of 30-40 dB for the dual tones and 8-10 dB for the recording. Also, the convergence rate for the filter is a few seconds with the tones, but requires more time for the washing machine recording. These were the coefficients for the dual tones:

We can also look at the coefficients for the secondary path estimation:

And same for the acoustic feedback:

References

S. M. Kuo and D. R. Morgan, "Active noise control: a tutorial review," in Proceedings of the IEEE, vol. 87, no. 6, pp. 943-973, June 1999.

K.-C. Chen, C.-Y. Chang, and S. M. Kuo, "Active noise control in a duct to cancel broadband noise," in IOP Conference Series: Materials Science and Engineering, vol. 237, no. 1, 2017. https://iopscience.iop.org/article/10.1088/1757-899X/237/1/012015.

Speedgoat Target Computers and Speedgoat Support (Simulink Real-Time)

Setting up the IO104 module in Simulink

Setting up the IO104 in interrupt-driven mode

See also: Active Noise Control Using a Filtered-X LMS FIR Adaptive Filter