Android and TI-RTOS applications that communicate over BLE. Android app reads the rotation vector from the phone (only the pitch and roll), and sends it to the TI-RTOS BLE application (firmware is installed on the CC-1350 launchpad).
Our initial goal was to make the Metal Marble Labyrinth Puzzle accesible, the game:
As one can see in the image, the game requires using both hands (one for axis controller). With our implementation, one can play this game with one (or none) hand. Besides the mentioned game, the software can be used for several application such as: model airplanes or ships, etc.
- TI CC1350 Launchpad:
- 2 * SG-90 servo engines:
- Samsung Galaxy S3:
- Bread Board:
Used Android Studio 3.0.1 for the development process.
- Using Android Sensor API to read the Rotation Vector (Pitch and Roll only), Used this example for the implementation. The pitch and roll orientation:
- For the BLE connection establishment with the micro-controller we used this example, from Google's Android examples Github.
- We changed the UI of the above example, and added the BLE writing data functionality.
- Finally, we combined both applications, so it will the read the rotation vector of the phone, and send it immediately to the micro-controller.
- Android application looks for the exact TI-RTOS application name in all optional BLE devices. If not found - raises an appropriate "Toast" message.
- If found, by the end of the scan, a "start" button will appear. Upon user's click on the "start" button the application will try to connect to the micro-controller.
- After connection is established, a listener for the rotation vector will be automatically registered, and in each vector read - the app will send the degree to the micro-controller.
- To end the connection - the user can click the "pause" button.
- Rotation vector sample rate is 120ms.
- Each time only one of {pitch, roll} is sent. The synchronization between the orientation (pitch/roll) and the corresponding servo engine is done by the MSB of the written data.
- Data is written on the 0xfff3 write characteristic of the TI-RTOS app.
- Limited the degrees to [-60, 60].
Used Code Composer Studio 7.3.0 for the development process.
- Using Simple BLE Peripheral example from the TI-RTOS examples library to establish the BLE connection to the Galaxy S3 device.
- Used the TI-RTOS PWM API to generate output pulses, which will determine the engines position.
- Used the SG90 datasheet to create a linear mapping from the required degree to the appropriate pulse width (measured in ms).
- Upon established connection, start reading the data from the 0xfff3 write characteristic.
- The read data will then be mapped to respective pulse width to the PIN output.
- Servo engines will be positioned accordingly.
- The linear mapping between the degree (deg) and pulse width (pw): pw = (deg/90 + 1.75) * 1000
- Upon reading the data, it is masked to get the MSB and to output to the corresponding engine.
- Limited the degrees to [-60, 60].
- First, we started by learning how write a simple "Hello, world" Android application, using Android Studio.
- After getting the hang of it, we wrote a slightly more complex application, which reads the rotation vector of the mobile device and displaying it on screen.
- Finally, after we have "mastering" the app writing skills, we wrote the main application mentioned above.
- First, we needed to remember on how to read data using BLE protocol (as we did on HW5).
- Controlling servo engines:
- First, we read the SG90 datasheet, and studied which pulse the engine needs to be in which degree.
- To output the appropriate pulse width we used the PWM API, that we have used in the PWMLed exercise.
- Java 8 (or above).
- Android SDK 27.
- Android Build tools v27.0.2.
- TI's CCS compiler.
- Download the latest Android Studio and Code Composer Studio.
- clone the project from the repository to your local PC, i.e.,
$ git clone https://github.com/netanelyo/AdvancedComputerSystems.git
- Open the AndroidApp/ControlServo-BLEApp project in Android Studio.
- Connect your android device.
- Download the app to your android device by entering "debug mode".
- Open the BoardApp/simple_peripheral_cc1350lp_stack_FlashROM and BoardApp/simple_peripheral_cc1350lp_app_FlashROM projects in Code Composer Studio.
- Connect your CC1350 launchpad.
- Download the app to the board by entering the "debug mode".