How Fast is Your Fidget Spinner?

You never know what people will do with your ideas, and it is always fun to see someone do something I would have never thought of with them.  I got a video from someone who built my Programmable Fidget Spinner, and used a leaf blower to see how fast they could get it to go.  Fortunately, they were wearing safety glasses, and no, it didn't come flying apart.  It did, however, start displaying erratically at about 3600 RPM (the fastest I can get it by hand is just under 2000 RPM).

So, what is going on?  TLDR: I figured it out and fixed it, and here is proof.

One of the reasons I love Arduino is because it is so easy to write and understand it's code.  All the hard parts that scare beginners away have been abstracted out.  Case in point, to turn on a single LED, all I have to do is call the function digitalWrite(LED, HIGH).  The only thing I need to know is what pin number the LED is attached to and that "HIGH" means "ON" (and "LOW" means "OFF").  To display on the eight LEDs on the fidget spinner, I can use
    for (int led=0;  led<8;  led++) {
      digitalWrite(LEDS[led], state[led]);
    }
Which means to iterate over the eight pins the LEDs are attached to, one at a time, and turn them on or off based on the value held in the state array.  Easy-peazy, and all is well, unless you are doing something that becomes time limiting like turning those LEDs on and off in an ever decreasing amount of time as the figet spinner speeds up.  At some point (about 3600 RPM), there just isn't enough time, and the CPU moves on to something else, leaving the LED output garbled.

Now intuitively, I know the Arduino is more than fast enough to do what I want, the problem is that the digitalWrite() function hides a lot of dirty work under the hood, and calling it in a loop only multiplies the problem by eight!  When you realize that each of the eight pins is actually an 8-bit port, and that you can set all eight at once using a PORT command, you can increase your speed by almost an order of magnitude.

Of course, there is a lot more detail (and math) to this than I feel qualified to try and explain, but I did try a few timing experiments a while back that probably helped me figure my current conundrum out. Perhaps the most instructive thing to do here is demonstrated how to do the venerable "blink" sketch using ports.

First step in leaving the comfort of Arduino abstaction is figuring out from a Pin-Out chart  that Digital Pin 13 (the built-in Arduino LED) is actually bit 5 of Port B on the Atmega328 chip, a.k.a "PB5".

Instead of pinMode(13, OUTPUT); we set the data direction bit of DDRB for bit 7 to 1 using the command DDRB = B00100000; 
Now to turn the LED on, we set bit 5 of port B high using PORTB = B00100000, and off using PORTB = B00000000

Realize, off course, that we are controlling all the bits of the port the same time, and that there are clever ways to hit just the bits we want, but I'll save that for a later post.

The most instructive part of this experiment is seeing the difference in the sizes of the regular blink sketch (1030 bytes), and the port manipulation equivalent (634 bytes) is almost 400 bytes!  That doesn't seem like much if you are thinking about 32K of memory, but realize that each byte represents an instruction, and you can see we are not just wasting program space, but also using a lot instructions to do the same thing.

I think the bottom line here is to realize that Arduino is great, and abstraction makes life easy, but at some point, you will have to get your hands dirty if you want to go fast!



500 Tindie Orders, 1200 Kits Sold!

When I started selling kits on Tindie, I made 50 Yet Another Programming Shield Kits, and hoped to sell half of them to break even.  The one thing I realized quickly was that I would need more than one kit offering if I hoped to make any money.

Three and a half years later, I've filled 500 orders consisting of more than 1200 kits of eleven different types.  This doesn't count kits I've sold for workshops and conferences, which would be at least another 500.  I'm making just enough money to keep developing new kits and buying PCBs from OSH Park without putting them on a credit card my wife can see.

I've been amazed at how many overseas sales I've had since the shipping costs seem prohibitive. I've sold to every continent except Antarctica (contact me and I'll make you a deal):


I've also sold something to every US state except Montana, North and South Dakota, Alaska, and Maine (contact me and I'll make you a deal).

I've got some great kits in the works, including an awesome low-cost robot and a Raspberry Pi Camera setup.  I can't wait to see where the next 500 kits go!



Girl Scout Girls Are Awesome

I got invited to do an electronics workshop at a Fall Girl Scout daycamp. I had been on a Maker hiatus since HP let me go back in February, and I was really missing the fun and joy of teaching. The camp was on the east side of the Oregon Coast Range, and although it was cool and a bit wet, the lodge was warm and dry and overlooked a serene pond.

The sessions were an hour and half which was more than enough time to assemble my simple LED kit and give the girls time to incorporate it into a craft project. Before starting, I talked about Ann Makosinski, a young lady who invented a LED flashlight powered by body heat, as an example of why you would want to learn to solder. I also gave the girls a "nanosecond" of wire and told briefly of the contribution of Grace Hopper to computer science.

The girls were positive and awesome and picked up the skills quickly. It always gives me warm fuzzies when I overhead comments like "this is fun" and see the girls helping each other! It is fun to learn, fun to do, and fun to teach others!

The final group was more advanced, and had purchased Adafruit LED goggle kits.  I pre-programmed the microcontrollers, and the session was just enough time to assemble and test them. Since the theme of the camp was Steam Punk, they fit right in with the costumes the girls had prepared.

I am always grateful that my girls are growing up in an age when they can be independent and do anything their heart desires. I am also grateful for opportunities to help others find their passion.

ChickTech Robotics 2015

