Question: JAVA Write a program that exhibits the behavior of a digital filter, which removes noise from a sampled signal. The filter removes noise by running

JAVA

Write a program that exhibits the behavior of a digital filter, which removes noise from a sampled signal. The filter removes noise by running a sequence of sample values through a formula which generates a current output from current and previous inputs and previous outputs. For this demonstration, use the following formula, which describes either a Chebyshev second order lowpass filter or a Butterworth second order low-pass filter:

y = (x + 2 * x1 + x2) / D0 A1 * y1 A2 * y2,

In the above formula, x, x1, and x2 are the current input sample and the two previous input samples, respectively, and y, y1, and y2 are the current filtered output and the two previous filtered outputs, respectively. For a 1.0 dB-ripple Chebyshev filter, the coefficients have the following values: D0 = 6.57; A1 = -0.696; A2 = 0.378. For a 0.5 dB-ripple Chebyshev filter the coefficients have the following values: D0 = 5.22; A1 = -0.491; A2 = 0.302. For a Butterworth filter the coefficients have the following values: D0 = 6.94; A1 = -0.677; A2 = 0.254.

Make your program conform to the following UML class diagram:

JAVA Write a program that exhibits the behavior of a digital filter,

Algorithm:

In main, print the heading, call initialize, and input the desired number of steps. Then do the simulation with a for-loop that increments time as follows:

print time

input x

print findY(x)

step

The initialize method prompts for and inputs D0, A1, and A2.

The findY method computes y using the formula given above.

The step method copies values from later-time variables to earlier-time variables.

Sample session:

2ND ORDER CHEBYSHEV OR BUTTERWORTH LOW-PASS FILTER

Enter D0: 5.22

Enter A1: -0.491

Enter A2: 0.302

Enter number of steps to simulate: 10

time= 0, input= 0

output= 0

time= 1, input= 100

output= 19

time= 2, input= 0

output= 47

time= 3, input= 0

output= 36

time= 4, input= 0

output= 3

time= 5, input= 0

output= -9

time= 6, input= 0

output= -5

time= 7, input= 0

output= 0

time= 8, input= 0

output= 1

time= 9, input= 0

output= 0

FilterDriver Filter -DO double 6.58 -A1: double -0.696 -A2: double 0.378 x double 0.0 x1 double 0.0 -x2 double 0.0 -y : double -y1: double 0.0 -y2 double 0.0 +main(args: Stringll:void +initialize): void +findY(input : double) : double +step() : void

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!