## RC Low-Pass Filter - 3 Button

Enter any two of parameters R, C or fc. Then hit the button of the desired parameter.

Design Example:
Suppose you have R=100 and a desired cutoff of fc=1e6.  Find the capacitance needed by entering the two parameters above and hit "Get C".

### Enter Components

 R Ohms R = 1/(2*pi*fc*C) C Farads C = 1/(2*pi*fc*R) fc (Hz) fc = 1/(2*pi*R*C)

### Download / Basics

To run or modify on your PC, download a simple version of this file with image (*.zip).
For a quick tour of some JavaScript / HTML basics, check out Inside the Code.

### JavaScript

This code features 3 separate function calls, one per "Get_x" button.

```//////////////////////////////////////////////
// calc R
//////////////////////////////////////////////
function getR_RC_Fil() {
// get values directly from form
var fc=document.myForm.fc.value
var C=document.myForm.C.value
var R
// calc
R=1/(fc*C*2*Math.PI);
// place in text box
document.myForm.R.value = (R).toPrecision(4);
}

//////////////////////////////////////////////
// calc C
//////////////////////////////////////////////
function getC_RC_Fil() {
// get values directly from form
var R=document.myForm.R.value
var fc=document.myForm.fc.value
var C
// calc
C = 1/(R*fc*2*Math.PI);
// place in text box
document.myForm.C.value = (C).toPrecision(4);
}

//////////////////////////////////////////////
// calc fc
//////////////////////////////////////////////
function getfc_RC_Fil() {
// get values directly from form
var R=document.myForm.R.value
var C=document.myForm.C.value
var fc
// calc
fc=1/(R*C*2*Math.PI);
// place in text box
document.myForm.fc.value = (fc).toPrecision(4);
}
///////////////////////////////////////////////
```

### HTML

Each input button calls its own JavaScript function when clicked.

<input type="button" value="Get R" onclick="getR_RC_Fil()">
<input type="button" value="Get C" onclick="getC_RC_Fil()">
<input type="button" value="Get fc" onclick="getfc_RC_Fil()">