Matlab with gizDuino SE board


The MATLAB support Packages for Arduino Hardware 32/64-bit Windows, we have available gizDuino boards that will let you communicate via USB cable. Here's the example using gizDuino SE or Student Edition, it is also tested in gizDuino LIN-UNO Atmega328P board both Arduino UNO compatible only, install the drivers and ready to go!. 


Step 1: Download Matlab 2017b

Log-in or Register, required

Go to: www.mathworks.com/downloads

Download the MATLAB 2017b and later.


Step 2: Installing MATLAB Support Package for Arduino Hardware

You must log in. or register, before you proceed.

 

New window will show or Search for add-ons "MATLAB Support Package for Arduino Hardware". Click "Manage".



Step 3: Arduino USB Driver Installation setup


(*)Note: I recommend that you already installed the CH340 driver before you do this. 


You can install the driver for Arduino hardware. The selection box should enable, then click "Next".




Set up your Arduino board connections. Select "Yes", then click "Next".



Choose Connection Type, Connect gizDuino via USB (if necessary) and select the "USB", then click "Next".



Upload Arduino Server, Select/Choose the board: "UNO", Choose port: "COM4", Select libraries (mine) i choose I2C,SPI and Servo Library, then click "Program".



Wait a few minutes to program.



Troubleshoot:


If there is an error message like this "Failed to program the Arduino board. Click the following link to see the error log. Contact Technical Support if you need more help."


Solution:
1.Make sure you select the Correct Com port number.
2. Open the 'Device Manager' to double check the port.

Step 4: Testing the board

On the command window, once the package are installed.
1. Connect your gizDuino board to your PC and type the first line.
>> a = arduino()
2. Select the correct comport
>> a = arduino('com3','uno')
MATLAB will communicate with your board. If successful, it will display the properties of the Arduino board connected to your PC. (see the image below)




Variable 'a' is equal to your gizDuino/Arduino board with com port number assigned. By clearing the object, type the following command.

>> clear a


It will remove the object from your workspace.


Using the Built-in LED in gizDuino Student Edition board.


Run this code.

>> a = arduino('com3','uno');

>> writeDigitalPin(a,"D13",1);pause(1);

>> writeDigitalPin(a,"D13",0);pause(1);


Type the first line, make sure the comport number and the board is correct:

<variable> = arduino('<com#>','<board>');

where:

variable = a

com# = comport number, if the device is connected

board = uno*

*(gizDuino SE is an Arduino UNO compatible board)


For pin 13, in turn on-high/off state use the Command:

writeDigitalPin(<variable>,"<Pins>",<1>);

where:

variable = a

Pins = if Digital I/O, always start with letter "D" followed by the number pin 13. D13

1 =  High or On state.

0 = Low or Off state.


Time Delay use:

pause(<second/s>);

where:

second/s = 1 second


Make sure you clear it first before you start another object, otherwise MATLAB will display an error message.

On this example, after you run the on-state the LED will light on, but when you run it in off-state the LED will turn off.


References:

Matlab forums - Installation of package

Allaboutcircuits - Arduino interface with matlab