Saltar al reproductorSaltar al contenido principal
  • hace 2 días
El paquete de soporte de Simulink para Arduino permite desarrollar algoritmos en Simulink, un entorno de diagrama de bloques para modelar sistemas dinámicos

Categoría

📚
Aprendizaje
Transcripción
00:00This time we're going to connect using the Simulink Toolbox.
00:05To do this, we must first install the plugins that allow us to make the connection.
00:10In MATLAB we select Addons and then Get Hardware Support Package.
00:18This will take us to a page that shows us the different plugins that MATLAB uses.
00:25This time we're going to use the one called Simulink Support Package by Arduino Hardware.
00:32We select it and it takes us to another window where it gives us the characteristics of the Simulink Support Package for Arduino Hardware.
00:41The important part here is that it specifies that this add-on is available for versions higher than 2016.
00:50I'm using the 2017 version, so we're good.
00:56I already have this add-on installed on my computer, so the install option doesn't appear.
01:03Since this is your first time, you will have the option to install.
01:06What you have to do is select, install, and continue with the suggested steps.
01:13Once the add-ons have been installed, we need to log into Simulink.
01:20We have two ways to enter for this.
01:24The first step is to click on the Simulink icon.
01:28Or the second one by typing the word Simulink and pressing Enter.
01:34Once logged in, a window similar to this one appears.
01:37We must choose a blank model.
01:42Simulink works based on models.
01:46And its programming is graphical, unlike MATLAB which uses scripts.
01:51What we need to do here now is configure the Arduino board to work in the environment of
01:58Simulink.
01:59To do this, the first thing we need to do is connect our Arduino board to the computer.
02:06In this way.
02:09Once the Arduino board is connected to the computer, we will proceed to perform the configuration steps.
02:16To do this, we go to the settings gear.
02:21In the menu we see several options, we go to Hardware Implementation.
02:27Now, what we need to do is select the card we are going to work with.
02:32In this case I will be working with an Arduino Uno board.
02:35We have several types of Arduino.
02:38I select Arduino Uno in my case.
02:42Once selected, we see the device vendor, which is Admel, and the device type, which is
02:50of AVR.
02:51Now, we're going to configure the COM port that our Arduino board will connect to.
02:57to Simulink.
02:58In this case, we go to the HostBoard Connection option, and here we have the COM port.
03:05In this case, on Arduino Uno boards, generally in most cases, it already recognizes us automatically.
03:11But we can also recognize it manually.
03:16To do this, we need to know the COM port to which our Arduino board is connected to our computer.
03:22This time, we're going to do it automatically.
03:26Let's apply.
03:29Now, let's go to the Solver option.
03:31In the Solver option we must set the stop time.
03:37In this case we have 10 seconds, which is the time in which the card will stop.
03:41As in this case, since we want the data acquisition to be infinite, we will set an infinite time.
03:48We write the hand Inf.
03:52Next, we will set the sampling time for our card.
03:57We must write the Fixed option here.
04:00After that, in additional options, we set the sampling time.
04:07In this case, we're going to put 100 milliseconds, so it's equal to 0.1 seconds.
04:14Let's Apply and OK.
04:18Finally, we must choose the acquisition firing method.
04:22Here, in these selections, we leave the External option selected, so that it is an external shot.
04:30And we proceed to record our model.
04:34I'm going to save it in this folder.
04:36I'm going to give it a name.
04:40Example.
04:42And save.
04:45You can put it in any address you have on your computer.
04:51Now, what we're going to do in this model is turn an LED on and off every second.
04:57To do this, we go to the bookstore.
05:02Inside the library, we looked for the Simulink ones.
05:07Within this library, we have the one that tells us Common.
05:12We entered.
05:13And we have several options.
05:15As we will do, turning an LED on and off is a digital output signal.
05:24We select it and drag it to the workspace.
05:30Now, let's find a power source that will allow us to turn this LED on and off.
05:36Once again, we returned to the bookstore.
05:39We searched within Simulink, Sources.
05:42And within Sources, we find this one that says Pulse Generator.
05:48We dragged her.
05:50And now, what do we do to make the connection?
05:53We drag the generator's output to the Arduino's input.
06:03Now, let's configure.
06:05Double click.
06:07And we completed the 100 parameters.
06:09In terms of amplitude, since this is a digital signal, will it be a logical 1 or a logical 0?
06:14We left it as is.
06:15The period.
06:16Since it's 1 second on and 1 second off, the period would be 2 seconds.
06:22And since I want the times to be equal, 1 second on and 1 second off, it will be 50%.
06:29of the pulse width.
06:33And on our Arduino board, double-click and we have to select the pin through which we want the signal to come out.
06:42sign.
06:42In this case, I'm going to use pin 13.
06:46Apply, accept and click on the arrow option.
06:52Once I have finished compiling, a summary screen like this will appear.
06:59If we look at the camera screen, we can see that the tool is flashing every second, like
07:06It was the programming.
07:09As an example, I have now added another signal, another pin that I want to activate.
07:15In this case, pin 8.
07:16And we can see on the camera, we are activating two pins with the same signal.
07:20Pin 13 and pin 8.
07:23So that it can be seen that we can have several pins available, with which we can make these options.
07:30In our next class, we will work with digital input signals, analog input signals, and finally with PW signals.
07:40That's all for today.
07:42Any comments or suggestions, please feel free to make them through my blog.
07:47See you later.
Comentarios

Recomendada