No need to hide from HID - End-to-end Windows Runtime HID Motion-Sensor

Today's Hardware Friday post is one that I thought had a number of cool and fun possibilities. Plus, anything that combines Windows 8.1, Netduino, C# and the chance to say "HID" can't be all that bad, can it?

Sample motion-sensor, firmware and Windows Runtime app for HID

This end-to-end solution includes a tutorial for building a simple passive-infrared sensor that supports the HID protocol

This end-to-end solution includes a tutorial for building a simple passive-infrared sensor that supports the HID protocol. The tutorial is provided as a whitepaper titled Building a motion sensor.docx. Included with this tutorial is a Visual Studio C# project, with source code, for creating the sensor firmware.

In addition to the tutorial for creating a device, this solution includes a sample Store App
that monitors the sensor for motion and captures a short five-second video each time motion is detected. (The app is described in a second tutorial titled Developing
a Human Interface Device (HID) app
.)

Note: This end-to-end solution uses firmware produced under the the Creative Commons Attribution-ShareAlike 3.0 Unported License. For license terms see: http://creativecommons.org/licenses/by-sa/3.0/

Operating system requirements

Client

Windows 8.1

Server

N/A

Installing Your Development Environment for the firmware

Before you can download the firmware onto your Netduino Plus board, you’ll need to complete the following steps:

  • Install Microsoft Visual C# Express 2010 on a development machine
  • Install .NET Micro Framework SDK v4.2
  • Install the Netduino Beta firmware v4.1.1 on your Netduino Plus board
  • Download the device firmware project and open in Visual C# Express
    Note that the video here provides a great explanation for installing the Beta firmware on your Netduino board. (See the accompanying tutorial for more details about building the device and installing the firmware.)

Building the HID-based motion sensor

The motion sensor consists of a Netduino Plus development board with an attached passive-infrared (PIR) sensor. You’ll find details for building this sensor in the whitepaper titled Building a motion sensor.docx. Once you build this sensor, you can attach it to your Windows 8.1 laptop or tablet and start the sample app.

Installing Your Development Environment for the Store App

Before you can build and run the sample app, you’ll need to complete the following steps:

  • Install Windows 8.1 on your development machine.
  • Install Microsoft Visual Studio Professional 2013 or Microsoft Visual Studio Ultimate 2013 on the machine that you’ll use to build the Store App.
  • Download  the sample app project
    See the accompanying tutorial titled Developing a Human Interface Device (HID) app for more details about the sample App. (If your development machine doesn’t support a video camera; you’ll want to deploy the app onto a machine that does.)

Building the sample app

After you build the motion sensor, you can begin testing it with the sample app. You’ll find details for building the app (as well as details about the app’s functionality) in the app tutorial.

...

Here are some snips from Building a motion sensor.docx.

image

 

Introduction

With the addition of the new HID WinRT API for Windows 8.1, Microsoft has given academics, hobbyists, and industrial engineers a great platform for connecting their remote devices to tablets and laptops. The new API simplifies the integration of a broad spectrum of devices: from measurement equipment in the scientific lab, to weather stations, to medical devices, to exercise devices.

The one common thread is that these devices all support the HID protocol. In its earliest days, the protocol supported: keyboards, mice, and joysticks—devices that acted as a “human interface” to a computer. Hence the name “Human Interface Device”, or, HID.

However, because the protocol is self-describing, it’s ideal for supporting a larger universe of disparate devices. (By self describing, we mean that a HID device announces its: purpose, capabilities, and packet sizes upon connection to a host PC.)

The motion sensor described in this paper is intended as a teaching tool—you can use this device, and its firmware, to learn about the HID protocol and the new WinRT API. This sensor is designed to work with the HidInfraredSensor app that ships as a sample in the modern SDK.

If you’re new to the HID protocol, or the USB transport, a great starting point is Jan Axelson’s book “USB Complete”. Read the sections on HID before you dive into the details of the firmware. Another helpful source of information is the Developers forum on usb.org.

QuickStart

This section of the whitepaper is designed to help you quickly build and deploy the motion sensor. This sensor is designed to work with the sample HidInfraredSensor app that ships on the MSDN Samples Gallery for Windows 8.1. This sample monitors, or “listens” for, motion events from the sensor. When an event occurs, and motion is detected, the app captures a brief video using the built-in web cam on the device.

The app monitors events using the new HID WinRT API; it captures video using the MediaCapture API.

(For a more detailed look at the inner workings of the device, see The device firmware later in this document.)

...

image

Finally you grab the code...

image

...build and run it...

Building the sample app

After you build the motion sensor, you can begin testing it with the sample app. You’ll find details for building the app (as well as details about the app’s functionality) in the app tutorial.

Once you’ve read the whitepaper and installed the app, you can
build it:

  1. Start Microsoft Visual Studio 2013 and select File > Open >Project/Solution.
  2. Go to the directory in which you unzipped the sample. Go to the directory named for the sample, and double-click the Visual Studio 2013 Preview Solution (.sln) file.
  3. Press F7 or use Build > Build Solution
         to build the sample.
  4. Power the Netduino board using an external power supply.
  5. Wait several seconds for the sensor to initialize.(The infrared sensor requires apx. 10 seconds to determine the ambient level of infrared light.)
  6. Attach the Netduino board to your tablet or laptop using a USB cable.
  7. With Visual Studio running and the sample project open, you can either debug the app, or run it without debugging. (To debug the app and then run it, press F5 or use Debug > Start Debugging. To run the app without debugging, press Ctrl+F5 or use Debug > Start Without Debugging.)

Run the sample

  1. Power the Netduino board using an external power supply.
  2. Wait several seconds for the sensor to initialize. (The infrared sensor requires apx. 10 seconds to determine the ambient level of infrared light.)
  3. Attach the Netduino board to your tablet or  laptop using a USB cable.
  4. With Visual Studio running and the sample project open, you can either debug the app, or run it without debugging. (To debug the app and then run it, press F5 or use Debug >Start Debugging.  To run the app without debugging, press Ctrl+F5 or use Debug > Start Without Debugging.)

And there you go, end-to-end HID in Windows 8.1...

Tags:

Follow the discussion

  • Oops, something didn't work.

    Getting subscription
    Subscribe to this conversation
    Unsubscribing
    Subscribing

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.