Category Archives: Design Tips & Tricks

Exploring smart meters in the Internet of Things

The Internet of Things (IoT) isn’t a single homogenous market but splits up into different segments with very different requirements. A lot of IoT markets are still in our future: next generation wearable medical devices, autonomous cars and more. One area where IoT has been going strong, long enough that it probably pre-dates the catchy buzzword IoT, is smart power meters.

Atmel recent announced their latest power line communications SoC specifically designed for this market. The SAM4CP16B is an extension of Atmel’s SAM4Cx smart energy platform built on a dual-core 32-bit ARM Cortex-M4 architecture. It is fully compatible with Atmel’s ATPL230A OFDM physical layer device compliant with PRIME standard specification. The flexible solution addresses OEM’s requirements for various system partitioning, BOM reduction and time-to-market requirements by incorporating independent application, protocol stack and physical layer processing functions within the same device. Key features of the SoC include integrated low-power driver, advanced cryptography, 1MB of embedded Flash, 152KB of SRAM, low-power real-time clock, and an LCD display controller.

I think that as various submarkets of the Internet of Things develop, we will see a lot of devices like this; SoCs that integrate everything that is required for a particular application, leaving the system company to customize the hardware, add their own software and so on. IoT will not be a market like mobile, with huge chips being done in the latest process generation. Many IoT designs will include analog, RF and sensors, all of which are best designed in older processes like 65nm or even 130nm.

The system volumes for many designs will be relatively low and so designing a specific chip for each application will be unattractive. Even in mobile where the volumes are much higher, only Apple and Samsung design their own application processors, as far as I know. Everyone else licenses one from Qualcomm, Mediatek or others… Even Apple gets the modem (radio) from Qualcomm. The aggregate volumes will end up being large (there will be a lot of things) so the prize goes to the semiconductor companies that do the best job of designing chips that match what the system companies require.

Interested in learning more? The data sheet for the part can be found here. (Warning: It’s 1,000 pages!)

This post has been republished with permission from SemiWiki.com, where Paul McLellan is a featured blogger. It first appeared there on August 13, 2014.

Check your crypto chip with a Saleae logic analyzer

I have already noted the tiny full-function logic analyzer from Saleae. You can imagine my delight when I found this app note written by our security chip group on how to use the Saleae logic analyzer to debug the serial interface with one of our CryptoAuthentication chips, the ATSHA204.

The ATSHA204A includes a 4.5Kb EEPROM divided into 16 slots. This array can be used for storage of keys, miscellaneous read/write, read-only, password or secret data, and consumption tracking. Access to the various sections of memory can be restricted in a variety of ways and then the configuration locked to prevent changes. Access to the chip is through a standard I²C interface at speeds up to 1Mb/sec.

The Saleae logic analyzer has no problem keeping up with these fast speeds. ATSHA204 device supports either a single-wire interface (SWI) or two-wire interface (TWI) depending on the part number.

Saleae-logic-for-ATSHA204

When you drop the right dll into the Saleae program directory, you will get a menu callout for the Atmel SWI (single-wire-interface).

You use a dll to add the single-wire debug analysis to the Saleae, while the two-wire interface debugging can be handled by the I²C menu pick. So check out the Saleae logic analyser. My buddies tell me it is worth every penny compared to the cheapo stuff on Seeed Studio since the mechanical engineering is so much better on the Saleae, and the quality of the test leads and the capability of the software, which is a huge part of what a logic analyzer does for you these days. It’s one thing to see highs and lows on the screen, but it’s really nice when the logic analyzer tells you what characters are being sent on the wire or wires.

Saleae-logic-analyzer

The Saleae logic analyzer comes with high-quality cables and clips.

So check out the Saleae logic analyzers and be sure to secure your systems with a hardware-based security chip. When it comes to securing our intelligent, connected world, there’s no need to fear… Atmel CryptoAuthentication devices are here!

Vegard Wollan reflects on AVR and Arduino

In this segment of my chat with Vegard Wollan, the co-inventor of the AVR explores the symmetry between the highly-popular microcontroller and the Arduino development board.

Personally, one of the great moments was when Vegard revealed that the entire AVR product line was meant from the start to be easy-to-use. This began with the instruction set, the architecture and continues to this day with things like Atmel Studio 6 integrated development environment (IDE), Atmel Spaces collaborative workspace, and Atmel Gallery, the place where you can find thousands of code samples and tutorials.

