loading

This board is designed to safely drive a 3.3V microcontroller and connected accoutrements. It supports primary and backup power sources and provides numerous over and under voltage safeguards.

The microcontroller here is a bare-bone, no-frills Atmega 328P-PU with no leds, driven by a 16 MHz crystal. An 8-Pin female connector is wired up to the Atmega chip and the 3.3V power regulator for a wireless transceiver to be connected. The transceiver board here can be any of the nRF24L01+ family and there is more than enough power to drive even the PA+LNA 1100 meter version at its highest power setting.

The Atmega programming connections (RX,TX, RST) are also wired up to a 6-Pin female header which is FTDI adapter ready. Just plug in the adapter and connect to your laptop or desktop with a USB-mini USB cable and it is ready to be flashed.

The circuits' dual power connections are assumed to be an AC/DC adapter and a battery backup. It can, of course, also be single-power source driven on either of the two barrel connectors.

As the circuit is designed to be powered by battery, at least as a backup, lower quiescent current is desired to support longer battery life.

The quiescent draw of this circuit with an Atmega 328-PU and an nRF24L01+ board was measured at ~150 uA @ 5V input and only 5uA when there is not enough power to turn on the 3.3V regulator. (A 3.7V LiPo, 4.15-4.20V when fully charged is the battery used here).

The battery life calculation numbers for a 56 second sleep-cycle configuration:

(Using 60% guideline and 5000mAh capacity rechargeable battery)

  • 150uA * 56 = 8,400 uA (56 second sleep cycle)
  • 2000uA * 2 = 4000 uA (2 second active cycle)
  • 12,400 uA divided by 58 seconds = 214 uA (power usage per second)
  • 3000 mAh (60% of 5000) / 214 uA = 14,018 hours on LiPo Battery
  • 14,018 / 24 hrs. = 584 days = ~1.60 years battery life

Lengthening the sleep cycle or shortening the duty cycle draw means longer battery life.

When powered and the voltage provided falls below the minimum voltage, here ~3.65V, the battery is disconnected from the regulator. This will save a partially discharged battery from being completely drained and destroyed.

The circuit will reconnect the battery again when the voltage at the MPU reset IC exceeds ~3.75V, providing hysteresis by having an upper and lower threshold to eliminate multiple transitions when the power is at or near disconnect level.

Against overvoltage, this circuit uses a simple Thyristor-based Crowbar to protect the 3.3V regulator and provide current flow control using a resettable 500 mA PTC fuse.

Should the wrong adapter or a power supply greater than 6.5V be connected to either of the barrel connectors, the crowbar circuit shorts the power rails, and causes the PTC fuse to inhibit the current flow. Due to the associated voltage drop, the MPU reset IC will also disconnect power from the regulator.

Once the overvoltage is removed, the PTC will cool and reset. The board will again turn on once a power source above the minimum ~3.75V and below the maximum ~6.5V is connected.

An STM809 MPU Reset IC is used to monitor the input voltage (post crowbar) and to cut off power to the regulator when the input voltage falls below the minimum input voltage (~3.65V).

The MCP1825 regulator used here is a 500 mA Low Dropout (LDO) linear regulator that provides high current and low output voltage. The 5 Pin versions have a Shutdown (SHDN) pin.

The SHDN pin requires a digital HIGH to be present for the regulator to produce its 3.3V output. A digital LOW will cause it to shut down. This is accomplished by connecting the SHDN pin of the MCP1825 to the RST output of the STM809 IC.

This microcontroller circuit has very little voltage drop, enough hysteresis to stop battery recovery cycling, overvoltage protection, and is ready to have any sensors or actuators added as required.

Each section of the schematic is discussed in the steps that follow.

Step 1: Parts List

Dual Power components

  • DC Power Jacks Barrel Connectors (2)
  • BAT43 Diodes (2)

Case & Platine

  • Platine 80 mm x 52 mm 35 µm (2.54 mm)
  • 88 x 58 x 30 Case

Crowbar

  • RXE050 - 500mA PTC Resettable Fuse
  • Zener Diode – 5V6, 1 Watt
  • Resistor – 470K Ohm, .25 Watt
  • MCR106-6 Thyristor
  • .100 µF ceramic output capacitor

Regulator Circuit

  • MCP1825-3302 E/AT (5 Pin TO-220-5 Package)
  • 4.7uf 50v electrolytic capacitor
  • 1uF ceramic capacitor
  • STM809T MPU reset (3.08)
  • SOT23-3 Adapter w/ Pins (Curved)
  • BAT43 or similar low drop Diode

