Quantcast
Channel: Embedded Lab
Viewing all 713 articles
Browse latest View live

Real-time sound spectrography using Atmega1284

$
0
0

A sound spectrogram is a visual representation of the frequency components contained in an audio signal. The device that generates the spectrogram is called spectrograph. In a spectrogram, the horizontal axis is time and the vertical axis represents frequency. The spectrogram is color coded or gray-scaled to represent the relative intensity of the sound in each frequency region and time. Some of the applications of spectrograms are speech analysis and enhancement, studying bird and animal calls, music formation, etc. During pre-computer era, the spectrograms were generated using analog techniques that involved a series of bandpass filters. With the advent of digital signal processing, the most common approach of doing sound spectrography these days is through Fast Fourier Transform (FFT) of the time domain audio signal. Varun, Hyun, and Madhuri are EE students at Cornell and they have implemented a FFT-based real-time sound spectrography using two Atmega1284 processors as their final project for the ECE4760 Digital Systems Design Using Microcontrollers class. The two processors have different responsibilities. The first one is a dedicated audio processor, which receives the input audio signal from a 3.5mm audio jack or microphone, digitize it, and convert it into frequency domain using a 128-point FFT. The second processor is in charge of receiving the FFT data from the Audio processor and generating and outputting a real-time 4-bit grayscale histogram on a TV screen in real-time. Tact switch inputs are also implemented to allow the user to control play/stop, or to change the scrolling speed and the vertical scaling of the display.

Real-time sound spectrography using Atmega1284

Real-time sound spectrography using Atmega1284

Here is their demo video.

The post Real-time sound spectrography using Atmega1284 appeared first on Embedded Lab.


Bluetooth controlled robot car

$
0
0

Christine and Shela‘s final project for the ECE4760 (Digital Systems Design Using Microcontrollers) class they took this fall was a Bluetooth controlled car with a dedicated remote control device. The car and the remote both uses Atmega1248P microcontrollers and HC-05 Bluetooth transceiver modules. The remote also consists of a MPU-6050 gyroscope/accelerometer module on board to sense the tilting angle of the remote. Once the two Bluetooth units are paired, the remote control device continuously sends out the tilt angle data to the car. The Atmega1248P on board the car then linearly maps the tilt angles to the the duty cycles of the PWM signals controlling the motors, thus varying the speed according to the tilt angle. Based on the direction you tilt the remote, the car will also move to forward, backward, left and right directions.

Bluetooth controlled car with a remote

Bluetooth controlled car with a remote

Watch the car in action below.

The post Bluetooth controlled robot car appeared first on Embedded Lab.

Single digit Nixie clock driven by PIC16F84A

$
0
0

This IN-18 Nixie tube clock project  utilizes the PIC16F84A microcontroller and displays hours and minutes on a single tube. The circuitry is simple and the author used salvaged parts from a disposable camera to construct the high voltage power supply required for the Nixie tube. The time is displayed in the single digit by periodically flashing the digits from tens of hours to minutes. A tact switch is also implemented to set the time. It has to be pushed when the digit you want to change is being displayed. The current display is increased by one each time the switch is pressed and cycle through 0-9.

Single digit nixie clock

Single digit nixie clock

The post Single digit Nixie clock driven by PIC16F84A appeared first on Embedded Lab.

Circuit printer: A rapid prototyping machine for electrical circuits

$
0
0

Another interesting micrcontroller-based design project done by Bruce Land‘s students at Cornell this fall is a circuit printer, a rapid prototyping machine that prints electrical circuits on a piece of paper. Designed by Connor Archard and Feiran Chen, this printer uses an electrically conductive ink pen to rapidly create circuits. The circuit to be printed is drawn through an Web-app and can be sent to the printer from anywhere in the local area network.

Circuit printer machine

Circuit printer machine

As shown in the following demo video, the Web-app allows users to draw out circuits quickly, converts them into vectors and then send them out frame by frame over a WiFi network to the server, which in turn communicates with an Atmega1284P microcontroller embedded into the printer. The Atmega1284P then controls the x and y-axis motors, and raises and lowers the pen as instructed to print the circuit. By measuring the position of the plotter head on each axis through the on-chip ADC and two servo potentiometers, the Atmega1284P processor is able to control the plotter head with an accuracy of approximately 1/10th of an inch on a typical piece of A4 paper.

Connor and Feiran have the following vision about their project,
This idea is aimed to make mass prototyping circuits on flexible surfaces so cheap and easy, and we see a great potential for this product both in industry and remote education. For future improvement, we are thinking of supporting multi-layer, multi-dimension circuits, and designing our own mechanics and support frame for the machine.

The post Circuit printer: A rapid prototyping machine for electrical circuits appeared first on Embedded Lab.

