Professional Documents
Culture Documents
j o u r n a l h o m e p a g e : h t t p : / / w w w. e l s e v i e r. c o m / l o c a t e / j e s t c h
H O S T E D BY
ScienceDirect
A R T I C L E I N F O A B S T R A C T
Article history: This paper presents an 8051 microcontroller-based control of ultrasound scanner prototype hardware
Received 13 December 2015 from a host laptop MATLAB GUI. The hardware control of many instruments is carried out by
Received in revised form microcontrollers. These microcontrollers are in turn controlled from a GUI residing in a computing machine
1 January 2016
that is connected over the USB interface. Conventionally such GUIs are developed using ‘C’ language or
Accepted 12 January 2016
Available online 1 February 2016
its variants. But MATLAB GUI is a better tool, when such GUI programs need to do huge image/video pro-
cessing. However interfacing MATLAB with the microcontroller is a challenging task. Here, MATLAB
interfacing through an intermediate MEX ‘C’ language program is presented. This paper outlines the MEX
Keywords:
MATLAB programming methods for achieving the smooth interfacing of microcontrollers with MATLAB GUI.
MEX program © 2016, Karabuk University. Publishing services by Elsevier B.V.
Microcontroller
Ultrasound scanner
USB
USBXpress
http://dx.doi.org/10.1016/j.jestch.2016.01.008
2215-0986/© 2016, Karabuk University. Publishing services by Elsevier B.V.
J.R. Raj et al. / Engineering Science and Technology, an International Journal 19 (2016) 964–969 965
Tx FPGA
Address / Data
bus Interface
Serial
USB Interface
Interface Micro
ADC controller
SPI MDIO
Interface Interface
Gigabit
Rx FPGA Ethernet Phy
the MATLAB GUI and the microcontroller is a challenging task. The The USBXpress includes windows device drivers, device driver in-
novel method used for interfacing using a C language interface func- staller, host interface function library (host API) provided in the form
tion called MEX program is described in this paper. of a DLL, and device firmware interface function library. Some of
the important functions performed by the host API are given in
2. Materials and methods Table 1. While performing each function, the function returns the
status of the operation like SI_SUCCESS or SI_DEVICE_NOT_FOUND
2.1. Interfacing architecture or SI_INVALID_PARAMETER, along with any return values to take
suitable corrective steps in read or write logics. The API is used in
The logical block schematic of the MATLAB GUI and an interrupt driven mode. The c8051340.h and USB_API.h files sup-
microcontroller interfacing with USB is given in Fig. 2, which indi- plied as part of the application are added to the project in addition
cates the microcontroller side as well as the MATLAB GUI side logic to the “main” firmware file. While building the target, the USBXpress
used for the study. A Silicon Laboratories C8051F340 microcontroller library file, USBX_F320_1.LIB is linked as an external object.
is used. It operates at a maximum speed of 48 MHz with 4 k of on-
board RAM (XRAM) and 64 k flash memory. The microcontroller has 2.3. Microcontroller firmware
integrated USB receiver and USB controller. It is 48 IO pins config-
ured as 5 IO buses of 8 IOs each. The microprocessor in the In the developed prototype, the microcontroller configures the
ultrasound scanner prototype interfaces with a bank of ADCs and different chips like ADC, FPGA, etc., through the control from the
FPGAs. The microprocessor firmware is written in C language. One MATLAB GUI. Hence the microcontroller firmware implements
IO Bus is used as the programming header for programming the the USB interface logic as well as the interface logic for the other
microcontroller. The firmware is transferred to the microcontroller devices. The header and the source files developed for the inter-
using the programmer hardware by M/s Silicon Labs. The develop- facing with the ADC, TxFPGA, RxFPGA and PHY device using the four
ment required the USBXpress API provided by M/s Silicon Labs for IO Buses are included in the firmware. Even though the ADC side
including in the microcontroller firmware, firmware develop- does not require any separate software logic, the FPGA side re-
ment, USBXpress driver installation in the host computer, installation quires the hardware logic written in languages such as Verilog or
of C++ compiler (Visual C++ used), development of the MEX file, de- VHDL. Similar interface logic is written in the FPGA side also for the
velopment of the MATLAB GUI, and compilation and linking of the read and write operations using the SPI interface. The SPI inter-
MEX file from MATLAB. face has read, write, chip enable, Master in Slave Out (MISO) and
Master Out Slave In (MOSI) pins for the interconnection. The
2.2. USBXpress API USB_API.h includes the definitions needed by common code to
control the state of the USB peripheral, but this doesn’t need to know
The Silicon Laboratories USBXpress provides the host and device about the specific implementation. The USB_API.h for the USB in-
software solution for interfacing communication bridges to the USB. terface functions and other files like C8051F340_def.h,
A high-level Application Program Interface (API) for both the host compiler_defs.h, stddef.h, stdio.h etc. are included in the compila-
software and device firmware is used to provide USB connectivity. tion. The flowchart of the firmware is given in Fig. 3.
USBXpress USBXpress
Micro USB USBXpress MEX
Library (API) Driver MATLAB
controller DLL supplied Program in
supplied by installed in GUI
Firmware by SiLabs C (DLL)
SiLabs Laptop
Table 1 Table 2
USB API device interface functions. USB DLL interface functions.
USB_Clock_Start Initializes the USB clock SI_GetNumDevices Returns the number of devices connected
USB_Init Enables the USB interface SI_GetProductString Returns a descriptor for a device
Block_Write Writes a buffer of data to the host via USB SI_Open Opens a device and returns a handle
Block_Read Reads a buffer of data from the host via USB SI_Close Cancels pending IO and closes the device
USB_Int_Enable Enables API interrupts SI_Read Reads a block of data from the device
USB_Disable Disables USB interface SI_Write Writes a block of data to the device
USB_Suspend Suspends the USB interface SI_SetTimeouts Sets read and write block timeout
SI_CheckRXQueue Gets the number of bytes in the device Rx Queue
Start
USB_Clock_Start
USB_Init
Port Initialisation
Timer Initialisation
Initial Configuration of
Interfaces and Devices
Device Suspend
Interrupt Stop
Type
USBXpress
Block Read
Case 1
T Write to TxFPGA
F
Case 2 Write to RxFPGA
F T
Case 3 Write to ADC
T
F
Case 4 Write to PHY
F T
Case 5 Read from TxFPGA
F T
Case 6 Read from RxFPGA
F T Block
Case 7 Read from ADC Write
F T
Case 8 Read from PHY
F T
SI_GetNumDevices
F Ethernet
Case Success Return Error
MAC
T
SI_GetProductString Ethernet
T
F PHY
Case Success Return Error
T
Rx FPGA
SI_SetTimeouts
Micro
T
F controller
Case Success Return Error
T
SI_Open
F
Case Success Return Error
T
SI_Write
F Tx FPGA Receiver & ADC
Case Success Return Error
T
Fig. 5. Ultrasound scanner prototype hardware.
SI_CheckRXQueue
<1
Bytes in Queue
[14] N. Sandeep, C. Sulochana, Dual solutions for unsteady mixed convection flow [19] J.J.R. Raj, S. Rahman, A. Sneh, Electronic hardware design for ultrasound transient
of MHD micropolar fluid over a stretching/shrinking sheet with non-uniform elastography, Int. J. Eng. Sci. Technol. 4 (2012) 3700–3704.
heat source/sink, Eng. Sci. Technol. 18 (2015) 738–745, doi:10.1016/ [20] D. Jones, Smartphone-compatible ultrasound probe, J. Diagn. Med. Sonogr. 30
j.jestch.2015.05.006. (2014) 200–204, doi:10.1177/8756479314534523.
[15] S. Padmanaban, E. Kabalci, A. Iqbal, H. Abu-Rub, O. Ojo, Control strategy and [21] B.-E. Byambasuren, M. Oyun-Erdene, S.-Y. Nam, D.-H. Kim, S.-M. Han, Design
hardware implementation for DC–DC boost power circuit based on of USB-based high rate data communication for transcranial Doppler ultrasound
proportional–integral compensator for high voltage application, Eng. Sci. system, Int. J. Control Autom. 5 (2012) 97–106.
Technol. 18 (2015) 163–170, doi:10.1016/j.jestch.2014.11.005. [22] Y.-S. Lee, J.-H. Yang, S.-Y. Kim, W.-S. Kim, O.-K. Kwon, Development of a rapid
[16] J.J.R. Raj, S. Rahman, S. Anand, Application of a novel software algorithm for control prototyping system based on Matlab and USB DAQ boards, J. Inst. Control
information reduction in high frame rate ultrasonography, Int. J. Comput. Appl. Robot. Syst. 18 (2012) 912–920, doi:10.5302/j.icros.2012.18.10.912.
Technol. Res. 3 (2014) 729–733, doi:10.7753/ijcatr0311.1016. [23] N. Li, J. Guo, H.S. Nie, W. Yi, H.J. Liu, H. Xu, Design of embedded bio-impedance
[17] J.J.R. Raj, S. Rahman, S. Anand, Acquisition of lossless data in transient window analyzer based on digital auto balancing bridge method, in: Applied Mechanics
through ethernet in high frame rate machines, in: 2015 2nd International and Materials, Trans Tech Publication Ltd, 2012, pp. 396–401.
Conference on Computing for Sustainable Global Development (INDIACom), [24] J. Raj, S. Rahman, S. Anand, Interfacing high frame rate data through ethernet
IEEE, New Delhi, 2015, pp. 591–596. without loss for tele-medical applications, in: 2015 International Conference
[18] M. Tiouririne, S. Nguyen, J.A. Hossack, K. Owen, F. William Mauldin Jr., Handheld on Signal Processing and Communication (ICSC), IEEE, 2015, pp. 51–55.
real-time volumetric imaging of the spine: technology development, J. Med.
Eng. Technol. 38 (2014) 100–103, doi:10.3109/03091902.2013.877989.