I've spent a lot of the past year designing and testing a low-cost robot that could be assembled and programmed in a workshop. It has been, in one form or another, demonstrated at three Maker Faires this year. I finally got a chance to put the project to a full test for ChickTech's Portland High School workshop. 
The event was held at Portland State University. There were more than one hundred students that got to chose between eight different workshops. We had fourteen girls for robotics. We spent the first day building the robot and learning how to program an Arduino microcontroller.
The second day we finished the robot and learned how to program it. In my workshops I always emphasize that makers have to patient and persistent, and the girls, most of whom had no prior programming or electronics experience, did a great job in picking up those skills.
At the end of the event, the girls got a chance to show off what they had learned to family and friends. This is always the pay off for me as I hear them proudly explain things I was teaching them just hours earlier. It always makes all the time planing, preparing, and teaching well worth it.

3D Printing and Design STEM Academy Summer Camp

In addition to Outside the Box, I volunteered to lead a 3D Design and Printing class for the OSU STEM Academy this summer. This time I had Margaret Mellinger, the 3D print guru from the OSU Library, as a co-teacher. This class was 3 hours a day for 5 days and had fifteen students. I was told there was a wait list of at least that many more!
We started each class off with a short instructional or inspiration video:
We also had a guest speaker, Kevin, an intern working with Margaret who does model rocketry and is working on a 3D printed Ironman mask. The students started with some tutorials in the web-based Tinkercad. We followed that up with taking a look at 123 Design. Later in the week we also looked at OpenScad. All these projects are free to use, and students were encouraged to continue their design work at home.
The kids had an hour of print time to work with, and they came up with some creative projects. They learned how to design for efficient prints, how and when to add supports, and how to slice projects into smaller units for printing. We also uses a Makerbot scanner to scan in small objects, and an X-box Kinect scanner to scan in a student.
In all, I think it was a very successful class. We learned a lot, and we got a lot of good feedback from both students and parents. I can't wait to do it again! Here is to the future of 3D design. . .







My First 3D Design and Printing Class

For this summers Outside the Box pre-college classes at Oregon State University I pitched an idea for a 3D design a printing class. Based on my experience with 3D printing in the Maker Exploratorium, I knew there was some interest, but when the kids signed up and the choices were sorted, I had nearly 60 students signed up over four different classes.

We had two Printrbot Simple Metal printers on hand, one mine, and the other a loaner from the OSU Valley Library.
The students were given an hour of print time to do with as they which. This is about enough for an object 2 inches by 2 inches. Some students created a number of small objects like ear rings.
Others created large single projects using all their time. Several gals created mult-room houses with removable roofs.
On the final day, for the older class, we broke out an X-Box Kinect scanner and replicated a couple of students.
While there were a number of super-creative project, including helicopters, tanks, stealth planes, spaceships, Minions, Eva, and Wall-E, my favorite two were puzzles. One was a cube puzzle and the other an enclosed "black box" maze.
We learned quite a bit about designing to minimize support, using filament as design elements (whiskers, canes, axles). We also learned a lot about post-processing prints including support removal, hot-glue gun repair and shaping. I also learned a lot about file and print queue management. For a first-time offering, I think the class went well.  I can't wait to do it again!

Maker Exploratorium 2015 Edition


We finished the third round of my offering for Oregon State's Adventures in Learning pre-college program. Here is the course description:
We are all makers at heart. We just have to find our passion. Explore electronics with Arduino microcontrollers. Learn how computers work with Raspberry Pi. Learn how to program in Scratch, JavaScript and Python. Incorporate computing in textiles with soft-circuits. Take apart an appliance to see how it works. Create art from junk. Explore and utilize online maker resources. Go home with the skills and confidence to follow your passion.
For this session we had seventeen young makers age 10 to 12. I had one college assistant, a mechanical engineering student named Jeremiah. This was the first class of the day and met for eighty minutes, Monday through Friday, for two weeks.

I like starting classes by showing showing short videos each day.  We start with Dale Dougherty's TED talk entitled "We are Makers".  He points out that there are lots of different types of makers, and that everyone is a maker of some sort or another.  I also showed videos about how everyone should learn to program, and that sometimes it is frustrating but worth it, and how you have to be persistent.

This time around we broke the kids in to four groups, and assigned a different activity for each group. Each group rotated to a new activity every day. This made it easier to monitor the intensive activities like soldering and required less hardware for activities like Arduino.  The first four projects were:
  • Blinky LED circuit where we learn a little bit about electrical circuits and how they work.
  • How to blink an LED with a programmable Arduino.
  • Some simple programming in Scratch.
  • 3D design with Tinkercad.
The 3D printing has come a long way since last year, when all they did was customize a coin which we then had the Valley Library print out for us. This year we had our hands on two printers, one mine and the other a loaner from the Valley Library. The students were given 15 minutes of print time, enough to print out an object about one square inch in size, and allowed to design anything they wanted. We had lots of MineCraft objects, a chess piece, and a replica of the Parthenon. I also taught dedicated 3D printing classes which you can read about here.

 Projects for the second series of rotations included:
 I also brought in my Maker-Faire turtle robot for the kids to play with and a Raspberry Pi.

The final two days we finished up the soldering projects, dissembled a laptop, created junkbots from the parts, and had the parents in to learn what the kids were doing. It was an exhausting and exhilarating week. I learn new things every time I teach. Hopefully the kids do too!