Main Content

Scope Block with Apple iOS Devices

This example shows how to plot real-time data on an Apple iOS device by using the Simulink® Scope block with Simulink Support Package for Apple iOS Devices.

Introduction

Apple iOS devices provide a user interface and a set of built-in sensors. The Scope block displays signals generated during simulation in real-time.

By displaying the scope on an Apple iOS device screen, you can:

  • Display signals in real-time.

  • View signals without a connection to your development computer.

  • Customize the scope style to suit your app.

This example provides two Simulink models:

  • iosscopesim: The Scope displays the roll and pitch signals from a simulated accelerometer.

  • iosscopeaccel: The Scope displays the roll and pitch of your Apple iOS device extracted from the Accelerometer.

Prerequisites

Required Hardware

  • iPhone, iPod, or iPad

  • USB cable to connect the device to your development computer

Task 1 - Display Signals During Simulation

Simulate the accelerometer signal as if the device is rotating around the Y-axis.

1. Open the iosscopesim model. The model simulates a device rotating between -45 and +45 degrees around the Y-axis.

2. Double-click the Scope block to open the Scope window.

3. Double-click the Calculate roll and pitch MATLAB Function block to see the equations that determine the roll and pitch.

4. On the model toolbar, click the Run button to see the simulated roll and pitch signals.

Task 2 - Display Signals on Your Apple iOS Device

Using the model from Task 1, display the simulated roll and pitch signals on your Apple iOS device

1. Open the iosscopesim model.

2. Click Simulation > Model Configuration Parameters to open Configuration Parameters dialog.

3. Select the Hardware Implementation pane and from the Hardware board parameter list, select Apple iOS Device.

4. Click Device options and ensure that the device matches your device setting. Click OK.

5. On the model toolbar, click the Deploy to Hardware button to build, download, and run the model on your device.

The app displays the simulated roll and pitch signals on your device screen.

Task 3 - Display Signals from the Apple iOS Device Accelerometer

Using the Accelerometer block, display the roll and pitch of your Apple iOS device on the device screen.

1. Open the iosscopeaccel model. This model replaces the Simulate accelerometer block from the model in Task 2 with the Accelerometer block from the Apple iOS Block Library.

2. On the model toolbar, click the Deploy to Hardware button to build, download, and run the model on your device.

3. Rotate the device around the Y-axis to see the roll and pitch displayed on your device screen.

The app plots the roll and pitch of your Apple iOS device extracted from the Accelerometer.

Task 4 - Customize the Scope Style on Your Apple iOS Device

Using the model from Task 3, configure the appearance and style of the Scope displayed on your Apple iOS device.

1. Open the iosscopeaccel model.

2. Double-click the Scope block to open the Scope window.

3. In the Scope menu, click View > Style to open the Style dialog.

3. Set the Figure color to gray.

4. Modify the Axes colors. Set the Axes background color to white. Set the Ticks, labels, and grid colors to gray.

5. Set Properties for line to Channel 1. Set Line width to 1.5 and Line color to blue.

6. Set Properties for line to Channel 2. Set Line width to 1.5 and Line color to red.

7. Click OK.

8. To see the style changes reflected in the app, you must remove the previous project. In the MATLAB Command Window, run:

rmdir('iosscopeaccel_ert_rtw', 's');

9. On the model toolbar, click the Deploy to Hardware button to build, download, and run the model on your device.

The Scope in the app reflects the new line and axes properties from the Style dialog box of the Scope block.

Other Things to Try

  • Display the roll and pitch on separate scopes.

  • Change the scope style to suit your app.

  • Modify the model to display signals from other sensors.

  • Modify the model to display signals from remote sources using UDP Receive or TCP/IP Receive blocks.

Summary

This example showed how to use the Simulink Scope block with Simulink Support Package for Apple iOS Devices to plot real-time data on an Apple iOS device.