Notifications
Clear all

Powering a Microcontroller and Motors with a Single Battery Source

33 Posts
5 Users
8 Reactions
546 Views
(@rhammell)
Member
Joined: 2 months ago
Posts: 9
Topic starter  

I'm working on building a two-wheeled bot, that uses n20 6V motors, and a Adafruit DRV8833 motor driver board, and an Arduino NanoESP32. 

I'd like to power it from a single battery source, and for size limitiations, I'd like to use two 14500 3.7V batteries. 

I'm looking for some confirmation that my planned wiring and understanding is correct (only power related wiring shown):

Screenshot 2025 02 05 at 10.52.01 AM

- Two 3.7V 14500 batteries will produce 7.4V

- The batteries are connected to the VIN and GND pins of an Adafruit 5V Buck Converter

- The 5V and GND pins from the buck converter are connected to the VMOTOR pins of the Adafruit DRV8833 Motor Driver board. This will provide 5V of power to the n20 motors (rated for 4.5V-6V nominal)

- The VIN and GND pins from the buck converter are conected to the VIN and GND pins on the Arduino NanoESP32. This will provide 7.4V of power to the Nano (which accepts 6-21V through its VIN pin)

My questionsn are: 

- Will this wiring provide the correct voltages to the components (7.4V to the Arduino NanoESP32, and 5V to the Motor driver)

