# Do I need a resistor between the microcontroller and the battery? [duplicate]

I'm doing a university assignment and I need some advice. Do I need a resistor between the 9V power source and the microcontroller that uses 5.5V and 1mA? Also between a gyroscope sensor that uses 3V and 5mA?

• Better to use voltage regulators. Apr 12 '15 at 14:40
• What if I told you that the given currents for those devices are not constant? Apr 12 '15 at 15:09
• Okay @jippie if the current is not constant, would voltage regulators work as Jim said? Sorry, electronics is new to me. Apr 12 '15 at 15:15
• You cannot do what you want with a resistor. You have to use a voltage regulator or similar voltage controlling circuit for each final voltage you want. Apr 12 '15 at 15:51
• You MUST use voltage regulators of some sort. You will destroy the microcontroller and gyroscope if you connect them to 9V without a voltage regulator!!! Apr 12 '15 at 17:44

If you knew exactly what current the microcontroller draws, that would work. $$R=\frac{9-5}{I_0}$$ But you can't. The current you state is a typical value, and it should actually be highly dependent on the frequency of the clock and the peripherals used. Even then, it will vary with noise and all sorts of other causes. After you fit R, you'll find that for a current: $$I=I_0\pm \Delta I$$ The voltage across the microcontroller's supply will be: $$V_{cc}=9-RI=9-R(I_0 \pm \Delta I)=5\mp R\Delta I$$ In your case, you'd like to fit a 4k resistor, and if the current is different from what you expected by as little as 0.125mA, either you'll fry the micro or it will fail to function properly.

Is there a way to adjust the resistance in function of the current drawn from the supply? Yes, and those are called linear regulators. They still waste a lot of power dropping the voltage, unlike switching regulators, but they're very compact, cheap, and accurate. There is a transistor inside which resistance is controlled by an opamp that compares a reference voltage with the output voltage. It's kind of the "dam" of electricity.

Short answer: use a regulator. It's nearly as simple, and much more efficient and safe.

P.S: As others have mentioned, I've used 5V instead of 5.5V because I'm pretty sure 5.5V is the absolute maximum of your microcontroller, not the nominal supply voltage. Your gyroscope certainly requires 3.3V, which you can obtain from a second (low drop) linear regulator wired to the 5V.

Since i assume you are relatively new to the electronics world i will try to explain the background as simple as possible:

In the electrical world there are 2 very important concepts: there is tension (voltage) and there is current (amperes). Current is a ratio that resembles the number of electrons (small particles that go through a device that conducts electricity (e.g. a resistor, a lamp ...) and tension (voltage) can be seen as the 'will' these electrons have to go from + to - (in fact from - to +, but that is not so important). Power (watt) means the product of tension and current.

In the electronics world if you connect a tension of 9 Volt to a device that is fit for max 5.5 volt what could happen is that the device will not be albe to sustain the tension: the power dissipated by the electrons that go though the device could be too high, overheat the device and destroy it. (product of number electrons and their voltage drop too high, too much power -> overheat -> break down). Something else that could happen is that de electrons create a way in the electronics components they are not supposed to follow also with very bad results for the component. (kind of flash)

However if your microcontroller board (such as arduino) contains a voltage regulator, it could support a voltage range: e.g. 7.2 ... 12V and then there is a component on your board that regulates the micro processor volage; it is a kind of gate that reduces the 'will' of the electons to a level that will not damage the micro processor.

The best you can do is check your board data sheet and beware: you should also look for the right connections (+ and -) on your board, right voltage and wrong connections could also damage components.

A really cheesy way to drop voltages that might be good enough for a toy or other device that doesn't need to be terribly robust is to use a series of diodes. A typical silicon diode has a voltage drop of approximately 0.7 Volts. While this voltage drop is certainly not independent of the current draw by the microcontroller, it varies less with current than does a resistor and is often sufficient to make things functional when you are extremely resource limited.

6 silicon diodes would give us a forward drop of roughly 4.2 Volts which is about right to get us from 9 Volts down to 5. You would simply put the diodes in series with the battery.

Red light emitting diodes (LEDs) have a forward voltage drop of about 1.5 Volts making them good alternatives if you would like to use fewer than 6 diodes. Light emitting diodes towards the bluer end of spectrum have higher voltages and are becoming inexpensive and plentiful. You can find diodes with forward voltage drops approaching 4 Volts. The newer extremely bright LEDs cost only a few bucks and can also carry rather high currents, in the hundreds of mAmps.

As you do not mention what type of microprocessor you using let's not assume there is a regulator on board.

The voltages you mention don't seem quite 'standard'. Normally you would have either a 5V or 3V3 device. 5V5 is probably the upper limit of supply before you could start to damage the device.

A fairly typical dual regulated supply would be something like this.

Basically D1 protects the circuit from reverse polarity (if you accidentally connect the input the wrong way around). R1 and LED1 indicate power is ON. The two regulators operate in parallel. The 7805 (others fixed voltage regulators are available) will produce a 5V output and will supply a variable current up to about 1 amp.

Note The size of the current is determined by the LOAD at its output. In other words the micro will take just the current it needs.

The AMS1117 3V3 (others are available) will supply the 3V3 output needed for the gyro sensor.

Could you just use a resistor?

The answer has to be yes and no, (but really NO)

Yes - BUT only if the current taken by the load is constant AND the original voltage supply is always constant then a resistor could work. This is generally NEVER the case.

The danger in taking this approach is that should the load current decrease, the voltage across the load would increase and may damage the device.

If the load current should increase the voltage across the device will decrease and may go below its lower operating condition, causing it to reset (brown out). There is no mechanism or control to prevent this just using a resistor.

No - You can't guarantee that the load current is constant so you need to regulate the voltage. These devices are inexpensive and freely available.