Practical Assignment 1: Arduino interface with Simulink

Similar documents
smraza Getting Start Guide Contents Arduino IDE (Integrated Development Environment)... 1 Introduction... 1 Install the Arduino Software (IDE)...

Application Note. Communication between arduino and IMU Software capturing the data

EE-110 Introduction to Engineering & Laboratory Experience Saeid Rahimi, Ph.D. Labs Introduction to Arduino

Arduino STEAM Academy Arduino STEM Academy Art without Engineering is dreaming. Engineering without Art is calculating. - Steven K.

Lesson 3: Arduino. Goals

Programming 2 Servos. Learn to connect and write code to control two servos.

Arduino Lesson 1. Blink. Created by Simon Monk

For this exercise, you will need a partner, an Arduino kit (in the plastic tub), and a laptop with the Arduino programming environment.

LESSONS Lesson 1. Microcontrollers and SBCs. The Big Idea: Lesson 1: Microcontrollers and SBCs. Background: What, precisely, is computer science?

Table of Contents. Chapter 1: Software Installation...1. Chapter 2: Running the Software II. Daily Practical Operation...10

Open Loop Frequency Response

Lab 2: Introduction to Real Time Workshop

Magnetic Levitation System

Lab 4 Rev. 1 Open Lab Due COB Friday April 6, 2018

Understanding the Arduino to LabVIEW Interface

Downloading a ROBOTC Sample Program

Overview... 3 Starting the Software... 3 Adding Your Profile... 3 Updating your Profile... 4

Installation Guide - Addendum Garmin to Contigo 6150 & 6151

Linear Motion Servo Plants: IP01 or IP02. Linear Experiment #0: Integration with WinCon. IP01 and IP02. Student Handout

Endurance R/C Wi-Fi Servo Controller 2 Instructions

Note: Objective: Prelab: ME 5286 Robotics Labs Lab 1: Hello Cobot World Duration: 2 Weeks (1/22/2018 2/02/2018)

HILINK REAL-TIME HARDWARE-IN-THE-LOOP CONTROL PLATFORM FOR MATLAB/SIMULINK

CURIE Academy, Summer 2014 Lab 2: Computer Engineering Software Perspective Sign-Off Sheet

How to import and sync your Scrivener projects from your computer via Dropbox?

The DesignaKnit Serial E6000 Link 1

Lab 1: Steady State Error and Step Response MAE 433, Spring 2012

Internet of Things Student STEM Project Jackson High School. Lesson 2: Arduino and LED

OverDrive for Kindle, Kindle Paperwhite, Kindle Voyage, and Kindle Oasis (not Kindle Fire and Fire Tablet) Contents

USB Multifunction Arbitrary Waveform Generator AWG2300. User Guide

VBRC 5. Radio Communicator. Installer Manual

AFN7500HD Decoder Troubleshooting Guide IMPORTANT DECODER UPDATE

Introduction to Simulink

Module: Arduino as Signal Generator

The Discussion of this exercise covers the following points: Differential-pressure transmitter. Differential-pressure transmitter

Laboratory Experiment #1 Introduction to Spectral Analysis

MAE106 Laboratory Exercises Lab # 1 - Laboratory tools

Studuino Icon Programming Environment Guide

LVTX-10 Series Ultrasonic Sensor Installation and Operation Guide

Issue No: MG025 Date: 05 June McMurdo SmartFind R5 GMDSS Radio IMO MSC. 1/Circ Update procedure

Root Locus Design. by Martin Hagan revised by Trevor Eckert 1 OBJECTIVE

Flash Blaster II v.2.00 for the Falcon digital console Falcon ENGLISH

Experiment 1 Introduction to Simulink

G E O S E R V E R I N S TA L L

Coding with Arduino to operate the prosthetic arm

PowerView Motorisation

LC-10 Chipless TagReader v 2.0 August 2006

Topcon Receiver Utility: GNSS Receiver Firmware Update Process. Oscar R. Cantu

EGG 101L INTRODUCTION TO ENGINEERING EXPERIENCE

EE 210 Lab Exercise #3 Introduction to PSPICE

Chanalyzer Lab. Chanalyzer Lab by MetaGeek USER GUIDE page 1

Instrumentation and Microcontrollers Using Automatic Code Generation

EE25266 ASIC/FPGA Chip Design. Designing a FIR Filter, FPGA in the Loop, Ethernet

Altair Avionics Corporation Monitor Link Program

MAXI Remote Location Kit MRLK 900 Installation and Configuration Manual

M-16DX 16-Channel Digital Mixer

Lab 5: Inverted Pendulum PID Control

Note: Objective: Prelab: ME 5286 Robotics Labs Lab 1: Hello World Duration: 1 Week

Reviewing Your Tax Return In Your Portal

