Showing posts with label NETMF. Show all posts
Showing posts with label NETMF. Show all posts

Saturday, January 10, 2015

Gadgeteer vs Arduino vs Phidgets



Hackaday.com recently ran an article called "Arduino vs. Phidgets - Dev Time Trials" which brought to attention a blog post by Ken (?) called "Hardware Protoyping Speed Test: Phidgets vs Arduino" which I thought was a rather fair set of tests for comparing development speed and costs for three simple projects. My objective is to run these same tests using the Gadgeteer rapid prototyping system and report my results. Of course, like any article of this sort there are always going to be some lively comments from the readers regarding the validity and bias of tests.  I fully expect that this article will generate plenty of its own.

Like [I suspect] Ken, I am not being paid to write this article and have not gone to every length to make everything as objective and scientific as possible simply because I am not interested in spending more than a few nights with these tests and producing the video.  However, I do feel that my tests are in line with the tests that Ken performed. Ken introduced us to Phidgets as an alternative rapid prototyping system for hardware.  His tests showed that Phidgets is indeed a faster development system than Arduino.  However, as he and the readers of the article pointed out there are several negatives to going this direction including:
  1. Cost - the Phidgets projects were considerably more expensive than the Arduino projects.
  2. PC Tether - Phidgets must be connected to a PC at all times.
  3. Proprietary

What is Gadgeteer and why use it?

My favorite hardware system for rapid prototyping is Gadgeteer.  Much like Phidgets, it uses modular components combined with software to provide a system which makes it possible to prototype extremely quickly.  In these tests I will demonstrate this.  I am also a big fan of Arduino and regularly use it in projects.  However, for rapid prototyping I haven't found anything better than Gadgeteer.  I have never used Phidgets myself.  Any statements about the platform come from Ken's article.

Gadgeteer also addresses the concerns numerated above with Phidgets.  You will see that the project costs when using Gadgeteer was only nominally higher than that of Arduino.  Considering the productivity gains, I believe it to be worth the investment.

Gadgeteer is microcontroller based.  So, a PC is only needed for programming and debugging.  Once that's done, you can untether it and power it from any DC source as you can with Arduino.
Gadgeteer is open source and is based on the open source .NET Micro Framework (NETMF) project.  Most of the modules and some of the mainboards are also open hardware & software.  Vendors can extend the core framework and add their own proprietary software to mainboard firmware.  However, no proprietary functions were used in my tests.

The Tests!

For more information about the tests, I encourage you to read Ken's article.  I'm going to focus this post on just showing my results and detailing concerns I uncovered when necessary.

TEST #1 : Blink an LED (aka "Hello World!")


For this test, I used the following components.
The results...

Some people may complain here that I didn't manually wire up an LED & resistor as Ken did in his tests.  I say that defeats the purpose of rapid prototyping.  One of the main advantages of Gadgeteer is that I don't need to know how to wire up circuits in order to quickly make something that works.

TEST #2 : Move a Servo 


For this test, I used the following components.
One thing I felt was an error in Ken's tests were that he didn't use the same servo in both tests but instead used a slightly more expensive Phidgets branded servo for the test of the Phidgets board.  Since the brand of servo really shouldn't matter, I thought it would be a more fair comparison to exclude the cost of the servo from the prices and assume that the same servo was used in every test since they all basically function the same way.

The results...

Some of the readers of Ken's article complained that he use "libraries" in his tests and I anticipate some will complain that I did the same.  To that I'll respond "you betcha!".  Built-in module drivers that have been written and tested specifically for a known module circuit that are easy to wire in via drag & drop programming is another big reason that rapid prototyping with Gadgeteer is so much faster.  Even if you have the libraries available to you in Aduino, you are going to have to locate them and figure out how to include them in your project which takes time that you do not have to spend with Gadgeteer.

TEST #3 : Pedometer


For this test, I used the following components.
The results...

Here we can see that as the complexity of a project increases, the development time saved by Gadgeteer really pays off.  It's also important to note that the cost of the Gadgeteer solution is only slightly higher than that of the Arduino solution and almost four times cheaper than the Phidgets solution.

OVERVIEW


Here I've plotted a summary of the results from the three tests.  The Y axis shows development time and the bubble size shows cost.  It is evident from this comparison that Gadgeteer makes a very good choice when choosing a rapid prototyping system.

