There is great flexibility in the design of a digital filter. You can design digital filters that behave very similarly to analogue filters (as Andy aka described). You can also build digital filters than can be hard to reproduce in analogue such as a Linear phase filter or a Half-Band filter. Or non-linear digital filters such as Median filters that have no analogue equivalence in LTI systems.
For your requirements of "a sharp, low pass filter" I'd suggest a simple IIR of the form:
out = (1-a)in + aout
the closer 'a' is to 1 the lower the cutoff frequency of your filter.
You may well have a problem with the 1MHz sample rate and 5Hz cutoff because:
a = exp(-2*pi*f/fs)
where f is the cutoff frequency and fs is the sample frequency. So for your example:
a= exp(-2*pi*5/1E6) = 0.99997
If you really do need a 1MHz sample rate (because your data must be sampled by a 1MSPS ADC for example), then a 3 stage multi-rate filter is more appropriate. For this you would:
- Average 32 values at 1MHz and output one sample out of 32 at 1MHz/32
- Average 32 values at 1MHz/32 and output one sample out of 32 at 1MHz/32^2 (1MHz/1024)
- Implement an LPF as above with a 1MHz/1024 sample rate.
UPDATE BASED ON NEW INFO FROM OP:
Based on your information that:
- You are interested only in DC
- You are not sure about the cutoff frequency because you mention 60Hz and 6kHz bandwidth but also "A cutoff frequency of 5Hz"
- You need flexibility in sample rate
I think your best choice is a CIC Decimator.
Basically, its an MA (FIR) digital filter, made up of
- an integrator at the input clocked at the ADC sample rate (36kHz shown),
a differentiator at the output clocked at the output rate.
You can control how much filtering you get by changing the output rate.
For example with an input rate of 36kHz and an output rate of 5Hz this gives you a 36000/5 = 7200 point moving average. In reality you'd like to keep the rates as binary ratios so M=13 gives 36kHz in 36kHz/2^13 out and MA length is 2^M = 8192
The group delay of this will be 2^(M-1)/Fin or 113ms for the above example. That's one of the disadvantages of such a simple circuit but would not be a problem in a system whose DC value varies slowly.
A capacitor by itself is not a filter at all, neither high pass, low pass, nor anything else.
A capacitor can be used as part of a high pass, low pass, or band pass filter, depending on how it's connected to other parts. For example, a capacitor with a resistor can be a high pass filter:
or a low pass filter:
Together with a inductor and some additional impedance (represented by the resistor), it can be a band pass filter:
Or a band rejection filter:
A crystal radio works like the left band pass filter. C1 and L1 form a resonant tank that has high impedance at the resonant frequency and low impedance at other frequencies. Even that by itelf is not a filter, since just a changing impedance isn't a filter. It is the changing impedance working against some other impedance that forms a voltage divider that then makes a filter. In the example above, R1 is that other impedance. In a crystal radio, it is the impedance of the signal coupled to L1 magnetically by the antenna coil. In that case the antenna coil is the primary of a transformer, and L1 is the secondary, which resonates at a particular frequency depending on the value C1 is tuned to.
Added about crystal radio:
I see from the comments that there is some confusion about how the capacitor in a crystal radio works and how such a radio is tuned. There are different ways a crystal radio can be made, but I'll stick to the very common configuration you can find all over the web, and that is implemented by most crystal radio kits:
The inductor is a single coil, ususally magnet wire wound round something like a carboard toilet paper roll. The coil is essentially a transformer. The transformer primary is the left section between the antenna and the tap. Since the tap is grounded, there is no direct flow of current between the two sections of the coil. Voltage is induced in the right part of the coil by transformer action. The only way for the signal to get from the left part of the coil (the transformer primary) to the right part (the transformer secondary), is by the magnetic coupling between the two parts of the coil.
The transformer creates a higher voltage at its right end, although at a higher impedance. Typical antennas have impedance in the 50-300 Ω range, whereas the crystal radio is intended to drive old style headphones that have a few kΩ impedance. The higher voltage at a higher impedance is a better match to the headphones, and allows the very limited power from the antenna to be used more efficiently.
The inductance of the coil together with the capacitance form a high Q tank circuit. The radio picks up a station when the capacitor is adjusted so that the tank resonates at the station's carrier frequency. Due to the finite impedance of the antenna driving the tank as seen thru the transformer, and the impedance of the headphones loading the output, the capacitor and the coil together form a narrow band pass filter.
Best Answer
Here's a picture (I drag out now and then) that explains the effect of Q on a 2nd order low pass filter: -
The top three pictures show you the effect of varying the Q-factor. Q-factor can also be reduced to make a maximally flat pass-band (aka a butterworth filter).
The picture goes on to explain where the pole zero diagram comes from and how you can relate natural resonant frequency (\$\omega_n\$) with zeta (\$\zeta\$). For your reference, zeta = 1/2Q.
You will also find that the shape of the curve reverses (with a hump) for 2nd order high pass filters: -
The high-pass filter picture came from here.
They have the equivalent of a centre frequency known as the natural resonant frequency and if you think about a series L and C making a notch filter: -
This becomes a 2nd order high pass filter if the output is taken from the junction of the capacitor and inductor. Also if L and C swap places, it's still a notch filter but now if you take the output from across C it becomes a 2nd order low pass filter. Same resonant frequency and Q formulas all apply.