There’s also a possibility to use a classical transformer.
In order to have a large range of voltage on input, we need to calculate the transformer at maximum ratings, in this case 240Vac, but to compensate the ratio number of turns primary vs secondary to work also at 100Vac input.
This means start to consider the minimum voltage needed in the secondary for 100Vac input, in order to obtain a 5Vdc output.
Let’s assume to use a standard LM7805 series of three terminal positive regulators.
Minimum dropout voltage =3V, so we need a minimum 8Vdc on input for a 5Vdc on the output.
For the full wave rectified wave, we need on secondary minimum (8/1.4 + 1.2)= 7Vac
In this situation (100Vac input) the ratio
Np/Ns= 100/7= 14.28
Now to change for the situation we apply 240Vac on input.
For the chosen ratio in the secondary we obtain 240/14.28= 16.8Vac
After the rectifier bridge a maximum of (16.8*1.41)=24Vdc output voltage.
A LM7805 can work with maximum 35Vdc on input.
Power dissipated by the integrated circuit
P=(24-5)*0.1= 1.9W, that’s OK if adequate heat sinking is provided.
To compensate power losses in the transformer a minimum 4VA is required.
Empirical solution:
4VA transformer design to work on 240Vac, with 16.8Vac on secondary will do the job.