Some readers of Ken's article commented that Phidgets was faster but due to the cost it wouldn't be useful for creating final projects.  As you can see in the cost comparisons of the Gadgeteer & Arduino solutions, Gadgeteer solutions can make very good options for many final projects.  In fact, I have consulted with a company in the past that is doing this very thing in a commercial product.  Certainly, if a company's volume gets high enough then it makes sense to convert to a custom PCB solution.  But if you are a start-up with more ideas than engineers then a Gadgeteer based solution is a very viable option.

Although at times it may sound like I'm getting paid to write this article, that is not the case.  I am just a really big fan of the Gadgeteer prototyping system and I'm excited to show you why.  There's much more power including rich debugging, inline help, and the full power of Visual Studio that these tests do not even begin to demonstrate.  

For more information, I encourage you to follow my blog and Gadgeteerin' YouTube channel for more information.  For up to the minute news about Gadgeteer, follow me on Twitter as @Gadgeteerin.

You can find all source code used in the video here.

http://hackaday.com/2015/01/12/arduino-vs-phidgets-vs-gadgeteer/
This post made Hackaday!

Tuesday, August 14, 2012

Gadgetab – the Gadgeteer Tablet

 

IMG_7943

2012-08-14 00.11.58

This story…

…begins a couple years ago when I started the Omnicopter.  To fly the copter, I needed a remote.  So, I built the Omnimote (right).  It was a Panda-II powered remote that used XBee to communicate with the copter.  It also had a small (slow) FEZ Touch display that was useful for displaying some info but had limited ability as a touch screen due to it being a resistive touch screen and it was just too slow to be depended on for use during flight.

As I’ve built other projects since then, it’s become more and more evident that I have a need for a universal device that can communicate and display information with other projects. 

In the past year, most of my focus has been drawn toward the Gadgeteer platform for electronics prototyping.  It’s a much more flexible and productive platform than anything else that exists at the moment and has dozens of powerful modules (subcircuits) that can be attached to it.  Gadgeteer has become my go-to platform when developing electronics projects.

I’ve been doing quite a bit of Gadgeteer evangelizing the past year by giving presentations at our local .NET users’ group and at conferences.  I’m also starting the Nashville Microcontrollers users’ group.  So, the desire to have a truly portable and compact solution for demoing Gadgeteer in addition to something that is useful for my other projects has become a little more important.

However, one piece has been missing to allow me to build the Gadgetab of my dreams – a large capacitive touch display. GHI Electronics recently solved that problem with the release of their CP7 module – a 7” capacitive touch display.  So, let the building begin!

The design goal was to build a tablet type device that could be useful as a remote, demo device, have some room for storage, be battery powered, and look nice – lots of software & sawdust.

 

The Mounting Plate

2012-08-04 19.38.44It just happened that I’d been talking to Steve Presley, who is starting up a custom CNC & 3D printing service, about building some mounting boards for Gadgeteer projects.  I gave him some dimensions and he went to work.  A few days later, I received a perfectly CNC machined piece of 1/4” blue acrylic in the mail and I went to work building the box that would house it.

 

Constructing the Box

2012-08-04 18.24.19

I started by taking a scrap piece of 3/4” walnut and cut it into three pieces. Two long pieces (9 3/4”) would serve as the top & bottom sides of the box.  A 6” piece was cut for the other two sides of the box.