Breadboard adapter for ESP8266 module

$
0
0

ESP8266 is an inexpensive serial-to-wifi tranceiver chip that allows to connect any microcontroller with a serial port to a WiFi network. Because of its simplicity and low cost, it is getting popular among hobbyists for building Internet of Things (IoT) applications. While there are varieties of breakout boards available for ESP8266 from the Chinese markets, the most popular one is the ESP-01 version that provides access to the ESP8266 pins through a 2×4 male header. While the headers are 0.1″ pitch, the pin arrangements are not breadboard friendly, which makes it little inconvenient for breadboarding. I have designed a very simple breadboard friendly adapter (shown below) to make prototyping with the ESP-01 module easier.

ESP8266 breadboard adapter

ESP8266 breadboard adapter

The adapter has a 2×4 female header to receive the ESP-01 module and a 10uF power supply filter on board. The ESP-01 module pins are accessible through two single row headers that are breadboard friendly.

ESP82663

ESP-01 module plugged into the breadboard adapter

If you are interested, you can get this adapter from our Tindie Store.

ESP82662

ESP8266 adapter kit

Buy ESP8266 breadboard adapter kit

The post Breadboard adapter for ESP8266 module appeared first on Embedded Lab.

Selfiebot: An autonomous photo capturing system

$
0
0

Two Cornell University students, Michael Wang and Jennifer Qian, have built Selfiebot, a personal photo companion that will capture your special moments autonomously. It consists of a physical selfie robot unit with camera holder (webcam in this example) that can pan and tilt the camera for proper positioning, and a control module residing in a laptop computer that relays pan and tilt commands to the robot based on the feedback received from the camera. The user gets control of various settings such as image properties, centering properties, and photo taking parameters.

Michael and Jennifer write,

We have designed and constructed an autonomous photo capturing system that detects and tracks faces, centers subjects in the frame, and takes pictures. Since the most straightforward application for our robot is to take pictures of oneself without the aid of others, we have fittingly dubbed our system the “Selfiebot”. When operating our device, the user may specify a variety of preferences through its simple GUI, including contrast, brightness, centering options, the number of people to capture, and the number of pictures to take.

Our system processes images taken from a webcam on a laptop computer, using facial detection to track subjects, and forms movement commands to center the subjects based on face positions. The laptop sends the commands to an ATmega1284 microcontroller via serial communication, and the microcontroller controls the movement of two servos on the robot. These two servos correspond with panning and tilting actions, allowing for two dimensional movement of the camera. Feedback from the camera is used to continuously update movement.

Selfiebot personal photo companion

Selfiebot personal photo companion

Check out there demo video below.

The post Selfiebot: An autonomous photo capturing system appeared first on Embedded Lab.

Embedded Lab wishes you a very happy new year

$
0
0

Christmas is over and we are now geared up to say good bye to 2014 and welcome to 2015. Embedded Lab would like to wish all of our readers, supporters, and contributors a very happy and prosperous new year. May 2015 bring you all the great things in your life.

And here is the last discount coupon for this year. The discount offer starts now and will run until Jan 1st, 2015.

15% OFF using the code: 6BCF43D

Applicable to all serial seven segment LED displays, Easy Pulse sensor, and cascadable LED matrix displays.

If you are not familiar with latest Easy Matrix displays, check out this cool Bluetooth controlled scrolling LED matrix display project using these modules.

Easy Matrix display

Scrolling Easy Matrix display with Bluetooth control

Thanks a lot for your support!

The post Embedded Lab wishes you a very happy new year appeared first on Embedded Lab.

Using BMP180 for temperature, pressure and altitude measurements

$
0
0

The BMP180 is a new generation digital barometric pressure and temperature sensor from Bosch Sensortec. In this tutorial, we will briefly review this device and describe how to interface it with an Arduino Uno board for measuring the surrounding temperature and pressure. We will also discuss about retrieving the sensor altitude from its pressure readings.

asass

Temperature, pressure and altitude measurements using BMP180

Experiment setup

Bosch Sensortag’s BMP180 is an ultra low-power digital temperature and pressure sensor with high accuracy and stability. It consists of a piezo-resistive sensor, an analog to digital converter and a control unit with EEPROM and a serial I2C interface. The raw measurements of pressure and temperature from the BMP180 sensor has to be compensated for temperature effects and other parameters using the calibration data saved into the EEPROM. In this tutorial, we will use an Arduino board to read the temperature and barometric pressure measurements from the BMP180 sensor and display the data on an 1.44″ ILI9163-based TFT display. If you would like to repeat this experiment, you will need the following things.

1. Any Arduino board running at 3.3V. I am using Crowduino Uno board from Elecrow, which has an onboard slide switch to select the operating voltage between 3.3V and 5.0V. If you want to use this board, make sure the switch is slided to 3.3V position.

