Sunday, January 15, 2017

Updating Wi-Fi Chips and Modules - Draft

I'm doing an update to my summer 2015 comparison of Wi-Fi boards boards for micro projects.

For this round, I'm breaking things up to a listing of chips and modules used, then a separate listing of popular breakout boards for those chips. So for part 1, I've developed a draft table of popular chips and modules.

I'm soliciting comments as to additions, changes, etc.


If the blog isn't displaying it well, here is the direct link: https://4.bp.blogspot.com/-f_XHmZ-JL9k/WHt6G4GxIJI/AAAAAAAAPGk/tL1ldiI-sbAmhYi8AZw7ohb01AE30XbxACLcB/s1600/wifi.PNG

Version 1/15
Link https://4.bp.blogspot.com/-VPa-T0Ej_hM/WH0RS7j_UCI/AAAAAAAAPHQ/Ic7jezGYZgwkCwrQPfrT-dQOFYHuCRNNACLcB/s1600/wifi2.PNG

Friday, January 13, 2017

Arduino as a Microcontroller Reference Platform

The Arduino line of microcontrollers has, arguably, been the spark that brought programmable hardware to Makers worldwide. This article takes a look at how Arduino furthered the use of microcontrollers and how it is important defining standards today.

Arduino dates back to Hernando Barragán's design of the Wiring platform in 2004. In 2005, Massimo Banzi, with David Mellis forked the Wiring source code and started running it as a separate project. Arduino use grew through successive product releases including the Arduino Diecimila, Arduino Duemilanove, and the baseline Arduino Uno board series (in its third revision). The evolution set the Atmel ATmega328P microcontroller in the Uno to become the microcontroller standard of its time.
The Arduino Uno R3 (photo via Adafruit)
The ecosphere of Arduino, consisting of the circuit board and Arduino Integrated Development Environment (IDE) became very compelling for developers. Many software libraries were created to extend Arduino software capability and hardware connectivity. This growing capability launched the ATmega328 into many project designs. The success of the Uno board design led to other companies and makers to make Uno compatible boards based on the '328. The price of the Uno was set at the time at $35 and it did not go on sale often, requiring an investment on the purchase of each board.

In expanding the Arduino product line, the Arduino team introduced other boards based on newer microcontrollers. Some have been more widely adapted into maker designs than others. Many software libraries required changes to support different microcontroller architectures.

The development of the Atmel ATmega328P has evolved from the ATmega168 and smaller ATmega8, which all use the Atmel's AVR architecture. The '328 chip runs at a nominal 16 MHz (on the Uno) with 32 kilobytes of flash memory. This is modest by computer standards, but this chip equalled much of the industry when it was introduced.

The Arduino team, in looking for better designs, introduced the Arduino Leonardo. Leonardo was based on the Atmel ATmega32U4 microcontroller with the same 32kB of flash at 16 MHz. The chip was mostly compatible with the '328 but also had the feature of native USB controller onboard, eliminating the need for a separate USB chip on boards such as Uno. The Leonardo was less popular than the Uno but found some interesting uses due to features not found in other microcontroller boards. The native USB was very popular with other company/Maker board designers who, to this day, use the ATmega32U4 and the Leonardo software to make compelling microcontroller boards at a low cost.
Arduino Leonardo (photo via arduino.cc)
Sadly the Leonardo has been discontinued by the Arduino team but the use of the ATmega32U4 lives on in many new designs.

The Arduino Due was the Arduino team's first commercial step into the Atmel SAM architecture chips. SAM features an ARM processor, capable of speeds much higher than the Uno/Leonardo 16 MHz and also capable of more flash and other compelling features. The Due, being the first Arduino SAM board did (has) not find (found) a wide following in products or maker projects but it did (has) start software migration of the Arduino software base to use non-AVR chips. (Note: While announced as discontinued, they are still available via arduino.cc).

Note: Yes, I am skipping some Arduino releases here and there which are also AVR based designs.

The Arduino Zero, beta tested in 2014 with release in 2015, has become the new tier for microcontroller designers. Based on the newer Atmel/Microchip SAMD series, the board provides the SAM higher clock rates, ARM core, and a much smaller size.

Microchip recently bought Atmel, hence the processor provider name change.

The Zero has not supplanted the venerable Arduino Uno, yet, but the day draws closer where there are no arguments for selecting the more modern chip. Variants are smaller and much easier for manufacturers to incorporate. The Arduino Zero software is defining a new generation of compatible boards, especially from Adafruit.com which is revising a number of their microcontroller boards to use the SAMD chips. The third party boards are often less expensive than the Zero as the Zero design uses an additional debug hardware chip not used by most hobbyists.