Atmega Microcontroller

  • Atmega 328P-PU Microcontroller w/ Bootloader
  • 28-pin IC-Socket
  • 16 MHz Crystal
  • 22pf ceramic capacitor (2)
  • nRF24L01+ Wireless Transceiver
  • Double-row socket 8-Pin

FTDI Interface

  • FT232RL 3.3V/5.5V FTDI Mini USB Adapter
  • 6-pin female header
  • USB A Male to Mini B Male USB Adapter Cable
  • 10k 1/4 Watt Resistor
  • .100uF Cap

Test Equipment

  • Multimeter
  • Bench DC Power Supply
  • Ac/Dc DC Adapter (5V, 1.5A) or similar
  • Battery (3.7 LiPo 5000 mAh or similar (3.7+ to 6V))

Step 2: Dual Power Barrels and Schottky Diodes

To set up the dual power, we need two barrel connectors. Each connector (+) is connected to a BAT32 Schottky diode. They share a common ground. The diode outputs are connected to one another and to one side of the RXE050 (500mA) PTC.

There is no other mediation between the power barrels, brute force wins. Whichever diode has the higher voltage will block the other. This was designed with an adapter of HIGHER voltage level and a battery backup of lower voltage level in mind.

If the adapter provides 5V and the battery 4.20 (3.7V LiPo when fully charged), the adapter will win, and there will be no drain on the battery. In the opposite case, a battery providing more voltage than the adapter, the battery will win and will be drained until such time as that is no longer true.

Assuming the first case, if the adapter goes dead for whatever reason, the battery will take over and working together with the 4.7uF+ input capacitor on the regulator; no power interruption should be seen.

There is no reason multiple batteries could not be used; in fact, the batteries would both be used as the active input would switch between them when they are at voltage levels close enough to one another to warrant the switching.

Step 3: Dual Power Barrels and Schottky Diodes With Transistor

This brute force approach is easily changed by the addition of a transistor, a PNP in the circuit above. This will guarantee that the barrel input feeding the transistor gate always wins until it no longer provides sufficient current.

The downside of this approach is that there will be a power drain due to the transistor. My testing, with a 2N3906 as the switch on the battery line, had a drain of ~7mA, rather significant when you are on battery and relying on it for any extended period.

For this reason, this approach was not used in this circuit.

Step 4: Overvoltage Crowbar Circuit

A crowbar circuit is often used to prevent an overvoltage condition from damaging sensitive circuits. It does this by putting a short circuit across the voltage rails, much as if one were to drop a crowbar across the terminals of a battery but without the sparks.

Crowbar circuits are often implemented using an SCR (silicon controlled rectifier). Here, a thyristor is used as the shorting device.

This SCR is particularly suitable for usage in a crowbar. It is basically a bistable switch and is triggered (turned on) by a current pulse of defined magnitude on the gate terminal. This allows current to flow from anode to cathode, the principal current.

In order for the thyristor to remain in the on state when the gate current is removed, it is necessary to have sufficient principal current flowing to keep the current level at or above the latching current, listed in thyristor descriptive data as IL.

In order to turn off, the principal current must be reduced below the level of the latching current. The current level where turn off occurs is called the holding current, IH. Both the latching current and the the holding currents are affected by temperature.

Here when the supply voltage is above the zener rating of the diode (5V6), a current begins to flow through the diode and the resistor R1 (470k).

When the current flow exceeds the trigger current of the thyristor, the thyristor will switch on. The supply rail will drop to ~1 V above ground. The 100nF capacitor used in the crowbar provides a bit of protection against short voltage spikes causing unwanted triggering.

If the current surge is too high, smoke could result, so for the crowbar to function reliably, the input needs to be current limited. This is the function of the RXE050 (500mA) PTC.

PTCs increase resistance as temperature increases due to increased current flow. They are designed to limit unsafe currents while allowing constant safe current levels, resistance will "reset" automatically when the current is removed and the temperature returns to a safe levels.

Limitations

Although this overvoltage circuit is very widely used, there are limitations to be aware of. Zener diodes have a relatively large error tolerance (~5 %), they are temperature dependent, and the breakdown voltage cannot be precisely controlled. In this circuit, the error is acceptable.

Step 5: MCP1825-3302 - STM809T Circuit

An STM809 MPU Reset IC is used to monitor the input voltage (post crowbar) and to cut off power to the regulator when the input voltage falls below a minimum level.

The STM809T is a 3.08V version which generates a digital LOW (RST pin) when the input voltage falls below the 3.08V level. Otherwise, it passes the voltage through (RST pin) which is then seen as a digital HIGH by the MCP1825 (SHDN pin).

To adjust the input voltage to the required level, two series diodes are used to create a voltage drop in the real input voltage level before it is seen by the STM809. Diodes are used to minimize any current flow during the voltage dropping.