Crowduino Uno board from Elecrow

2. BMP180 sensor module

BMP180 sensor breakout module

BMP180 sensor breakout module

3. ILI9163-based TFT display (I am using one with 1.44″ size display from Elecrow).

1.44" TFT display (ILI9163 driver)

1.44″ TFT display (ILI9163 driver)

4. A breadboard and few jumper wires for hooking up the sensor and the display to the Arduino board.

The following diagram describes the experimental setup for this tutorial. The BMP180 and the TFT display are both powered by 3.3V. The BMP180 supports I2C interface and therefore the SDA and SCL pins go to A4 and A5 pins of the Arduino board. The ILI9163 TFT driver supports SPI interface. The table shown on the right side of the diagram below describes the wiring between the display and Arduino. The I2C and SPI pin names are printed on the bottom layer silkscreen of the BMP180 and the TFT display modules.

Sensor and display setup

Sensor and display setup

Here is the actual setup for this experiment made on a breadboard.

BMP180 sensor hookup with Arduino

BMP180 sensor hookup with Arduino

Arduino firmware

For sensor readings, I am using the BMP180 Arduino Library from Love Electronics Ltd (I am not sure if this company exists now or not bu that’s what it says in the library). You need to download it (link provided below) and install this library into your Arduino/libraries/ location.

Download BMP180 Library

For the ILI9163 TFT LCD, I am using another free and open source Arduino Library called TFT_ILI9163C, which you can download from the following link.

Download TFT_ILI9163C Arduino Library

The TFT library uses Adafruit_GFX libraries for fonts, so you need to download and install it too.

Download Adafruit_GFX_Library

After installing both of these libraries, it’s time to write firmware for the Arduino. The firmware I have written and shared below displays temperature in Celsius and Fahrenheit scales and barometric pressure in millibar and inHg. In order to compute the sensor altitude, we need to know the reference surface pressure value as discussed in the following section.

Important Note about retrieving sensor altitude

Please note that the BMP180 sensor provides absolute measurements for temperature and pressure, but do not give a direct output for the altitude. Since the atmospheric pressure reduces with altitude, you can find out the vertical displacement of the sensor by knowing the reference pressure value at the ground. For example, in order to compute the sensor altitude, say from the sea level, you need to know the current mean sea level pressure at your local place. The mean sea-level pressure is not a constant and varies diurnally with ambient temperature and weather patterns. An easiest way to find out the current sea-level pressure would be to check the website of your nearest airport or the national weather service. They usually update it on their website hourly or so. I live in Williamsburg, VA and I checked the mean sea-level pressure from Weather.gov website. At the time I was doing this experiment, the mean sea level pressure was 1027.7 millibars or 102770 Pascal. In the Arduino code below (float seaLevelPressure = 102770;), I used this value for the mean sea level pressure and used the difference in the sensor read pressure and this value to compute the altitude of the sensor location, which was the second floor of my house in Williamsburg, VA. Therefore, in order to compute the altitude of your sensor location, you have to replace this value with your current local sea-level pressure value in Pascal (1 millibar = 100 Pascal). With the knowledge of the local sea-level pressure, the Arduino firmware below also displays the altitude above the sea level in feet and meters. 
Mean sea-level pressure data

Mean sea-level pressure data

Here is a complete Arduino code for this project. I would recommend to use the download file below instead of copying and pasting the code from here, which does not work sometime.