It is conceivable that Microchip may look to discontinue AVR production through price hikes, leaving the SAMD and possibly their own PIC lines more widely available.
Arduino Zero (photo via Adafruit)
Where does the flood of Arduino compatibles leave the Arduino team?  Actually in a fairly good spot. The team are the Research and Development group foremost, providing both the low level chip firmware and the ever more powerful IDE to tap into new chips. The Arduino team continues to bring forward very compelling boards in different form factors: the Arduino Zero, MKR1000, and MKRZero boards have a great amount of capability at a cost lower than the Arduino Uno of old.

The Arduino team also has been collaborating on non-Microchip boards, including Arduino Yun, Arduino 101, and others. They also are important in expanding both the capabilities of the Arduino ecosphere and in partnering with companies other than Microchip to include Intel. The ability to easily use new, powerful microcontrollers and Linux based processors only benefits the ability of both companies and Makers to use the newer processors.

We all can look forward to the growth of the Arduino family tree, which has grown from a seedling over ten years ago. The innovation of the Arduino team has enabled people worldwide to harness some incredible hardware in making incredible products.

Wednesday, October 12, 2016

Videos on My New Tone Controlled Robot

I have been working for awhile on an Adafruit Circuit Playground simple robot, mainly controlled wirelessly via sound.

Cute and capable
The whole tutorial should be out soon, but here are two of my Youtube videos showing the robot.


Here is the bot controlled via two whistles (harder to do than using a tone box):

Saturday, September 3, 2016

Microsoft: Refrigerators, not now - IoT Basics, yes please

Microsoft and Liebherr announced yesterday they are collaborating on a new "SmartDeviceBox" that allows the kitchen appliance to remind people what they need at the market, Microsoft principal data scientist TJ Hazen said in a blog post.

Fir now, let's not make jokes about your refrigerators updating at bad times or having blue screen of death episodes.

Rather, let's connect this announcement with an article that was published by former Apple executive Jean-Louis Gassée (link here). Most Internet of Things watchers are very skeptical right now. With some companies discontinuing the services behind their products and support often horrible, the consumer space has been very mixed. And some of the ideas are just not well thought out.


Gassée states 'The IoT randomly works. Devices stop and restart, they require visits to unsupportive customer support pages and helpless Your Call Is Important To U.S. help lines (and now we have chatbots). If you think I exaggerate, google “Nest trouble” or “smart bulbs trouble”.... Companies buy the cheapest possible processor, grab some software from the open source shelves, throw on a skimpy UI, hastily assemble and test, ship it.' Then he states "After a device has made it to the market, the real fun begins. Software updates are a problem when your connected lock or your connected car is in the middle of an update and you need to get in the house or drive to the emergency room."

If you look at my favorite vantage point, security, on that topic Gassée writes "Then there’s the truly ugly side of Consumer IoT: security, or the lack of it. The lackadaisical, to be polite, approach to software leaves many connections open to hackers who can see passwords exchanged in clear text on home WiFi while they sit in a car parked outside the house. Or we see that 100M Volkswagen cars are open to wireless hacking."

Then let's look at standards.

On Twitter, Alasdair Allan (@aallan) states: The #iot has 3 problems; security, refresh cycle, and standards. Of these standards least important, but only one the Valley cares about.

Companies don't often want cross-company standards. The classic "if we build our own ecosystem, we can keep people buying only our products" (examples: Nest, Apple).

Ok, so much for the doom & gloom (for now).

Getting back to Microsoft. They are jumping on refrigerators and cars and what not. But this is the perfect opportunity for Microsoft or whomever to be a pivotal group in spurring the Internet of Things. How? Make it easier for people. Connecting IoT devices to the home and talking to each other is currently hard. Microsoft knows this space, they can make it easier for us. Take Windows 10 IoT and double the staff and tie them into your research group.  Make It Simple is the goal.

I never want to have to reboot my GE smart bulb, certainly not having to do this manually, that is not asking too much. If Microsoft got IoT basics right, it wouldn't matter if company X did a great Kickstarter, then 2 years later went out of business - if we had common basis, things would still work in a standard way which communicates in a way that is easy to use (thanks to Microsoft or whomever heeds this).

A starting point. Integrate the DynDNS type service in. Microsoft did it for Windows Home Server, they know how.  Bake it in. Keep building in the simple, positive steps.

We didn't go to the moon on the first launch. Microsoft and others, ensure you build a standards compliant base which includes security and intercompatibility, for IoT to grow on.

Wednesday, August 24, 2016

An Adafruit Circuit Playground Rolling in a Pringles Can

Good response today as I posted on social media the picture below - the Adafruit Circuit Playground low cost experimenter board and a 3xAAA battery pack fit well in a Pringles potato chip (crisp) can:


