Tag Archives: MCU

Webcast: Programming AVR Microcontrollers in C



Elliot Williams is a Ph.D. in Economics, a former government statistician and a lifelong hacker. He taught himself to program microcontrollers (MCUs) long before the wildly popular Atmel-based Arduino hit the streets.

Most recently, he is author of the Maker Media book “Make: AVR Programming, Learning to Write Software for Hardware,” which is packed with a plethora of MCU programming tidbits.

On Tuesday, March 18th, Williams will be presenting a free O’Reilly webcast titled “Beyond the Arduino: Programming AVR microcontrollers in C.” The 60 minute webcast – hosted in San Francisco – is slated to kick off at 10AM PT.

“In this webcast, we’ll dive straight into the deep end. I’ll show you what you need to get started programming the AVR ATMega (and tinyAVR) series microcontrollers, give you an overview of their built-in peripherals, and demonstrate most of the important functionality,” Williams explained.

“I can’t teach you C in a webcast, but if you’ve every programmed in any language before, you’ll be able to follow along with the code examples. If you are an experienced coder, I’ll give you some insight into what makes writing directly for hardware a bit different. If you’ve worked with an Arduino before, I’ll show you how to do everything you’re now doing faster, better, and cheaper.”

Interested in joining the free webcast hosted by Elliot Williams? You can sign up here.


This 6X USB charger has a current monitor

Frank Zhao, an electrical engineer and DIY hobbyist, has designed a simple 6 port USB device charger with an individual current monitor on each port.

“The problem I faced was that I had too many devices to recharge at once, not having enough chargers and not having enough AC jacks,” Zhao explained in a recent blog post.

“Also my new Sony wireless headset was being picky about both the cable I use and the charger I use. I decided to troubleshoot this problem by building this tool.”

Key project specs include Atmel’s versatile ATmega328P microcontroller (MCU), an INA169 breakout board and an OKR-T10-W12.

The charging current is indicated using RGB LEDs. More specifically, blue means slow charge (under 250mA), green 250mA-750mA, red over 750mA and purple over 1500mA (for tablets).

“Wiring is done using 30 gauge Kynar coated wire. A decently capable wall-wart is needed, anywhere between 4.5V to 12V is acceptable and it must be able to supply enough current for all the devices to be charged,” Zhao continued.

“A DC/DC converter is used to increase efficiency, so a 12V wall-wart supplying 4A can actually charge about 8A total. The D+ and D- signals have the appropriate resistors to enable high charging rates on Apple devices – which is compatible with Sony, Samsung and other brands.”

Zhao also noted that he deliberately omitted a number of features from his charger due to cost and time constraints, including reverse polarity protection, input fuse, individual over-current cutoff and LED dimming.

Interested in learning more? You can check out the project’s official page here.

A closer look at Atmel’s SAM R21 Xplained Pro

Atmel’s SAM R21 Xplained Pro evaluation kit allows developers to more easily design connected lighting, smart metering and wireless sensor network systems based on true Internet-connectivity and open standards such as IPv6 and 6lowpan.

Key hardware specs include:

  • Atmel’s ARM-based ATSAMR21G18A microcontroller (MCU)
  • Embedded debugger (EDBG) and USB interface
  • Programming and debugging on board SAM R21 via SWD
  • Virtual COM-port interface to target via UART
  • Atmel Data Gateway Interface (DGI) to target via SPI and TWI
  • Four GPIOs connected to target for code instrumentation
  • Digital I/O
  • Two mechanical buttons (user and reset button)
  • One user LED
  • Two extension headers
  • Three possible power sources
  • External power
  • Embedded debugger USB
  • Target USB
  • 32KHz crystal
  • 16MHz crystal
  • Atmel Software Framework support

The SAM R21 Xplained Pro was recently showcased at Atmel’s Embedded World 2014 booth by Thingsquare. Indeed, a number of Thingsquare’s demonstrations were powered by the evaluation board, illustrating the seamless integration of Thingsquare’s software stack with Atmel’s new SAM R21 ultra-low power wireless microcontroller (MCU).

As Atmel Product Marketing Director Magnus Pedersen notes, developers are demanding complete, easy-to-use IoT solutions that can quickly bring a full system to market.

“Our cooperation with Thingsquare is an example of that, with a web-based toolchain and open source firmware to offer our customers a fully integrated hardware and software solution for various IoT applications.”

Thingsquare CEO Adam Dunkels expressed similar sentiments.

“The addition of Atmel’s hardware solutions provides our customers additional options,” he said. “Atmel’s new SAM R21 wireless microcontroller is an important step forward in the emerging IoT space.”