Vegard-Wollen_Paul-Rako_AVR-ease-of-use

Vegard Wollan gestures to the AVR schematics as he explains to Paul Rako how ease of use was a primary design goal from the start.

So it is only natural that Arduino was built on this foundation to make their great ecosystem of development boards and their wonderful IDE. You can see Vegard truly appreciates and respects how Massimo Banzi made the entry into AVR programming even easier for both technical and non-technical folks alike.

Today, AVR 8-bit MCUs (as well as Atmel 32-bit ARM®-based MCUs) power a variety of Arduino’s easy-to-use boards including:

  • Arduino Uno: The most “standard” board currently available, the Uno is based on the ATmega328
  • Arduino Yún: The Yún is a microcontroller board based on the ATmega32u4 (datasheet) and the Atheros AR9331.
  • Arduino Nano: The Nano is a small, complete, and breadboard-friendly board based on the ATmega328.
  • Arduino Mega 2560: The version of the Mega released with the Uno, this version features the ATmega2560, which has twice the memory, and uses the ATmega 8U2 for USB-to-serial communication.
  • Arduino Leonardo: Based on the ATmega32u4, the Leonardo is a low-cost Arduino board, featuring the same shape and connectors as the Uno board but with a simpler circuit.
  • Arduino Micro: The Micro is based on the ATmega32u4, developed in conjunction with Adafruit.
  • Arduino Esplora: Derived from the Arduino Leonardo, the Esplora is a ready-to-use, easy-to-hold controller based on the ATmega32u4.
  • Arduino LilyPad: Powered by an ATmega32u4, the LilyPad is designed for wearables and e-textiles, allowing for the board to be sewn into fabric and similarly mounted power supplies, sensors and actuators with conductive thread.
  • Arduino Due: Based on an Atmel ARM Cortex®-M3 processor-based MCU — also known as the SAM3 MCU — the Due board is ideal for home automation projects and can run up to 96MHz.
  • Arduino Wi-Fi Shield: Built for Wi-Fi applications, the Arduino Wi-Fi shield is powered by the Atmel AVR UC3 MCU and an H&D wireless module, and provides developers a powerful Wi-Fi interface.
  • Arduino Zero: The board is powered by an Atmel SAM D21 MCU, which features a 32-bit ARM Cortex® M0+ core.

If you haven’t had the chance to tune-in to all of Vegard’s 1:1 interviews with the Atmel Analog Aficionado, you can check ’em out here.

Building real-time monitoring for IoT device state

You may have a couple Arduinos, or billions of IoT devices connected in a single instance. A common need today is the requirement to detect when devices are turned on and turned off, also known as device state. And, monitoring the device state of connected devices and machines in real-time is called presence.

In this blog post, we’ll walk you through how to use presence to monitor IoT devices and hardware connected with PubNub (for both Java and JavaScript).

PresenceIotDevices

Why You Need to Monitor Your IoT Devices in Real-Time

IoT hardware comes in all shapes, sizes, and prices. But despite their differences, monitoring device state is essential, and we need to know exactly when they’re online and offline. Say you have an (Atmel based) Arduino hooked up to your apartment doorbell for whatever reason. Your Arduino goes offline, the pizza man is standing outside, and you’re not eating. Or maybe the situation is more dramatic. You may have hundreds of IoT devices hooked up to manage your farm. Keeping tabs on those devices is vital for the health of your farm, and you need to know when they go offline.

Device Monitoring Using Presence

We’ll first walk you through using Presence for IoT devices with Java, then move onto JavaScript. With both, you’ll first need to sign up for a PubNub account. Once you sign up, you can get your unique PubNub keys in the PubNub Developer Portal. In the developer’s portal, click to enable Presence. Feel free to play around as much as you want in our free Sandbox tier.

Check out our simulated Presence demo to get a better idea of how Presence can be used for real-time monitoring of Internet of Things devices.

Java

Step 1: Presence and here_Now() are two features of PubNub that update device or user state in real-time. Whether you choose to use JavaScript or the PubNub Java Presence SDK, the output for Presence is the same. You will get an output in this format:

{"message":"OK","status":200,"uuids":["uuid1"],"service":"Presence",
"occupancy":1}

where “uuids” contains a list of the uuids online and occupancy gives the number of online users.

