Skip to content

netanelyo/AdvancedComputerSystems

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ControlServo-BLEApp

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).

Motivation

Our initial goal was to make the Metal Marble Labyrinth Puzzle accesible, the game:

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.

Equipment

  • TI CC1350 Launchpad:

board

  • 2 * SG-90 servo engines:

servo

  • Samsung Galaxy S3:

galaxy

  • Bread Board:

matrix

Implementation

Android application

Used Android Studio 3.0.1 for the development process.

Development process:

  1. Using Android Sensor API to read the Rotation Vector (Pitch and Roll only), Used this example for the implementation. The pitch and roll orientation: rotation
  2. For the BLE connection establishment with the micro-controller we used this example, from Google's Android examples Github.
  3. We changed the UI of the above example, and added the BLE writing data functionality.
  4. Finally, we combined both applications, so it will the read the rotation vector of the phone, and send it immediately to the micro-controller.

Application flow:

  1. Android application looks for the exact TI-RTOS application name in all optional BLE devices. If not found - raises an appropriate "Toast" message.
  2. 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.
  3. 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.
  4. To end the connection - the user can click the "pause" button.

Technical details:

  • 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].

TI-RTOS application (servo engines control)

Used Code Composer Studio 7.3.0 for the development process.

Development process:

  1. Using Simple BLE Peripheral example from the TI-RTOS examples library to establish the BLE connection to the Galaxy S3 device.
  2. Used the TI-RTOS PWM API to generate output pulses, which will determine the engines position.
  3. Used the SG90 datasheet to create a linear mapping from the required degree to the appropriate pulse width (measured in ms).

Application flow:

  1. Upon established connection, start reading the data from the 0xfff3 write characteristic.
  2. The read data will then be mapped to respective pulse width to the PIN output.
  3. Servo engines will be positioned accordingly.

Technical details:

  • 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].

Demonstration (press image to see video):

Demonstration

Our learning process

Android

  • 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.

TI-RTOS

  • 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.

Building the Project

Pre-requisites:

  • Java 8 (or above).
  • Android SDK 27.
  • Android Build tools v27.0.2.
  • TI's CCS compiler.

Recommended build steps:

  1. Download the latest Android Studio and Code Composer Studio.
  2. clone the project from the repository to your local PC, i.e.,
$ git clone https://github.com/netanelyo/AdvancedComputerSystems.git
  1. Open the AndroidApp/ControlServo-BLEApp project in Android Studio.
  2. Connect your android device.
  3. Download the app to your android device by entering "debug mode".
  4. Open the BoardApp/simple_peripheral_cc1350lp_stack_FlashROM and BoardApp/simple_peripheral_cc1350lp_app_FlashROM projects in Code Composer Studio.
  5. Connect your CC1350 launchpad.
  6. Download the app to the board by entering the "debug mode".

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published