The ATSAM R21 Xplained Pro board is available at the official Atmel Store, with Atmel currently sampling the ATSAM R21 series to select customers. Public sampling will be available the end of March with production quantities slated for July 2014. Pricing for the SAM R21? Starting at $2.75 in 10,000-piece quantities.

Interested in learning more? The SAM R21 device combined with the Thingsquare open source firmware is available at http://thingsquare.com and as a separate delivery via Atmel’s Studio 6 Gallery.

In related IoT news, Bits & Pieces readers may also want to check out the Atmel-backed 2014 IPSO challenge. Essentially, IPSO strives to advance the development and standardization of the Internet of Things (IoT).

The initiative challenges participants to submit working prototypes from innovative concepts in interfaces, interactions and applications which demonstrate the use of the Internet Protocol (IP) in real world sensor/control and machine-to-machine (M2M) applications. 

In 2014, IPSO and its sponsors will offer prizes and incentives worth over $50,000. All ten semi-finalists will be given the opportunity to demonstrate working prototypes to industry experts and investors at Sensors Expo 2014, the largest event devoted to sensor and actuator-integrated technology in North America.

Interested in learning more? You can click here for additional details.

Arduino Uno powers this three-zone thermostat



Last week, Bits & Pieces took a closer look at a smart thermostat in the Netherlands powered by an Arduino Mega 2560 (ATmega2560 MCU). Today, we’re going to be getting up close and personal with a three-zone thermostat built around an Atmel-based Arduino Uno (ATmega328).

The three zone system – which recently surfaced on Instructables courtesy of hbomb9000 – is also equipped with DS18B20 temperature sensors, DS1307 RT Clock, 16×2 character display, LCD keypad Arduino shield, along with various miscellaneous wire leads, connectors and resistors. 

On the software side, hbomb9000 used an add on for SublimeText known as Stino, as well as two libraries: OneWire and DallasTemperature.

“The first step in making the program actually work was to get the temp sensors working. They are at the heart of the thermostat. Without them, the furnace doesn’t know when to turn on or off,” hbomb9000 explained.

“The temperature sensor is pretty cool in that it uses a single wire to send data back to the Arduino. What’s more, each sensor has an address, a unique number which identifies the sensor. This is really exciting because it means you can have multiple sensors sending their inputs into the same pin on the Arduino.”

In terms of wiring, hbomb9000 described the process as “super simple.”

“Run one wire into the analog pin of your choice (my program reads from pin A0), and connect that to one side of the button array. The other side of the button array is connected to ground,” he said.

“From there, the buttons are simply chained together via a resistor network. An additional wire is added from each button to the analog input pin, so every button has a direct path to the analog pin.”

At this stage, hbomb9000’s three-zone thermostat is mostly theoretical, although he does intend on installing it after further soldering, tweaking and adding Internet connectivity.

“My next steps will be to fashion a housing for the main thermostat as well as the two remote temperature sensors. These housings will sit on the wall in their respective zones,” he concluded.

“I’ve decided I will be using hardwood maple for the housings, so they should look fairly sharp once attached to the wall. Beyond that, some simple soldering and affixing the components to permanent breadboards will be required, as again these breadboards are not designed for permanent use. I have to either procure or build out some zone dampers.”

Interested in learning more? You can check out the project’s official Instructables page here.

Building a Yún-powered weather station

The Arduino Yún – designed in collaboration with Dog Hunter – is based on Atmel’s popular ATMega32u4 microcontroller (MCU) and also features the Atheros AR9331, an SoC running Linino, a customized version of OpenWRT. The Yún is somewhat unique in the Arduino lineup, as it boasts a lightweight Linux distribution to complement the traditional microcontroller (MCU) interface.

The Atmel-powered Yún – which hit the streets late last year – has been used in a wide variety of Maker projects that we’ve recently covered on Bits & Pieces, including an electricity monitor, mesh extender platform, Foursquare soap bubble machine, a Gmail (alert) lamp, water heater regulator and Evil Alarm System.

Today, we’re going to be taking a look at how Marc-Olivier Schwartz built a cloud-connected weather station with the Yún. Aside from the Atmel-based board, key hardware specs include:

  • DHT11 (or DHT22) sensor and 4.7K resistor (for humidity)
  • 
BMP085 sensor on a simple breakout board/Adafruit BMP180 sensor board (for pressure and temperature)
  • Photocell with a 10K Ohm resistor (light level)
  • Breadboard + assorted male-male jumper wires

On the software side, Schwartz used the Arduino IDE, Temboo, DHT library, the BMP085/BMP180 library, unified sensor library and a Google Docs account for the collected data to be analyzed and stored.