#include <Wire.h>
#include <BMP180.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <TFT_ILI9163C.h>
// Define pins for ILI9163 SPI display
#define __CS 10
#define __DC 9 // Labeled as A0 in some modules
#define __RST 8
// Connect SDA to Arduino pin 11 (MOSI), and SCK to 13 (SCK)
// Color definitions
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0 
#define WHITE 0xFFFF
#define TRANSPARENT -1
TFT_ILI9163C display = TFT_ILI9163C(__CS, __DC, __RST);
// Store an instance of the BMP180 sensor.
BMP180 barometer;
// Store the current sea level pressure at your location in Pascals.
float seaLevelPressure = 102770; // Williamsburg, VA on Dec 31, 2014, 14:54 Eastern Time
void setup()
{
 display.begin();
 display.setBitrate(24000000);
 display.setRotation(2);
 display.clearScreen();
 // We start the serial library to output our messages.
 Serial.begin(9600);
 // We start the I2C on the Arduino for communication with the BMP180 sensor.
 Wire.begin();
 // We create an instance of our BMP180 sensor.
 barometer = BMP180();
 // We check to see if we can connect to the sensor.
 if(barometer.EnsureConnected())
 {
 Serial.println("Connected to BMP180."); // Output we are connected to the computer.
 // When we have connected, we reset the device to ensure a clean start.
 barometer.SoftReset();
 // Now we initialize the sensor and pull the calibration data.
 barometer.Initialize();
 }
 else
 { 
 Serial.println("No sensor found.");
 }
}
void loop()
{
 if(barometer.IsConnected)
 {
 // Retrive the current pressure in Pascals.
 long currentPressureP = barometer.GetPressure();
 float currentPressuremb = currentPressureP/100.0;
 float currentPressureinHg = currentPressuremb*0.02953;

 // Print out the Pressure.
 Serial.print("Pressure: ");
 Serial.print(currentPressureP);
 Serial.println(" Pa");
 Serial.print("Pressure: ");
 Serial.print(currentPressuremb);
 Serial.println(" mbar");
 Serial.print("Pressure: ");
 Serial.print(currentPressureinHg);
 Serial.println(" inHg");
 // Retrive the current altitude (in meters). Current Sea Level Pressure is required for this.
 float altitudem = barometer.GetAltitude(seaLevelPressure);
 float altitudeft = altitudem*3.2808;
 // Print out the Altitude.
 Serial.print("\tAltitude: ");
 Serial.print(altitudem);
 Serial.print(" m");
 Serial.print("\tAltitude: ");
 Serial.print(altitudeft);
 Serial.print(" ft");

 // Retrive the current temperature in degrees celcius.
 float currentTemperatureC = barometer.GetTemperature();
 float currentTemperatureF = (9.0/5.0)*currentTemperatureC+32.0;
 // Print out the Temperature
 Serial.print("\tTemperature: ");
 Serial.print(currentTemperatureC);
 Serial.write(176);
 Serial.print("C");
 Serial.print(currentTemperatureF);
 Serial.write(176);
 Serial.print("F"); 
 Serial.println(); // Start a new line.

 // Now display results on LCD

 display.fillScreen();
 display.setCursor(0, 0);
 display.setTextColor(WHITE); 
 display.setTextSize(1);
 display.print("BMP180 Sensor Demo");

 // Display temperature in F 
 display.setCursor(0, 16);
 display.setTextColor(YELLOW); 
 display.setTextSize(2);
 display.print("T=");
 display.print(currentTemperatureF);
 display.setTextSize(1);
 display.print(" o");
 display.setTextSize(2);
 display.print("F");
 // Display temperature in C
 display.setCursor(24, 32);
 display.print(currentTemperatureC);
 display.setTextSize(1);
 display.print(" o");
 display.setTextSize(2);
 display.print("C");

 //Now display pressure in mbar
 display.setCursor(0, 48);
 display.setTextColor(CYAN); 
 display.setTextSize(2);
 display.print("P=");
 display.print(currentPressuremb,1);
 display.print("mb");
 // Display pressure in inHg
 display.setCursor(24, 64);
 display.setTextColor(CYAN); 
 display.print(currentPressureinHg,1);
 display.print("inHg");

 //Now display pressure in mbar
 display.setCursor(0, 80);
 display.setTextColor(WHITE); 
 display.setTextSize(2);
 display.print("H=");
 display.print(altitudeft,1);
 display.print("ft");
 // Display pressure in inHg
 display.setCursor(24, 96);
 display.setTextColor(WHITE); 
 display.print(altitudem,1);
 display.print("m");

 delay(5000); // Show new results every second.
 }
}
 

Download the Arduino sketch here

Output

The sensor altitude shown was about 88 feet above the sea level, which seems to be right as compared to the city data published here: http://en.wikipedia.org/wiki/Williamsburg,_Virginia

asasa

Second floor measurements

The sensor is very sensitive to altitude. The following measurement was taken by placing the sensor on my dining table in the first floor. The altitude was reduced by ~8 feet, which seems to be reasonable.

asasas

First floor measurements

The post Using BMP180 for temperature, pressure and altitude measurements appeared first on Embedded Lab.


Shower room door sensor

$
0
0

James and his other colleagues often bike to work to stay healthy. The problem is their work place has only one shower stall. So he built this shower room door sensor to provide an at-desk indication of whether the shower room is free or occupied so that he doesn’t have to run to the bathroom to check its status. While there are other similar projects done before, this has a distinguishing feature that it detects the bolt of the door lock, and therefore it is more reliable than just sensing if the door is shut. He used some paper-clips and post-it notes to build the sensor part and Spark Core to read the sensor output and push the occupancy status to a web page.

Shower room occupency sensor

Shower room occupency sensor

The post Shower room door sensor appeared first on Embedded Lab.

Portable multifunctional tool with Nokia 3310 casing

$
0
0