The 6” piece was resawed using the table saw to produce two thinner pieces for the end sides of the box where the openings would exist. 2012-08-04 18.25.39
2012-08-04 18.45.11 After resawing, the side pieces were ripped into two pieces to allow for the space on the sides where the external connectors would be located.
Next, I used the router table to mill several dados in the pieces where they would fit together. 2012-08-04 21.16.08
2012-08-04 21.14.59 Time for a test fit.  Perfect fit! :)
Let’s glue it up! 2012-08-04 21.39.48
2012-08-05 12.14.07 While the sides were drying, I worked on the top & bottom.  I found a wide piece of 7/8” walnut and cut it to 9 1/2” x 7”.
I then resawed it on the bandsaw to produce two pieces roughly 3/8” thick.  A quick pass on the thickness planer to smooth out the saw marks and ensure they were flat and they’re ready to go. 2012-08-05 12.14.34
2012-08-05 12.21.21 After giving the glue 24 hrs to harden, I took the clamps off and glued up the top & bottom.  Glue was brushed on to ensure 100% coverage of the glued surfaces.  Too much glue is better than two little.  The right amount of glue will produce some squeeze out that will help ensure you have no gaps.
Using some scrap plywood as cauls to help ensure even pressure and to prevent the wood from clamp damage, I then clamped it up.  Lots of pressure is essential here to ensure there’s no gaps and everything stays together. 2012-08-05 12.31.22
2012-08-06 19.34.06 Wait another 24 hours then take off the clamps.  Note all the extra glue on the box.  Also, I forgot to wax my scrap plywood and it glued to the box along the edges.  Not a problem…
Using a hand plane and a card scraper, I removed the extra glue and plywood.  Looking better, huh? 2012-08-06 19.48.18
2012-08-06 20.06.49 Next, I put a 3/8” roundover bit in the router table and rounded over all the edges of the box to make it comfortable to hold in my hands.
Using an orbital sander, I smoothed out any problem areas using 80 grit sandpaper then followed up with 120 grit sandpaper over the entire box.  No reason to smooth it any further at this point.  We’ll save the fine sanding for later. 2012-08-06 20.20.01
2012-08-06 22.06.34 Time to cut a whole for the CP7 display.  Since it’s hard to see pen marks on the dark walnut, I add some green tape to the areas to be cut and then mark out the opening for the display.
Drill some holes in opposite corners big enough to fit a jigsaw into. 2012-08-06 22.09.33
2012-08-06 22.16.16 Cut out the opening using a jigsaw then remove the tape.
Time for a test fit.  NICE! 2012-08-06 22.19.07
2012-08-06 22.29.52 So, you’ve probably been asking yourself… “Self, how’s he going to open that box since it’s glued together?”  Simple, we’re going to cut it in half.  Fortunately, we only have to saw two sides of this box since the other two are already open in the middle.  We line up the saw blade so that it cuts perfectly with the edge of the opening and set the blade height so that it’s just a hair short of cutting all the way though.  We don’t want to cut all the way though or the box will flop around when we cut the other side and will create unwanted damage from the saw blade.  Cut both sides.
Using a hand saw, we’ll carefully cut out the hair thin piece that’s holding the two parts together.  The box will likely pop apart shortly after you begin sawing. 2012-08-06 22.31.13
2012-08-06 22.32.49 Clean up the remaining bits of the thin strip using a box cutter.
Time for a test fit of the mounting plate.  Oh yea! 2012-08-06 23.06.01
2012-08-06 23.07.04 Those joysticks need holes now…
Using a Forstner bit on the drill press, I make quick work of that task. 2012-08-06 23.21.00
2012-08-07 19.35.51 The joystick bases are semi-spherical and need a little more space.  So, using a drum sander attachment on the Dremel tool we make the hole openings concave.
Time to cut the dovetails…  We start by routing a dado where the dovetail sliders will run.  This will remove a lot of the wood and make the actual dovetail slot much easier for the dovetail bit and prevent it from breaking.  We do this in two passes.  Cutting half the height in each pass.  We repeat these steps for all four dovetail slots (two on the top and two on the bottom) 2012-08-07 20.01.38
2012-08-07 20.19.35 And finally, install the 1/2” dovetail bit and cut the slots.
Lookin’ good? image
2012-08-07 21.10.16 Now the tricky part… We have to cut the sliders so that they fit perfectly and don’t allow any slop and make the box appear lose.  We cut some rectangular strips out of hickory (for color contrast) that are exactly the height from top to bottom of the slot and are exactly 1/2” wide.  Keeping the dovetail bit at the same height, we adjust the fence so that it aligns over the bit such that the bottom corner of the bit lines up perfectly with the bottom edge of the hickory strip.  Run each strip across the bit four times to cut the double dovetail slider.
Test fit.  SMOOTH! 2012-08-07 21.42.20
2012-08-07 22.36.38 After sanding the entire box with 220 grit then some 400 grit sandpaper, it’s time to start applying the finish.  I apply one heavy coat of Watco Danish Oil first and let it sit 24 hrs.  Be sure not to leave any standing oil.
After the first coat dries, I lightly sanded the whole thing in 400 grit sandpaper.  Then I repeated this process with four coats of satin wipe-on polyurethane.  Then I attached the CP7 using the double-stick tape that is supplied.  AFTER the CP7 is mounted, apply a coat of paste wax to the box and polish it to a smooth sheen. 2012-08-12 16.36.48