“The hardware connections for this project are actually quite simple: we have to connect the DHT11 sensor and then the part responsible for the light level measurement with the photocell. First, connect the Arduino Yun +5V pin to the red rail on the breadboard and the ground pin to the blue rail,” Schwartz explained in a detailed Adafruit tutorial.

“Then, connect pin number 1 of the DHT11 sensor to the red rail on the breadboard and pin number 4 the blue rail. Also connect pin number 2 to pin number 8 of the Arduino Yún. To finish up with the DHT11 sensor, connect the 4.7k Ohm between pin number 1 and 2 of the sensor.”

Next up is the photocell.

“First place the cell in series with the 10k Ohm resistor on the breadboard. Then, connect the other end of the photocell to the red rail on the breadboard and the other end of the resistor to the ground. Finally, connect the common pin to the Arduino Yún’s analog pin A0,” Schwartz continued.

“For the BMP085 or BMP180 sensor, connect the VIN pin to the +5V, GND to Ground, SCL to Arduino Yún pin number 3 and SDA pin to Arduino Yún pin number 2.”

According to Schwartz, multiple Yún boards can be used in various parts of a single residence.

“You can also customize the email alert part: you can build more complex alerts based on the measured data, or set the project to email you the sensor data at a regular time interval,” he added.

Interested in learning more? You can check out Schwartz’s full Adafruit tutorial here.

Video: Designing an Uno-based energy meter



Electrical engineer Debasish Dutta has designed an energy meter built around an Atmel-powered Arduino Uno (ATmega328 MCU).

)

“I [come from the] village of Odisha, India, where frequent power cut are very common. Continuing studies after dusk was a real challenge [so] I designed a solar system for my home on a experimental basis,” Dutta explained in a recent Instructables blog post.

“I used a solar panel of 10 Watt, 6V for lighting few bright LEDs. Then I decided to monitor the voltage, current, power and energy involved in the system, [which inspired] the idea of designing an energy meter.”

Dutta said he chose Arduino as “the heart” of his energy meter due to the numerous available open source libraries and intuitive IDE environment.

Aside from the Arduino Uno, key project features and specs include:

  • 16×2 character LCD display
  • Arduino Ethernet shield
  • ACS 712 current sensor
  • Resistors (10K,330ohm)
  • Potentiometer (10K)
  • Jumper wires
  • Ethernet cable (CAT-5E)
  • Bread board
  • Supports Xively upload
  • SD card data logging

The energy meter uses three primary parameters to measure energy consumption: voltage, current and time.

“Voltage is measured by the help of a voltage divider circuit. As the Arduino analog pin input voltage is restricted to 5V I designed the voltage divider in such a way that the output voltage from it should be less than 5V. My battery used for storing the power from the solar panel is rated 6v, 5.5Ah. So I have to step down the 6.5v to a voltage lower than 5V,” said Dutta.

“I used R1=10k and R2 =10K. The value of R1 and R2 can be lower (one), but the problem is that when resistance is low, higher current flow through it. As a result, a large amount of power (P = I^2R) is dissipated in the form of heat. So different resistance value can be chosen but care should be taken to minimize the power loss across the resistance.”

For current measurement, Dutta used a Hall Effect current sensor ACS 712 (20 A), while leveraging the Uno’s built-in timer. The collected data is then uploaded to Xively.com for additional analysis.

Interested in learning more? You can check out the project’s official Instructables page here.

Atmel’s Tech on Tour heads to SF



After successfully wrapping up SXSW 2014 in Austin, Atmel’s Tech on Tour (ToT) trailer is back on the road to the Bay Area – with a long-awaited San Francisco SoMa stop scheduled for March 18, 2014.

We’ll be at China Basin, Lot C @ 185 Berry Street (between 3rd and 4th) from 10AM-6PM, showcasing a wide variety of tech across a number of spaces including touchsecuritymicrocontrollers (MCUs), wirelesslighting and automotive.

More specifically, you can check out:

Atmel’s ToT will also be hosting an industry panel on the rapidly evolving Internet of Things (IoT) at 4:00PM.

Join industry experts from Atmel, ARM, Humavox and August for an interactive discussion on how the IoT, the hottest topic in the technology sphere, is impacting today’s market across multiple segments.

Interested? You can register for the event here. See you in SoMa!!!

Tannin is a DIY MIDI controller



Last week, Bits & Pieces got up close and personal with the Atmegatron, an 8-bit mono synth powered by Atmel’s ATmega328P microcontroller (MCU).

