Time-Oriented Task Manager

…for 8-bit PIC Microcontrollers

For many new embedded applications, an 8-bit MCU is just right. Pedro
shows how to build a time-oriented task manager using Microchip’s PIC
16F628A 8-bit microcontroller.

By Pedro Bertoleti

Microcontrollers are everywhere. From a simple remote control to an advanced car embedded system, microcontrollers surround us all. But while an 8-bit microcontroller is a relatively simple device, the software on them can get more sophisticated as more functionality is added to embedded systems. One of the most interesting advances in software technique is managing tasks. That involves enabling a microcontroller to execute several scheduled tasks, ensuring periodic and precise time execution. Here, we will examine how to implement a time-oriented task manager for a simple microcontroller—in this case, a Microchip 8-bit PIC microcontroller.

A graphic representation of a time-oriented task manager and its tasks

A graphic representation of a time-oriented task manager and its tasks

A good place to start is to ask: What is a task? A task is a part of a software program that’s dedicated to do something exclusively. In other words, a task is a piece of software that can be implemented and executed as an independent software program. Take, for example, an embedded system that has to blink an LED, send something through the UART interface and check an input’s state. Each one of these activities can be defined as a task. In a general way, each function of an embedded system can be defined as a task. A time-oriented task manager is a piece of software that performs these three main activities:

  • Execute tasks periodically
  • Execute tasks in the amount of time specified for them
  • Ensure time-precision measurement for the execution of tasks

In terms of coding, the time-oriented task manager and the tasks are different parts of the same software program. ….

Read the full article in the September 326 issue of Circuit Cellar

Not a Subscriber yet? Become one today:


Or purchase the September 2017 issue at the  CC-Webshop

Two New PIC Families with Core-Independent Peripherals

Looking for an 8-bit microcontroller for an IoT application? Microchip Technology announced from ESC 2015 Silicon Valley two new 8-bit families that expand its growing portfolio of PIC microcontrollers with Core-Independent Peripherals (CIPs).

The PIC16F1579 and PIC16F18877 8-bit MCU families provide you with with a variety of intelligent options in low pin count packages and a wide operating voltage range.Microchip PIC16F157X

Both families offer the Peripheral Pin Select feature for flexible pin mapping and PCB routing to minimize EMI and crosstalk. Intended applications include consumer electronics, the Internet of Things (IoT), wearable technology and safety-critical systems.

The Curiosity Development Board costs $20. Pricing for the PICs starts at $0.51 each in 10,000-unit quantities.

Source: Microchip Technology

Microchip PICs with Integrated Crypto Engine

Anticipating the need for secure communications for the next level of device connectivity, Microchip Technology has integrated a complete hardware crypto engine into its PIC24F family of microcontrollers. Computers normally use software routines to carry out data encryption number crunching, but for low-power microcontrollers, this method will generally use up too much of the processor’s resources and be too slow.microchipPIC24FGB2

Microchip has integrated several security features into the PIC24F family of microcontrollers (identified by its “GB2” suffix) to protect embedded data. The fully featured hardware crypto engine supports the AES, DES and 3DES standards to reduce software overhead, lower-power consumption, and enable faster throughput. A Random Number Generator is also implemented that can be used to create random keys for data encryption, decryption, and authentication to provide a high level of security. For additional protection, the one-time-programmable (OTP) key storage prevents the encryption key from being read or overwritten.

These security features increase the integrity of embedded data without sacrificing power consumption. With XLP technology, the “GB2” family achieves 180-µA/MHz run currents and 18-nA sleep currents for long battery life in portable applications.

[via Elektor]

New 8-bit PIC Microcontrollers: Intelligent Analog & Core Independent Peripherals

Microchip Technology, Inc. announced Monday from EE Live! and the Embedded Systems Conference in San Jose the PIC16(L)F170X and PIC16(L)F171X family of 8-bit microcontrollers (MCUs), which combine a rich set of intelligent analog and core independent peripherals, along with cost-effective pricing and eXtreme Low Power (XLP) technology. Available in 14-, 20-, 28-, and 40/44-pin packages, the 11-member PIC16F170X/171X family of microcontrollers integrates two op-amps to drive analog control loops, sensor amplification and basic signal conditioning, while reducing system cost and board space.

PIC16F170X/171X MCUs reduce design complexity and system BOM cost with integrated op-amps, zero cross detect, and peripheral pin select.

PIC16F170X/171X MCUs reduce design complexity and system BOM cost with integrated op-amps, zero cross detect, and peripheral pin select.

These new devices also offer built-in Zero Cross Detect (ZCD) to simplify TRIAC control and minimize the EMI caused by switching transients. Additionally, these are the first PIC16 MCUs with Peripheral Pin Select, a pin-mapping feature that gives designers the flexibility to designate the pinout of many peripheral functions.

The PIC16F170X/171X are general-purpose microcontrollers that are ideal for a broad range of applications, such as consumer (home appliances, power tools, electric razors), portable medical (blood-pressure meters, blood-glucose meters, pedometers), LED lighting, battery charging, power supplies and motor control.

The new microcontrollers feature up to 28 KB of self-read/write flash program memory, up to 2 KB of RAM, a 10-bit ADC, a 5-/8-bit DAC, Capture-Compare PWM modules, stand-alone 10-bit PWM modules and high-speed comparators (60 ns typical response), along with EUSART, I2C and SPI interface peripherals. They also feature XLP technology for typical active and sleep currents of just 35 µA/MHz and 30 nA, respectively, helping to extend battery life and reduce standby current consumption.

