labview universal driver presentation part a shmulik & pia zobel advisor: mony orbach
Post on 21-Dec-2015
229 views
TRANSCRIPT
Project Goal
• Build a universal driver to connect between LabView and any type of hardware
• This semester we built a specific driver for a Physics Momentum USB Chip
• Based on this driver, we are building the full driver
Driver Architecture
• The universal driver receives the interface from the user and builds a specific driver for each chip
• The specific driver is built from two parts:Pseudo hardware – VIs in LabViewSoftware – C++ code
• The two parts communicate through DLLs
Psuedo Hardware Architecture
• An application in LabView is called a VI - Virtual Instrument
• A VI is built from subVIs (i.e. other VIs )
Momentum USB Chip Driver
• A driver for a chip which measures position• The chip is connected to the computer through
the USB• Functionality:
I. Opens a connection to the chip
II. Configures it
III. Reads the data
IV. Closes the connection
Main Software Architecture
• The main program is activated by a DLL from LabView using createproccess()
• Runs in memory continuously
• Initializes the DLL
• Manages:Hardware – through Hardware DriverData in memory for application
Communication
• DLL – Dynamic Link Library
• Called from LabView through DLL VI
• Once the DLL is loaded into the memory,
any proccess can call DLL functions
DLL Interface
_declspec(dllexport) long open_driver(void);
_declspec(dllexport) long close_driver(void);
_declspec(dllexport) long read_driver(long , long );
_declspec(dllexport) long write_driver(long , CSTR );
Momentum Driver Interfaceclass Usb{
public:
static int iDevice_; // number of device
static DWORD numDevs_; // number of devices connected
Usb(); // default constructor
/class methods:
void openUsb;()
void closeUsb;()
BOOL readUsb(DWORD bytesToRead, void* read_buffer);
BOOL writeUsb(DWORD bytesToWrite, void* write_buffer);
BOOL setRecQueEventNot;()
void StopUntilRec_4;()
char* serialUsb;()
void errorUsb;()
FT_HANDLE getHandle;()
BOOL setLatency(int latency);
BOOL setTimeOut(int timeout);
~Usb;()
protected:
char serial_[16]; // serial number
BOOL deviceOpen_; // TRUE = open, FALSE = close
FT_HANDLE handle;_
//FT_Read/FT_Write parameters:
FT_STATUS r_w_status;_
DWORD num_bytes_s_r_;// number of bytes that was sent/recieved correctly
//
FT_ListDevices parameters:
FT_STATUS ftStatus;_
//Event notification paramaters
HANDLE hEvent;_
DWORD EventMask;_
//class protected methods
;}