Mastro Gippo’s 1337 3310 multifunctional portable tool is hacker’s Swiss knife in the shell of Nokia’s most durable and iconic 3310 phone and is also the winner of Hackaday’s Trinket Everyday Carry Contest. It features ohmmeter, graphing multimeter with simultaneous measurements of current and voltage, as well as instantaneous and average power consumption measurements that help to estimate the battery life of your prototypic design. He also maintained the original look and feel of Nokia 3310 by developing the similar user interface for his tool. The continuity tester feature plays the original Nokia tune as output.

Nokia 3310 portable multifunctional tool

Nokia 3310 portable multifunctional tool

 

The post Portable multifunctional tool with Nokia 3310 casing appeared first on Embedded Lab.

ESP8266 module and breadboard adapter kit

$
0
0

Elecrow is now offering the popular ESP-01 Serial-to-WiFi transceiver module along with our breadboard adapter kit for simplifying the prototyping of the ESP8266-based IoT applications. While you can buy the breadboard kit alone from our Tindie Store, we don’t ship it worldwide. Elecrow offers worldwide shipping at reasonably lower shipping costs.

ESP8266 module and breadboard adapter

ESP8266 module and breadboard adapter

ESP8266 is an inexpensive serial-to-wifi tranceiver chip that allows to connect any microcontroller with a serial port to a WiFi network. Because of its simplicity and low cost, it is getting popular among hobbyists for building Internet of Things (IoT) applications. While there are varieties of breakout boards available for ESP8266 from the Chinese markets, the most popular one is the ESP-01 version that provides access to the ESP8266 pins through a 2×4 male header. While the headers are 0.1″ pitch, the pin arrangements are not breadboard friendly and are not labeled on board, which makes it little inconvenient for breadboarding. We have designed this very simple breadboard friendly adapter (shown below) with clear pin labels printed on the board to make prototyping with the ESP-01 module easier.

Breadboard adapter makes prototyping easier

The adapter has a 2×4 female header to receive the ESP-01 module and a 10uF power supply filter on board. The ESP-01 module pins are accessible through two single row headers that are breadboard friendly.

Buy Adapter only from Elecrow Store (recommended for international buyers)

Buy Adapter plus ESP-01 module from Elecrow Store (recommended for international buyers)

Buy Adapter only from our US store (recommended for US customers)

The post ESP8266 module and breadboard adapter kit appeared first on Embedded Lab.

Musical holiday card with a CD case

$
0
0

Dmitry Griberg’s musical holiday card project is really cool and plays a full song in full fidelity from an SD card. The project uses Attiny85 microcontroller and a 4-MOSFET amplifier circuit, both powered from a LiPo battery. The complete circuit is enclosed inside a CD case, and a simple flexible metal strip is used to make a contact sensor that will activate the player when the CD case is opened. The songs are saved on the SD card as WAV files with 32KHz sampling rate and 8-bit samples.

Musical holiday card

Musical holiday card


Here is a demo video of this:

The post Musical holiday card with a CD case appeared first on Embedded Lab.

Arduino sound direction locator

$
0
0

This Arduino-based sound direction locator uses a Pac-Man like ghost that runs towards the direction of the origin of sound. It uses three microphones amplifier modules arranged in a triangle to locate the direction of the sound and an 8×8 LED grid display for output. The Arduino Uno senses the incoming audio levels from the three microphones and moves the ghost in the direction with the loudest sound detected by turning on the appropriate LEDs on the grid.

Arduino sound direction locator

Arduino sound direction locator

Check out this video showing it in action.

The post Arduino sound direction locator appeared first on Embedded Lab.

Arduino binary clock with seven segment LED displays

$
0
0

Brett Oliver’s latest version of Arduino-controlled binary LED clock uses a 4×20 character LCD and three MAX7219-based serial 8-digit seven segment displays to show time and date, which is synchronized to the DCF77 time code transmitter in Germany. The display brightness is auto adjusted to room level using a photoresistor as ambient light sensor. Brett also implemented a PIR sensor for motion detection that will automatically shut down the main 7 segment display and LCD display when there is no body to watch the clock.

asa

Arduino-based binary LED clock

The post Arduino binary clock with seven segment LED displays appeared first on Embedded Lab.

Arduino calculator box

$
0
0

Kale_3D has posted this instructable about his build of an Arduino-based calculator with a laser cut wooden enclosure.

In this Instructable I will show you how to make an Arduino calculator that is just as good as any other calculator (well… sort of). Even though it’s probably not practical due to it’s size, repetitive use of the equals button (due to the lack of keys), and cost (You can probably buy a calculator that does the same thing for $2), It is really fun and adds a few skills to your inventory. Let me tell you how I got started on this project. It all starts at school where the original calculator was made by my friend/teacher Gabe. If your curious how the old version looked click here. Soon enough students began to play with it and soon broke it. I was the only student who knew how to fix it so I decided I might as well try. In the process I basically took the whole thing apart and started from scratch. I also rewrote most of the code. I learned alot, spent lots of time debugging, and added many new features. In the end it was a project definitely worth doing. The good thing is that now that I figured it out you don’t have to. Let’s get started.

 

