This document summarizes Matthew Herndon's presentation on using a Raspberry Pi to control scientific instruments over a local area network and consolidating instrument control using Matlab. The presentation covers using a Raspberry Pi and USB over IP to control USB devices remotely over a network. It then discusses using Matlab to create a unified interface for controlling multiple instruments through simple code by implementing a object-oriented design with a singleton pattern. The goals are to make instrument control and initialization easy through a single, modular interface.
Advanced Internet of Things firmware engineering with Thingsquare and Contiki...
Communicating with Scientific (Current)
1. Using A Raspberry Pi to Control
Scientific Instruments over LAN and
Instrument Control Consolidation Using
the Scientific Programming Environment
Matlab
Matthew Herndon
Lloyd Bumm Research Group
03/29/2014
2. Presentation Overview:
•Part One
Control USB interfaced scientific instruments over a Local
Area Network (LAN) using a Raspberry Pi
•Part Two
Create a single, feature-rich interface capable of
controlling many scientific instruments using simple
Matlab code.
•Acknowledgments
4. Controlling USB devices over LAN with a
Raspberry Pi
•It was decided that this communication would be
done using a technique called USB over IP
• This works by encapsulating USB packets
within TCP/IP packets and sending them over a
network to be interpreted by a remote client
• The Raspberry Pi had a program called
VirtualHere USB IP readily available, so I
made use of that
5. USB over LAN vs. direct USB: Why?
• It’s much more convenient
• Virtually no cable restrictions
USB
Device
Host
Comp.
Server
Comp.
USB
Device
Network
Host
Comp.
USB: Limited to <16
ft without repeaters
Virtually no limit on the
physical distance between
the two devices
6. USB over IP: The general idea
TCP/IP
Packets
TCP/IP Request
Received Data
TCP/IP Request
Received Data
Write Received Data
Read Incoming Data
ConvertIncomingDatato
TCP/IP,SendtoClient
ConvertTCP/IPpacketsfrom
clientbacktoUSBpackets
WrapdatafromvirtualUSBas
TCP/IP,sendtoserver.
ConvertTCP/IPpacketsfrom
serverbacktoUSBpackets
Write Received Data
Read Incoming Data
Effective
Bridge
Remote
Physical
USB
Device
USB IP
Server
Software
USB IP
Client
Software
Rasbian
OS
Virtual
USB
Device
Windows
OS
Client
Network
Hardware
Pi
Network
Hardware
Raspberry
Pi
Windows
PC
TCP/IP
Packets
9. Goals
•Create an interface that allows
one to control a group of
instruments with ease through one
unified interface
•Make this interface handle the
initialization of all of the
instruments, a process which can
often be complicated and easy to
forget
•Make this interface easy to use,
modular, and intuitive
Seen Below: The initialization
code for the Shutter.
10. Problems to Overcome:
•How to organize the program so as to insure
modularity without compromising an intuitive user
experience
•How to effectively implement it within Matlab
11. Organization
•This problem was
solved using the
design concepts of
Object Oriented
Programming (OOP),
as seen in the
Unified Modeling
Language (UML)
diagram to the
right.
Class
Name
Class
Variable
s
Methods
12. Implementation
• UnifiedHandler should only be instantiated once, but
Matlab’s handling of OOP makes this difficult
• Using a Singleton class solved this problem
•Only allows one instance to be created
•Can still be referenced multiple times.
13. •Easy to use, easy to read
•Example code:
The Final Product
uh=UnifiedHandler(1);
uh.Shutter.open();
uh.FilterWheel.moveToPositionN(3);
% UnifiedHandler instantiation statement
% Variable that holds the instantiated UnifiedHandler object
% Function call that references one of UH’s internal objects
% Function call to a function within an internal instrument
14. Future efforts
•Improve basic functionality of the UnifiedHandler
class.
• Improve how certain functions in the Shutter class work,
making sure to utilize built in features of the Shutter
controller to insure maximum performance
• Better error handling, more predictable performance
•Make it easier to use client computers by compiling
a list of required software for Shutter, Filter
Wheel, etc.
15. My fellow group members: Michael Reynolds, Nick Kantack, Mitchell
Yothers, Jacob Higginbotham, for their help and support
More Specifically:
• Dr. Lloyd Bumm, for his assistance in all aspects of my projects
• Nick Kantack, for his work on communicating with the Shutter over USB
• Eric Holbrook, for his work on communicating with the Filter Wheel over
USB
• Mitchel Yothers, for helping me learn Matlab
• VirtualHere Pty. Ltd, for their USBIP software package
• UROP, for their generous grant
• The HERE program, for providing me with this research opportunity
Acknowledgements