Microcontroller-Based Air Quality Mapper

Raul Alvarez Torrico’s Air Quality Mapper is a portable device designed to track levels of CO2 and CO gasses for constructing “Smog Maps” to determine the healthiest routes. Featuring a Renesas RDKRL78G13 development board, the Mapper receives location data from its GPS module, takes readings of the CO2 and CO concentrations along a specific route, and stores the data in an SD card. With the aid of PC utility software, you can upload the data to a web server and see maps of gas concentrations in a web browser.

air q

The portable data logger prototype

In his Circuit Cellar 293 article (December 2014), Torrico notes:

My design, the Air Quality Mapper, is a data-logging, online visualization system comprising a portable data logger and a webserver for the purpose of measuring and visualizing readings of the quality of air in given areas. You take readings over a given route and then upload the data to the server, which in turn serves a webpage containing a graphical representation of all readings using Google Maps technology.

The webpage displaying CO2 measurements acquired in a session

The webpage displaying CO2 measurements acquired in a session

The data logging system features a few key components: a Renesas YRDKRL78G13 development board,  a Polstar PMB-648 GPS module, an SD card, and gas sensors.

The portable data logger hardware prototype is based on the Renesas YRDKRL78G13 development board, which contains a Renesas R5F100LEA 16-bit microcontroller with 64 KB of program memory, 4 KB of data flash memory, and 4 KB of RAM, running from a 12-MHz external crystal…

Air Quality Mapper system

Air Quality Mapper system

The board itself is a bit large for a portable or hand-held device (5,100 x 5,100 mils); but on the other hand, it includes the four basic peripherals I needed for the prototype: a graphic LCD, an SD card slot, six LEDs, and three push buttons for the user interface. The board also includes other elements that could become very handy when developing an improved version of the portable device: a three-axis accelerometer, a temperature sensor, ambient light sensor, a 512-KB serial EEPROM, a small audio speaker, and various connection headers (not to mention other peripherals less appealing for this project: an audio mic, infrared emitter and detector, a FET, and a TRIAC, among other things). The board includes a Renesas USB debugger, which makes it a great entry-level prototyping board for Renesas RL78/G13 microcontrollers.

For the GPS module, I used a Polstar PMB-648 with 20 parallel satellite-tracking channels. It’s advertised as a low-power device with built-in rechargeable battery for backup memory and RTC backup. It supports the NMEA0183 v2.2 data protocol, it includes a serial port interface, and it has a position accuracy 2DRMS of approximately 5 m and velocity accuracy of 0.1 m per second without selective availability imposed. It has an acquisition time of 42 s from a cold start and 1 s from a hot start. It also includes a built-in patch antenna and a 3.3- to 5-V power supply input.

The GPS module provides NMEA0183 V2.2 GGA, GSV, GSA, and RMC formatted data streams via its UART port. A stream comes out every second containing, among other things, latitude, longitude, a timestamp, and date information. In the system, this module connects to the R5F100LEA microcontroller’s UART0 port at 38,400 bps and sources the 3.3-VDC power from the YRDKRL78G13 board.

For the CO2 sensor, I used a Hanwei Electronics Co. MG-811 sensor, which has an electrolyte that in the presence of heat reacts in proportion to the CO2 concentration present in air. The sensor has an internal heating element that needs to be powered with 6 VDC or 6 VAC. For small CO2 concentrations, the sensor outputs a higher voltage, and for high concentrations the output voltage decreases. Because I didn’t have proper calibration instrumentation at hand for this type of sensor, I made a very simple calibration process just by exposing the sensor to a “clean air” environment outside the city. I took an average of various readings in a 15-minute period to define a 400-PPM concentration, which is generally defined as the average for a clean air environment. Not an optimal calibration method of course, but I thought it was acceptable to get some meaningful data for prototyping purposes. For a proper calibration of the sensor, I would’ve needed another CO2 sensing system already calibrated with a high degree of accuracy and a set up in a controllable environment (e.g., a laboratory) in order to generate and measure the amount of CO2.