The first of these is one of the two BAT43 Schottky used to mediate between the two power barrel connectors, the second is another BAT43 placed in series with the VCC input to the STM809. The voltage drop across the diodes is additive.

The MCP1825 regulator is a 500 mA Low Dropout (LDO) linear regulator that provides high current and low output voltage. The MCP1825 3302 (E/AT) used here is a fixed version with an output voltage of 3.3V. The quiescent current consumed by the MCP1825 is typically less than 120 µA. It also has a maximum input voltage of ~6V, hence the crowbar.

The 5 Pin versions, like the one used here, have a Shutdown (SHDN) pin. When shut down, the quiescent current is reduced to less than 0.1 µA.

The SHDN pin requires a digital HIGH to be present for the regulator to produce its 3.3V output. A digital LOW will cause it to shut down. This is accomplished by connecting the SHDN pin to the RST output of the STM809 IC.

The output voltage is also internally monitored and a power good (PWRGD) output is provided when the output is within 92% of regulation (typical).

This pin is currently not used in this circuit, but is available should a downstream component desire to use it. This means that you could, as an example, connect this pin to a microcontroller as a secondary voltage monitor.

If you choose to use it, the document calls for a resistor to be placed between it and the power out pin. (See the associated documentation for the MCP11825 in the references section below.)

Step 6: Atmega 328 Microcontroller Cicuit

One of the main reasons you build your own Arduino compatible is to control the amount of power the microcontroller needs as well as to minimize the parts you require. You create a custom solution for the problem at hand.

Here we are using the basic Atmega 328P-PU chip, a 16MHz crystal, and a couple of 22 pF caps. If you wish to run at 8 MHz instead of 16, you can do without the crystal and caps as well. (See “From Arduino to a Microcontroller on a Breadboard” linked in the references section below.)

The Atmega Pin Mapping image below shows the 168 but both the 168 and 328 have the same pin mappings.

Step 7: NRF24L01+ Header Wiring

The 8-Pin Female header is wired to the Atmega and the MCP1825 3.3V output to support the nRF24L01+ family of transceivers. The task required is to map the pins on the nRFs to the header and then wire the header pins to the Atmega. The connections required are shown below.

In the circuit schematic above, the D2 pin is shown linked to the IRQ pin on the nRF24L01+. This is optional and usage is not recommended if you expect to run off battery for longer periods of time. Running an nRF24 in interrupt mode is a battery killer. Skip this unless you will be running off AC Adapter only or only need battery backup for short periods of time.

Step 8: Wiring the FTDI Header

To program the Atmega, I normally use an FT232RL FTDI USB to TTL Serial Converter Adapter and a USB to mini USB cable. Make sure to set the jumpers to 3.3V and not 5V on the FTDI Adpater.

I usually use one of the longer USB to mini-USB cables, rather than the really short ones you often see advertised on the online sites. The longer cables simply give more room to work and the short ones can sometimes be frustrating to use.

The FTDI board and support circuitry allow you to upload sketches as well as monitor the program output via the Serial Monitor. It also allows you to power your project while testing.

The FTDI board sends a reset signal to the chip, to activate the bootloader in preparation for receiving the sketch being uploaded. Connect the DTR pin of the FTDI, via a 0.1uF capacitor to Pin 1 on the Atmega and don’t forget to connect the 10k resistor to 3.3V and the DTR line. Flashing will not work reliably without it.

Next the FTDI needs to communicate with the Atmega. You need to connect the FTDI’s TX to the Atmega RX (Pin 2) and the FTDI’s RX to the Atmega TX (Pin 3).

Connect the VCC Pin from the FTDI header to pins 7, 20, and 21 on the Atmega and the FTDI GND to pins 8 and 22.

The header should now be ready to accept the FTDI adapter.

 

Step 9: Programming the Atmega Chip

Once you have the FTDI adapter installed and connected to your laptop or desktop, you can bring up the Arduino IDE. (It can be downloaded here.)

Libraries Used

Low Power Library

Supports all sleeping mode of ATmega328P and has selectable sleep duration:

  • 15 ms, 30 ms, 60 ms, 120 ms, 250 ms, 500 ms, 1 s, 2 s, 4 s, 8 s
  • Idle
  • ADC reduction mode
  • Power save
  • Power down
  • Standby
  • Extended standby

nRF24L01+ Library and Docs

This is an Arduino NRF24 library. It provides an object-oriented interface for sending and receiving data messages with Nordic nRF24L01 based radio modules.

Guide on how to install Arduino libraries can be found here.