This has been a fun project that yielded a platform that I’m sure you’ll see as an essential of many future projects.  So, stay tuned and keep making!

Special Thanks

Steve Presley – for milling a perfectly fitting acrylic base plate.  If you have any custom CNC or 3D printing needs, contact Steve.

Skewworks – for making the best UI controls available for .NET Micro Framework and letting me try out his new Tinkr controls.

GHI Electronics – for building the best Gadgeteer components and for setting the gold standard in customer support.  They’ve also built the best NETMF/Gadgeteer community on the planet.  Got Gadgeteer questions?  Bring them to tinyclr.com.

Coding4Fun

Microsoft’s Channel 9 Coding 4 Fun site featured this project! 

Tuesday, April 17, 2012

Getting Started With a FEZ Hydra Basic Kit


I’m teaching a NETMF Gadgeteer lab for the Nashville .NET User’s Group this week.  Our gracious sponsors have purchased several FEZ Hydra Basic Kits made by GHI Electronics that we’ll be using to introduce everyone to the Gadgeteer world.

The FEZ Hydra Basic Kit consists of:
So, the challenge is what can we build with just these components?



THE PLAN
We’re going to build a simple project that will use the green LEDs on the outer ring of the LED7R module as a gauge to show the light level that is reported by the LightSense module.  In the center of the LED7R module is a bright red LED.  I’m going to use the Joystick module to vary the brightness of this LED.





CREATING THE PROJECT
Before we can start assembling pieces and writing code, there are some prerequisites that we need to ensure you have on your laptop.  Install all of these if you don’t have them already.  Make sure that you are running the latest versions.
  1. Visual Studio 2010 (or later).  Any flavor will do including Express.
  2. Microsoft .NET Micro Framework v4.1 SDK.
  3. GHI NETMF v4.1 and .NET Gadgeteer Package
imageNow that we have all of the bits installed, open Visual Studio and go to File –> New –> Project.  From the “New Project” dialog, we’ll choose the “Gadgeteer” section underneath the “Visual C#” group and we’ll create a new project using the “.NET Gadgeteer Application” template.

After we click “OK”, a new Gadgeteer project will be created and the Gadgeteer GUI designer appears showing an image of the FEZ Hydra mainboard.  If we open the Toolbox we will see a list of modules under the “GHI Electronics” section.  We’ll select the Joystick module and drag & drop it onto the white area somewhere around your mainboard.  Then we’ll do the same for the LED7R module and the LightSense module.

