This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

legoev3

Create connection between host computer and EV3 hardware

Syntax

myev3 = legoev3(ipaddress)
legoev3(ipaddress)

Description

myev3 = legoev3(ipaddress) creates a connection between the MATLAB® software on your host computer and the operating system on the EV3 hardware. You can use this connection to start, stop, or delete Simulink® models that you deployed to the EV3 hardware.

legoev3(ipaddress) verifies that the MATLAB software can reach an EV3 brick with the specified IP address on the network.

Examples

collapse all

After you run a Simulink model on the EV3 hardware, you can use commands to stop, restart, and delete the model.

Create a connection between the MATLAB software on your host computer and the operating system on the EV3 hardware.

myev3 = legoev3('172.21.128.249')
myev3 = 

  legoev3 with properties:

    ipAddress: '172.21.128.249'

The function returns a handle, myev3, that you will use as the first argument in the following commands.

To stop the model on the EV3 hardware, enter:

stopModel(myev3,'ev3_gettingstarted')
ans =

     0

When the function has stopped the model, it returns 0.

To restart the model on the EV3 hardware, enter:

runModel(myev3,'ev3_gettingstarted')
ans =

     0

When the function has restarted the model, it returns 0.

To delete the model on the EV3 hardware, enter:

deleteModel(myev3,'ev3_gettingstarted')
ans =

     0

When the function has deleted the model, it returns 0.

You can verify that an EV3 brick with a specific IP address is reachable on the network. For example, you can use this syntax to check that the EV3 power is on before you deploy a model to the EV3 brick.

legoev3('172.21.128.249')
ans = 

  legoev3 with properties:

    ipAddress: '172.21.128.249'

The function returns the IP address of the reachable EV3 brick on the network.

If an EV3 brick is not reachable at the specified address, the command returns an error.

legoev3('172.21.128.250')
Error using legoev3 (line 60)
Failed to connect to '172.21.128.250'.
Please check your network settings.

Input Arguments

collapse all

IP address of EV3 hardware, specified as a character vector. You can get the IP address from Brick Info screen on the EV3 hardware.

Example: '192.168.1.7'

Data Types: char

Output Arguments

collapse all

Connection to a specific EV3 brick, specified as a handle.

After creating a myev3 handle, you can use the handle with the following methods:

You can use myev3 to read and write the ipAddress property.

For example, to read the current IP address, enter:

myev3.ipAddress
ans =

172.21.128.249

For example, to connect to a different EV3 brick without clearing and recreating a connection, assign a new IP address to the connection:

myev3.ipAddress = '172.21.128.250'
myev3 = 

  legoev3 with properties:

    ipAddress: '172.21.128.250'