UK
Offline
Faraday Member
Karma: 99
Posts: 4153
Where is your SSCCE?!?!


« Reply #3 on: June 23, 2012, 01:17:41 pm » 
Ohm's Law describes the relationship between voltage, current and resistance. If you know two of those three, you can calculate the third.
If you don't know two of them, but only one, which matches your case, then Ohm's Law, while it may be involved in parts of the work, is not capable of calculating what you want.
For example, your 19V>5V. If you knew either the resistance of the load you were going to connect it to, or the exact (and static) current draw of the load, you could use Ohm's law to calculate a resistance that would drop enough voltage to get to 5V. But you don't know either of those values.
One example, where Ohm's law is applicable, is when calculating for an LED as a load. Take for example a typical LED  say it has a forward voltage (V_{f})of 2V and a current (I_{f}) of 25mA. To run it off a 19V power supply you would have to lose 17 of those 19 volts to get it down to the 2V V_{f}. So, we now have two knowns  the voltage drop of the resistor, and the current through the resistor  the 25mA I_{f} of the LED.
Pop those into Ohm's Law, and we get:
R=V/I = 17/0.025 = 680Ω
However, if you don't know all those figures, or the figures are likely to change  as in a power supply, where the current draw changes depending on what you connect it to  then you will need something far more complex. These methods involve the use of nonlinear devices (resistors are linear  double the current, and you double the voltage). Ohm's Law is a linear law. With nonlinear devices there are a whole gamut of other calculations.
The simplest device that would result in what you want would be the Zener diode. This is like a normal diode, but has a specific reverse voltage at which in breaks down. So, you could take a 5V Zener diode and use that in reverse across your power supply  and anything over 5V would go through the diode, leaving you with 5V on your output. However, the diode will allow huge currents through it, overheating, and blowing up your power supply, or the diode. So, we need to limit the current. That is where Ohm's law comes in. Now we have a voltage, and a desired current (the limit we don't want to go over  usually just under the limit of the Zener diode), so we can use Ohm's law to calculate the value of a resistor to limit the current to just what we want.
Then, more complex, but far more stable, is the voltage regulator. These come in 2 flavours  Linear and Switching. Linear regulators are kind of like an automatic variable resistor. They change their internal resistance automatically depending on the current flowing to get a specific voltage out. These are rather inefficient and often get very hot and waste power. Switching regulators are somewhat more tricky to work with (there are some monolithic ones available, but they can be a bit tempramental) and if you're not careful you can radiate lots of noise throughout your circuit, but they can provide much better conversion of voltages. They basically work a bit like a lowpass filter on a PWM signal to provide a voltage  as you would with the PWM outputs on the Arduino. A feedback signal allows it to monitor the actual output voltage and adjust itself to get the right voltage. Far more energy efficient as it's only really using any power during the "on" cycle of the PWM waveform. The bigger the voltage difference between input and output, the smaller that "on" part, and so no power is wasted.