I will be using the code feature to see ‘who’s there?’. All you need to provide is the channel name, and then check if there is anyone on that channel. The code sample below is basic usage.

pubnub.hereNow("my_channel", new Callback() {
     public void successCallback(String channel, Object response) {
         System.out.println(response);
     }
     public void errorCallback(String channel, PubnubError error) {
         System.out.println(error);
     }
 });

This will output the devices that are online which is identified by the UUIDs. In order to consume this information, all you need is to modify the callback function a little. The following code shows you how:

Step 2:

Callback callback = new Callback() {
	public void successCallback(String channel, Object response) {
	    String temp = response.toString();
	    int start = temp.indexOf('[');
	    int end = temp.indexOf(']');
	    for(int index = start+1;index<end;index++){
		    if(temp.charAt(index)!=','){	
		    	uuid1 = uuid1 + temp.charAt(index);
		    }
		    else{
		    	System.out.println();
		    }
	    }
    	String replaced = uuid1.replace("\""," ");
    	String[] uuidlist = replaced.split("\\s+");
    	for (String tempstring : uuidlist){
    		System.out.println(tempstring);
    	}	
	}
		
	public void errorCallback(String channel, PubnubError error){
		System.out.println(error.toString());
	}
};
	
	public void herenow(){
		Pubnub pubnub = new Pubnub("demo", "demo");
		pubnub.hereNow("my_channel", callback);
	}

This code, modifies the information received by the hereNow function, and stores and prints it in an array called ‘uuidlist’. In this manner, you can now use this information according to your requirements.

JavaScript

Step 1: The PubNub JavaScript Presence feature is an optional parameter used along with the subscribe call in JavaScript. The code sample below is basic usage:

pubnub.subscribe({
     channel: "my_channel",
     presence: function(m){console.log(m)},
     callback: function(m){console.log(m)}
 });

The presence feature will output the devices that are online as identified by their UUIDs, along with their timestamp, an action that indicates join/leave/timeout and the occupancy of the channel. This information will be displayed in the console.

But what if you want to consume this information by publishing it to a screen or store it somewhere? The following code lets you do just that.

Step 2: Now we’ll bring the presence to life with JavaScript

var deviceList[],
devices =[];