Arduini-powered calculator

Arduini-powered calculator

The post Arduino calculator box appeared first on Embedded Lab.


Open-source ARM Pro Mini

$
0
0

Zapta has shared the design files on github for his ARM PRO MINI, which is an open source ARM M0 microcontroller development board that could be handy for quick prototyping and as a starting point for your own ARM based custom designs.

Arm Pro Mini board

Arm Pro Mini board

Highlights

  • Prototyping friendly. Compatible with standard soldieries breadboards and can be soldered to a standard 0.1” proto board.
  • Straight forward barebone design. Customize for your own PCB design by selecting the portions of the circuit you need.
  • Single package install of the free and fully feature IDE (NXP Eclipse/LPCXpresso).
  • Zero software installation when using with the mbed.org online IDE.
  • Full support of Windows, Mac OSX and Linux.
  • Easy firmware upgrade using a file drag and drop. Programmers and adapters are not required, even if you are bringing up your own board!
  • Supports optional debuggers (such as the OM13014,598) for single stepping and full debugging capabilities.
  • I/O library and a hello world example (with serial printing over USB, parallel port io, blinking LED, and timing).
  • No-nonsense open source license (no commercial restrictions, sharing and attribution not required).

 

The post Open-source ARM Pro Mini appeared first on Embedded Lab.

XMega DAC

$
0
0

In embedded systems, oftentimes it is needed to generate analog outputs from a microcontroller. Examples of such include, generating audio tones, voice, music, smooth continuous waveforms, function generators, voltage reference generators, etc. Traditionally in such cases the most common techniques applied are based on Pulse Width Modulation (PWM), resistor networks and external Digital-to-Analog Converter (DAC) chips like MCP4921. The aforementioned techniques have different individual limitations and moreover require external hardware interfacing, adding complexities and extra cost to projects.  XMega micros are equipped with 12 bit fast DACs apart from PWM blocks and again it proves itself to be a very versatile family of microcontrollers. In this post we will have a look into this block.

DAC Internal Block Diagram

A brief overview

I used ATXMega32A4U just as always and it has only one dual channel DAC designated DACB but there are other XMega devices that have more than one DAC.

The internal block diagram of the DAC block above shows its major parts. The DAC of XMega is perhaps one of the simplest block to understand. Apart from DMA and event system interfacing, the DAC can provide reference source for the analog comparator and ADC blocks. It also has the capability to directly drive both resistive and capacitive loads (check device datasheet for limits). Just like the ADC block, the DAC block itself needs a reference source and this reference source can be both internal (internal 1.0V reference) and external (AVCC or AVREF). As stated earlier there are two independent DAC channels in the XMega32A4U and so there are two separate analog outputs (PB2 and PB3) available from this micro.

The basic formula for voltage output from the DAC is as follows:
Formula

The digital data value ranges from 0 – 4095 (0×0000 – 0x0FFF) since it is a 12 bit DAC. How fast it can operate will depend on peripheral clock’s operating frequency. Just like the clock system, the DAC output can be precisely calibrated by using gain error and offset error registers. Though calibrating the DAC ensures more accurate data output, it is seldom used. If it is needed to calibrate the DAC for sensitive operations one must do so carefully and should use standard instruments that have least possible error, otherwise it is pointless to calibrate it. You can use the XMega ADC block for calibration purpose if you don’t have access to good measurement instruments. In my previous post I showed how to use the XMega ADC. I, however, never calibrated the DAC block. Calibration process is well explained in the reference manual.

Shown below are pin diagrams of both the most popular XMega A1 and A4 devices. Checkout the DAC output pin locations because these are not mentioned in the reference manual.

XMega A4 Pin Map XMega A1 Pin Map

 

 

Registers

The simplified register map for the DAC block shows that there are only a few registers to deal with. I’m not going to detail about them as the reference manuals are already doing so.

Control registers A-C are sequentially set first. These registers are responsible for selecting reference source, channel, power mode, etc. Calibration registers have names ending with “CAL” and data input registers have names ending with “DATA”. Lastly there is event system register that select which event system channel would trigger the DAC and there is a STATUS register which flags when it is possible to write new values to a specific DAC channel.

XMega DAC Register Map

 

Coding

