Download presentation
Presentation is loading. Please wait.
Published byMary Gallagher Modified over 6 years ago
1
Topics: ArduinoIO package Simulink with arduinoIO
Arduino Part 3 Topics: ArduinoIO package Simulink with arduinoIO
2
Workshop Overview Matlab VS IDE Getting started
Hands-on Project 1: LED control Hands-on Project 2: LED dimmer Hands-on Project 3: Reading digital signal Hands-on Project 4: Up counter Hands-on Project 5: Reading analog signal Hands-on Project 6: LED dimmer v2 Hands-on Project 7: Relay control Hands-on Project 8: 7-segment control
3
Using MATLAB vs. IDE Environment
1 MATLAB is more interactive, results from Digital/Analog I/O instructions can be seen immediately without needing to program – compile – upload – execute each time. It is a good idea even just for algorithm prototyping 2 For wider-breadth projects (that might include data analysis, signal processing, calculations, simulation, statistics, control design …) MATLAB is better suited
4
1 2 MathWorks Solutions Arduino IO Package:
Used to perform analog and digital input and output as well as motor control from the MATLAB command line 2 Arduino Target: Used to compile and download Simulink® code directly to the Arduino board
5
1 2 3 Getting started Install Matlab 2012a or later version
Get arduinoIO package, unzip and place the folder inside a MATLAB folder : C:\Program Files\MATLAB 3 Open pde folder. By using arduino IDE software, load adiosv.pde into your arduino
6
Getting started(cont.)
4 Go to arduinoIO folder, copy everthing inside examples and simulink folder and paste it in the main arduinoIO folder Paste here 5 Open the matlab software, change your current folder to ArduinoIO folder ArduinoIO 6 Double click the arduino_io_lib.mdl file
7
Getting started(cont.)
7 You should be able to see simulink library for the arduino IO package Supported simulink block for arduino ArduinoIO Click to launch your first simulink example example
8
Getting started(cont.)
8 Your first arduino-simulink block Click to start simulation Your on-board led should blink once the program run. Select your com port Output to arduino led pin13
9
Hands-on Project 1: LED control
Prepare your simulink block: Click library browser to view other simulink block Click new to create new simulink model
10
Hands-on Project 1: LED control
Compulsory when using ArduinoIO package Prepare your simulink block: Drag and drop the required block to create new model Can be obtained from simulink library browser
11
Hands-on Project 1: LED control
2 Click to start simulation Run your simulink model Set to ‘inf’ This block will send digital signal 0 or 1 to arduino pin13. When the simulation runs, double click to change the switching position and observe the LED on your board
12
Hands-on Project 2: LED dimmer
1 Simulink model Prepare your hardware When simulating, vary slider gain to adjust the led brightness
13
Hands-on Project 3: Reading digital signal
1 2 Hardware Simulink model 10kOhm When you release the switch When you press the switch
14
Hands-on Project 4: Up counter
1 2 Hardware Simulink model 10kOhm
15
Hands-on Project 4: Up counter
2 Simulink model(cont.)
16
Hands-on Project 5: Reading analog signal
1 2 Hardware Simulink model
17
Hands-on Project 6: LED dimmer v2
1 2 Hardware Simulink model Gain : 5/1024 Gain : 255/1024 R 1k Ohm R 220 Ohm
18
Hands-on Project 7: relay control
1 hardware setup (use relay module from SIRIM robokit): relay2 relay1 relay4 relay3 GND 5v
19
Hands-on Project 7: relay control
2 The simulink model: 12
20
Hands-on Project 8: 7-segment control
1 hardware setup (use 7segment module from SIRIM robokit): 5v GND Bit 1 Bit 0 Bit 3 Bit 2 display4 display3 display2 display1
21
Hands-on Project 8: 7-segment control
2 The setting: bit3 bit2 bit1 bit0 display 1 2 3 4 5 6 7 8 9 we will use display number 4 only the number will be displayed based on the following table: 5v GND Bit 1 Bit 0 Bit 3 Bit 2
22
Hands-on Project 8: 7-segment control
2 Simulink model:
23
Hands-on Project 8: 7-segment control
2 Simulink model:
24
Hands-on Project 8: 7-segment control
2 Simulink model: uint8([ ]) uint8([ ]) uint8([ ]) uint8([ ]) uint8([ ]) uint8([ ]) uint8([ ]) uint8([ ]) uint8([ ])
25
Hands-on Project 8: 7-segment control
3 The results:
26
http://www.mathworks.com/har dware-support/arduino- matlab.html
dware-support/arduino- matlab.html References
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.