The Arduino Nano single board computer can be powered in three ways. In the note I will analyze the selected method. In addition, I will describe the battery charge control option.
Power supply options for Arduino Nano
Via USB, the board receives power from the computer when debugging the program or from the Power Bank. USB power is 5 volts (approximately, I met 4.6 – 5.1 V). As far as I understand, these 5 volts immediately “fall through” on the 5V leg. That is, it can be assumed (although it is a controversial issue) that the power supply from USB is not particularly different from applying voltage from the corresponding wiring of the USB cable to the 5V pin.
Vin leg serves an external power supply higher than 5 volts. The upper value is sometimes indicated by 12 volts, and sometimes 9. The lower value should be with some margin of more than 5 volts. The external voltage passes through the DC-DC step down, a chip with circuit, which makes 5 volts from a higher voltage. Again, we can assume that these converted five volts are on the 5V pin. This chip is located on the back of the board.
The 5V leg is the most mysterious, because at first glance it looks like the output of voltage from the board for powering external modules, such as digital indicators, sensors, etc. Moreover, when powering the entire project through Vin, it is so.
In fact, it is more correct to assume that the 5V leg is the main input for powering the Arduino. That is, when powered from USB, the input voltage is connected to this leg and it feeds on the Arduino chip and connected external devices. When powering through Vin, the same thing happens, but through the built-in DC-DC step down circuit. And when you receive power directly from the 5V leg, everything happens quite naturally. In the description of the board on this account, it seemed to me not enough clarity, so I will not give it 🙂
Thus, to power the project, it is necessary to organize external reliable power supply of 5 volts (in practice, it is possible from 3 to 5 volts), which is supplied to all other modules and to the Arduino 5V leg. The power chip on the back of the Arduino board is not involved. Several times I tried to use it when debugging the radio module, and each time it did nothing. That is, the power through the Vin should be left for some cases when there is only 9-12 volts at hand.
Here is a diagram of the connections from the Timing system for Alpine skiing based on Arduino. Addition.
Power is organized from the battery, and without voltage regulation. How much battery gives, and it is from 4.2 to 3.0 volts, so much goes to power all the elements of the circuit. Arduino supplied, getting the voltage on the leg 5V.
For the “responsible” blocks, in our case, those with radio modules, the power of the entire circuit must be stabilized. Therefore, when powered by a lithium-ion battery (3 – 4.2 volts), you need to add a booster.
Battery voltage control
In fact, in the timekeeping for skiing, battery control is not very necessary. Before training, all batteries must be charged (good in lithium-ion batteries there is no memory effect). The battery charge should be enough for 2-3 hour skiing with a triple reserve.
However, there should be some kind of “battery low” signal. More precisely, we need confidence that everything is in order with the battery. Then, if the system suddenly stops working, for example, the radio channel disappears, it is easier to find a fault. For quality control of the battery, Ali-Express sells a huge number of modules with a separate indicator in numbers or in a line of LEDs of different colors. But quality control is not needed, and even if there is an analog-to-digital converter on board Arduino, then why the additional module?
In the Arduino Nano chip, there is one analog-to-digital converter (ADC), which can be programmatically connected to the A0-A7 legs via a multiplexer (switch). In our case, it is better to A6 or A7, because these legs are configured to work “only” with the ADC. The rest can be configured, for example, as digital outputs on indicators.
The ADC measures voltage from zero to the so-called reference voltage. The reference voltage can be programmatically selected from three options: the default voltage is on the leg 5V (that is, the onboard power supply), a specially applied voltage on the REF leg (the leg to the left of A0 on the top picture), and the chip’s internal reference voltage is 1.1 volts . With the REF leg, you need to be extremely careful, there are some input requirements, the non-observance of which can burn the chip. In addition, this leg can work as output, it can show the selected “internal” reference voltage of 1.1 V. In general, I played with it, fortunately did not burn chip, and decided that in my case it would be more correct to assume that the option “REF ” not present 🙂
The reference voltage on the leg 5V in the network mainly used to measure relative values. For example, a variable resistor connected by the extreme outputs to zero (GND) and 5V, and the average output (variable) to the input of the ADC. The current values of the resistor are digitized relative to its full resistance. These proprtions became constant if onboard voltage will change. Even when working with a stabilized source, the on-board voltage may vary depending on the overall load of the circuit. And even more so will be different when powered by USB or battery. Therefore, if the measurement is somehow interested in the proportions, rather than the absolute values of the voltage, then the choice of 5V as the reference voltage works well. This does not apply to the case of battery charge control, as it is necessary to measure the voltage on the battery, and not any proportions.
Therefore, to control the battery, one way or another, you need to use an internal reference voltage of 1.1 volts. Where does it come from? It turns out from Nature. The chip is made of silicon. The energy gap of silicon ranges from 1.17 eV (at absolute zero) to 1.11 eV (at room temperature), the numbers here (in other sources, oddly enough may differ). In 1964, a scheme was invented on how to use this property to create a reference voltage (search on “bandgap voltage reference”, for example Wikipedia). The reference voltage may differ slightly from chip to chip, but if calibrate measured values, you can then use it as a stable bench mark, independent of temperature or circuit load.
To use a 1.1 V reference voltage, you must measure a voltage less than this value. That is, to measure the voltage on the battery, you need to make a divider on two resistors. In the network, this is the main approach, although as a rule each specific implementation in the comments is subjected to severe criticism. The fact is that the divider closes the plus and minus circuits through itself, so it immediately takes the current, the less resistance “in the arms” of the divider, the more current simply “goes into the sand.” At the same time, it is impossible to put large resistances, since the ADC welcomes certain values at the input, approximately 10 kΩ, although this is also in question. In general, I don’t like the idea of the divider. Moreover, you can do without it.
In the network there is a trick, which options are on the search “Secret Voltmeter Arduino”, for example here. In the note “Timing system for Alpine skiing based on Arduino. Addition” this trick was used to determine the absolute values of the voltage on the leg 5V. The point is that using the onboard voltage as a reference voltage, it is possible to measure the voltage of 1.1 V in fractions of the reference voltage using the “picking” in the chip registers. And since the voltage of 1.1 V is actually known, the value of the on-board voltage on the leg 5V is obtained by re-counting. Therefore, it is possible to digitize the voltage on the battery relative to the already known on-board voltage. The voltage on the battery must be supplied through a 10 kΩ resistor. If supplied directly, the voltage passes through the multiplexer keys and can strangely turn on Arduino. However I did not find any clear recommendations on why exactly 10 kOhm, just do it 🙂
According to measurements by a multimeter, when the voltage on the battery is 4 volts on this 10K resistor drops 0.04 volts. Since the resistor is involved in the divider with further internal resistance of Arduino, when the battery is discharged up to 3 volts on the “leg” of the input (A7 in the figure above) it should be 0.03 volt less. For some unknown reason, when translating into “numbers” no voltage drop across the resistor is calculated. Therefore, I leave this paragraph just so that the question does not arise again 🙂
The digitized voltage value jumps significantly more than that measured by an external voltmeter. This is normal. The network has hardware and software solutions. But in our case it is not necessary. It is quite simple when fixing the voltage measured on the battery less than 3 V to light the control red LED.
Here are collected all the notes on the theme “Timing for skiing on Arduino”.