- Is the wiring from the buck converter to the Nano appropriate? The only other way I can think of to get the 7.4V from the battery to the Nano is to split the wire coming out of the battery holder to go to both the Nano and the converter. (The wiring of my project won't include a breadboard - all connections will be soldered)


   
Quote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 8047
 

@rhammell That should be ok, just check that no motor noise is getting back to the NANO although the VR in the NANO should protect you.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, 360, fairly knowledge in PC plus numerous MPU's & MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
(@davee)
Member
Joined: 4 years ago
Posts: 1947
 

Hi @rhammell,

RE: he only other way I can think of to get the 7.4V from the battery to the Nano is to split the wire coming out of the battery holder to go to both the Nano and the converter. 

  Splitting the both of the (positive and negative) wires as close as possible to the battery, as you suggest, is the better idea, because it minimises the inductance and resistance that is common to both the Arduino and the buck converter/motor driver circuits, hence minimising the chance of the motor side upsetting the Arduino.

I would also suggest inserting an inline fuse into the positive line, before the split, and as close as possible to the battery, just in case you get a short ... Li-ion based cells can often supply a high current when shorted.

Good luck, Dave


   
Ron reacted
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 8047
 

@davee FYI @rhammell Can you elaborate a LITTLE bit on that wiring Dave? My street-sense tells me having the NANO at the furthest part of the 'power rail (wires)' is better. Any voltage drop is unimportant since we start with 7.4ish and only need 6ish at the NANO. I have no formal training anywhere near as deep so can easily be 100% wrong. What would be useful to the forum in general is some sort of guideline or 'Rule Of Thumb' for this kind of design decision.

As far as the fuse is concerned, I doubt it is needed. I did a quick google of '14500 lithium battery' and found the following (see pic)

HOWEVER, it is probably a good idea to just get in the habit of always having a 'disaster' fuse as close to the battery + terminal as possible (NOTE this does NOT preclude having normal use smaller fuse located in a convenient location such as the back of the battery case)

ASIDE: I am not at all convinced that 2500mAh is an honest depiction of the battery capacity. I think I have a couple of those size batteries and if I do I will put them through a capacity test on my SkyRC M3000 battery tester. Google says 600 to 900 mAh. It is also possible to get a ballpark capacity by simply weighing the battery. It will produce a higher than real number of course due to the weight of non active components, but I just multiply by 80%. I will report that number as well when I report the capacity test numbers. It will take a few hours.

My pup is sleeping on my legs so I can't do the tests yet, but I did grab some info from the net. NOT one suggests 2500mAh. See attached pics and pdf.

 

 

Screenshot 2025 02 08 at 11.17.44
Screenshot 2025 02 08 at 11.56.17
Screenshot 2025 02 08 at 11.54.17

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, 360, fairly knowledge in PC plus numerous MPU's & MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
(@davee)
Member
Joined: 4 years ago
Posts: 1947
 

Hi Ron @zander,

Re:Can you elaborate a LITTLE bit on that wiring Dave? My street-sense tells me having the NANO at the furthest part of the 'power rail (wires)' is better. Any voltage drop is unimportant since we start with 7.4ish and only need 6ish at the NANO.  etc.

My reasoning is not about average (over time) voltage drop, but noise spikes, etc.

It applies to electrical systems in general, but the speed of modern electronic systems means that glitches lasting a nanosecond or less can be enough for a logic circuit to see a 'high' when it should have remained 'low', or vice versa, and whilst this may not do any physical damage, it can certainly get something like a microcontroller confused.

In a little more detail
When you have systems that can 'see' pulses in the microseconds and shorter times, even a short wire, say 1cm in length, can have enough inductance to produce 'unexpected' effects. Similarly, when circuits switch quickly, even though the average current flow being switched may be small, the peak current during the transition can be surprisingly high as the local capacitance is charged or discharged.

The combined impedance effect of the resistance and inductance of even a short wire can produce an unexpectedly large voltage drop, albeit for only a tiny fraction of a second ... but that can be enough for a logic circuit to see a high instead of a low (or vice versa).

In some cases, the effect can be so dramatic, the circuit completely fails, which is relatively easy to fault find. But in other cases, it causes the circuit to fail about once every few hours, or even days ... and tracing these faults can be very frustrating!

So, why do I recommend splitting the wires near to the power source (i.e. the battery)?

Simplistically, this circuit has two power loads, a Nano and a Motor. If they are both powered by a single wire, then any changes of current demand by the motor will cause a change in the voltage drop across that wire, (due to the inductance and resistance of the wire), which will affect the instantaneous voltage seen by both the Nano and the motor. In some cases, the voltage spikes could be large enough to affect the Nano.

---------------

Please note, I am NOT saying that the spikes will be enough to cause problems in this particular case ... merely that they MIGHT be.

Hence, I am recommending what is generally a good design practice, in the hope of making the circuit as reliable and robust as possible.

I agree with your suggestion that the Nano's voltage regulator will probably help to ameliorate such effects, but it will not eliminate them.

NB The problem is not confined to the positive rail voltage falling when a current demand spike occurs. In many cases, logic circuits are confused by spikes of the '0V' line rising in potential, so it is essential to treat the negative (0V) rail with as much care and consideration as the positive rail.

------

Sorry, if my explanation as to how problems arise, sounds a bit esoteric, but the main 'takeaway' is that it is good design practice to separate the current flows, and thereby minimise the chance of unwanted interactions.

Best wishes and take care, Dave


   
Ron reacted
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 8047
 

@rhammell Dave forgot to include you in the following post https://forum.dronebotworkshop.com/postid/50642/

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, 360, fairly knowledge in PC plus numerous MPU's & MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 8047
 

@davee FYI @rhammell Thanks Dave, I was playing devil's advocate there, I know to wire from the source to each component rather than daisy-chain but I thought your Engineer's explanation might be a useful addition to my layman's Rule Of Thumb (ROT). I think you struck the perfect balance in terms of length. Who said old dogs can't learn new tricks.

HOWEVER, I am probably about to make things worse.

I was a tad bit surprised you didn't recommend decoupling capacitors (e.g., 0.1 µF ceramic + 10 µF electrolytic) near the microcontroller’s VCC and GND pins.

What are your thoughts about also adding inductors or ferrite beads to filter out noise?

I know in the past you often mention 'star ground topolgy', why wasn't it used here, and what would that look like in this case?

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, 360, fairly knowledge in PC plus numerous MPU's & MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 8047
 

@davee FYI @rhammell  I have also read where some designers now also add a third capacitor (like 1 nF or 10 nF ceramic) to cover ultra-high-frequency transients that the 0.1 µF might miss due to parasitic inductance. 

Is that something to consider in our circuits, if so when or under what conditions?

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, 360, fairly knowledge in PC plus numerous MPU's & MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
(@davee)
Member
Joined: 4 years ago
Posts: 1947
 

Hi Ron @zander,

Re:@davee FYI @rhammell  I have also read where some designers now also add a third capacitor (like 1 nF or 10 nF ceramic) to cover ultra-high-frequency transients that the 0.1 µF might miss due to parasitic inductance.

Is that something to consider in our circuits, if so when or under what conditions?

Basically, yes ... the aim is to minimise the power supply voltage transients when the devices change the current they are drawing. Different circuits, not surprisingly, require different solutions, and the circuit designer needs to have an appreciation of how the devices behave. A full description could fill a book, if not a bookshelf, so I'll just give a flavour.

Most logic circuits now are based on CMOS devices. A typical CMOS chip will draw very little current, when there are no logic transitions taking place, but when there are transitions, each transition results in small current pulse.  Although a single logic gate transition may only result in a very small current pulse, the combined effect of billions of gates, at frequencies in the gigahertz region, which are typical of a desktop PC microprocessor or graphics processor, can result in power demand and dissipation of more than 100 Watts.

In addition, some chips are required to drive buses at similar speeds, and each transition drive may result in a momentary current demand of 1 Amp or more, to charge/discharge the capacitive bus load.

Consequently, these circuits are often provided with local power regulator circuits to minimise the problems of supplying substantial currents with high frequency demands.

-----

A common case when designing a small to medium-sized PCB with a mixture of logic chips, say a microcontroller, some 74 series logic, plus some (low power) peripheral chips, and assuming they all use the same 3.3V logic supply, might consist of three capacitor sizes, all connected between +3.3V and 0V(Gnd). These circuits are typically slower and smaller than the PC example, so the current transitions are less demanding, and can usually be handled by adding capacitors.

The lowest frequency demands, say 0-100kHz,  of such a board are typically handled by 'decoupling' capacitors in the 10s or 100s of microFarads range. The most economical parts are aluminium electrolytics, and most frequently chosen. A small board may only have a single such part, but larger boards may have a few scattered around. In some cases, tantalum or ceramic parts may be preferred for this role. 

The next range, say 100kHz-5MHz, can be handled with a lower capacitance, but requires components that have a low ESR Equivalent Series Resistance at higher frequencies. ESR is not a physical part, but a real capacitor behaves more like a 'perfect' capacitor and a resistance in series. A value of 0.1 microFarads, usually ceramic, is often chosen for this role. Some circuit designers, particularly if the logic switching speeds are modest, may rely on 'sprinkling' a number of such capacitors around a board, maybe one per 74 series device, and 2-4 for chips with higher pin counts, like microcontrollers.

For higher frequencies, say 5Mhz upwards, lower capacitance values are effective, but reducing inductance, and minimal wire lengths are crucial, so 0.01 microFarad capacitors connected as close as possible between the Vcc and Gnd pins are often employed.

-------------------
Please understand that the whole topic of decoupling capacitors is somewhat of an art. Circuits will often work with fewer capacitors than might be imagined from this note, but if insufficient decoupling is provided, then a specific board may intermittently show problems when circumstances change, such as change of temperature or as the battery supply discharges. Similarly, many designers have been embarrassed when the prototype circuit passed all the tests, but substantial numbers of the final product failed in the field. Hence, I would generally recommend 'too much' rather than 'too little'.

I have mentioned some illustrative frequency ranges, but in practice, many capacitors will continue to provide some effect of over a wider range than stated.

Some circuits, such as switch mode power supplies, can put a high physical stress on capacitors in certain roles. There are additional factors to consider in such cases.

As discussed above, adequate decoupling is not just 'enough microFarads', but also ensuring the combined effect of the capacitors can handle the entire frequency range, and that the inductance between the capacitance and the transition causing components is minimised. At the higher frequencies encountered in the faster logic circuits, just a millimetre of wire or PCB track can substantially reduce the effectiveness of the capacitor.

---------------------

I hope this gives you some idea of what is involved. For one-off applications, sensibly applying a few simple rules will usually suffice, providing you are prepared to modify a circuit if the circumstances dictate. Designs destined for production clearly need more care!!

Best wishes, Dave


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 8047
 

@davee I am not surprised that it CAN be complex, but for those of us not building a PC or other multi dozens if not hundreds of chips but rather more in the 1 to 6 range, then I am thinking what you described while I am sure accurate is rather overkill for us. HOWEVER, I am of the belief that if a 3rd cap costing at most $1 from Amazon to $0.10 from Aliexpress is so cheap you may as well use it in any case.

i have good quantities of the 0.1 µF ceramic and 10 µF electrolytic, so now I will order a hundred of the collection of 1nF to 10nF ceramics.

Thanks Dave, my HS training didn't have very much theory, we were just being trained to diagnose and fix TVs so your engineering knowledge is occasionally of interest at least to me although as you know I don't deal well with the sermon length. Some of the terms you use are 100% foreign to me, but I just skip over them.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, 360, fairly knowledge in PC plus numerous MPU's & MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
(@davee)
Member
Joined: 4 years ago
Posts: 1947
 

Hi Ron @zander,

RE:

I was a tad bit surprised you didn't recommend decoupling capacitors (e.g., 0.1 µF ceramic + 10 µF electrolytic) near the microcontroller’s VCC and GND pins.

What are your thoughts about also adding inductors or ferrite beads to filter out noise?

I know in the past you often mention 'star ground topolgy', why wasn't it used here, and what would that look like in this case?

I would like to think that a dev board, like a Nano, already has decoupling capacitors for its own microcontroller. Of course, that could be wishful thinking, especially with clone boards, but I was trying to stick to the question.

In addition, adding capacitors to the dev boards, close enough to the microcontroller to be useful, could be physically tricky for those inexperienced with soldering on surface mount PCBs.

So, I just hope the dev board designers have provided enough.

----

Actually, I am suggesting a form of 'star ground topology', albeit the star has only 3 points ... battery terminal, motor controller/motor and Arduino.

---

Ferrite beads and inductors, when combined with capacitors, can indeed filter out noise, but that is getting rather more involved. I was just expressing preference of using a few more cm of wire, not designing filters, etc.

The strength of 'logic circuits', compared to 'analogue circuits' is that they can tolerate much higher levels of noise and voltage offsets. e.g. If a logic input regards voltages in the range 0V to 0.8V as a 'low', then noise peaks that always stay within that range, will not accidentally cause the device to perceive an accidental 'high'. Thus, providing precautions are taken to minimise transferring current peaks, it may not be necessary to filter out the last traces of noise. (For fun, consider what noise peaks of up to 0.8V applied to the microphone input would do to a typical audio amplifier output!)

Best wishes, Dave


   
Ron reacted
ReplyQuote
(@davee)
Member
Joined: 4 years ago
Posts: 1947
 

Hi Ron @zander,

  Sorry, but apart from ESR, which I very briefly mentioned, and I am sure can be Googled, I didn't realise I had used any terms that would be unfamiliar. (ESR is not complex, but is a vital issue in this context and worth looking up.) Perhaps it would help if you pointed the other unfamiliar terms out?

Also, as I finished up with, choosing decoupling capacitors is partly an art based on having a gut feeling of how the circuit will behave ... and the manner of how they are physically wired is often a crucial aspect.

Best wishes, Dave


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 8047
 

@davee I am not planning on soldering onto the board, just to the pins or in the case of a 'strip like board' anywhere along the path (the path is HUGE compared to the wire size so an extra 1 cm is irrelevant.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, 360, fairly knowledge in PC plus numerous MPU's & MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 8047
 

@davee If it is a technical word other than resistor or capacitor it is either 100% unknown by me or mostly unknown. 

When I went to HS I took the 4 yr non-university stream called Technical. We were mostly being trained to be either TV repair men, auto mechanics, carpenters, machinsts, and electricians. Some of those involved an apprenticeship, and 3 of the 30 including me went on to a 3 yr college not affiliated with a University. This was training to be a technologist. A higher paying job than TV repairman but today I can't tell you what the Job would be upon graduating. I quit after 2 yrs and ultimately joined IBM after a short stint as an industrial electrician.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, 360, fairly knowledge in PC plus numerous MPU's & MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
(@rhammell)
Member
Joined: 2 months ago
Posts: 9
Topic starter  

@davee
@zander

Thank you for the dicussion, as its helping me understand this topic a bit more as someone getting into it. 

Dave, for clarification, you're suggesting from this initial setup: 

Screenshot 2025 02 08 at 8.40.52 PM

To this one, where there is a split of the positive and ground wires close to the battery: 

Screenshot 2025 02 08 at 8.42.58 PM

Correct? 

For further clarity: 

- Creating this 'Y' split form one wire into two (for both the positive and ground wire coming out of the battery), is acheived by soldering two wires to the end of the original one, correct? 

- It sounds like the physical distance from the battery of where this split occurs is important - having the split occur close to the battery is better than having it closer to the components, correct? Otherwise, at the extreme, the 'split' would be occuring at the converter itself, like in my original image. 


   
ReplyQuote
Page 1 / 3