Page 1 of 1

Phidgets and .Net MicroFramework

Posted: Thu Jun 10, 2010 12:58 pm
by becafuel
Hello all,

some time ago, I and other people asked about NetMF support for Phidgets. I will present you my solution to this "problem".

My goal was to be able to control Phidgets boards from an autonomous .NetMF board, such as FEZ Domino (an Arduino 2000 clone). This board can act as a USB Host, so I thought that it should work almost straigth forward.
This wasn't really the case, but it finally works !

Here's a video of a demo : ... r_embedded

The setup is :
- a Phidget 1018 connected to a FEZ Domino board
- a button on one input of the 1018
- a LED on one output of the 1018
- a LED and a button on the FEZ Domino board

The FEZ Domino runs a C# program I've made and does the following :
- when the button on the 1018 is pressed, the led on its output is lit and the led on the FEZ Domino is lit
- when the button on the FEZ Domino is pressed, it shuts off both leds
This small example of "simple" Led lighting indicates nothing less than communication and interaction between the two boards...

The program in the FEZ board is quite simple :

Code: Select all

using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using System.Threading;

using GHIElectronics.NETMF.FEZ;
using FEZPhidgets;   // My driver

namespace MFConsoleApplication1
    public class Program
        static Phidget1018 IF1018 = new Phidget1018();   
        static OutputPort Led = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, false);  // Led on Domino board
        static InterruptPort Bouton = new InterruptPort((Cpu.Pin)FEZ_Pin.Interrupt.LDR, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeBoth);  // Button on Domino board
// Main program
        public static void Main()
            Bouton.OnInterrupt += Bouton_OnInterrupt;
            IF1018.InputChange += Phidget1018_InputChange;


// Event thrown when the button on the FEZ Domino is pressed
        static void Bouton_OnInterrupt(uint data1, uint data2, System.DateTime time)
            IF1018.Output(7, false);   // Shutdown 1018 LED
            Led.Write(false);   // And FEZ Domino LED

// Phidget 1018 button pressed
        static void Phidget1018_InputChange(object sender, Phidget1018InputChangeEventArgs e)
            if (e.Index == 6) { IF1018.Output(7, true); Led.Write(true); }   // Light on both LEDs

I've tried to stay as near as possible to Phidgets assemblies. That's why properties/methods/events are almost the same.

But to achieve this, I had to write drivers for the USB Host on the Domino board.
The driver is C# code and is the result of try & fail ... Using USB sniffer and C code from Phidgets...

The driver is available here : ... idgets.rar

Please note that this is not complete and that it "just works". No more promise on this code ;)
You will also notice that there's a 1052 class that permits the use of the Phidgets 1052 Digital encoder.

A more complete page about this project is available on the FEZ Domino site : ... e=Phidgets

If I write here, that's because of two things :
- some people here (like me :) ) wanted such .NetMF support
and, most of all :
- Phidgets staff has just sent me unvaluable information so that I will be able to code a driver for the 1062 & 1060 boards.

I couldn't make less than also sharing what I've done. Both teams (Phidgets & GHI Electronics) were so kind in provinding info and support ! I hadn't seen this since a long time, for sure :shock:

So, I will now code the drivers for these boards and revise the structure of the whole thing to be more consistent.

If you have any question regarding this project, you're welcome !

And again, a big THANK YOU to the Phidgets team for its very good boards and the associated incredible support, and also to GHI Electronics for the same reasons ;)

Re: Phidgets and .Net MicroFramework

Posted: Wed Jul 21, 2010 9:50 am
by becafuel
FYI, I've updated the project file. It now support the Phidget RFID board, adds new events/properties to 1018 and 1052 boards as well.

The complete solution (with source code) can be downloaded here : ...

Also, I've just started to code a driver for the 1062 board. This one is not that simple ;)
Anyway, I get some results :
Of course, it's only the beginning so it's pretty much useless as is, but the fact that I can move a stepper and get its position is a good start.

As usual, code will be very simple to use. Here's the code that is running on the FEZ board :

Code: Select all

static void Button_OnInterrupt(uint data1, uint data2, System.DateTime time)
            if (data2 == 0)  // Button pressed
                Stepper.TargetPosition = 1000;
                Stepper.Engaged = true;

Re: Phidgets and .Net MicroFramework

Posted: Wed Jul 21, 2010 11:16 am
by Robert

Re: Phidgets and .Net MicroFramework

Posted: Wed Jul 21, 2010 2:15 pm
by becafuel
Robert wrote:Impressive.

This wouldn't have been possible without the help of Patrick, that has sent very useful information to me. I will never thank him enough for this !

His help, the C sources and an USB sniffer are all that I have used. And time, of course... :?