Please confirm < 1 mA max load current. This makes an immense difference.
Simple shunt regulator with zener diode preregulator to greatly reduce spikes :
Two resistors, a zener diode and a TL431 or similar shunt regulator and a few capacitors would be VERY adequate in many cases.
Resistors in series drop the 24 V to 5V. A zener at the resistor midpoint clamps this to say 12V or some convenient value and greatly reduces transients. A capacitor across the zener further increases this effect. TL431 dissipates unwanted current.
Example - Say you want <= 1 mA, Vin min = 20V, Vin max = 30V, Vout = 5V.
Rmax = Vdrop/I max = (20-5) / 0.001A = 15k.
Now design for 5 mA max for lots of headroom = 3k max for 5 mA so a bit higher OK.
Split !~= 3k by ~= 2:1 to be say 2k2 and 1k.
2k2 will drop ~10V at Vinmin=20V, and 1k will drop about 5V.
Place a ~+ 9V Zener at midpoint of two R's. Say 8V2.
Program TL431 to 5V with say 2 x 10k resistors.
Check:
Vin = 20V.
I zener unloaded = V/R = (20-8.2)/2k2 =~ 11.8/2.2 = 5.4 mA.
I in 1k for 5V out = V/R = (8.2-5)/1k = 3.2 mA.
OK as we want <= 1 mA - could decrease R.1k slightly
Dissipation in 2k2 = V^2/R = (20-8.2)^2 / 2200 = 63 mW.
Now try Vinmax = 30V.
Current in unloaded zener = V/R = (30-8.2)/2200 =~ 10 mA.
Situation for 1k does not change as 8V2 is the same.
In practice Vzener will rise very slightly.
Dissipation in 2k2 = V^2/R = (30-8.2)^2/2200 = 0.22 Watt.
Use 1/2 Watt resistor OR reduce current somewhat.
Add a say 10 uF and 0.1 uF ceramic across zener and result should be good in many cases. Time constant of 2k2/1k + 10 uF =~ 150 Hz. About 25 Hz corner frequency. Use a 100 uF electrolytic for more notional rejection. TL431 will add extra noise rejection.
**Comment on LM29xx family regulators:
Many of these are are specially designed for an automotive environment (check spec sheet in each case) and will survive in places where an LM7805 will be destroyed or will protect your 5V powered circuit in situations where an LM7805 would allow it to be destroyed.
LM2940 data sheet here.
This is a 5V. 1A regulator. $1.65/1 at Digikey and $1.15/100 and about $0.60 in very large volumes - for TO220 package in each case.
They say:
The LM2940/LM2940C positive voltage regulator features the
ability to source 1A of output current with a dropout voltage of
typically 0.5V and a maximum of 1V over the entire temperature range. Furthermore, a quiescent current reduction circuit has been included which reduces the ground current
when the differential between the input voltage and the output
voltage exceeds approximately 3V. The quiescent current
with 1A of output current and an input-output differential of 5V
is therefore only 30 mA. Higher quiescent currents only exist
when the regulator is in the dropout mode (VIN
− VOUT ≤ 3V).
Designed also for vehicular applications,
The LM2940 / LM2940C and all regulated circuitry are protected from
reverse battery installations or 2-battery jumps [related to conditions experienced in cars].
During line transients, such as load dump when the input voltage can
momentarily exceed the specified maximum operating voltage, the regulator will automatically shut down to protect both
the internal circuits and the load.
The LM2940/LM2940C cannot be harmed by temporary mirror-image insertion.
Familiar regulator features such as short circuit and thermal overload
protection are also provided.
Features
Dropout voltage typically 0.5V @Iout = 1 Amp
Output current in excess of 1A
Output voltage trimmed before assembly
Reverse battery protection
Internal short circuit current limit
Mirror image insertion protection