Student Projects

cancel
Showing results for 
Search instead for 
Did you mean: 

myKeyboard

Title: myKeyboard


Overview of what project is:

The myRIO features a Host USB port, which can be used for additional flash storage, USB Cameras, etc.  It can also be used to connect keyboards, and other input devices to be read from for control in projects.  In this project you will learn how the Linux RT kernel input subsystem works, and how to read a USB Keyboard with LabVIEW.


Picture of project:
keyboard.png

Parts List:

USB Keyboard

Background Info:

The Linux Input Subsystem is the part of the Linux kernel that manages the various input devices (such as keyboards, mice, joysticks, etc.) that a user uses to interact with the kernel/system.  Interaction between the kernel and input devices are handled through events, which are implemented as structures (ie C struct).  These events contain the following: a simple timestamp, event type, code, and value. 

The type field shows the generic type of event being reported, for example, a key press or button press, relative motion (like a moving mouse) or absolute motion (like moving a joystick).  The code field tells which of the various buttons or axes are being manipulated, while the value field tells you what the state or motion is.

In LabVIEW, this event struct is implemented as a cluster of all these elements:

input cluster.PNG

The documentation for the defined values for the event structure can be found in the Linux source uapi/linux/input.h.


When a keyboard is connected to the Host USB port on the myRIO, and if it is the only input device, it will appear in Linux as a file at: /dev/event0.  All the keyboard actions will be sent to this file to be read into LabVIEW using simple file I/O, since the file behaves like a normal file on the filesystem.

In this example, the LabVIEW "Read from Binary File" VI is used, with the above event struct (ie cluster in LabVIEW) as the datatype.  This allows each event to be read completely in each read from the input file.

keyboard_read_snip.png


Instructions:
1. SSH into myRIO and edit "/etc/mdev.conf" file permission for input events

2. Launch LabVIEW and Run "ReadKeyboard.vi"


C or LV?: LabVIEW


Version of LV: LabVIEW 2013

Sources and References:

http://www.linuxjournal.com/article/6396

http://lxr.free-electrons.com/source/include/uapi/linux/input.h

Systems Engineer
SISU
Contributors