Today, we’re going to be taking a closer look at the Tannin, a DIY MIDI controller built around the Atmel-based Arduino Nano (ATmega328). 

Deisgned by Shantea, the system is equipped with 16 potentiometers, 19 buttons and four LEDs controller.

“It fully supports MIDI Note On/Off and CC messages, including the MIDI In (I’m using that feature in Traktor to control LEDs and set modifiers). It even features experimental MIDI Clock In support,” Shantea explained in a recent HackADay Project post.

“I’ve set it in a way that LEDs blink in sync with that clock, but there’s more work to be done to make it work fully. The buttons also have built-in feature of long press, that is, if you press button for half second (that can easily be defined) it will send another MIDI Note On on another channel (2, regular presses are sent on channel 1). The pots as well send MIDI Note On/Off messages, 6 per pot, depending on their position, with CC messages, of course.”

On the software side, Shantea used The Hairless MIDI to Serial Bridge, routing the messages via virtual MIDI cable software (loopBe30).

“When you match your virtual port in hairless-midi software, the once-serial messages from Arduino will become MIDI messages routed over virtual MIDI cable,” he said. “After that you can easily map your controller to any software which supports MIDI learn.”

In terms of hardware specifics, Tannin’s faceplate is manufactured out of a special plastic board 1.5mm thick (glued to 3mm plexiglas) and houses three PCBs designed in Eagle.

“Two for two groups of potentiometers to get really stable values (I used to connect the pots with wires which often resulted in gibberish values), and they both use ground planes on both sides,” Shantea added. “[Meanwhile], the main PCB [is fitted with the Atmel-based] Arduino, with connectors for two PCBs for pots. Each pot PCB has 4051 chip on it to read potentiometers. Buttons and LEDs [are] connected in a matrix with shared columns.”

Interested in learning more? You can check out HackADay’s introductory blog post here and the project’s official HackADay page here.

AVR programming with Elliot Williams (MakerShed)

So you’ve designed a plethora of cool DIY Maker projects with Atmel-based Arduino boards. Want to take the next step with stand-alone Atmel AVR microcontrollers (MCUs)? 

Written by Elliot Williams, Make: AVR Programming will help you discover how the AVR’s built-in hardware peripherals can be harnessed to solve various design issues, allowing Makers and engineers to fully benefit from working with Atmel’s AVR-based hardware.

makeavrmakershed

“The Arduino platform is great to learn the basics on. But if you’re a hacker on a budget and you’d like to make a swarm of robots, you’re going to want to use the AVR chips directly,” said Williams. 

”This book focuses on interfacing between the real world and the virtual world throughout. The two together open up infinite possibilities for creative projects.”

As the author notes, nearly everything in the book is project-oriented. Makers will learn microcontroller basics, as well as intermediate and advanced topics.

For example, you can:

  • Respond instantly to as many external events as your AVR has pins
  • Build an inexpensive footstep detector
  • Build circuitry to drive DC and stepper motors as well as other demanding loads
  • Make your projects talk by storing voice sample data in the AVR’s non-volatile memory
  • Learn to speak SPI and I2C

“Bottom line: If you’ve had some experience programming an Arduino, and you’d like to get to know the AVR chip more intimately, Make: AVR Programming is the book you need,” Williams added.

Interested? You can purchase Make: AVP Programming for $45 at the official MakerShed here.

An AVR-based public transport display

When it is reliable, public transportation is almost certainly the way to go, especially for those who are environmentally conscious. 

Take Adrian and Obelix, for example. These two university students recently hacked an LED dot matrix display to show arrival times for stops near their dorm.



The duo found the display for the project, albeit with a defective controller, on eBay. However, Adrian and Obelix quickly swapped out the controller for a trusty AVR-based ATmega328P microcontroller (MCU) and TP-Link MR3020.

“The ATmega328P does all the hard work pushing every line into the registers of the display and multiplexing, [while] the MR3020 takes care of network communication where it’s wireless interface comes in handy, because you only need to provide power to the display,” the two explained in a detailed blog post.

“For now, a PC takes care of collecting all information and rendering an image, but this will eventually be done by the MR3020 in the future. For now, it’s more practical to do the rendering on a PC with Python, where later on a C-program would do all the work on the MR3020.”

It should probably be noted that the above-mentioned display actually comprises two separate displays – each with a resolution of 128*16 pixels. Indeed, each line is connected to a binary decoder.

“Both displays have a common line select, clock pin, enable and latch, but separate data pins and data output pins, so we connected the first dataout to the second and get a virtual 256*16 pixel display,” the two added.

Interested in learning more? You can check out HackADay’s write up here and the project’s official page here.