pubnub.subscribe({

    channel: 'my_channel',
    presence: function(message,channel){
        if(message.action == "join"){
        	devices.push(message.uuid);
    		deviceList.append("<li text-align:
    		center>" + message.uuid + "</li>");
      		}
        else{
          devices.splice(devices.indexOf(message.uuid), 1);
          deviceList.find(message.uuid).remove();
	}
 }
});

Here, we define a custom function for presence which basically uses the different actions of a presence event that could occur, such as join, timeout and leave.

  • If a ‘join’ occurs, we append the UUID to the list of devices that are online.
  • If a ‘leave or a timeout’ occurs, we remove that UUID from the list of list of devices that are online.

You now have the online users, both in an array called ‘devices’ and also as list printed on a page.

This way, you can now be updated on the different devices joining and leaving your network in real-time.

You can check out the PubNub JavaScript Presence documentation here.

Additional PubNub Presence Resources

28 new application notes for Atmel | SMART SAM4S devices

Atmel engineers recently published 28 application notes for the company’s comprehensive Atmel | SMART SAM4S devices. Based on the powerful ARM Cortex-M4 core, this Atmel | SMART product line extends our Cortex-M portfolio to offer:

  • Increased performance and power efficiency
  • Higher memory densities: up to 2MB of Flash and 160KB of SRAM
  • And a rich peripheral set for connectivity, system control and analog interfacing

According to an Atmel engineering rep, the application notes target the use of peripheral modules and are based on drivers already available in the ASF (Atmel Software Framework).

“The application notes highlight the availability of the drivers and offers the reader relevant details about the API (application programming interface),” the rep told Bits & Pieces.

“This significant increase in the number of application notes for the SAM4 series gives the engineer a better starting point for using the products. More specifically, the new application notes cover the Atmel SAM4S/SD, SAM4N, SAM4L/LS, SAM4E, and to some extent, also the SAM4C and SAM G51/53 families.”

atmel_SMART_Microsite_980x352

So without further ado, the following app notes are now available from the Atmel website in PDF format:

Resurrecting a Macintosh Plus from the dustbin

Stuart Cording, an Atmel aficionado over in Europe, tipped me off to this blog where a fellow got his old Mac Plus up and running. Jeff Keacher had the typical hardware problem, a power supply capacitor blew on him after a short while. What was amazing is he also got it to connect to the World Wide Web.

Mac-Plus_surfing-Internet

Jeff Keacher got this 27-year-old Macintosh computer up and running and then got it to browse the web.

My buddy Alan Martin over at honored competitor Texas Instruments has a saying “It’s always a cap”. With old radios and such it is the large can electrolytic that dry out. They stop filtering the wall voltage so you then hear a bad hum in the output. Eventually they “punch through” and blow up. For test equipment, Alan often comments on how great it was that Tektronix used all those “lemon drop” tantalum capacitors, since they all fail and make it easy to buy really good test equipment really cheap. Then you just replace all the tantalum and electrolytic capacitors. Like the old Macintosh, you can always find a suitable replacement at Digi-Key, or one of the other distributors. I have described how Eric Schlaepfer over at Google manages to put a new capacitor in the original can, so the gizmo still has that classic vintage took to it.

X-Y-capacitor-failure

This is the X-rated capacitor that failed in the Mac Plus.

The cap in the Mac was an X-cap, a film capacitor that is rated for long life and designed to be across line voltage, the 120AC in your house. It is a little disturbing that it failed, film caps don’t dry out like electrolytic. I know some of my pals use a Variac to slowly bring up the line voltage the first time they power up old equipment. I hear that doing that is less stressful to the capacitors and you can see things smoking at a lower voltage so you might not do as much damage.

Variac_General-Radio-Company_V10MT10-B13-N2

My analog aficionado pals bring up old equipment with a variac like this. That way you are applying voltage to the input capacitors with a slow ramp-up.

Now there was quite a hardware and software challenge to get the Mac Plus on the web. I think it was a bit of a cheat to use a Raspberry pi. Heck the pi will run Linux and has a video system. Why not just toss the Mac Plus in the garbage and connect a monitor the Raspberry pi? Well, sure, anybody can do that. So the author solved the hardware problem letting a Raspberry Pi be the middle-ware between the Mac and the Web. But there was still plenty of fun putting in a TCP/IP stack and a browser and all the other fun coding they had to do to get a web page to render. Bravo, now I think I will listen to that Merle Haggard song about Fords and Chevys lasting ten years like they should.

Museum of American Heritage highlights technology 1750 – 1950

A tip of the hat to audio guru Steve Williams, who tipped me off to the Museum of American Heritage. What started as a private collection of Frank Livermore has grown into a full-blooded museum.

They intend to combine elements of history, technology, and design. This will illustrate the evolution of technology, how and why it has influenced society from inception to the current time, and give a glimpse of future expectations. The museum has an average of 12,000 visitors per year, plus 3,000 to 6,000 visitors for special holiday displays and over 5,000 attendees at its annual Vintage Vehicles and Family Festival.

Museum Entrance

Museum Entrance, courtesy Britt Bredstad

There is a nice archive of exhibits and you can poke around their site to see a great spread of technology over the decades.

Located at 351 Homer Avenue in Palo Alto, CA, MOAH exhibits are open from 11am to 4pm on Friday, Saturday and Sunday, except during exhibit changeover weeks and selected holidays. Call MOAH at 650-321-1004 for further details.

ATmega328P inside the Nexus Q

Talking to one of my Google buddies at the eFlea, he mentioned that there is an ATmega328P inside the Google Nexus Q media streaming device. I asked what it did and he explained there is a row of LEDs around the device and Google wanted those LEDs to light and flash in sequence the second you applied power. A perfect application for a Flash microcontroller that boots in microseconds.

I was concerned that this was a Google secret until a quick check on the Internet showed a post over at the great folks from iFixit. It verifies that there is an ATmega328P inside the Nexus Q, and you can even see the Atmel logo in the picture.

ATmega328P-Nexus-Q

The Atmel ATmega328P is used to flash the LEDs around the periphery of the Google Nexus Q. It’s the bigger chip at the top right (courtesy iFixit).

Going back to the beginning of AVR with Vegard Wollan

The first episode of this series talked about the very beginning history of the AVR microcontroller chip co-invented by Vegard Wollan. In this clip, we delve into the beauty of Flash memory.

As mentioned in the previous post, engineers used to have to develop their firmware using special ceramic chips with quartz windows.

MicroChip-UVEEPROM-microcontroller

This early microcontroller has a quartz window in its expensive ceramic package so you can erase the program in an ultraviolet eraser.

Bad enough the chips themselves cost a lot, the real headache was when you had to debug or change your program. You had to pry it out of its socket, and stick it in a ultraviolet eraser for 20 minutes. This really slowed down your code development. It was like playing tennis in molasses.

UV_eraser

This UV eraser was used to erase the microcontroller program memory so you could reprogram it with something that you hoped would fix the bugs.

That is what Vegard realized back in the early 1990s: You could make a microcontroller using Flash memory and reprogram in seconds, not hours. Atmel already had a Flash 8051-style micro, so we were a natural to develop the AVR chips.

The aforementioned video touches on the low-power heritage of AVR, which as you already know, Atmel memory products are famous for extremely low power. This advantage was “baked into” the AVR products, since they knew that many applications would run on battery power.

Vegard was also nice enough to bring some early AVR prototypes from his lab in Norway.

Vegard Wollan holds one of the first 10 AVR prototype chips, the S1200.

Vegard Wollan holds one of the first 10 AVR prototype chips, the S1200.

When Vegard holds up the various prototype chips, you can see the pride of an innovator on his face. I think every engineer gets a real charge out of that first prototype, as even I have a collection of my own at home.

In case you missed our earlier segment on the history of AVR, you can check that out here. Feeling inspired to create and share your own 8-bit ideas? Enter them in our Simply AVR Design Contest today for your chance at $1,500!

Vegard Wollan talks about the history of AVR

We were lucky enough to drag Vegard Wollan into the Atmel Studio while he was visiting headquarters from Norway a few weeks ago. For those of you who may not know, Vegard is commonly believed to be the “V” in AVR. After having spent hours in the Studio, we decided to break the film into separate segments — this one is about the history of the AVR. And, what better day to recount the earliest days of the revolutionary microcontroller than Throwback Thursday?

You young whippersnappers might not realize it, but Atmel started life as a memory company. We made EEPROM memory, and soon branched into Flash memory. Vegard and his pal Alf Bogen (the “A” in AVR) met on computer forums while students at Norges teknisk-naturvitenskapelige universitet, also called NTNU, or the Norwegian University of Science and Technology. They saw the need for a microcontroller based on Flash memory, which you could reprogram as many times as needed, even when it was in-circuit.

Vegard-Wollen_holding-AVR-Masters-thesis

AVR inventor Vegard Wollan holds his Master’s thesis from college that began the AVR MCU architecture.

This was at the time where development engineers had to buy expensive ceramic package microcontrollers with a quartz window. You would program the part with your Data IO programmer, and when you had to make any change, you took the part out of its socket and put it in an ultraviolet eraser for 20 minutes. Savagery.

So Vegard and Alf pitched their MCU design to Atmel, who immediately saw the great potential in it. Atmel had already started to make 8051-style MCUs in the Colorado fab facility, which we had just purchased from Honeywell. One great thing about those parts was most instructions executed in one cycle instead of the 4 to 12 that the original 8051 needed.

So when Vegard explained the AVR was a RISC (reduced instruction set) machine designed to execute instruction in one cycle, it was music to Atmel’s ears. You could say that AVR was RISC before RISC was cool. And, it explains why AVR has passionate followers just like ARM-core RISC chips also have passionate followers… I guess that explains why Atmel makes 8- and 32-bit AVR chips, as well as a whole line of Atmel | SMART ARM-based chips.

The other cool thing that this video touches upon is how AVR chips were designed to run C programs well. You might remember the early days, when Intel would make whatever hardware people thought was cool and Microsoft would program in ways that software people thought was cool. Things didn’t always line up. I remember how you had to do a software reboot to take a 80286 out of protected mode, or that “thunking” in Win 95 to switch between 16- and 32-bit.

Vegard is a Renaissance Man that understood the hardware implications of good software design. So he made sure that C code would compile superbly into AVR assembly language. My buddy Wayne Yamaguchi routinely writes C programs for AVR that compile down into a few hundred bytes. AVR is one of those magnificent examples of computer science, not computer “slap this together and push this out so we can sell it”.

Like all Norwegians, Vegard is incredibly modest about his contribution. He credits his co-founder, and the team at Atmel that developed the AVR. But you just have to look at the billions of AVR chips that Atmel has sold to see what a remarkable thing Vegard created. Check out the video and stay tuned for the next installment.