This sensor provides an output voltage between 30 and 50 mV. And due to their high output impedance, the signal must be properly conditioned with an op-amp. So, I used a Microchip Technology MCP6022 instrumentation amplifier in a noninverting configuration with a gain of 9.2.

You can read the complete article in Circuit Cellar 293 (December 2014).

The Sun Chaser Energy-Harvesting System

When Sjoerd Brandsma entered the 2012 Renesas Green Energy Challenge, he wanted to create a fun project that would take advantage of his experience at a company that heavily uses GPS.

Brandsma, who lives in Kerkwijk, The Netherlands, has worked as a software engineer and is currently an R&D manager at CycloMedia, which produces 360° street-level panoramic images with geographic information system (GIS) accuracy.

Ultimately, Brandsma’s Sun Chaser project won third prize in the Renesas Green Energy Challenge. The Sun Chaser is an energy-harvesting system that automatically orients a solar panel to face the sun.

Photo 1: The Sun Chaser’s stepper motor controls the solar panel‘s “tilting.”

Photo 1: The Sun Chaser’s stepper motor controls the solar panel‘s “tilting.”

“The Sun Chaser perfectly follows the sun’s path and keeps the battery fully charged when there’s enough sunlight,” Brandsma says in his article about the project, which appears in Circuit Cellar’s June issue. ”It can power a small electronics system as long as there’s enough sunlight and no rain, which would damage the system due to lack of protection. This project also demonstrates that it’s possible to build an interesting green-energy system with a tight budget and a limited knowledge of  electronics.”

A registered GPS calculates the orientation of the Sun Chaser’s solar panel, which is mounted on a rotating disc. “You can use an external compass, the internal accelerometer, a DC motor, and a stepper motor to determine the solar panel’s exact position,” Brandsma says. “The Sun Chaser uses Renesas Electronics’s RDKRL78G13 evaluation board running the Micriµm µC/OS-III real-time kernel.”

The following article excerpt describes the GPS reference station and evaluation board in greater detail. The issue with Brandsma’s full article is available online for membership download or single-issue purchase.

GPS REFERENCE STATION
Whenever you want to know where you are, you can use a GPS receiver that provides your position. A single GPS receiver can provide about 10 to 15 m (i.e., 33’ to 50’) position accuracy. While this is sufficient for many people, some applications require positioning with significantly higher accuracy. In fact, GPS can readily produce positions that are accurate to 1 m (3’), 0.5 m (18”), or even 1 to 2 cm (less than 1“). A technique called “differential GPS” can be used to achieve higher accuracy.

The differential technique requires one GPS receiver to be located at a known position (often called a control or reference point) and a second “rover” receiver at the location to be measured. The information from the two GPS receivers (rover and control) is combined to determine the rover’s position. That’s where a GPS reference station comes in. It functions as the control point and serves potentially unlimited users and applications. Leica Geosystems has published an excellent introductory guide about GPS reference stations (Refer to the Resources at the end of this article.)

The GPS reference station should always be located at a position with a broad sight. In some situations it can be difficult to provide a decent power supply to the system. When regular power isn’t available, a solar panel can power the GPS reference station.

My Sun Chaser GPS reference station uses a 10-W solar panel connected to a 12-V battery to provide enough power. To increase the energy harvesting, the solar panel is mounted on a rotating disc that can be controlled by a DC motor to point in the desired direction. A stepper motor controls the solar panel’s “tilting.” Photo 1 highlights the main components.

USING THE EVALUATION BOARD
The RDKRL78G13 is an evaluation and demonstration tool for Renesas Electronics’s RL78 low-power microcontrollers. A set of human-machine interfaces (HMIs) is tightly integrated with the RL78’s features. I used several of these interfaces to control other devices, read sensors, or store data.

Most of the system’s hardware is related to placing the solar panel in the correct position. Figure 1 shows the top-level components used to store the GPS information and position the solar panel.