imageIf we left-click on the socket (the orange box) on our module then compatible sockets on our mainboard will be highlighted in green.  We can then drag the connector to the compatible socket that we want to plug the module into and click.  The sockets will then turn blue and a blue wire will be drawn between them.  Repeat for the other modules.
image
Now we’ll connect our physical components & cables up to match the connection decisions we made in the GUI designer.  Also, we’ll plug our SP power module (the red one) into the D socket (#2) and connect the USB cable to it and to our computer.

image
TIP: The name below each module in the GUI is the variable name that you’ll use in code to reference the module. If you want to change it, you can do so by click the name in the GUI a couple times to get into edit mode. If you change it after code has been written then your code will automatically update.


Let’s write some code!!!


HELLO WORLD!
Now that everything is connected and powered up, we should see a red LED on our power module, on our mainboard, and on our LED7R module.

imageNext, let’s make sure that our project is configured to run on our Hydra and not the emulator.  In the Solution Explorer, we’ll right-click on our project and go to Properties.  In the Properties page, choose the “.NET Micro Framework” tab on the left.  We’ll choose the “USB” Transport option.  When we do this, the “Device” should automatically populate with “FEZ Hydra_Gadgeteer” (assuming we only have one mainboard connected to our PC).  Save your options and close the page.

Hit F5!  If everything is connected correctly, the default program should compile and deploy to the Hydra and in our Debug Window we should see a lot of memory information flash by and then finally you should see…
image

If you don’t then it’s time to call for help


imageLED7R MODULE
We’ll start by writing a quick test of our LED7R module.  Note that I have renamed my module from it’s default name to “led” in the code below. 

The LED7R module has the following methods available to it:image
Animate() Cycles through all the LEDs on the module in a circular pattern. There are parameters to determine speed, direction, whether the lights are to be turned on or off, and an option to leave the lights on or to turn them off before moving to the next one.
TurnLightOn() Turns an LED on. It has one parameter – the number of the LED to turn on. Note the “D” numbers printed next to the LEDs on the module. They are the index numbers.
TurnLightOff() Turns an LED off. Same parameter as TurnLightOn().

Let’s add some code to test out our LEDs.  In the Program.cs file in ProgramStarted() let’s add the following code below the Debug.Print line that was added automatically.
   1:  // Cycle through the lights to show we're alive.
   2:  led.Animate(100, true, true, false);
   3:  led.TurnLightOff(6);  // a bug causes the last light to stay on...

Hit F5 to compile, deploy, & run the code and you should see the LEDs on the module light up in a clockwise direction.


imageLIGHTSENSE MODULE
Now that we know our LED7R module is working fine, let’s do something with our LightSense module.  The LightSense module has two methods.  Both are used for polling the sensor to capture it’s settings.

ReadLightSensorPercentage()Returns the light level as a percentage value from 0.0 (dim) to 1.0 (bright).
ReadLightSensorVoltage()Returns the light level as a measure of voltage from the sensor (0V-3.3V).

As you can tell from the methods, to do anything with the meter we are going to have to poll it on a regular basis.  For this we’ll need a timer.  At the bottom ProgramStarted() let’s add the following:

   1:  // Light meter 
   2:  var timer1 = new GT.Timer(100);
   3:  timer1.Tick += OnLightMeterTick;
   4:  timer1.Start();

And let’s add a new function to our Program class…

   1:  private void OnLightMeterTick(Timer timer)
   2:  {
   3:      var lightLevel = (int) lightSensor.ReadLightSensorPercentage();
   4:   
   5:      for (var ndx = 1; ndx < 7; ndx++)
   6:      {
   7:          if (ndx <= lightLevel/100.0*7)
   8:          {
   9:              led.TurnLightOn(ndx);
  10:          }
  11:          else
  12:          {
  13:              led.TurnLightOff(ndx);   
  14:          }                
  15:      }
  16:  }

Run the code again and you should now see the LED7R do it’s initialization loop and then the number of LEDs lit should vary depending on the brightness that the LightSense is reading.  Try moving your hand over the LightSense module.  The number of LEDs lit should decrease.

Having fun yet?


JOYSTICK MODULE
It’s time to put our hands on this thing!  I bet you never thought you’d be able to actually touch a C# project :D 

The Joystick module moves in X & Y directions and has a button we can use when the stick is pushed downward.  We’re going to use the Y (up & down) direction of the Joystick to dim the red LED in the middle of our LED7R module.  Fully explaining the Joystick module is beyond the scope of this post.  I’ll do that in the near future.

But wait!  If we take another look at the LED7R module we’ll notice that there isn’t a method we can use to dim LEDs.  What to do?  We’ll use an optical trick called persistence of vision (POV) to make the LED appear dim by using a timer to pulse the light on & off many times per second and vary the length of time that it is on between pulses.

Add the following to ProgramStarted():

   1:  // Monitor joystick to update red LED brightness.
   2:  var timer2 = new GT.Timer(10);
   3:  timer2.Tick += OnRedBrightnessTick;
   4:  timer2.Start();

And let’s add this new function to our Program class…

   1:  void OnRedBrightnessTick(Timer timer)
   2:  {
   3:      led.TurnLightOn(7);
   4:      Thread.Sleep((int)(joystick.GetJoystickPostion().Y*100)/20);
   5:      led.TurnLightOff(7);
   6:  }

Run the program and now when you move the Joystick up & down you should see a slight variation in the brightness of the red LED in the middle of the LED7R module. 

Surely, you’re having fun now???

You may be asking yourself why we used Timers instead of just putting a loop in our ProgramStarted() event.  This is one area where Gadgeteer is very different than traditional NETMF projects.  Read this blog post for an excellent explanation and you’ll save yourself some frustration down the line.


WHAT NEXT?
Well, that’s up to you!  I’ve given you a simple example of a couple things you can do with the FEZ Hydra Basic Kit.  Now, take this example and improve it or come up with something better (a game maybe?).  Be sure to leave a comment on this post and tell me what you did or even better post a link to a video.

Have fun!

Download the complete project source here.