Arduino MOSFET-Based Power Switch

Circuit Cellar columnist Ed Nisley has used Arduino SBCs in many projects over the years. He has found them perfect for one-off designs and prototypes, since the board’s all-in-one layout includes a micrcontroller with USB connectivity, simple connectors, and a power regulator.

But the standard Arduino presents some design limitations.

“The on-board regulator can be either a blessing or a curse, depending on the application. Although the board will run from an unregulated supply and you can power additional circuitry from the regulator, the minute PCB heatsink drastically limits the available current,” Nisley says. “Worse, putting the microcontroller into one of its sleep modes doesn’t shut off the rest of the Arduino PCB or your added circuits, so a standard Arduino board isn’t suitable for battery-powered applications.”

In Circuit Cellar’s January issue, Nisley presents a MOSFET-based power switch that addresses such concerns. He also refers to one of his own projects where it would be helpful.

“The low-resistance Hall effect current sensor that I described in my November 2013 column should be useful in a bright bicycle taillight, but only if there’s a way to turn everything off after the ride without flipping a mechanical switch…,” Nisley says. “Of course, I could build a custom microcontroller circuit, but it’s much easier to drop an Arduino Pro Mini board atop the more interesting analog circuitry.”

Nisley’s January article describes “a simple MOSFET-based power switch that turns on with a push button and turns off under program control: the Arduino can shut itself off and reduce the battery drain to nearly zero.”

Readers should find the article’s information and circuitry design helpful in other applications requiring automatic shutoff, “even if they’re not running from battery power,” Nisley says.

Figure 1: This SPICE simulation models a power p-MOSFET with a logic-level gate controlling the current from the battery to C1 and R2, which simulate a 500-mA load that is far below Q2’s rating. S1, a voltage-controlled switch, mimics an ordinary push button. Q1 isolates the Arduino digital output pin from the raw battery voltage.

Figure 1: This SPICE simulation models a power p-MOSFET with a logic-level gate controlling the current from the battery to C1 and R2, which simulate a 500-mA load that is far below Q2’s rating. S1, a voltage-controlled switch, mimics an ordinary push button. Q1 isolates the Arduino digital output pin from the raw battery voltage.

The article takes readers from SPICE modeling of the circuitry (see Figure 1) through developing a schematic and building a hardware prototype.

“The PCB in Photo 1 combines the p-MOSFET power switch from Figure 2 with a Hall effect current sensor, a pair of PWM-controlled n-MOFSETs, and an Arduino Pro Mini into

The power switch components occupy the upper left corner of the PCB, with the Hall effect current sensor near the middle and the Arduino Pro Mini board to the upper right. The 3-D printed red frame stiffens the circuit board during construction.

Photo 1: The power switch components occupy the upper left corner of the PCB, with the Hall effect current sensor near the middle and the Arduino Pro Mini board to the upper right. The 3-D printed red frame stiffens the circuit board during construction.

a brassboard layout,” Nisley says. “It’s one step beyond the breadboard hairball I showed in my article “Low-Loss Hall Effect Current Sensing” (Circuit Cellar 280, 2013), and will help verify that all the components operate properly on a real circuit board with a good layout.”

For much more detail about the verification process, PCB design, Arduino interface, and more, download the January issue.

The actual circuit schematic includes the same parts as the SPICE schematic, plus the assortment of connectors and jumpers required to actually build the PCB shown in Photo 1.

Figure 2: The actual circuit schematic includes the same parts as the SPICE schematic, as well as the assortment of connectors and jumpers required to actually build the PCB shown in Photo 1.