MLP Troubleshooting Fault Isolation Checklist for MLP

Stratix II Filtering Lab

Start Here. Installing your Microtek ScanMaker 9800XL Plus PC:

Introduction to the Analog Discovery

WIRES-X Portable Digital Node Function. Instruction Manual

The DesignaKnit USB Brotherlink 1

DataCAD Softlock License Activation and Management

UWYO VR SETUP INSTRUCTIONS

The USB Brotherlink 4 - or Cartridge Cable

Introduction to Simulink Assignment Companion Document

DPM Kit DK-1. Using the DPM Kit

The DesignaKnit Serial Brotherlink 1

BEI Device Interface User Manual Birger Engineering, Inc.

Lab 4 An FPGA Based Digital System Design ReadMeFirst

Omniverse Setup Instructions

The DesignaKnit Serial Brotherlink 3

Quick Start Guide. Contents

Electronic Plans Management Training. Upload Drawings

VESDA Technical Tip. Upgrade of the VLF-250 to support. VESDAnet Interface Card

Lab 8: Introduction to the e-puck Robot

Getting started 1 System Requirements... 1 Software Installation... 2 Hardware Installation... 2 System Limitations and Tips on Scanning...

Tel & Fax : Install and Operate Sharp Shape USB3D Foot Scanner Copyright, Sharp Shape, July 2014

Brightness and Contrast Control Reference Guide

EGG 101L INTRODUCTION TO ENGINEERING EXPERIENCE

Programming a Servo. Servo. Red Wire. Black Wire. White Wire

DataCAD 18 Softlock. Universal Installer. Installation. Evaluation

INTRODUCTION TO DATA STUDIO

VBRC 4. Radio Communicator. Installer Manual

The SilverLink 5. For Silver Reed & Knitmaster electronic machines

Application Note AN 157: Arduino UART Interface to TelAire T6613 CO2 Sensor

Blue Bamboo P25 Device Manager Guide

1Getting Started SIK BINDER //3

MityCAM-B2521 EPIX XCAP User s Guide

GNSS Conductor GF. User s Guide. (Document No. SE )

RAZER RAIJU TOURNAMENT EDITION

ScaleRCHelis.com Light Controller Users Manual

Quick Start. Precis-BX305. Precise GNSS RTK Board.

ifeel Sensor USER GUIDE SUPPLEMENT

Blackfin Online Learning & Development

Lab 1: Analog Modulations

MIX SUITE + VOCAL BOOTH BASICS

Accessing e-books with your e-reader

Transcription:

!! Department of Electrical Engineering Indian Institute of Technology Dharwad EE 303: Control Systems Practical Assignment - 1 Adapted from Take Home Labs, Oklahoma State University Practical Assignment 1: Arduino interface with Simulink 1 OBJECTIVE This assignment is an introduction to the experimental set-up to be used throughout this course. The instructions for installing MATLAB Support Package for Arduino Hardware and Simulink Support Package for Arduino Hardware are given first. After installing these necessary Add-Ons, you will verify that everything is installed correctly by using the hardware and software to successfully blink an LED on the Arduino board, using two different methods for running models on the Arduino with Simulink: Normal Mode and External Mode. 2 SETUP 2.1 REQUIRED MATERIALS 2.1.1 HARDWARE Your kit will contain either Arduino MEGA 2560 or Arduino UNO. The experiment procedure is identical for both the boards. Arduino Mega 2560 R3 OR Arduino Uno R3 We will use original boards and not the clones to avoid any difficulties in the interface with Simulink/MATLAB.!1

USB cable (Standard A to B plug) 2.1.2 SOFTWARE Matlab/Simulink R2013a or later (Institute licences are available for the latest versions) The steps and images related to Matlab/Simulink for this experiment are created using Matlab/ Simulink 2018a. Therefore some steps and images may be a little different for other versions of Matlab. Personal Computer with administrator access. 3 EXPERIMENTAL PROCEDURES The first exercise of this lab demonstrates how to install the Add-Ons: MATLAB Support Package for Arduino Hardware and Simulink Support Package for Arduino Hardware. The next exercise will verify that the first exercise was successful. The exercise consists of creating Simulink models to blink the Arduino s built-in LED using Normal Mode and External Mode. 1. Connect the Arduino board to the computer using the USB cable. The Power ON LED on the board will glow as shown below:!2

3.1 EXERCISE 1: INSTALLING ARDUINO SUPPORT IN SIMULINK 1. On the Home" toolstrip, navigate to Resources" and click the Add-Ons" dropdown menu followed by Get Hardware Support Packages" as shown in the Figure below. 2. This will open a window named Add-On Explorer. Choose the following two packages (Exact Name should match): a. MATLAB Support Package for Arduino Hardware b. Simulink Support Package for Arduino Hardware For each of the package, select install. 3. A MathWorks account will be needed to proceed, so log in with your account linked to your institute email address. 4. Follow the remainder of the on-screen prompts until the installation is finished, and exit out by clicking Finish".!3

