communicating with scientific (current)
Post on 10-Feb-2017
78 Views
Preview:
TRANSCRIPT
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 Group03/29/2014
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
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
USB over LAN vs. direct USB: Why?• It’s much more convenient• Virtually no cable restrictions
USBDevice
HostComp.
ServerComp.
USBDevice
Network HostComp.
USB: Limited to <16 ft without repeaters
Virtually no limit on the physical distance
between the two devices
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
Convert Incom
ing Data to
TCP/IP, Send to C
lient
Convert TC
P/IP packets from
client back to USB
packets
Wrap data from
virtual USB
as TC
P/IP, send to server.
Convert TC
P/IP packets from
server back to USB
packets
Write Received Data
Read Incoming Data
Effective Bridge
Remote Physical
USBDevice
USB IP Server
Software
USB IP Client
Software
Rasbian OS
VirtualUSB
Device
Windows OS
Client Network
Hardware
Pi Network
Hardware
Raspberry Pi
Windows PC
TCP/IP Packets
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.
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
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 VariablesMethods
Implementation
•UnifiedHandler should only be instantiated once, butMatlab’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.
•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
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.
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
top related