Open-Source Guide for Embedded Systems Developers (EE Tip #114)

What comes to mind when you hear the term “open source”? Hopefully, it means more to you than just a software application running on a PC.

As an embedded systems developer, you should familiarize yourself with the wide range of open-source programs, programming tools, and hardware platforms currently available. In addition to saving yourself the costs of pricey user licenses, you’ll find that open-source community forums helpful, informative, and engaging.

Open-source software offers a number of advantages. The product is independent of a particular manufacturer and there aren’t license costs. Plus, the product is usually high quality because it is often supported by a large active community of users. When a program’s source code is available, you have the chance to fix errors, change its behavior, and even add new features.

The aforementioned advantages should be good enough reasons for any designer of microcontroller applications to work with open-source software. PC tools such as editors, documentation programs, toolchains (for the vast majority of microcontrollers), operating systems, and libraries are widely available with open-source code.

On the hardware side, open-source microcontroller boards are gaining popularity among serious engineers. The circuits, PCBs, and CAD files are available so you can modify them, improve them, and add more features to meet the demands of your applications. It’s an added benefit that open-source hardware is always supported by software code and libraries that enable you to get up and running fairly quickly.

Since we couldn’t include in the space provided all the open-source resources currently available, we simply list several open-source projects that Elektor and Circuit Cellar engineers and editors recommend.

Below we provide the following lists: hardware; libraries and run-time tools; PC tools, and GNU toolchains. By no means are the lists complete. Still, they’re helpful starting points.

Download your Arduino Uno poster

Click image to download a free Arduino Uno poster

Arduino—This popular platform offers a range of simple microcontroller and development boards that you can purchase from several suppliers. The Arduino website has an active forum and the wide range of software examples will ensure that you are up and running in minimum time.

Openmoko—It’s a complete software stack for a smart. The Neo FreeRunner mobile phone is the target hardware platform. Development and debug boards are also available.

GNU Radio & Universal Software Radio Peripheral—The GNU Radio project is a software toolkit to produce a software-defined radio. The open-source hardware for this project is the Universal Software Radio Peripheral (USRPBoard), which is based on an FPGA.

KiCAD—One of the best-known suites of CAD programs for hardware production, KiCAD includes tools for generating circuit diagrams and PCBs. You can view 3-D representations of the finished board.

Fab Lab—This interesting project offers 3-D laser cutters, 3-D printers, and other machines for use by the general public. It’s a handy resource for making robot parts and art objects.

uIP/lwIP—Two outstanding network stacks, the first is for 8-bit microcontrollers. lwIP is a development of the first and more suited to medium sized controllers. The uIP licence is not so strict allowing the stack to be used in commercial products.

LUFA (formally MyUSB)—A large library of applications for interfacing (both Host and Device) USB enabled AVR controllers. The demonstration applications allow an AVR controller for example to emulate a keyboard and many other devices (mass storage device, audio I/O etc.)OpenSource2

Crypto-avr-lib—It’s a library of optimized cryptographic routines for the Atmel ATmega controller. Issued under the GPL Version 3 licence. Contact the author for other types of licence.

FreeRTOS—FreeRTOS is a lightweight Real Time kernel which can run on many controller families. It can be used in commercial applications and allows the use of closed-source software.

U-Boot—Universal bootloader with a large range of routines for memory, UART interface, SD card, network and USB etc. Conceived originally as a bootloader but now through comprehensive hardware support can be used as the basis of a C code module.

Embedded Filesystems Library—A useful (FAT) file format, when you are short of memory. The GPL licence includes a clause allowing static linking to the library without public disclosure of your code.

.NET Micro Framework—Now open source this very compact, trimmed down .NET Framework running on diverse ARM platforms. Programmable using the object orientated C variant C#; lots of resources including support for I2C, Ethernet and many more. Helps reduce development time.

Eclipse—This is a good development environment. It has a modular structure which makes it very easy to configure. There are around 1,000 plug-in modules (both open source and commercial) for a range of program languages and target systems.

Kdevelop—Kdevelop is an integrated development environment which should satisfy most power-user needs. Runs in MS Windows, Mac OsX, Linux, Solaris and FreeBSD. Plug-in expandable.

Programmer’s Notepad—A lightweight but efficient editor for writing source code. Allows fast, simple and comfortable program production. Can be expanded with plug-ins.

Doxygen—An intelligent tool which can automatically generate code documentation (C, C++, Java etc.). The programmer provides tags in the source file; Doxygen generates the comprehensive documentation in PDF or HTML format. It can also extract the code structure from undocumented source files.

WinMerge—A good tool for code comparison and code synchronization. The program can also compare the contents of folders/files and display the results in a visual text format that makes it easy to understand.

Tera Term—A terminal program to access COM ports, supports Telnet communication Protocol. A debugging tool to eavesdrop on serial communications.

Note: Toolchains for GNU projects are available most processor architectures AVR, Coldfire, ARM, MIPS, PowerPC and Intel x86. The GNU-toolchain includes not only compilers for C, C++ and in most cases also Java (GCC = GNU Compiler Collection), but also Linkers, Assemblers and Debuggers together with C libraries (libc = C library). The tools are used from within other-open source projects, like WinAVR, which provides a familiar user interface to speed up program development.

MCU-Based Projects and Practical Tasks

Circuit Cellar’s January issue presents several microprocessor-based projects that provide useful tools and, in some cases, entertainment for their designers.

Our contributors’ articles in the Embedded Applications issue cover a hand-held PIC IDE, a real-time trailer-monitoring system, and a prize-winning upgrade to a multi-zone audio setup.

Jaromir Sukuba describes designing and building the PP4, a PIC-to-PIC IDE system for programming and debugging a Microchip Technology PIC18. His solar-powered,

The PP4 hand-held PIC-to-PIC programmer

The PP4 hand-held PIC-to-PIC programmer

portable computing device is built around a Digilent chipKIT Max32 development platform.

“While other popular solutions can overshadow this device with better UI and OS, none of them can work with 40 mW of power input and have fully in-house developed OS. They also lack PP4’s fun factor,” Sukuba says. “A friend of mine calls the device a ‘camel computer,’ meaning you can program your favorite PIC while riding a camel through endless deserts.”

Not interested in traveling (much less programming) atop a camel? Perhaps you prefer to cover long distances towing a comfortable RV? Dean Boman built his real-time trailer monitoring system after he experienced several RV trailer tire blowouts. “In every case, there were very subtle changes in the trailer handling in the minutes prior to the blowouts, but the changes were subtle enough to go unnoticed,” he says.

Boman’s system notices. Using accelerometers, sensors, and a custom-designed PCB with a Microchip Technology PIC18F2620 microcontroller, it continuously monitors each trailer tire’s vibration and axle temperature, displays that information, and sounds an alarm if a tire’s vibration is excessive.  The driver can then pull over before a dangerous or trailer-damaging blowout.

But perhaps you’d rather not travel at all, just stay at home and listen to a little music? This issue includes Part 1 of Dave Erickson’s two-part series about upgrading his multi-zone home audio system with an STMicroelectronics STM32F100 microprocessor, an LCD, and real PC boards. His MCU-controlled, eight-zone analog sound system won second-place in a 2011 STMicroelectronics design contest.

In addition to these special projects, the January issue includes our columnists exploring a variety of  EE topics and technologies.

Jeff Bachiochi considers RC and DC servomotors and outlines a control mechanism for a DC motor that emulates a DC servomotor’s function and strength. George Novacek explores system safety assessment, which offers a standard method to identify and mitigate hazards in a designed product.

Ed Nisley discusses a switch design that gives an Arduino Pro Mini board control over its own power supply. He describes “a simple MOSFET-based power switch that turns on with a push button and turns off under program control: the Arduino can shut itself off and reduce the battery drain to nearly zero.”

“This should be useful in other applications that require automatic shutoff, even if they’re not running from battery power,” Nisley adds.

Ayse K. Coskun discusses how 3-D chip stacking technology can improve energy efficiency. “3-D stacked systems can act as energy-efficiency boosters by putting together multiple chips (e.g., processors, DRAMs, other sensory layers, etc.) into a single chip,” she says. “Furthermore, they provide high-speed, high-bandwidth communication among the different layers.”

“I believe 3-D technology will be especially promising in the mobile domain,” she adds, “where the data access and processing requirements increase continuously, but the power constraints cannot be pushed much because of the physical and cost-related constraints.”

Arduino Uno Blueprint — Free Download

Elektor.Labs recently produced an Arduino Uno blueprint poster for element14. The poster details everything you need to know about the Arduino Uno.

Download it for free here.

Download your Arduino Uno poster

Download your Arduino Uno poster

The poster also includes coding notes that will get you working with your Arduino Uno in no time.

About the Arduino Uno:

  • Core Architecture: AVR
  • Core Sub-Architecture: megaAVR
  • Silicon Core: ATmega328
  • Features: The Arduino Uno is powered via USB or an external supply. It’s programmed with Arduino software.

Recent Arduino-related articles from Circuit Cellar:

 

Client Profile: Digi International, Inc

Contact: Elizabeth Presson
elizabeth.presson@digi.com

Featured Product: The XBee product family (www.digi.com/xbee) is a series of modular products that make adding wireless technology easy and cost-effective. Whether you need a ZigBee module or a fast multipoint solution, 2.4 GHz or long-range 900 MHz—there’s an XBee to meet your specific requirements.

XBee Cloud Kit

Digi International XBee Cloud Kit

Product information: Digi now offers the XBee Wi-Fi Cloud Kit (www.digi.com/xbeewificloudkit) for those who want to try the XBee Wi-Fi (XB2B-WFUT-001) with seamless cloud connectivity. The Cloud Kit brings the Internet of Things (IoT) to the popular XBee platform. Built around Digi’s new XBee Wi-Fi
module, which fully integrates into the Device Cloud by Etherios, the kit is a simple way for anyone with an interest in M2M and the IoT to build a hardware prototype and integrate it into an Internet-based application. This kit is suitable for electronics engineers, software designers, educators, and innovators.

Exclusive Offer: The XBee Wi-Fi Cloud Kit includes an XBee Wi-Fi module; a development board with a variety of sensors and actuators; loose electronic prototyping parts to make circuits of your own; a free subscription to Device Cloud; fully customizable widgets to monitor and control connected devices; an open-source application that enables two-way communication and control with the development board over the Internet; and cables, accessories, and everything needed to connect to the web. The Cloud Kit costs $149.