From 194be212e96b830b62545bb42ab55730cfb5fdf6 Mon Sep 17 00:00:00 2001 From: Pragya28 Date: Wed, 6 Jun 2018 23:16:39 +0530 Subject: Images in documentation --- .../Resources/Images/DefaultSynchronize.png | Bin 27764 -> 66468 bytes OpenModelicaArduino/Resources/Images/Interval.png | Bin 25627 -> 225058 bytes .../Resources/Images/ModelPlugLog-nomarkers.png | Bin 32933 -> 172348 bytes .../Resources/Images/ModelPlugLog-withmarkers.png | Bin 30569 -> 510685 bytes OpenModelicaArduino/Resources/Images/PinNumber.png | Bin 3138 -> 36423 bytes .../Resources/Images/QuotedSerialPort.png | Bin 6785 -> 54182 bytes OpenModelicaArduino/Resources/Images/StopTime.png | Bin 15893 -> 224766 bytes .../Resources/Images/SynchronizeSetting.png | Bin 15362 -> 66468 bytes OpenModelicaArduino/package.mo | 75 ++++++++++++--------- 9 files changed, 44 insertions(+), 31 deletions(-) diff --git a/OpenModelicaArduino/Resources/Images/DefaultSynchronize.png b/OpenModelicaArduino/Resources/Images/DefaultSynchronize.png index b1192c1..8dfbc8f 100644 Binary files a/OpenModelicaArduino/Resources/Images/DefaultSynchronize.png and b/OpenModelicaArduino/Resources/Images/DefaultSynchronize.png differ diff --git a/OpenModelicaArduino/Resources/Images/Interval.png b/OpenModelicaArduino/Resources/Images/Interval.png index 849f8f4..514bff0 100644 Binary files a/OpenModelicaArduino/Resources/Images/Interval.png and b/OpenModelicaArduino/Resources/Images/Interval.png differ diff --git a/OpenModelicaArduino/Resources/Images/ModelPlugLog-nomarkers.png b/OpenModelicaArduino/Resources/Images/ModelPlugLog-nomarkers.png index c719a11..ea0e7df 100644 Binary files a/OpenModelicaArduino/Resources/Images/ModelPlugLog-nomarkers.png and b/OpenModelicaArduino/Resources/Images/ModelPlugLog-nomarkers.png differ diff --git a/OpenModelicaArduino/Resources/Images/ModelPlugLog-withmarkers.png b/OpenModelicaArduino/Resources/Images/ModelPlugLog-withmarkers.png index 40ab6da..9549bd2 100644 Binary files a/OpenModelicaArduino/Resources/Images/ModelPlugLog-withmarkers.png and b/OpenModelicaArduino/Resources/Images/ModelPlugLog-withmarkers.png differ diff --git a/OpenModelicaArduino/Resources/Images/PinNumber.png b/OpenModelicaArduino/Resources/Images/PinNumber.png index e45324f..1aff89a 100644 Binary files a/OpenModelicaArduino/Resources/Images/PinNumber.png and b/OpenModelicaArduino/Resources/Images/PinNumber.png differ diff --git a/OpenModelicaArduino/Resources/Images/QuotedSerialPort.png b/OpenModelicaArduino/Resources/Images/QuotedSerialPort.png index cf0c4c3..8702a59 100644 Binary files a/OpenModelicaArduino/Resources/Images/QuotedSerialPort.png and b/OpenModelicaArduino/Resources/Images/QuotedSerialPort.png differ diff --git a/OpenModelicaArduino/Resources/Images/StopTime.png b/OpenModelicaArduino/Resources/Images/StopTime.png index 1ad1767..c7d1662 100644 Binary files a/OpenModelicaArduino/Resources/Images/StopTime.png and b/OpenModelicaArduino/Resources/Images/StopTime.png differ diff --git a/OpenModelicaArduino/Resources/Images/SynchronizeSetting.png b/OpenModelicaArduino/Resources/Images/SynchronizeSetting.png index 41a2924..8dfbc8f 100644 Binary files a/OpenModelicaArduino/Resources/Images/SynchronizeSetting.png and b/OpenModelicaArduino/Resources/Images/SynchronizeSetting.png differ diff --git a/OpenModelicaArduino/package.mo b/OpenModelicaArduino/package.mo index 5c6ebfd..342c1cf 100644 --- a/OpenModelicaArduino/package.mo +++ b/OpenModelicaArduino/package.mo @@ -5,10 +5,10 @@ package OpenModelicaArduino "Connecting OpenModelica with Arduino"
.
The first thing you need to do is upload the Firmware code to your board .
- +Figure 1. Location of the Firmware sketch.
Once the the Firmware code is in the board, you need to write down the serial port that it is using. This is important because you need to give the port name to OpenModelicaArduino in order to communicate with the board. You can find the serial port in Tools->Serial Port or in the bottom-right corner of the Arduino software window (see Figure 2). In Windows the serial port name is something like “COM5”, while in OS X and Linux the name will be something like “/dev/ttyACM0”. Now you are ready to make your first model.
- +Figure 2. Finding the serial port being used.
As a first exercise, you are going to reproduce with OpenModelicaArduino the blinking LED example. You can either open the prebuilt example (OpenModelicaArduino.Examples.BlinkLed) or build it by yourself. To build the model, locate the components:
@@ -18,27 +18,27 @@ package OpenModelicaArduino "Connecting OpenModelica with Arduino"Connect the components as in Figure 3. One thing to notice is that the DigitalOutput model is connected to the Arduino component to specify that the pin belongs to that board. This connection is necessary because OpenModelicaArduino can use multiple boards with multiple pins at the same time.
- +Figure 3. Diagram of the blinking LED.
Next you need to specify the serial port that the board is using. This is done by selecting the Arduino component and showing its parameters. In the parameter view, you can find the Port parameter. Write the port name that you got in the section “Preparing your board”. Important: the name must be have quotation marks as shown in Figure 4.
- +Figure 4. Specifying the serial port name.
Now you need to set the pin number that you are going to use in the DigitalOutput component. Usually, the Arduino boards have an LED attached to pin 13. Set that number in the Pin parameter as shown in Figure 5.
- +Figure 5. Specifying the pin to use.
For the BooleanPulse component, set the 'period' parameter to 1. The model is ready to simulate. Press the simulate button and wait to see the results.
The first time you run the model, it is probably simulated so fast that you do not have time to react. The reason is that OpenModelica simulates the model as fast as possible. In order to interact with your models using OpenModelicaArduino, it is necessary to synchronize the simulation time with real time. This is done in by using Synchronisation block in ModelicaDeviceDriver library. After simulating the model one time, you need to check in the checkbox “Synchronize with real-time” as shown in Figure 6.
- //+ //
//
Figure 6. Synchronizing your simulation with real time.
//If you are building many models with the OpenModelicaArduino library, you should set the “Synchronize with real-time” option as a default simulation setting in SimulationCenter under the menu Tools->Options in the section SimulationCenter->Default Experiment (see Figure 7).
- //+ //
//
Figure 7. Setting \"Synchronize with real-time\" as default.
//Now run the simulation again and you should see the LED blinking until the simulation reaches the stop time. If you want to keep the simulation running continuously, you need to change the stop time to “infinite” as shown in Figure 8.
- // + // //Figure 8. Setting the stop time to infinite.
//If you run the simulation again, you should see the LED blinking continuously.
One thing that you may have noticed is that OpenModelicaArduino prints status messages in the simulation log (see Figure 9). The first thing it prints is a list of the available ports. In that list, you should see your current port (A). After that, it prints the current port and the speed used (B). Once the port is opened, you receive a notification that the board is initialized (C). Usually the boards report the version of Firmata that you are running. Then you set the sampling interval that the board uses (D). In this example, you can see that you are setting pin 13 to be an output because you have used the DigitalOutput component (E). Finally you will see that the board will send you a list of all the pins available and thier capabilities (F). This list contains the number of the pin and the modes in which it can be used, for example: DigitalInput, DigitalOutput, AnalogInput, AnalogOutput, and Servo.
- +Figure 9. Messages shown by OpenModelicaArduino.
This is a checklist that you can follow in order to solve most of the problems that can occur when using the ModelPlug library:
@@ -57,6 +57,7 @@ package OpenModelicaArduino "Connecting OpenModelica with Arduino"OpenModelicaArduino contains a series of basic examples showing the functionality of the components. You can check the Examples under ModelPlug.Examples. Once you have learned how to use the basic components of OpenModelicaArduino, you can check the Arduino Playground to learn how to connect other sensors and actuators (http://playground.arduino.cc).