3.1.1 CHECKPOINT: Verify that the installation was successful by performing the following: 5. Type simulink in the Matlab Command Window or click on icon. 6. A window similar to the following will open. 7. Click on Blank Model. 8. It will open a new window similar to the following: 9. Click on the Library Browser icon which is highlighted in Red in the figure above.!4

10. Now, in the Libraries" section, verify that the Simulink Support Package for Arduino Hardware is there, as shown in the figure below: 3.2 EXERCISE 2: BLINKING AN LED Now that the Arduino support is installed in Simulink, the next step is verifying the PC can communicate with the board properly. There are two methods that will be used to demonstrate proper communication between the board and the PC: Normal Mode and External Mode. Both methods have their pros and cons, and, depending on the project, one method may prove to be more beneficial than the other. Thus, it is important to introduce both methods now so that the student is familiar with them before starting any of the later labs. A simple experiment to introduce both of these methods is blinking an LED. Besides the Arduino and the USB cable, there is no additional hardware needed for this experiment, because the Arduino has a built-in LED. 3.2.1 NORMAL MODE As indicated by its name, Normal Mode is just the normal method used to download programs onto the Arduino. A program downloaded to the board in Normal Mode will stay on the board until another program overwrites it. This means that even when the board is disconnected from power and reconnected later, the program is still loaded onto the board, and will just start executing again. The main disadvantage with Normal Mode is that if any data needs to be recorded, they will be more difficult to acquire than with External Mode. The main advantage with Normal Mode is that it allows programs to run at a much faster rate than External Mode. The following steps show how to use Normal Mode to blink the onboard LED of the Arduino. The final Simulink Model will look like following:!5

! 18. Open MATLAB, then open a new Simulink Model using either of the following methods: In the Matlab window s Home" toolstrip, choose File New Simulink Model. Type simulink in the Matlab Command Window, then press the New Model! icon. 19. Open the Library Browser by pressing the! icon, or selecting View LibraryBrowser. 20. Under the Libraries section add a Pulse Generator block to the model: Simulink Sources Pulse Generator 21. Under the Libraries section add an Arduino Digital Output block by selecting: Matlab R2013b/R2014a: Simulink Simulink Support Package for Arduino Hardware Common Digital Output 22. Save the Simulink model as any filename. 23. Double-click the Pulse Generator block, make the following changes and then hit OK: Set Pulse type" to Sample based Set Period" to 4 Set Pulse width" to 2 Set Sample time to 1!6

24. Double-click the Arduino Digital Output block, make the following changes and then hit OK: Set Pin number to 13, this is the pin the onboard LED is connected to. 25. Connect the Pulse Generator block to the Digital Output block. The model should look like 26. Now select Tools Run on Target Hardware Prepare to Run... 27. A window should appear as that in the figure below. Set Hardware board to Arduino Mega 2560, and wait a moment for the window to update.!7

28. Select Solver on the left hand side of the window, then make the following changes and hit OK. Set Stop time to inf Set Type" to Fixed-step In Solver details, set Fixed-step size" to 0.05 29. Now run the model by clicking the Build Model" button 30. Wait until the the model has successfully downloaded to the board, now observe the onboard LED of the Arduino shown in the figure below.!8

31. Describe what the LED is doing. Estimate and record the timing. Is the timing consistent with the settings of the pulse generator you made earlier? Explain. 32. Change the Pulse Generator block sample time from 1 second to 0.1 seconds. 33. Download the modified model onto the board. Describe the changes in the LED operation. How has the timing changed? Did it change in the way that you expected? 34. Change the parameters of the Pulse Generator block so that the LED will be on for 4 seconds and off for 1 second. Record your settings, download the modified model, and describe the resulting operation. If the timing does not produce a 4 second on period and a 1 second off period, make the necessary changes to the parameters of the Pulse Generator and test the operation again. 35. Record your data in the table of the following format. Pulse Generator Settings Period Pulse Width Sample Time Description of LED behaviour TROUBLESHOOTING: If there are any errors encountered throughout this section, try the following: If Matlab cannot find the board when attempting to run the model, try setting the COM port manually. In Simulink, go to Tools Run on Target Hardware Prepare to Run, then change Set host COM port:" from Automatically to Manually as shown in the figure below!9