So I have been playing with the accelerometer sensor in the Circuit Playground. You can do some sophisticated things with an accelerometer.  Let's see what I did with the can.

Parts:
Adafruit Circuit Playground experimenters board - $19.95
3xAAA Battery Pack - $1.95
3 AAA batteries
Pringles Can - from the bin
Putty - from the craft supplies basket

Use some Blu-Tack, silly putty, clay, etc. to attach Circuit Playground to the battery pack. Just be sure the adhesive is not permanent and non-conductive. Plug the battery pack into the Circuit Playground and turn it on. Slide it into the can, it'll fit fine and not slide around (yay!).



First, I'll light up one Circuit Playground LED NeoPixel green. Program Circuit Playground with the first sketch below (which turns on NeoPixel #2).  Then I put the Circuit Playground into the can so it is fixed to the bottom. Then I roll the can. The LED will do loop-de-loops in circles similar to the following diagram:

And in the dark it looks like this:

Now, say I want the LED to always be at the top of the can. I can try to time the lighting of the LED to the rate at which I spin the can but I'm not a good can roller and it would get all messy.

So I use the accelerometer on Circuit Playground to tell which way is "up" as the can rolls at any speed.  An accelerometer measures both the pull of gravity on the sensor and changes in movement. If you roll Circuit Playground like we did above, there will be changes in the X and Y directions (the Z axis doesn't change rolling the can as I have mounted it).  See the board for which ways are

Is keeping the LED lit at the top of the ring as the can rolls even possible?  Yes. It takes some math though. You can read the acceleration values as the can rolls in rolling distance and as the can presses on the ground due to gravity. Kind of like the figure below from the Wikipedia article Circular Motion under the non-uniform heading
Program the Circuit Playground with the second sketch below. The code boils down to finding the angle between the x and y values of the accelerometer reading, calculating an angle. That angle is used to determine which of the 10 NeoPixels on Circuit Playground needs to be lit to remain at the top of the ring. That method allows for the rate of rolling the can (shown as v in the diagram) to vary and the rate of rolling does not matter (except a tiny bit for code speed). 

The LED at the top of the circle is lit at all times. It looks like this in the Pringles can:


So with little more than an empty can, Circuit Playground and a battery pack, we've used a bit of sensing and programming to make something do what intuitively it shouldn't do. This behavior is actually VERY useful and can be used to make bigger and better things.

And that's the beauty of Circuit Playground.  You can do so much with the capabilities onboard and you don't need to buy a lot of stuff to make it do great things, just look in the cupboard perhaps.

Code


Code for one LED:

// CPoneLED
//
// Set for Circuit Playground to display one LED Continually
//
// Mike Barela  August 23, 2016  MIT License

#include <Adafruit_CircuitPlayground.h>

#define brightness 16

void setup()
{
  CircuitPlayground.begin();
  CircuitPlayground.setBrightness(brightness);
}

void loop()
{
  if(CircuitPlayground.slideSwitch()) {
    CircuitPlayground.setPixelColor(2,0,brightness,0);
  }
  else {
    CircuitPlayground.setPixelColor(2,0,0,0);
  }
  CircuitPlayground.strip.show();
}

and code for the accelerometer aided LED:

// CPaccelerometerLED 
//
// Set the LED at the "top" of the Circuit Playground NeoPixel ring
//   no matter the x or y orientation (like when rolling)
//
// Mike Barela  August 23, 2016  MIT License

#include <Adafruit_CircuitPlayground.h>

#define NUMBER_OF_LEDS_ON_RING 10
const int brightness = 16;
int ledPosition, currentQueueSize;

void setup() {
  CircuitPlayground.begin();
  CircuitPlayground.setBrightness(brightness);
  CircuitPlayground.clearPixels();
}

int led, previousLed=0;
float x, y, nx, ny, angle; 

void loop(){

  x = CircuitPlayground.motionX();  // Read the accelerometer X & Y
  y = CircuitPlayground.motionY();
  nx = x / 10.0;                    // Scale to -1 to +1 in
  ny = y / 10.0;                    //    both directions
  angle = atan((ny/nx)) * 180 / 3.14; // get the angle from "down"

  if(angle > 0.0){   // As Arctangent won't give the angle over the
    if(nx < 0.0)     // entire 360 degrees, adjust depending
      angle += 180;  // on direction the acceleration was going
  } 
  else {
    if(ny > 0.0)
      angle += 180;
    else
      angle += 360;
  }

  if(angle == 360.0)
    angle = 0;

  // We have 10 LEDs in a circle - need to light the right one
  led = circularize(angle / (360 / NUMBER_OF_LEDS_ON_RING));

  // make led movement smooth
  if(previousLed == led){  // no movement, just reloop
    // nothing to do 
  }
  else if (counterClockwiseDistanceBetweenLeds(previousLed, led) <= 8) {
    led = circularize(previousLed + 1); // change detected, 
    makeLightShow(previousLed, led);    // change LED
    previousLed = led;
  }
  else {
    led = circularize(previousLed - 1);
    makeLightShow(previousLed, led);
    previousLed = led;
  }

  delay(25);
}

void makeLightShow(int previousLed, int led) { // light NeoPixel
  CircuitPlayground.strip.setPixelColor(previousLed,0,0,0);
  CircuitPlayground.strip.setPixelColor(led, 0, brightness, 0);
  CircuitPlayground.strip.show();
}

int circularize(int pos){ // if a position gets to be < 0 or > 9
  if(pos >= NUMBER_OF_LEDS_ON_RING)
    return(pos - NUMBER_OF_LEDS_ON_RING);
  else if(pos < 0)
    return(pos + NUMBER_OF_LEDS_ON_RING);
  else
    return(pos);
}

int counterClockwiseDistanceBetweenLeds(int prevPos, int nextPos){
  int distance;
  distance = nextPos - prevPos;
  if(distance < 0)
    distance += NUMBER_OF_LEDS_ON_RING;
    
  return(distance); 
}

An exercise for the student / magician is to make one sketch, it acts one way with the slide switch at the + position, another when switched to -.

Code heavily modified from https://petervojtek.github.io/diy/2015/01/24/neopixel-gravitation.html, the page gives some good info on the subject also.

Thursday, August 18, 2016

New Project: Adafruit Circuit Playground Sound & Music

My latest work was posted yesterday on the Adafruit Learning System. Their new Circuit Playground experimenting board has alot of uses. I explored using the onboard speaker to make sound and music. It progresses using the onboard light, temperature, and motion sensors. Finally it is programmed to play a Simon lights and sound game using the capacitive touch pads. It's a very flexible board.
Circuit Playground from Adafruit
See the full tutorial at https://learn.adafruit.com/circuit-playground-music

There will be more demos for this board - do you have ideas for projects?


Saturday, July 23, 2016

NeoPixel Rings in Poke Ball Colors

Just a quick post.  I'm playing with NeoPixels lately.  One set for my entry in the GE-Make-Hackster.io contest Lights for Life Challenge for one concept. The other is Adafruit's new Circuit Playground educational board.


Unless you've been stuck upgrading all your computers to Windows 10 before the deadline of July 29th, you may have heard that the 2000's sensation Pokemon has been reborn in a new augmented reality game Pokemon Go.

Poke Balls are the red and white spheres that a person uses to catch Pokemon.

Adafruit's NeoPixel light rings can be set to half red and half white to simulate a Poke Ball.

The code below has been set for the 10 pixels on Circuit Playground.  The code can be used on any Adafruit NeoPixel ring with quick changes to the constants at the start.

Have fun!

// CPpokeball   Paints your Adafruit NeoPixel ring in Poke Ball colors
//
// Set for Circuit Playground but works for all Adafruit NeoPixel Rings with
//   correct pixel pin number and pixel count 
//
// Mike Barela  July 23, 2016  MIT License

#include <Adafruit_NeoPixel.h>

const int pixelPin = 17;         // NeoPixel pin number for Circuit Playground
const int pixelCount = 10;       // Number of Neopixels (10 for Circuit Playground)
const int pixelBrightness = 30;  // 0 to 255

Adafruit_NeoPixel strip = Adafruit_NeoPixel(pixelCount, pixelPin, NEO_GRB + NEO_KHZ800);

uint32_t red = strip.Color(255, 0, 0);
uint32_t white = strip.Color(255, 255, 255);
uint32_t black = strip.Color(0, 0, 0);

void setup()
{
  // this resets all the neopixels to an off state
  strip.begin();
  strip.show();
  strip.setBrightness(pixelBrightness);
}

void loop()
{
  setPixelsPokeBall();              // set Pokeball colors
  delay(5000);                      // delay 5 deconds
  for( int8_t j=1; j<=5; j++) {     // blink Pokeball colors 5 times
     setPixelsOff();
     delay(700);
     setPixelsPokeBall();
     delay(700);
  }
  delay(2000);                     // wait a bit and start again
}

void setPixelsOff(void) {
   for(int8_t i=0; i<=9; i++) {
      strip.setPixelColor(i, black);
   } 
   strip.show();
}

void setPixelsPokeBall(void) {
    for(int8_t i=0; i<(pixelCount/2); i++) {
        strip.setPixelColor(i, red);
    }
    for(int8_t i=(pixelCount/2); i<pixelCount; i++) {
        strip.setPixelColor(i, white);
    }
    strip.show();
}