-
-
Notifications
You must be signed in to change notification settings - Fork 8
Regulating 5V
The 5V is used for the input and control side of the board revisions 1.x-2.x. It powers the Arduino and all of the TTL components. As the Arduino doesn't like voltages at the edge where it can operate (brown out), the regulated 5V need to be treated with care. Some options are noted here.
It is possible to use a simple LM7805 regulator to obtain 5V from the input voltage. These regulators bypass the voltage if it drops below the minimum input level. I.e. if the input voltage slowly drops to 0V when the machine is turned off, the 5V will also slowly drop once the input drops below 6-7V.
The Arduino doesn't like this. When operated at the critical levels around ~2.7V, it may behave in an unpredicted way and may (and will!) even corrupt its own memory, both flash and EEPROM. This will lead to a malfunctioning board!
Here is an excerpt from the ATmega 328p datasheet (section 26.2.3, Preventing Flash Corruption):
Flash corruption can easily be avoided by following these design recommendations (one is sufficient):
- Keep the AVR RESET active (low) during periods of in sufficient power supply voltage. This can be done by enabling the internal Brown-out Detector (BOD) if the operating voltage matches the detection level. If not, an external low VCC reset protection circuit can be used. If a reset occurs while a write operation is in progress, the write operation will be completed provided that the power supply voltage is sufficient.
- Keep the AVR core in Power-down sleep mode during periods of low VCC. This will prevent the CPU from attempting to decode and execute instructions, effectively protecting the SPMCSR Register and thus the Flash from unintentional writes.
The solution is to change the brown out detection level of the Arduino from the default 2.7V to 4.3V. This will put the Arduino into reset as soon as the input voltage drops below 4.3V. The Arduino will be safe this way.
Fusing the Arduino requires physical programmer access as the fuses cannot be changed through the Arduino bootloader. You can read here how to build your own ISP. Alternatively just buy a readily available ISP programmer, e.g. from Pololu.
To configure the brown out detection level (BODLEVEL) to 4.3V you need to change the extended fuse to 0xfc. See a fuse calculator for details, the Arduino nano is powered by the Atmega 328p. This can be don using the avrdude software.
I have fused the Arduino with following avrdude command on Linux:
avrdude -v -V -patmega328p -cavrisp -b19200 -P/dev/ttyUSB0 -D -F -Uefuse:w:0xfc:m
The fuses can be read like this:
avrdude -v -V -patmega328p -cavrisp -b19200 -P/dev/ttyUSB0 -D -F -Uefuse:r:-:i
When using avrdude on Windows, the port command will look something like -Pcom<serial port number>
.
💥 WARNING 💥 |
---|
Also, when using these regulators, you can easily damage the board when ground is left unconnected! When now a row input switches to ground, there is a path for the full lamp matrix current through the 74165's clamping diode at the row input pin, which the chip doesn't like. |
More sophisticated DC/DC converters can be used. They often provide undervoltage shutdown and additional nice features like short detection.
Although I have not measured it, I have not experienced Arduino problems with boards using this regulator.
There are plenty of simple 3pin voltage detectors available. The schematic and PCB could be extended to use such a device that will put the Arduino into reset when the necessary voltage is not supplied. This is the same as the Arduino does, just externally.