The PIC16F170X/171X family is supported by Microchip’s standard suite of world-class development tools, including the PICkit 3 (part # PG164130, $44.95), MPLAB ICD 3 (part # DV164035, $189.99), PICkit 3 Low Pin Count Demo Board (part # DM164130-9, $25.99), PICDEM Lab Development Kit (part # DM163045, $134.99) and PICDEM 2 Plus (part # DM163022-1, $99.99). The MPLAB Code Configurator is a free tool that generates seamless, easy-to-understand C code that is inserted into your project. It currently supports the PIC16F1704/08, and is expected to support the PIC16F1713/16 in April, along with all remaining microcontrollers in this family soon thereafter.

The PIC16(L)F1703/1704/1705 microcontrollers are available now for sampling and production in 14-pin PDIP, TSSOP, SOIC and QFN (4 x 4 x 0.9 mm) packages. The PIC16F1707/1708/1709 microcontrollers are available now for sampling and production in 20-pin PDIP, SSOP, SOIC and QFN (4 x 4 x 0.9 mm) packages. The PIC16F1713/16 MCUs are available now for sampling and production in 28-pin PDIP, SSOP, SOIC, QFN (6 x 6 x 0.9 mm) and UQFN (4 x 4 x 0.5 mm) packages. The PIC16F1718 microcontrollers are expected to be available for sampling and production in May 2014, in 28-pin PDIP, SSOP, SOIC, QFN (6 x 6 x 0.9 mm) and UQFN (4 x 4 x 0.5 mm) packages. The PIC16F1717/19 microcontrollers are expected to be available for sampling and production in May 2014, in 40/44-pin PDIP, TQFP and UQFN (5 x 5 x 0.5 mm). Pricing starts at $0.59 each, in 10,000-unit quantities.

Source: Microchip Technology, Inc.

An Engineer Who Retires to the Garage

Jerry Brown, of Camarillo, CA, retired from the aerospace industry five years ago but continues to consult and work on numerous projects at home. For example, he plans to submit an article to Circuit Cellar about a Microchip Technology PIC-based computer display component (CDC) he designed and built for a traffic-monitoring system developed by a colleague.

Jerry Brown sits at his workbench. The black box atop the workbench is an embedded controller and is part of a traffic monitoring system he has been working on.

Jerry Brown sits at his workbench. The black box atop the workbench is an embedded controller and part of  his traffic monitoring system project.

“The traffic monitoring system is composed of a beam emitter component (BEC), a beam sensor component (BSC), and the CDC, and is intended for unmanned use on city streets, boulevards, and roadways to monitor and record the accumulative count, direction of travel, speed, and time of day for vehicles that pass by a specific location during a set time period,” he says.

Brown particularly enjoys working with PWM LED controllers. Circuit Cellar editors look forward to seeing his project article. In the meantime, he sent us the following description and pictures of the space where he conceives and executes his creative engineering ideas.

Jerry's garage-based lab.

Brown’s garage-based lab.

My workspace, which I call my “lab,” is on one side of my two-car garage and is fairly well equipped. (If you think it looks a bit messy, you should have seen it before I straightened it up for the “photo shoot.”)  

I have a good supply of passive and active electronic components, which are catalogued and, along with other parts and supplies, are stored in the cabinets and shelves alongside and above the workbench. I use the computer to write and compile software programs and to program PIC flash microcontrollers.  

The photos show the workbench and some of the instrumentation I have in the lab, including a waveform generator, a digital storage oscilloscope, a digital multimeter, a couple of power supplies, and a soldering station.  

The black box visible on top of the workbench is an embedded controller and is part of the traffic monitoring system that I have been working on.

Instruments in Jerry's lab include a waveform generator, a digital storage oscilloscope, a digital multimeter, a couple of power supplies, and a soldering station.

Instruments in Brown’s lab include a waveform generator, a digital storage oscilloscope, a digital multimeter, a couple of power supplies, and a soldering station. 

Brown has a BS in Electrical Engineering and a BS in Business Administration from California Polytechnic State University in San Luis Obispo, CA. He worked in the aerospace industry for 30 years and retired as the Principal Engineer/Manager of a Los Angeles-area aerospace company’s electrical and software design group.

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.”

Wi-Fi-Connected Home Energy Monitor

The Kunzig brothers of Pennsylvania use the word “retired” loosely.

Donald and Robert are both retired—each from long careers in the telecommunications industry. And after retirement, each took on a new job (Donald developing software to track and manage clinical trials managed by BioClinica, Inc., and Robert at a large data center).

So while other semi-retirees might prefer relaxing in poolside chairs or on the couch, what do these two do? They eagerly take on some technologies they haven’t worked with before and build a Wi-Fi-connected device to monitor a home’s power usage. And after two years of trial, error, and, finally, success, they develop an e-commerce website to sell it.

“Robert’s son, Jay, a design engineer working in San Jose, CA, suggested the project,” the two brothers say in article they wrote for the May 2013 edition of Circuit Cellar. “The main purpose was to design a Wi-Fi-connected monitor that would be able to measure usage from both a utility and an alternate source of power such as solar or wind.”

Their article describes how they designed a usable device that offers programmability and function. They used a Microchip MRF24WB0MB 802.11 transceiver for Wi-Fi access and a Microchip Technology PIC24FJ256GB108 microprocessor in their design. They eventually wrote the article about the ups and downs of the process (which included five prototypes) because they felt elements of their work would help readers developing their own embedded electronics devices.

“All this effort has been rewarding, perhaps not financially (yet), but certainly intellectually,” the brothers say. “After almost two years of effort, we have produced a product with an excellent hardware design, coupled with software that is better than average. The platform can be used for just about any implementation.”

“We wanted to produce an energy monitor that was fully wireless, very accurate, extremely easy to use, and based on hardware and software that is very stable. We think we were successful on all counts.”

Check out the May issue of Circuit Cellar for their article. And for more information, visit their e-commerce website at www.wattsmyusage.com.