The code, just as in previous posts, starts with clock and I/O configuration setups and then the DAC is setup. In this code example I coded the XMega as such that both of its outputs will give sinusoidal voltage variations or in other words the DAC output pins will output sine wave signals. I also coded a DAC header file for quick coding and less meddling with register values. The DAC block is coded to use  (3.3V) as reference source and both DAC channels are employed. One DAC channel will output sine wave output while the other at the same instance will give out phase shifted sine wave or cosine wave signal. MikroC CMath library is used for the trigonometric (sine-cosine) functions. PB2 and PB3 are set as output pins. Lastly left adjustment of DAC data is avoided to keep things simple. Please note that I didn’t calibrate the DAC and still it worked good enough.

#include "clock.h"
#include "dac.h"
#include "io.h"
 
void setup();
void clock_setup();
void io_setup();
void dac_Setup();
void dac_write(unsigned char channel, unsigned int value);
 
void main() 
{
   signed int temp1 = 0;
   signed int temp2 = 0;
   unsigned int degree = 0;
 
   setup();
   
   while(1)
   {
       for(degree = 0; degree < 360; degree++)
       {
           temp1 = (2047 * cos(degree * 0.0174532925));
           temp1 = (2048 - temp1);
           temp2 = (2047 * sin(degree * 0.0174532925));
           temp2 = (2048 - temp2);
           dac_write(0, ((unsigned int)temp1));
           dac_write(1, ((unsigned int)temp2));
           delay_us(10);
       }
   };
}
 
void setup()
{
   clock_setup();
   io_setup();
   dac_Setup();
}
 
void clock_setup()
{
   OSC_CTRL |= OSC_RC32KEN_bm;
   while(!(OSC_STATUS & OSC_RC32KRDY_bm));
   OSC_CTRL |= OSC_RC32MEN_bm;
   CPU_CCP = CCP_IOREG_gc;
   CLK_PSCTRL = ((CLK_PSCTRL & (~(CLK_PSADIV_gm | CLK_PSBCDIV1_bm 
                | CLK_PSBCDIV0_bm))) | CLK_PSADIV_1_gc | CLK_PSBCDIV_2_2_gc);
   OSC_DFLLCTRL = ((OSC_DFLLCTRL & (~(OSC_RC32MCREF_gm | OSC_RC2MCREF_bm))) |
                  OSC_RC32MCREF_RC32K_gc);
   DFLLRC32M_CTRL |= DFLL_ENABLE_bm;
   while(!(OSC_STATUS & OSC_RC32MRDY_bm));
   CPU_CCP = CCP_IOREG_gc;
   CLK_CTRL = ((CLK_CTRL & (~CLK_SCLKSEL_gm)) | CLK_SCLKSEL_RC32M_gc);
   OSC_CTRL &= (~(OSC_RC2MEN_bm | OSC_XOSCEN_bm | OSC_PLLEN_bm));
   PORTCFG_CLKEVOUT = 0x00;
}
 
void io_setup()
{
   PORTB_OUT = 0x00;
   PORTB_DIR = 0x0C;
   PORTB_PIN0CTRL = (PORT_OPC_TOTEM_gc | PORT_ISC_BOTHEDGES_gc);
   PORTB_PIN1CTRL = (PORT_OPC_TOTEM_gc | PORT_ISC_BOTHEDGES_gc);
   PORTB_PIN2CTRL = (PORT_OPC_TOTEM_gc | PORT_ISC_INPUT_DISABLE_gc);
   PORTB_PIN3CTRL = (PORT_OPC_TOTEM_gc | PORT_ISC_INPUT_DISABLE_gc);
   PORTB_INT0MASK = 0x00;
   PORTB_INT1MASK = 0x00;
}
 
void dac_setup()
{
   DACB_CTRLA = ((DACB_CTRLA & (~(DAC_IDOEN_bm | DAC_CH0EN_bm | DAC_CH1EN_bm
                | DAC_LPMODE_bm))) | DAC_CH0EN_bm | DAC_CH1EN_bm | DAC_ENABLE_bm);
   DACB_CTRLB = ((DACB_CTRLB & (~(DAC_CHSEL_gm | DAC_CH0TRIG_bm 
                | DAC_CH1TRIG_bm))) | DAC_CHSEL_DUAL_gc);
   DACB_CTRLC = ((DACB_CTRLC & (~(DAC_REFSEL_gm | DAC_LEFTADJ_bm)))
                | DAC_REFSEL_AVCC_gc);
}
 
void dac_write(unsigned char channel, unsigned int value)
{
   switch(channel)
   {
       case 0:
       {
           while(!(DACB_STATUS & DAC_CH0DRE_bm));
           DACB_CH0DATA = value;
           break;
       }
       case 1:
       {
            while(!(DACB_STATUS & DAC_CH1DRE_bm));
            DACB_CH1DATA = value;
            break;
       }
   }
}

 

XMega DAC Demo

Demo (1) Demo (2) Demo (3) Demo (4)

 

 