Attached is a simple sketch which can be used to test the board. It wakes up every 56 seconds or so, creates a message, and then sends it to an output pipe. It has a couple of debugg statements left in so that it can be watched on the Serial monitor. The next few steps explain the sketch.

Arduino sketch..

Step 10: Globals (Code Section Explained)

Code Explanation

  • #include "SPI.h"
  • #include "nRF24L01.h"
  • #include "RF24.h"
  • #include "LowPower.h"

These are libraries used in the sketch. The links to these libraries are in the preceding section. Instructions on how to install these libraries can be found here.

int loops = 7;

The Arduino spends most its time sleeping. It powers down for an 8 second period, this is the maximum time slice the "Low Power" library supports. The Loops variable is the number of times we will use that time slice before checking on any incoming messages and reacting to whatever command we receive. (8 loops = 56 seconds)

int myID = 9;

When we receive a message from the NRF, we verify that the command we read is actually for this device.

int ctr = 80;

This is the simple counter variable which is incremented after each message send and then reset to starting value again.

int measures[3];

This is a simple message buffer. The first integer is the message address; the next two are for control variables or data.

#define CE_PIN 9

#define CSN_PIN 10

Here we are defining the CSN (chip select pin) and the CE (chip enable) pins to be used by the NRF24L01+ library. If you used other pins, here is where you set them.

const uint64_t pipes[2] = { 0xE8E8F0F0E1LL, 0xE8E8F0F0E9LL};

Define the pipe addresses used in communications, here pipe[0] is set up to be the address of a central gateway. If you are not using one, you can ignore this. The Second address is this controller. This is the pipe that will be read when calling "radio.read" (not done in this simple sketch).

Step 11: Setup() (Code Section Explained)

Code Explanation

The setup() function is run when the Arduino starts up or is reset.

Serial.begin(9600);

Sets the data rate in bits per second (baud) for serial data transmission.Make sure this is the same rate used when bringing up the Serial Monitor.

radio.begin();

Start the radio, the NRF24.

radio.setDataRate(RF24_250KBPS);

Here I am setting the data rate to the lowest setting for the maximum distance.

radio.setPALevel(RF24_PA_HIGH);

Set the Power level to the highest setting.

radio.setPayloadSize(8);

This library uses a pre-established fixed payload size for all transmissions. If this method is never called, the driver will always transmit the maximum payload size (32 bytes), no matter how much was sent to write(). This improves performance and reliability.

radio.openWritingPipe(pipes[0]);

I use this to write status to a central gateway. This should be the pipe address used by your listener.

radio.powerDown();

Power down the radio. This is to save battery power as the radio will eat milliamps while powered up.

sendData();

Call the routine which will be called each time we come out of our sleep. This is done here so that we do not go through the sleep in the main loop before we send out first message out.

Step 12: Loop() (Code Section Explained)

Code Explanation

Once the setup() function has run and initialized all as required, the loop is entered. The code within the loop is endlessly repeated.

for (int i = 0; i < loops; ++i)

{

LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);

}

Here we will sleep for the defined time slice for the defined number of loops. Here 8 seconds is the time slice and with the loops variable defined as 7, we basically enter a 56 second "Low Power" state where the Arduino will use minimum power or close to that. We do wake up every 8 seconds, but immediately go back to sleep so minimal uAs are consumed but they are included in our measurements and calculations.

sendData();

Once we come out of the "Low Power" loop, we format a message, send it out, and return here to go back to sleep.

Step 13: SendData() (Code Section Explained)

Code Explanation

SendData is responsible for formatting a message, sending it out and updating our counter to range between 80 and 99.

radio.powerUp();

The first thing to do is to power up the NRF board. A short delay gives it time to initialize.

measures[0] = myId;

measures[1] = (int)(ctr * 100);

measures[2] = (int)(29 * 100);

radio.write( measures, sizeof(measures) );
delay(10);

This section of the routine broadcasts the message to any listeners, normally a central gateway or a controller. After initializing the message, the message is written to the pipe defined in the setup() routine.

ctr += 1;

if(ctr >= 100)

ctr = 80;

Increment the counter and if it is greater than 99, reset back to 80.

radio.powerDown();

Finally, power down the radio and exit the routine.

About This Instructable

1,209views

15favorites

License:

Bio: Retired tinkerer, programmer ...
More by GSink:An nRF24L01+ and FTDI Ready Atmega 328P-PU (3.3V, 500 mA) Microcontroller with Dual Power Capability, Undervoltage, Hysteresis, and Thyristor-Crowbar Overvoltage Protection Voltage Clamp for Arduino using Zener Diode, PTC, and an NPN Transistor Manage a Wireless 120 dB Alarm Siren using an Arduino Pro Mini 3.3V and nRF24L01+  
Add instructable to: