Mbed Magnet Location Classification System
Project Members
Tanmay Bangalore, Blake Bergquist, Ye Tian, and Zhenxuan Zhang
Introduction
This Wiki page shows you how to build a magnet location detection system described in [1] using the mbed platform. This system can potentially be used as a tongue-computer-interface device to help people with severe disabilities in their daily life. While the Tongue Drive System in [1] sends raw data to the PC for signal processing, this system performs the location classification algorithm in the microcontroller. Also, we utilize accelerometer data to cancel the Earth’s magnetic field to increase the accuracy of the system when in motion. We have implemented an RPC communication protocol over serial between Mbed and a C# based GUI. In the future, we will build a BLE based wireless Mbed solution to communicate with a smartphone platform.
Hardware Requirements
- Mbed LPC1768
- LSM303D Breakout Board x 4
- MicroSD card (tested using 4GB)
- SparkFun microSD Transflash Breakout
- Breadboard
- Wire Kit
- Windows PC
- Small Disk Permanent magnet
- (Optional) Male to Male Jumper Wire
- (Optional) MicroSD card USB reader
Software Requirements
- Windows 7 and above
- Visual Studio 2012 and above
- Access to Internet to download source code and compile mbed code
Wiring info
| Mbed pin | MicroSD | LSM303D1 | LSM303D2 | LSM303D3 | LSM303D4 | Description |
|---|---|---|---|---|---|---|
| GND | GND | GND | GND | GND | GND | |
| VOUT | VCC | VIN | VIN | VIN | VIN | 3.3V regulated voltage out from mbed |
| p5 | DI | mbed SPI MOSI | ||||
| p6 | DO | mbed SPI MISO | ||||
| p7 | SCK | mbed SPI SCK | ||||
| p10 | CS | |||||
| p11 | SDA | SDA | SDA | SDA | mbed SPI MOSI | |
| p12 | SDO | SDO | SDO | SDO | mbed SPI MISO | |
| p13 | SCL | SCL | SCL | SCL | mbed SPI SCK | |
| p14 | CS | |||||
| p15 | CS | |||||
| p16 | CS | |||||
| p17 | CS |
Information
We discovered during testing that the SD card cannot share the same SPI bus as the LSM303D chips.
Source Code
C# GUI source code and executable
mbed binary file
Import programECE4180_final_project_serial
the rpc serial interface part of the project
Technical Detail - GUI
A customized C# based GUI is developed to control the magnet location classification system from PC.
A RPC Serial library from mbed is used to communicate with PC. The library can be found here:
Import libraryRPCInterface
Examples are available at this link: /users/nambvarun/notebook/rpc-tutorial/
The C# RPC Library is also used in this project. The code can found at the following link:/media/uploads/tianyeapply/4180_final_project.7z
NOTE We have only tested Digital IO and RPC call for the C# library.
A serial callback function is used to collect responses from mbed. The example is available here: https://msdn.microsoft.com/en-us/library/system.io.ports.serialport.datareceived(v=vs.110).aspx.


GUI Instruction
- Serial Port: Showing all available Serial Ports.
- Connect: Connect to the selected Serial Port.
- emf: Collect the external magnetic field data. Please make sure that no magnet is close to the system.
- Number of Points: The number of data points collected at each label.
- Number of Labels: The number of labels for this training session.
- Repeat Times: The number of repetitions for each labeled trial.
- Reset: Clean all train data in mbed.
- Confirmation: Request mbed to start collecting training data.
- Train: When all data is collected, start training process.
- Update frequency: Setting how often the program will update the position info. Default is 1 second.
- Start: Request the location of the magnet.
- Magnet Location: Output screen that indicate the location of the next labeled training data set.
- Current Magnet Location: Showing the predicted location of magnet based of training data.
- Debug info: Show all return message from mbed.
First time user's guide
- Connect to Serial Port
- Collect EMF Data
- Reset Train Data
- Training
- Input training arguments
- Input Number of Points per Label
- Input Number of Labels
- Input Repeat Times
- Move magnet to the location shown in Magnet Location and collect train data
- Click Train button when all the points data have been successfully collected
- Input training arguments
- Test
- Set frequency and start test.
- Moving magnet. Its current location is shown in the Current Magnet Location text box.
Note
The program will collect x points at each Label 0, 1, 2.....y. It will repeat z times. So the program will collect x*y*z points in total.
Technical Detail - mbed
Mbed will take the RPC call from C# and implement appropriate functions.

Technical Detail - Magnet Location Classification Algorithm
Please see details in the following link: Magnet Location Classification Algorithm using Support Vector Machines
Technical Detail - Data Acquisition
Please see details in the following link: LSM303D Library
Demo
Future Work
- Add BLE based wireless communication between mbed to a smart phone
- Select Suitable mbed solution and peripheral hardwares
- Customize PCB design
- Clinical Trial
References
[1] Z. Zhang, S. Ostadabbas, M.N. Sahadat, N. Sebkhi, D. Wu, A.J. Butler, and M. Ghovanloo, "Enhancements of a tongue-operated robotic rehabilitation system," Proc. IEEE Biomedical Circuits and Systems Conf. , pp. 25-28, Oct. 2015.
DOI: 10.1109/BioCAS.2015.7348284.
Please log in to post comments.