! Find out the COM port number being used for Arduino (based on operating system, there are different ways to find out the COM port number. Google it.) and enter it. If Simulink cannot connect to the board either: try disconnecting and reconnecting the USB cable, or closing and reopening Matlab. Any other issues encountered may be solved by reading the Arduino troubleshooting page located at http://www.arduino.cc/en/guide/troubleshooting. 3.3.2 EXTERNAL MODE In External Mode you are given the ability to tune parameters, and monitor data in real-time, without having to re-download the model each time parameters are adjusted. Once External mode is started, it uses the serial port to communicate between the board and the PC. Therefore, to run in External mode, the USB should be connected between the board and the PC. This ability to adjust and monitor changes in real-time is what makes External Mode such an enticing option for running these experiments. You can benefit from being able to see the immediate effects your changes have on the hardware. However, this ability to make changes real-time comes at a cost. To communicate back and forth, the serial port is kept open and has a limited amount of bandwidth. This limitation affects the rate at which the program can run. External Mode s ability to make real-time adjustments will be shown in the following steps, using the Arduino s onboard LED. 34. Open a new Simulink Model, and name it something different from the previous model. 35. Add the following items from the Simulink Library Browser: Two Pulse Generators: Simulink Sources Pulse Generator Manual Switch: Simulink Signal Routing Manual Switch Arduino Digital Output Block: Simulink Support Package for Arduino Hardware Common Digital Output 36. Save the model, and connect the blocks so that they look like Figure 3.23. 37. Double-click the Digital Output block and set the pin number to be 13.!10

38. Double-click the top Pulse Generator block, make the following changes and hit OK: Set Pulse type" to Sample based Set Period" to 4 Set Pulse width" to 2 Set Sample time" to 1 second 39. Double-click the bottom Pulse Generator block, make the following changes and hit OK: Set Pulse type" to Sample based Set Period" to 4 Set Pulse width" to 2 Set Sample time" to 0.1 second 40. Set up the Arduino to run in External Mode. Select Tools Run on Target Hardware Prepare to Run 41. Set Target hardware to Arduino Mega 2560, and wait a moment for the window to update. 42. Select Solver on the left hand side of the window, then make the following changes and hit OK. Set Stop time" to inf Set Type" to Fixed-step Set Fixed-step size" to.05 Uncheck Treat each discrete rate as a separate task Refer to the figure on the next page.!11

!! 43. Make sure the drop-down menu shown in the figure below is set to External. 44. Download the model to the Arduino using the same method used for Normal Mode. 45. Press the Run button!, as shown in the figure below: 46. Record what the Arduino s LED is doing. Estimate timing. Is the timing consistent with the parameter settings?!12

! 47. Double click the Manual Switch in the Simulink Model. The switch should now be connecting the bottom Pulse Generator to the Digital Output. 48. Record what the Arduino s LED is doing now. Describe any timing changes. Explain why the timing changed. How is the process different than Normal Mode? Which Mode is better? Why? 49. Press the Stop button!, as shown in Figure 3.29. Figure 3.29: External Mode Disconnect: R2013b or later 50. Disconnect the USB from the Arduino and PC. TROUBLESHOOTING: The most common error that may be encountered using External Mode is Simulink being unable to connect to the Arduino. This can happen when running in External mode if a previous simulation was not stopped correctly. The serial port may have been left open creating issues when trying to reconnect to the board. Another possible cause is that the model was not rebuilt after making changes. Possible fixes for this error are: Try rebuilding the model. Disconnect the USB from the Arduino and reconnect. (This usually fixes most of the errors). Try hitting the reset button on the Arduino, shown below:!13

Close Matlab and re-open. Any other issues encountered may be solved by reading the Arduino troubleshooting page located at http://www.arduino.cc/en/guide/troubleshooting. 4 CONCLUSION This introductory lab was constructed to show how to install the necessary support for the Arduino in Simulink, and on the PC. Control of the Arduino s onboard LED was used to verify that everything was installed correctly. There were two methods used to test this Normal Mode and External Mode. This experiment only provided a glimpse of these two modes. A more in depth comparison of the two modes is provided in the subsequent experiments. 5 DELIVERABLES The assignment is to be submitted by each student individually. Even though the kits were issued in groups, students are encouraged to perform the assignment individually using their laptops/pcs as the steps followed in this assignment are prerequisites for all the subsequent assignments. For submitting the assignment, prepare a new document containing the following information: Name: Roll No.: Department: For Normal mode, reproduce the observation table given in this document. Write down all the questions asked in this document with your answers. Save this file as pdf with the filename as <Department Code><Roll No>-A1.pdf, for example if you are in Electrical Engineering and your roll number is 160030005, then the file should be named as ME160030005-A1.pdf. Compress the pdf file and the two simulink files (with *.slx extension) in a single zip file with file name of the format <Department Code><Roll No>-A1.zip (e.g. ME16003005-A1.zip) and upload it on the Moodle portal before 9:30 am on 9th August, 2018.!14