Figure 1: The Sun Chaser’s components include a Renesas Electronics RDKRL78G13 evaluation board, a GPS receiver, a stepper motor, and an SD card.

Figure 1: The Sun Chaser’s components include a Renesas Electronics RDKRL78G13 evaluation board, a GPS receiver, a stepper motor, and an SD card.

The RDKRL78G13 evaluation board has an on-board temperature and light sensor. Both sensor values are stored on the SD card. The on-board light sensor is used to determine if rotating/tilting makes sense (at night it’s better to sleep). For this project, the temperature values are stored just for fun so I could make some graphs or do some weather analysis.

A micro-SD memory card slot on the RDKRL78G13 evaluation board provides file system data storage. I used it to store all incoming data and log messages using the FAT16/FAT32 file system.

The on-board Renesas Electronics RQK0609CQDQS MOSFET controls the DC motor that rotates the evaluation board. The DC motor can be controlled by applying a PWM signal generated from one of the RL78’s timers. The MOSFET is controlled by the RL78’s TO05 port and powered from the 12-V battery. A PWM signal is generated on TO05 by using Timer4 as a master and Timer5 as a slave. It’s only necessary to rotate clockwise, so additional hardware to rotate the platform counterclockwise is not required.

A digital compass is needed to determine the evaluation board’s rotated position or heading (see Figure 2). The Honeywell HMC5883L is a widely used and low-cost compass. This I2C-based compass has three-axis magnetoresistive sensors and a 12-bit ADC on board. It can read out values at a 160-Hz rate, which is more than enough for this project.

Figure 2: A Honeywell HMC5883L digital compass verifies the evaluation board’s rotated position or heading.

Figure 2: A Honeywell HMC5883L digital compass verifies the evaluation board’s rotated position or heading.

The compass uses the RL78’s IICA0 port through the Total Phase Beagle debug header, which is mounted on the RDKRL78G13 evaluation board. The Beagle analyzer provides easy access to this I2C port, which increases the flexibility to change things during prototyping.