Demo video link: https://www.youtube.com/watch?v=O61v0nww6vU.

Files: XMega DAC

 

References: XMega AU Manual and Datasheet.

 

Happy coding.

 
Author: Shawon M. Shahryiar
https://www.facebook.com/groups/microarena/  
https://www.facebook.com/MicroArena 
+8801970046495                                                                                                                      
                       
26.01.2015

The post XMega DAC appeared first on Embedded Lab.

Basic Experimenter Board for easy prototyping of electronic circuits

$
0
0

Most electronics projects require some common stuff like regulated power supply, input tact switches, and output LEDs during prototyping and testing phase. Wiring these things on a breadboard for every new project could be time consuming and boring. We introduce you the Basic Experimenter Board, a general purpose develoment tool that will not only reduce the prototyping time for your next project but also free up plenty of space on the breadboard. It features regulated 3.3V and 5.0V power supply on board along with four output LEDs, four input tact switches, one output buzzer with driver circuit, a potentiometer for simulating analog input, and a 480-point breadboard for rapidly prototyping and testing your electronic circuits.

sss

Basic Experimenter Board

Features:

  • Regulated 5.0V and 3.3V power supply. Maximum DC input is 15V, and maximum output current is 500mA. The board contains a 500mA PTC fuse for overload or short circuit protection.
  • Four LEDs for digital outputs. The current limiting resistances are already implemented on board. All LED access pins (available on JP1 header) are active HIGH (which means a logic high applied to the LED access pin turns it on).
  • Four tact switches for digital inputs. The output logic high voltage of the tact switches can be set to 3.3V or 5.0V through a 2-pin shunt jumper on JP4 header. The tact switches outputs (available on JP1 header) are high during normal condition and are low when pressed.
  • On-board buzzer with a transistor driver circuit. The buzzer is continuous-type and activates when a logic high is applied to the BUZ input pin on JP1.
  • Potentiometer for simulating an analog signal. The range of the potentiometer output can be set to 0-3.3V or 0-5.0V through a 2-pin shunt jumper on JP6 header. The potentiometer output is accessible through the POT pin on JP1.
ssss

On board features of Basic Experimenter Board

aaaa

Using jumper cables to supply power to the breadboard side rails

ssss

Closer look of Basic Experimenter Board

You can buy Basic Experimenter Board from our Tindie Store. The package consists of a fully assembled Basic Experimenter Board, a 9V battery clip, and a set of male-to-male jumper cables with varying length (see the picture below).

Basic Experimenter Board kit content

Basic Experimenter Board kit content

Buy Basic Experimenter Board today!

The post Basic Experimenter Board for easy prototyping of electronic circuits appeared first on Embedded Lab.

Making an audio treasure hunt box

$
0
0

Treasure hunts are a great adventure to play inside or outside of house. Jasen Smith’s audio treasure hunt box project is a unique variation of this game, where the treasure hunters are given a code to enter into the box, and the box plays a short audio clip containing a clue as to where to look for next. As they arrive at this location, they get a new code, which has to be entered into the box again to get next clue. This continues until the treasure is found.

Treasure hunt box

Treasure hunt box

The wave shield connects to the Arduino board with header pins on the bottom side of the wave board. These pins fit into the pin sockets on the Arduino. Adjacent to the pin holes where these header pins are mounted is a second set of holes that are connected to them. These let you connect external components to the pins on the Arduino. You can solder wires directly to these holes or you can use header pins for removable connections. The kit comes with eight additional header pin connectors. Two of these I soldered to the 5V and GND pin holes. The remaining six I connected to the analog input pins.

The post Making an audio treasure hunt box appeared first on Embedded Lab.

Microchip’s new Gesture controller IC

$
0
0

Microchip Technology has announced the second member of its award-winning and patented GestIC® family. The new MGC3030 3D gesture controller features simplifies user-interface options focused on gesture detection, enabling true one-step design-in of 3D gesture recognition in consumer and embedded devices. Housed in an easy-to-manufacture SSOP28 package, the MGC3030 expands the use of highly sought after 3D gesture control features to high-volume cost-sensitive applications such as toys, audio and lighting.

3D gesture controller

3D gesture controller

The simplicity of gesture-detection integration offered by the MGC3030 is also achieved through Microchip’s free, downloadable AUREA graphical user interface (GUI) and easily configurable general purpose IO ports that even allow for host MCU/processor-free usage. The MGC3030’s on-chip 32-bit digital signal processor executes real-time gesture processing, eliminating the need for external cameras or controllers for host processing, and allowing for faster and more natural user interaction with devices.

The post Microchip’s new Gesture controller IC appeared first on Embedded Lab.

Viewing all 713 articles
Browse latest View live