The HMC5883L compass turned out to be a very sensitive device. Even the slightest change in the hardware setup seemed to influence the results when rotating. This meant some sort of calibration was needed to ensure the output was consistent every time the system started. [Brandsman’s full article descibes how how the HMC5883L can be calibrated. It’s important to know that every time the system starts, it makes a full turn to calibrate the compass.

A GPS module must be connected to the system to provide the system’s current location. I wanted the GPS module to be inexpensive, 3.3-V based, and have an easy and accessible interface (e.g., UART).

Figure 3 shows a schematic of a Skylab M&C Technology SKM53 GPS module, which is based on the MediaTek 3329 GPS receiver module. This module supports NMEA messages and the MTK NMEA Packet Protocol interface to control things such as power saving, output message frequency, and differential global positioning system (DGPS).

Unfortunately, the 3329 receiver can’t output “raw” GPS data (e.g., pseudorange, integrated carrier phase, Doppler shift, and satellite ephemeris), which would significantly improve the GPS reference station’s capabilities. Due to budget and time limitations (it takes some more software development effort to handle this raw data), I didn’t use a receiver that could output raw GPS data.

Figure 3:A Skylab M&C Technology SKM53 GPS receiver obtains the system’s current location.

Figure 3:A Skylab M&C Technology SKM53 GPS receiver obtains the system’s current location.

The SKM53 GPS receiver is connected to the RL78’s UART2. All data from the GPS receiver is stored on the SD card. As soon as a valid GPS position is received, the system calculates the sun’s position and moves the platform into the most ideal position.

A compact stepper motor is needed to tilt the platform in very small steps. The platform had to be tilted from fully vertical to fully horizontal in approximately 6 h when the sun was exactly following the equator, so speed wasn’t really an issue. I wanted to do very fine tilting, so I also needed a set of gears to slow down the platform tilting.

I used an inexpensive, easy-to-use, generic 5-V 28BYJ-48 stepper motor (see Figure 4). According to the specifications, the 28BYJ-48 stepper motor has a 1/64 gear reduction ratio and 64 steps per rotation (5.625°/step) of its internal motor shaft.

An important consideration here is that you don’t want to retain power on the stepper motor to keep it in position. This particular stepper motor has some internal gears that prevent the platform from flipping back when the stepper motor is not powered.

The stepper motor can be controlled by the well-known ULN2003 high-voltage high-current Darlington transistor array. The ULN2003 is connected to P71-P74. Each of the ULN2003’s four outputs is connected to one of the stepper motor’s coils. When two neighbor coils are set high (e.g., P72 and P73), the stepper motor will step in that direction.

When it comes to solar panels, you can build your own panel out of individual solar cells or buy a fully assembled one with known specifications. I used a no-name 10-W solar panel. The size (337 mm long × 205 mm wide × 18 mm high) was acceptable and it delivered more than enough energy. I used a charge controller to protect the battery from overcharging and to prevent it from supplying power to the solar panel at night.

Like solar panels, many charge controllers and battery protectors can be used in such a system. I chose the lazy approach: Just take one off the shelf. The CMP12/24 charge controller is specially designed for small solar systems. It has a stabilized 12-V output, which is taken from the connected battery. It can handle up to 12 A of charging or load current and, according to the specifications, it consumes about 20 mA of quiescent current. There is some room for improvement, but it worked for my project.

I had some 7805 voltage regulators lying around, which I figured could do the job and supply just enough power when the system was starting up. However, when it comes to power saving, the 7805 is not the way to go. It’s a linear regulator that works by taking the difference between the input and output voltages and burning it up as wasted heat.

What I needed was a switching regulator or a buck converter. I used a National Semiconductor (now Texas Instruments) LM2596. Note: The LM2596 is made by several companies and is available in inexpensive, high-quality modules (most cost a little more than $1 per converter). These ready-to-use modules already have the necessary capacitors, diodes, and so forth on board, so it’s really a matter of plug and play.

I used a lead acid RT1219 12-V 1.9-AH battery for power storage. You can use any 12-V battery with sufficient capacity.

Editor’s Note: Check out other projects from the 2012 Renesas RL78 Green Energy Challenge.

MCU-Based Experimental Glider with GPS Receiver

When Jens Altenburg found a design for a compass-controlled glider in a 1930s paperback, he was inspired to make his own self-controlled model aircraft (see Photo 1)

Photo 1: This is the cover of an old paperback with the description of the compass-controlled glider. The model aircraft had a so-called “canard” configuration―a very modern design concept. Some highly sophisticated fighter planes are based on the same principle. (Photo used with permission of Ravensburger.)

Photo 1: This is the cover of an old paperback with the description of the compass-controlled glider. The model aircraft had a so-called “canard” configuration―a very modern design concept. Some highly sophisticated fighter planes are based on the same principle. (Photo used with permission of Ravensburger.)

His excellent article about his high-altitude, low-cost (HALO) experimental glider appears in Circuit Cellar’s April issue. The MCU-based glider includes a micro-GPs receiver and sensors and can climb to a preprogrammed altitude and find its way back home to a given coordinate.

Altenburg, a professor at the University of Applied Sciences Bingen in Germany, added more than a few twists to the 80-year-old plan. An essential design tool was the Reflex-XTR flight simulation software he used to trim his 3-D glider plan and conduct simulated flights.

Jens also researched other early autopilots, including the one used by the Fiesler Fi 103R German V-1 flying bomb. Known as buzz bombs during World War II, these rough predecessors of the cruise missile were launched against London after D-Day. Fortunately, they were vulnerable to anti-aircraft fire, but their autopilots were nonetheless mechanical engineering masterpieces (see Figure 1)

“Equipped with a compass, a single-axis gyro, and a barometric pressure sensor, the Fiesler Fi 103R German V-1 flying bomb flew without additional control,” Altenburg says. “The compass monitored the flying direction in general, the barometer controlled the altitude, and the gyro responded to short-duration disturbances (e.g., wind gusts).”

Figure 1: These are the main components of the Fieseler Fi 103R German V-1 flying bomb. The flight controller was designed as a mechanical computer with a magnetic compass and barometric pressure sensor for input. Short-time disturbances were damped with the main gyro (gimbal mounted) and two auxiliary gyros (fixed in one axis). The “mechanical” computer was pneumatically powered. The propeller log on top of the bomb measured the distance to the target.

Figure 1: These are the main components of the Fieseler Fi 103R German V-1 flying bomb. The flight controller was designed as a mechanical computer with a magnetic compass and barometric pressure sensor for input. Short-time disturbances were damped with the main gyro (gimbal mounted) and two auxiliary gyros (fixed in one axis). The “mechanical” computer was pneumatically powered. The propeller log on top of the bomb measured the distance to the target.

Altenburg adapted some of the V-1’s ideas into the flight control system for his 21st century autopilot glider. “All the Fi 103R board system’s electromechanical components received an electronic counterpart,” he says. “I replaced the mechanical gyros, the barometer, and the magnetic compass with MEMS. But it’s 2014, so I extended the electronics with a telemetry system and a GPS sensor.” (See Figure 2)

Figure 2: This is the flight controller’s block structure. The main function blocks are GPS, CPU, and power. GPS data is processed as a control signal for the servomotor.

Figure 2: This is the flight controller’s block structure. The main function blocks are GPS, CPU, and power. GPS data is processed as a control signal for the servomotor.

His article includes a detailed description of his glider’s flight-controller hardware, including the following:

Highly sophisticated electronics are always more sensitive to noise, power loss, and so forth. As discussed in the first sections of this article, a glider can be controlled by only a magnetic compass, some coils, and a battery. What else had to be done?

I divided the electronic system into different boards. The main board contains only the CPU and the GPS sensor. I thought that would be sufficient for basic functions. The magnetic and pressure sensor can be connected in case of extra missions. The telemetry unit is also a separate PCB.

Figure 3 shows the main board. Power is provided by a CR2032 lithium coin-cell battery. Two low-dropout linear regulators support the hardware with 1.8 and 2.7 V. The 1.8-V line is only for the GPS sensor. The second power supply provides the CPU with a stable voltage. The 2.7 V is the lowest voltage for the CPU’s internal ADC.

It is extremely important for the entire system to save power. Consequently, the servomotor has a separate power switch (Q1). As long as rudder movement isn’t necessary, the servomotor is powered off. The servomotor’s gear has enough drag to hold the rudder position without electrical power. The servomotor’s control signal is exactly the same as usually needed. It has a 1.1-to-2.1-ms pulse time range with about a 20-ms period. Two connectors (JP9 and JP10) are available for the extension boards (compass and telemetry)..

I used an STMicroelectronics LSM303DLM, which is a sensor module with a three-axis magnetometer and three-axis accelerometer. The sensor is connected by an I2C bus. The Bosch Sensortec BMP085 pressure sensor uses the same bus.

For telemetry, I applied an AXSEM AX5043 IC, which is a complete, narrow-band transceiver for multiple standards. The IC has an excellent link budget, which is the difference between output power in Transmit mode and input sensitivity in Receive mode. The higher the budget, the longer the transmission distance.

The AX5043 is also optimized for battery-powered applications. For modest demands, a standard crystal (X1, 16-MHz) is used for clock generation. In case of higher requirements, a temperature-compensated crystal oscillator (TCXO) is recommended.

The main board’s hardware with a CPU and a GPS sensor is shown. A CR2032 lithium coin-cell battery supplies the power. Two regulators provide 1.8  and 2.7 V for the GPS and the CPU. The main outputs are the servomotor’s signal and power switch.

Figure 3: The main board’s hardware with a CPU and a GPS sensor is shown. A CR2032 lithium coin-cell battery supplies the power. Two regulators provide 1.8 and 2.7 V for the GPS and the CPU. The main outputs are the servomotor’s signal and power switch.

Altenburg’s article also walks readers through the mathematical calculations needed to provide longitude, latitude, and course data to support navigation and the CPU’s most important sensor— the u-blox Fastrax UC430 GPS. He also discusses his experience using the Renesas Electronics R5F100AA microcontroller to equip the prototype board. (Altenburg’s glider won honorable mention in the 2012 Renesas RL78 Green Energy Challenge, see Photos 2 and 3).

The full article is in the April issue, now available for download by members or single-issue purchase.

One of the final steps is mounting the servomotor for rudder control. Thin cords connect the servomotor horn and the rudder. Two metal springs balance mechanical tolerances.

Photo 2: One of the final steps is mounting the servomotor for rudder control. Thin cords connect the servomotor horn and the rudder. Two metal springs balance mechanical tolerances.

Photo 2: This is the well-equipped high-altitude low-cost (HALO) experimental glider.

Photo 3: This is the well-equipped high-altitude low-cost (HALO) experimental glider.

RL78 Challenge Winner’s Workspace in Lewisville, TX

Lewisville, TX-based electrical engineer Michael Hamilton has been a busy man. During the past 10 years, he created two companies: A&D Technologies, which supplies wireless temperature and humidity controllers, and Point & Track, which provides data-gathering apps and other business intelligence tools. And in his spare time, he designed a cloud electrofusion machine for welding 0.5″ to 2″ polyethylene fittings. It  won Second Prize in the 2012 Renesas RL78 Green Energy Challenge.

In an interview slated for publication in Circuit Cellar 273 (April 2013), Hamilton describes some of his projects, shares details about his first microcontroller design, and more.

Michael Hamilton in his workspace. Check out the CNC machine and 3-D printer.

During the interview process, he also provided a details about his workspace, in which he has a variety of interesting tools ranging from a CNC machine to a MakerBot 3-D printer. Hamilton said:

I have a three-axis CNC machine and MakerBot 3-D printer. I use the CNC machine to cut out enclosures and the 3-D printer to create bezels for LCDs and also to create 3-D prototypes. These machines are extremely useful if you need to make any precise cuts or if you want to create 3-D models of future products.

Hamilton also noted:

I recently purchased a Rigol Technologies DSA-815-TG spectrum analyzer. This device is a must-have, right behind the oscilloscope. It enables you to see all the noise/interference present in a PCB design and also test it for EMI issues.

Michael Hamilton’s test bench and DSA815

He has a completely separate area for PCB work.

A separate space for PCB projects

Overall, this is an excellent setup. Hamilton clearly has a nice collection must-have EE tools and test equipment, as well as a handy CNC machine and decent desktop storage system. The separate PCB bench is a great feature that helps keep the space orderly and clean.

As for the 3-D printer, well, it’s awesome.

Design a Low-Power System in 2013

A few months ago, we listed the top design projects from the Renesas RL78 Green Energy Challenge. Today, we’re excited to announce that Circuit Cellar‘s upcoming 25th anniversary issue will include a mini-challenge featuring the RL78. In the issue, you’ll learn about a new opportunity to register for an RL78/G14 demonstration kit that you can use to build a low-power design.

Renesas RL78

The RL78/G14 demonstration kit (RDK) is a handy evaluation tool for the RL78/G14 microcontrollers. Several powerful compilers and sample projects will be offered either free-of-charge (e.g., the GNU compiler) or with a code-size-limited compiler evaluation license (e.g., IAR Systems).  Also featured will be user-friendly GUIs, including the Eclipse-based e2studio.

RL78G14 RDK KIT

  • 32-MHz RL78/G14 MCU board with integrated debugger and huge peripheral, including Wi-Fi, E Ink display, matrix LCD, audio ports, IR ports, motor control port, FET and isolated triac interfaces
  •  256-KB On-chip flash
  • USB Debugger cable
  • Four factory demos showcasing local and cloud connectivity through Wi-Fi

The CC25 anniversary issue is now available.