diff options
author | SudhakarKuma | 2021-04-29 11:30:12 +0530 |
---|---|---|
committer | SudhakarKuma | 2021-04-29 11:30:12 +0530 |
commit | bf8d64a29b9681238dffab49c9bfa1a15e848206 (patch) | |
tree | 72da723d2cbad38a44dc6e0f807f6570d7d035d3 | |
parent | d379bc8abbc7ad810229f8cec2e7e8f94396569f (diff) | |
download | FLOSS-Arduino-Book-bf8d64a29b9681238dffab49c9bfa1a15e848206.tar.gz FLOSS-Arduino-Book-bf8d64a29b9681238dffab49c9bfa1a15e848206.tar.bz2 FLOSS-Arduino-Book-bf8d64a29b9681238dffab49c9bfa1a15e848206.zip |
Update chapter 4
30 files changed, 2565 insertions, 2444 deletions
diff --git a/floss-arduino.aux b/floss-arduino.aux index e74b23f..ba5f4ef 100644 --- a/floss-arduino.aux +++ b/floss-arduino.aux @@ -207,6 +207,7 @@ \newlabel{py-linux}{{3.4.2}{45}} \citation{pySerial} \@writefile{toc}{\contentsline {subsection}{\numberline {3.4.3}Python Arduino toolbox}{46}\protected@file@percent } +\newlabel{sec:python-toolbox}{{3.4.3}{46}} \newlabel{11@xvr}{{}{46}} \newlabel{11@vr}{{}{46}} \citation{julia-ref} @@ -240,6 +241,7 @@ \@writefile{lof}{\contentsline {figure}{\numberline {3.34}{\ignorespaces Linux terminal to enter Pkg REPL in Julia\relax }}{55}\protected@file@percent } \newlabel{julia-pkg}{{3.34}{55}} \@writefile{toc}{\contentsline {subsection}{\numberline {3.5.3}Julia Arduino toolbox}{55}\protected@file@percent } +\newlabel{sec:julia-toolbox}{{3.5.3}{55}} \newlabel{13@xvr}{{}{55}} \newlabel{13@vr}{{}{55}} \citation{om-ref} @@ -280,24 +282,24 @@ \@writefile{lof}{\contentsline {figure}{\numberline {3.43}{\ignorespaces Output window of OMEdit\relax }}{64}\protected@file@percent } \newlabel{om-sim-success}{{3.43}{64}} \@writefile{toc}{\contentsline {subsection}{\numberline {3.6.4}OpenModelica Arduino toolbox}{64}\protected@file@percent } -\newlabel{load-om-toolbox}{{3.6.4}{64}} +\newlabel{sec:load-om-toolbox}{{3.6.4}{64}} \newlabel{15@xvr}{{}{64}} \newlabel{15@vr}{{}{64}} \newlabel{itm:library}{{4}{65}} -\newlabel{itm:locate}{{6}{65}} -\newlabel{itm:simulate}{{7}{65}} +\newlabel{itm:locate}{{5}{65}} +\newlabel{itm:simulate}{{6}{65}} +\@writefile{toc}{\contentsline {subsection}{\numberline {3.6.5}Firmware}{65}\protected@file@percent } +\newlabel{om-firmware}{{3.6.5}{65}} +\newlabel{sec:test-firmware-OpenModelica}{{3.6.5}{65}} +\@writefile{cod}{\addvspace {10pt}} \@writefile{lof}{\contentsline {figure}{\numberline {3.44}{\ignorespaces Examples provied in OpenModelica-Arduino Toolbox\relax }}{66}\protected@file@percent } \newlabel{om-examples-toolbox}{{3.44}{66}} -\@writefile{toc}{\contentsline {subsection}{\numberline {3.6.5}Firmware}{66}\protected@file@percent } -\newlabel{om-firmware}{{3.6.5}{66}} -\newlabel{sec:test-firmware-OpenModelica}{{3.6.5}{66}} -\@writefile{cod}{\addvspace {10pt}} \@writefile{thm}{\contentsline {OpenModelicamass}{{OpenModelica Code}{3.{1}}{}}{66}\protected@file@percent } \@writefile{OpenModelicad}{\contentsline {section}{\numberline {3.{1}}An OpenModelica code to check whether the firmware is properly installed or not}{66}\protected@file@percent } -\newlabel{16@xvr}{{}{67}} -\newlabel{16@vr}{{}{67}} -\newlabel{OpenModelica:test-firmware}{{3.{1}}{67}} -\@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/tools/openmodelica/test\textunderscore firmware.mo}{67}\protected@file@percent } +\newlabel{16@xvr}{{}{66}} +\newlabel{16@vr}{{}{66}} +\newlabel{OpenModelica:test-firmware}{{3.{1}}{66}} +\@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/tools/openmodelica/windows//test\textunderscore firmware.mo}{66}\protected@file@percent } \@writefile{toc}{\contentsline {chapter}{\numberline {4}Interfacing a Light Emitting Diode}{69}\protected@file@percent } \@writefile{lof}{\addvspace {10\p@ }} \@writefile{lot}{\addvspace {10\p@ }} @@ -308,7 +310,7 @@ \newlabel{fig:ledsym}{{4.1}{69}} \@writefile{lof}{\contentsline {figure}{\numberline {4.2}{\ignorespaces Internal connection diagram for LED on the shield\relax }}{70}\protected@file@percent } \newlabel{fig:ledblock}{{4.2}{70}} -\@writefile{lof}{\contentsline {figure}{\numberline {4.3}{\ignorespaces Connecting Arduino and Shield\relax }}{70}\protected@file@percent } +\@writefile{lof}{\contentsline {figure}{\numberline {4.3}{\ignorespaces Connecting Arduino Uno\ and shield\relax }}{70}\protected@file@percent } \newlabel{fig:uno-shield-connect}{{4.3}{70}} \@writefile{lof}{\contentsline {figure}{\numberline {4.4}{\ignorespaces Interfacing an RGB LED with Arduino Uno using a breadboard\relax }}{71}\protected@file@percent } \newlabel{fig:ard-rgb-bread}{{4.4}{71}} @@ -422,15 +424,25 @@ \@writefile{toc}{\contentsline {section}{\numberline {4.6}Lighting the LED from Python}{82}\protected@file@percent } \@writefile{toc}{\contentsline {subsection}{\numberline {4.6.1}Lighting the LED}{82}\protected@file@percent } \newlabel{sec:light-py}{{4.6.1}{82}} +\citation{pySerial} \@writefile{lot}{\contentsline {table}{\numberline {4.4}{\ignorespaces Parameters to make the green LED blink every second\relax }}{83}\protected@file@percent } \newlabel{tab:led-green-blink}{{4.4}{83}} \newlabel{36@xvr}{{}{83}} \newlabel{36@vr}{{}{83}} +\@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led\textendash blue.py}{83}\protected@file@percent } +\@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led\textendash blue.py}{83}\protected@file@percent } +\@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led\textendash blue.py}{83}\protected@file@percent } +\@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led\textendash blue.py}{84}\protected@file@percent } +\@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led\textendash blue.py}{84}\protected@file@percent } +\@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led\textendash blue.py}{84}\protected@file@percent } +\@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led\textendash blue\textendash delay.py}{84}\protected@file@percent } +\@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led\textendash blue\textendash delay.py}{84}\protected@file@percent } +\@writefile{thm}{\contentsline {egmass}{{Exercise}{4.{4}}{}}{85}\protected@file@percent } \@writefile{toc}{\contentsline {subsection}{\numberline {4.6.2}Python Code}{85}\protected@file@percent } \newlabel{sec:led-python-code}{{4.6.2}{85}} \@writefile{pyd}{\addvspace {10pt}} \@writefile{thm}{\contentsline {pymass}{{Python Code}{4.{1}}{}}{85}\protected@file@percent } -\@writefile{pyd}{\contentsline {section}{\numberline {4.{1}}Turning on the LED through Python}{85}\protected@file@percent } +\@writefile{pyd}{\contentsline {section}{\numberline {4.{1}}Turning on the blue LED through Python}{85}\protected@file@percent } \newlabel{37@xvr}{{}{85}} \newlabel{37@vr}{{}{85}} \newlabel{py:led-blue}{{4.{1}}{85}} @@ -441,21 +453,28 @@ \newlabel{38@vr}{{}{86}} \newlabel{py:led-blue-delay}{{4.{2}}{86}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led\textendash blue\textendash delay.py}{86}\protected@file@percent } -\@writefile{thm}{\contentsline {pymass}{{Python Code}{4.{3}}{}}{87}\protected@file@percent } -\@writefile{pyd}{\contentsline {section}{\numberline {4.{3}}Turning on blue and red LEDs for 5 seconds and then turning them off one by one}{87}\protected@file@percent } -\newlabel{39@xvr}{{}{87}} -\newlabel{39@vr}{{}{87}} -\newlabel{py:led-blue-red}{{4.{3}}{87}} +\@writefile{thm}{\contentsline {pymass}{{Python Code}{4.{3}}{}}{86}\protected@file@percent } +\@writefile{pyd}{\contentsline {section}{\numberline {4.{3}}Turning on blue and red LEDs for 5 seconds and then turning them off one by one}{86}\protected@file@percent } +\newlabel{39@xvr}{{}{86}} +\newlabel{39@vr}{{}{86}} +\newlabel{py:led-blue-red}{{4.{3}}{86}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led\textendash blue\textendash red.py}{87}\protected@file@percent } -\@writefile{thm}{\contentsline {pymass}{{Python Code}{4.{4}}{}}{88}\protected@file@percent } -\@writefile{pyd}{\contentsline {section}{\numberline {4.{4}}Blinking the green LED}{88}\protected@file@percent } -\newlabel{40@xvr}{{}{88}} -\newlabel{40@vr}{{}{88}} -\newlabel{py:led-green-blink}{{4.{4}}{88}} -\@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led\textendash green\textendash blink.py}{88}\protected@file@percent } -\@writefile{toc}{\contentsline {section}{\numberline {4.7}Lighting the LED from Julia}{89}\protected@file@percent } -\@writefile{toc}{\contentsline {subsection}{\numberline {4.7.1}Lighting the LED}{89}\protected@file@percent } -\newlabel{sec:light-julia}{{4.7.1}{89}} +\@writefile{thm}{\contentsline {pymass}{{Python Code}{4.{4}}{}}{87}\protected@file@percent } +\@writefile{pyd}{\contentsline {section}{\numberline {4.{4}}Blinking the green LED}{87}\protected@file@percent } +\newlabel{40@xvr}{{}{87}} +\newlabel{40@vr}{{}{87}} +\newlabel{py:led-green-blink}{{4.{4}}{87}} +\@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led\textendash green\textendash blink.py}{87}\protected@file@percent } +\citation{julia-serial-ports} +\@writefile{toc}{\contentsline {section}{\numberline {4.7}Lighting the LED from Julia}{88}\protected@file@percent } +\@writefile{toc}{\contentsline {subsection}{\numberline {4.7.1}Lighting the LED}{88}\protected@file@percent } +\newlabel{sec:light-julia}{{4.7.1}{88}} +\@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led\textendash blue.jl}{89}\protected@file@percent } +\@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led\textendash blue.jl}{89}\protected@file@percent } +\@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led\textendash blue.jl}{89}\protected@file@percent } +\@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led\textendash blue.jl}{89}\protected@file@percent } +\@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led\textendash blue\textendash delay.jl}{89}\protected@file@percent } +\@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led\textendash blue\textendash delay.jl}{89}\protected@file@percent } \@writefile{toc}{\contentsline {subsection}{\numberline {4.7.2}Julia Code}{90}\protected@file@percent } \newlabel{sec:led-julia-code}{{4.7.2}{90}} \@writefile{juliad}{\addvspace {10pt}} @@ -465,52 +484,50 @@ \newlabel{41@vr}{{}{90}} \newlabel{julia:led-blue}{{4.{1}}{90}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led\textendash blue.jl}{90}\protected@file@percent } -\@writefile{thm}{\contentsline {juliamass}{{Julia Code}{4.{2}}{}}{91}\protected@file@percent } -\@writefile{juliad}{\contentsline {section}{\numberline {4.{2}}Turning on the blue LED and turning it off after two seconds}{91}\protected@file@percent } -\newlabel{42@xvr}{{}{91}} -\newlabel{42@vr}{{}{91}} -\newlabel{julia:led-blue-delay}{{4.{2}}{91}} -\@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led\textendash blue\textendash delay.jl}{91}\protected@file@percent } -\@writefile{thm}{\contentsline {juliamass}{{Julia Code}{4.{3}}{}}{91}\protected@file@percent } -\@writefile{juliad}{\contentsline {section}{\numberline {4.{3}}Turning on blue and red LEDs for 5 seconds and then turning them off one by one}{91}\protected@file@percent } -\newlabel{43@xvr}{{}{91}} -\newlabel{43@vr}{{}{91}} -\newlabel{juila:led-bmoe-red}{{4.{3}}{91}} -\@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led\textendash blue\textendash red.jl}{91}\protected@file@percent } -\@writefile{thm}{\contentsline {juliamass}{{Julia Code}{4.{4}}{}}{91}\protected@file@percent } -\@writefile{juliad}{\contentsline {section}{\numberline {4.{4}}Blinking the green LED}{91}\protected@file@percent } -\newlabel{44@xvr}{{}{91}} -\newlabel{44@vr}{{}{91}} -\newlabel{julia:lemogreen-blink}{{4.{4}}{91}} +\@writefile{thm}{\contentsline {juliamass}{{Julia Code}{4.{2}}{}}{90}\protected@file@percent } +\@writefile{juliad}{\contentsline {section}{\numberline {4.{2}}Turning on the blue LED and turning it off after two seconds}{90}\protected@file@percent } +\newlabel{42@xvr}{{}{90}} +\newlabel{42@vr}{{}{90}} +\newlabel{julia:led-blue-delay}{{4.{2}}{90}} +\@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led\textendash blue\textendash delay.jl}{90}\protected@file@percent } +\@writefile{thm}{\contentsline {juliamass}{{Julia Code}{4.{3}}{}}{90}\protected@file@percent } +\@writefile{juliad}{\contentsline {section}{\numberline {4.{3}}Turning on blue and red LEDs for 5 seconds and then turning them off one by one}{90}\protected@file@percent } +\newlabel{43@xvr}{{}{90}} +\newlabel{43@vr}{{}{90}} +\newlabel{julia:led-blue-red}{{4.{3}}{90}} +\@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led\textendash blue\textendash red.jl}{90}\protected@file@percent } +\@writefile{thm}{\contentsline {juliamass}{{Julia Code}{4.{4}}{}}{90}\protected@file@percent } +\@writefile{juliad}{\contentsline {section}{\numberline {4.{4}}Blinking the green LED}{90}\protected@file@percent } +\newlabel{44@xvr}{{}{90}} +\newlabel{44@vr}{{}{90}} +\newlabel{julia:led-green-blink}{{4.{4}}{90}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led\textendash green\textendash blink.jl}{91}\protected@file@percent } -\@writefile{toc}{\contentsline {section}{\numberline {4.8}Lighting the LED from OpenModelica}{92}\protected@file@percent } -\@writefile{toc}{\contentsline {subsection}{\numberline {4.8.1}Lighting the LED}{92}\protected@file@percent } -\newlabel{sec:light-OpenModelica}{{4.8.1}{92}} +\@writefile{toc}{\contentsline {section}{\numberline {4.8}Lighting the LED from OpenModelica}{91}\protected@file@percent } +\@writefile{toc}{\contentsline {subsection}{\numberline {4.8.1}Lighting the LED}{91}\protected@file@percent } +\newlabel{sec:light-OpenModelica}{{4.8.1}{91}} +\@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led\textendash blue.mo}{91}\protected@file@percent } +\@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led\textendash blue.mo}{91}\protected@file@percent } +\@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led\textendash blue.mo}{92}\protected@file@percent } +\@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led\textendash blue.mo}{92}\protected@file@percent } +\@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led\textendash blue\textendash delay.mo}{92}\protected@file@percent } +\@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led\textendash blue\textendash delay.mo}{92}\protected@file@percent } \@writefile{toc}{\contentsline {subsection}{\numberline {4.8.2}OpenModelica Code}{93}\protected@file@percent } \newlabel{sec:led-OpenModelica-code}{{4.8.2}{93}} \@writefile{OpenModelicad}{\addvspace {10pt}} \@writefile{thm}{\contentsline {OpenModelicamass}{{OpenModelica Code}{4.{1}}{}}{93}\protected@file@percent } \@writefile{OpenModelicad}{\contentsline {section}{\numberline {4.{1}}Turning on the LED}{93}\protected@file@percent } -\newlabel{45@xvr}{{}{93}} -\newlabel{45@vr}{{}{93}} \newlabel{OpenModelica:led-blue}{{4.{1}}{93}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led\textendash blue.mo}{93}\protected@file@percent } \@writefile{thm}{\contentsline {OpenModelicamass}{{OpenModelica Code}{4.{2}}{}}{93}\protected@file@percent } \@writefile{OpenModelicad}{\contentsline {section}{\numberline {4.{2}}Turning on the blue LED and turning it off after two seconds}{93}\protected@file@percent } -\newlabel{46@xvr}{{}{93}} -\newlabel{46@vr}{{}{93}} \newlabel{OpenModelica:led-blue-delay}{{4.{2}}{93}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led\textendash blue\textendash delay.mo}{93}\protected@file@percent } \@writefile{thm}{\contentsline {OpenModelicamass}{{OpenModelica Code}{4.{3}}{}}{94}\protected@file@percent } \@writefile{OpenModelicad}{\contentsline {section}{\numberline {4.{3}}Turning on blue and red LEDs for 5 seconds and then turning them off one by one}{94}\protected@file@percent } -\newlabel{47@xvr}{{}{94}} -\newlabel{47@vr}{{}{94}} \newlabel{OpenModelica:led-blue-red}{{4.{3}}{94}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led\textendash blue\textendash red.mo}{94}\protected@file@percent } \@writefile{thm}{\contentsline {OpenModelicamass}{{OpenModelica Code}{4.{4}}{}}{95}\protected@file@percent } \@writefile{OpenModelicad}{\contentsline {section}{\numberline {4.{4}}Blinking the green LED}{95}\protected@file@percent } -\newlabel{48@xvr}{{}{95}} -\newlabel{48@vr}{{}{95}} \newlabel{OpenModelica:led-green-blink}{{4.{4}}{95}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led\textendash green\textendash blink.mo}{95}\protected@file@percent } \@writefile{toc}{\contentsline {chapter}{\numberline {5}Interfacing a Pushbutton}{97}\protected@file@percent } @@ -535,14 +552,14 @@ \@writefile{ard}{\addvspace {10pt}} \@writefile{thm}{\contentsline {ardmass}{{Arduino Code}{5.{1}}{}}{101}\protected@file@percent } \@writefile{ard}{\contentsline {section}{\numberline {5.{1}}Read the status of the pushbutton and displaying on the serial monitor}{101}\protected@file@percent } -\newlabel{49@xvr}{{}{101}} -\newlabel{49@vr}{{}{101}} +\newlabel{45@xvr}{{}{101}} +\newlabel{45@vr}{{}{101}} \newlabel{ard:push-100}{{5.{1}}{101}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/push/arduino/push\textendash button\textendash status/push\textendash button\textendash status.ino}{101}\protected@file@percent } \@writefile{thm}{\contentsline {ardmass}{{Arduino Code}{5.{2}}{}}{101}\protected@file@percent } \@writefile{ard}{\contentsline {section}{\numberline {5.{2}}Turning the LED on or off depending on the pushbutton}{101}\protected@file@percent } -\newlabel{50@xvr}{{}{101}} -\newlabel{50@vr}{{}{101}} +\newlabel{46@xvr}{{}{101}} +\newlabel{46@vr}{{}{101}} \newlabel{ard:push-200}{{5.{2}}{101}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/push/arduino/led\textendash push\textendash button/led\textendash push\textendash button.ino}{101}\protected@file@percent } \@writefile{toc}{\contentsline {section}{\numberline {5.4}Reading the Pushbutton Status from Scilab}{102}\protected@file@percent } @@ -555,34 +572,34 @@ \@writefile{cod}{\addvspace {10pt}} \@writefile{thm}{\contentsline {codemass}{{Scilab Code}{5.{1}}{}}{103}\protected@file@percent } \@writefile{cod}{\contentsline {section}{\numberline {5.{1}}Read the status of the pushbutton and displaying on the serial monitor}{103}\protected@file@percent } -\newlabel{51@xvr}{{}{103}} -\newlabel{51@vr}{{}{103}} +\newlabel{47@xvr}{{}{103}} +\newlabel{47@vr}{{}{103}} \newlabel{sci:push-100}{{5.{1}}{103}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/push/scilab/push\textendash button\textendash status.sce}{103}\protected@file@percent } \@writefile{thm}{\contentsline {codemass}{{Scilab Code}{5.{2}}{}}{103}\protected@file@percent } \@writefile{cod}{\contentsline {section}{\numberline {5.{2}}Turning the LED on or off depending on the pushbutton}{103}\protected@file@percent } -\newlabel{52@xvr}{{}{103}} -\newlabel{52@vr}{{}{103}} +\newlabel{48@xvr}{{}{103}} +\newlabel{48@vr}{{}{103}} \newlabel{sci:push-200}{{5.{2}}{103}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/push/scilab/led\textendash push\textendash button.sce}{103}\protected@file@percent } \@writefile{toc}{\contentsline {section}{\numberline {5.5}Accessing the Pushbutton from Xcos}{103}\protected@file@percent } \newlabel{sec:push-xcos}{{5.5}{103}} \@writefile{lof}{\contentsline {figure}{\numberline {5.4}{\ignorespaces Printing the push button status on the display block}}{104}\protected@file@percent } -\newlabel{54@xvr}{{}{104}} -\newlabel{54@vr}{{}{104}} +\newlabel{50@xvr}{{}{104}} +\newlabel{50@vr}{{}{104}} \newlabel{fig:push-button-status}{{5.4}{104}} \@writefile{lot}{\contentsline {table}{\numberline {5.1}{\ignorespaces Parameters to print the push button status on the display block\relax }}{104}\protected@file@percent } \newlabel{tab:push-button-status}{{5.1}{104}} -\newlabel{55@xvr}{{}{104}} -\newlabel{55@vr}{{}{104}} +\newlabel{51@xvr}{{}{104}} +\newlabel{51@vr}{{}{104}} \@writefile{lof}{\contentsline {figure}{\numberline {5.5}{\ignorespaces Turning the LED on or off, depending on the pushbutton}}{105}\protected@file@percent } -\newlabel{57@xvr}{{}{105}} -\newlabel{57@vr}{{}{105}} +\newlabel{53@xvr}{{}{105}} +\newlabel{53@vr}{{}{105}} \newlabel{fig:led-push-button}{{5.5}{105}} \@writefile{lot}{\contentsline {table}{\numberline {5.2}{\ignorespaces Xcos parameters to turn the LED on through the pushbutton\relax }}{105}\protected@file@percent } \newlabel{tab:led-push-button}{{5.2}{105}} -\newlabel{58@xvr}{{}{105}} -\newlabel{58@vr}{{}{105}} +\newlabel{54@xvr}{{}{105}} +\newlabel{54@vr}{{}{105}} \@writefile{thm}{\contentsline {egmass}{{Exercise}{5.{1}}{}}{105}\protected@file@percent } \@writefile{toc}{\contentsline {section}{\numberline {5.6}Reading the Pushbutton Status from Python}{106}\protected@file@percent } \@writefile{toc}{\contentsline {subsection}{\numberline {5.6.1}Reading the Pushbutton Status}{106}\protected@file@percent } @@ -594,14 +611,14 @@ \@writefile{pyd}{\addvspace {10pt}} \@writefile{thm}{\contentsline {pymass}{{Python Code}{5.{1}}{}}{107}\protected@file@percent } \@writefile{pyd}{\contentsline {section}{\numberline {5.{1}}Read the status of the pushbutton and displaying on the serial monitor}{107}\protected@file@percent } -\newlabel{59@xvr}{{}{107}} -\newlabel{59@vr}{{}{107}} +\newlabel{55@xvr}{{}{107}} +\newlabel{55@vr}{{}{107}} \newlabel{py:push-100}{{5.{1}}{107}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/push/python/push\textendash button\textendash status.py}{107}\protected@file@percent } \@writefile{thm}{\contentsline {pymass}{{Python Code}{5.{2}}{}}{107}\protected@file@percent } \@writefile{pyd}{\contentsline {section}{\numberline {5.{2}}Turning the LED on or off depending on the pushbutton}{107}\protected@file@percent } -\newlabel{60@xvr}{{}{107}} -\newlabel{60@vr}{{}{107}} +\newlabel{56@xvr}{{}{107}} +\newlabel{56@vr}{{}{107}} \newlabel{py:push-200}{{5.{2}}{107}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/push/python/led\textendash push\textendash button.py}{108}\protected@file@percent } \@writefile{toc}{\contentsline {section}{\numberline {5.7}Reading the Pushbutton Status from Julia}{109}\protected@file@percent } @@ -613,14 +630,14 @@ \@writefile{juliad}{\addvspace {10pt}} \@writefile{thm}{\contentsline {juliamass}{{Julia Code}{5.{1}}{}}{109}\protected@file@percent } \@writefile{juliad}{\contentsline {section}{\numberline {5.{1}}Read the status of the pushbutton and displaying on the serial monitor}{109}\protected@file@percent } -\newlabel{61@xvr}{{}{109}} -\newlabel{61@vr}{{}{109}} +\newlabel{57@xvr}{{}{109}} +\newlabel{57@vr}{{}{109}} \newlabel{julia:push-100}{{5.{1}}{109}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/push/julia/push\textendash button\textendash status.jl}{109}\protected@file@percent } \@writefile{thm}{\contentsline {juliamass}{{Julia Code}{5.{2}}{}}{110}\protected@file@percent } \@writefile{juliad}{\contentsline {section}{\numberline {5.{2}}Turning the LED on or off depending on the pushbutton}{110}\protected@file@percent } -\newlabel{62@xvr}{{}{110}} -\newlabel{62@vr}{{}{110}} +\newlabel{58@xvr}{{}{110}} +\newlabel{58@vr}{{}{110}} \newlabel{julia:push-200}{{5.{2}}{110}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/push/julia/led\textendash push\textendash button.jl}{110}\protected@file@percent } \@writefile{toc}{\contentsline {section}{\numberline {5.8}Reading the Pushbutton Status from OpenModelica}{110}\protected@file@percent } @@ -631,14 +648,14 @@ \@writefile{OpenModelicad}{\addvspace {10pt}} \@writefile{thm}{\contentsline {OpenModelicamass}{{OpenModelica Code}{5.{1}}{}}{110}\protected@file@percent } \@writefile{OpenModelicad}{\contentsline {section}{\numberline {5.{1}}Read the status of the pushbutton and displaying on the serial monitor}{110}\protected@file@percent } -\newlabel{63@xvr}{{}{110}} -\newlabel{63@vr}{{}{110}} +\newlabel{59@xvr}{{}{110}} +\newlabel{59@vr}{{}{110}} \newlabel{OpenModelica:push-100}{{5.{1}}{110}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/push/OpenModelica/push\textendash button\textendash status.mo}{111}\protected@file@percent } \@writefile{thm}{\contentsline {OpenModelicamass}{{OpenModelica Code}{5.{2}}{}}{111}\protected@file@percent } \@writefile{OpenModelicad}{\contentsline {section}{\numberline {5.{2}}Turning the LED on or off depending on the pushbutton}{111}\protected@file@percent } -\newlabel{64@xvr}{{}{111}} -\newlabel{64@vr}{{}{111}} +\newlabel{60@xvr}{{}{111}} +\newlabel{60@vr}{{}{111}} \newlabel{OpenModelica:push-200}{{5.{2}}{111}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/push/OpenModelica/led\textendash push\textendash button.mo}{111}\protected@file@percent } \@writefile{toc}{\contentsline {chapter}{\numberline {6}Interfacing a Light Dependent Resistor}{113}\protected@file@percent } @@ -671,14 +688,14 @@ \@writefile{ard}{\addvspace {10pt}} \@writefile{thm}{\contentsline {ardmass}{{Arduino Code}{6.{1}}{}}{117}\protected@file@percent } \@writefile{ard}{\contentsline {section}{\numberline {6.{1}}Read and display the LDR values}{117}\protected@file@percent } -\newlabel{65@xvr}{{}{117}} -\newlabel{65@vr}{{}{117}} +\newlabel{61@xvr}{{}{117}} +\newlabel{61@vr}{{}{117}} \newlabel{ard:ldr-read}{{6.{1}}{117}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/ldr/arduino/ldr\textendash read/ldr\textendash read.ino}{117}\protected@file@percent } \@writefile{thm}{\contentsline {ardmass}{{Arduino Code}{6.{2}}{}}{118}\protected@file@percent } \@writefile{ard}{\contentsline {section}{\numberline {6.{2}}Turning the blue LED on and off}{118}\protected@file@percent } -\newlabel{66@xvr}{{}{118}} -\newlabel{66@vr}{{}{118}} +\newlabel{62@xvr}{{}{118}} +\newlabel{62@vr}{{}{118}} \newlabel{ard:ldr-led}{{6.{2}}{118}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/ldr/arduino/ldr\textendash led/ldr\textendash led.ino}{118}\protected@file@percent } \@writefile{toc}{\contentsline {section}{\numberline {6.4}Interfacing the LDR through Scilab}{118}\protected@file@percent } @@ -689,49 +706,49 @@ \@writefile{cod}{\addvspace {10pt}} \@writefile{thm}{\contentsline {codemass}{{Scilab Code}{6.{1}}{}}{119}\protected@file@percent } \@writefile{cod}{\contentsline {section}{\numberline {6.{1}}Read and display the LDR values}{119}\protected@file@percent } -\newlabel{67@xvr}{{}{119}} -\newlabel{67@vr}{{}{119}} +\newlabel{63@xvr}{{}{119}} +\newlabel{63@vr}{{}{119}} \newlabel{sci:ldr-read}{{6.{1}}{119}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/ldr/scilab/ldr\textendash read.sce}{119}\protected@file@percent } \@writefile{thm}{\contentsline {codemass}{{Scilab Code}{6.{2}}{}}{120}\protected@file@percent } \@writefile{cod}{\contentsline {section}{\numberline {6.{2}}Turning the blue LED on and off}{120}\protected@file@percent } -\newlabel{68@xvr}{{}{120}} -\newlabel{68@vr}{{}{120}} +\newlabel{64@xvr}{{}{120}} +\newlabel{64@vr}{{}{120}} \newlabel{sci:ldr-led}{{6.{2}}{120}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/ldr/scilab/ldr\textendash led.sce}{120}\protected@file@percent } \@writefile{toc}{\contentsline {section}{\numberline {6.5}Interfacing the LDR through Xcos}{120}\protected@file@percent } \@writefile{lof}{\contentsline {figure}{\numberline {6.5}{\ignorespaces Xcos diagram to read LDR values}}{121}\protected@file@percent } -\newlabel{70@xvr}{{}{121}} -\newlabel{70@vr}{{}{121}} +\newlabel{66@xvr}{{}{121}} +\newlabel{66@vr}{{}{121}} \newlabel{fig:ldr-read}{{6.5}{121}} \@writefile{lot}{\contentsline {table}{\numberline {6.1}{\ignorespaces Xcos parameters to read LDR\relax }}{121}\protected@file@percent } \newlabel{tab:ldr-read}{{6.1}{121}} -\newlabel{71@xvr}{{}{121}} -\newlabel{71@vr}{{}{121}} +\newlabel{67@xvr}{{}{121}} +\newlabel{67@vr}{{}{121}} \@writefile{lof}{\contentsline {figure}{\numberline {6.6}{\ignorespaces Xcos diagram to read the value of the LDR, which is used to turn the blue LED on or off}}{122}\protected@file@percent } -\newlabel{73@xvr}{{}{122}} -\newlabel{73@vr}{{}{122}} +\newlabel{69@xvr}{{}{122}} +\newlabel{69@vr}{{}{122}} \newlabel{fig:ldr-led}{{6.6}{122}} \@writefile{toc}{\contentsline {section}{\numberline {6.6}Interfacing the LDR through Python}{122}\protected@file@percent } \@writefile{toc}{\contentsline {subsection}{\numberline {6.6.1}Interfacing the LDR}{122}\protected@file@percent } \@writefile{lot}{\contentsline {table}{\numberline {6.2}{\ignorespaces Xcos parameters to read LDR and regulate blue LED\relax }}{123}\protected@file@percent } \newlabel{tab:ldr-led}{{6.2}{123}} -\newlabel{74@xvr}{{}{123}} -\newlabel{74@vr}{{}{123}} +\newlabel{70@xvr}{{}{123}} +\newlabel{70@vr}{{}{123}} \@writefile{thm}{\contentsline {egmass}{{Exercise}{6.{3}}{}}{123}\protected@file@percent } \@writefile{toc}{\contentsline {subsection}{\numberline {6.6.2}Python Code}{124}\protected@file@percent } \newlabel{sec:ldr-python-code}{{6.6.2}{124}} \@writefile{pyd}{\addvspace {10pt}} \@writefile{thm}{\contentsline {pymass}{{Python Code}{6.{1}}{}}{124}\protected@file@percent } \@writefile{pyd}{\contentsline {section}{\numberline {6.{1}}Read and display the LDR values}{124}\protected@file@percent } -\newlabel{75@xvr}{{}{124}} -\newlabel{75@vr}{{}{124}} +\newlabel{71@xvr}{{}{124}} +\newlabel{71@vr}{{}{124}} \newlabel{py:ldr-read}{{6.{1}}{124}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/ldr/python/ldr\textendash read.py}{124}\protected@file@percent } \@writefile{thm}{\contentsline {pymass}{{Python Code}{6.{2}}{}}{125}\protected@file@percent } \@writefile{pyd}{\contentsline {section}{\numberline {6.{2}}Turning the blue LED on and off}{125}\protected@file@percent } -\newlabel{76@xvr}{{}{125}} -\newlabel{76@vr}{{}{125}} +\newlabel{72@xvr}{{}{125}} +\newlabel{72@vr}{{}{125}} \newlabel{py:ldr-led}{{6.{2}}{125}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/ldr/python/ldr\textendash led.py}{125}\protected@file@percent } \@writefile{toc}{\contentsline {section}{\numberline {6.7}Interfacing the LDR through Julia}{126}\protected@file@percent } @@ -743,14 +760,14 @@ \@writefile{juliad}{\addvspace {10pt}} \@writefile{thm}{\contentsline {juliamass}{{Julia Code}{6.{1}}{}}{127}\protected@file@percent } \@writefile{juliad}{\contentsline {section}{\numberline {6.{1}}Read and display the LDR values}{127}\protected@file@percent } -\newlabel{77@xvr}{{}{127}} -\newlabel{77@vr}{{}{127}} +\newlabel{73@xvr}{{}{127}} +\newlabel{73@vr}{{}{127}} \newlabel{julia:ldr-read}{{6.{1}}{127}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/ldr/julia/ldr\textendash read.jl}{127}\protected@file@percent } \@writefile{thm}{\contentsline {juliamass}{{Julia Code}{6.{2}}{}}{127}\protected@file@percent } \@writefile{juliad}{\contentsline {section}{\numberline {6.{2}}Turning the blue LED on and off}{127}\protected@file@percent } -\newlabel{78@xvr}{{}{127}} -\newlabel{78@vr}{{}{127}} +\newlabel{74@xvr}{{}{127}} +\newlabel{74@vr}{{}{127}} \newlabel{julia:ldr-led}{{6.{2}}{127}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/ldr/julia/ldr\textendash led.jl}{127}\protected@file@percent } \@writefile{toc}{\contentsline {section}{\numberline {6.8}Interfacing the LDR through OpenModelica}{127}\protected@file@percent } @@ -761,14 +778,14 @@ \@writefile{OpenModelicad}{\addvspace {10pt}} \@writefile{thm}{\contentsline {OpenModelicamass}{{OpenModelica Code}{6.{1}}{}}{128}\protected@file@percent } \@writefile{OpenModelicad}{\contentsline {section}{\numberline {6.{1}}Read and display the LDR values}{128}\protected@file@percent } -\newlabel{79@xvr}{{}{128}} -\newlabel{79@vr}{{}{128}} +\newlabel{75@xvr}{{}{128}} +\newlabel{75@vr}{{}{128}} \newlabel{OpenModelica:ldr-read}{{6.{1}}{128}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/ldr/OpenModelica/ldr\textendash read.mo}{128}\protected@file@percent } \@writefile{thm}{\contentsline {OpenModelicamass}{{OpenModelica Code}{6.{2}}{}}{129}\protected@file@percent } \@writefile{OpenModelicad}{\contentsline {section}{\numberline {6.{2}}Turning the blue LED on and off}{129}\protected@file@percent } -\newlabel{80@xvr}{{}{129}} -\newlabel{80@vr}{{}{129}} +\newlabel{76@xvr}{{}{129}} +\newlabel{76@vr}{{}{129}} \newlabel{OpenModelica:ldr-led}{{6.{2}}{129}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/ldr/OpenModelica/ldr\textendash led.mo}{129}\protected@file@percent } \@writefile{toc}{\contentsline {chapter}{\numberline {7}Interfacing a Potentiometer}{131}\protected@file@percent } @@ -776,8 +793,8 @@ \@writefile{lot}{\addvspace {10\p@ }} \newlabel{potmeter}{{7}{131}} \@writefile{toc}{\contentsline {section}{\numberline {7.1}Preliminaries}{131}\protected@file@percent } -\newlabel{81@xvr}{{}{131}} -\newlabel{81@vr}{{}{131}} +\newlabel{77@xvr}{{}{131}} +\newlabel{77@vr}{{}{131}} \newlabel{fig:pot}{{7.1a}{132}} \newlabel{sub@fig:pot}{{(a)}{a}} \newlabel{fig:potsch}{{7.1b}{132}} @@ -798,8 +815,8 @@ \@writefile{ard}{\addvspace {10pt}} \@writefile{thm}{\contentsline {ardmass}{{Arduino Code}{7.{1}}{}}{134}\protected@file@percent } \@writefile{ard}{\contentsline {section}{\numberline {7.{1}}Turning on LEDs depending on the potentiometer threshold}{134}\protected@file@percent } -\newlabel{82@xvr}{{}{134}} -\newlabel{82@vr}{{}{134}} +\newlabel{78@xvr}{{}{134}} +\newlabel{78@vr}{{}{134}} \newlabel{ard:pot-100}{{7.{1}}{134}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/pot/arduino/pot\textendash threshold/pot\textendash threshold.ino}{134}\protected@file@percent } \@writefile{toc}{\contentsline {section}{\numberline {7.4}Reading the potentiometer from Scilab}{135}\protected@file@percent } @@ -811,22 +828,22 @@ \@writefile{cod}{\addvspace {10pt}} \@writefile{thm}{\contentsline {codemass}{{Scilab Code}{7.{1}}{}}{136}\protected@file@percent } \@writefile{cod}{\contentsline {section}{\numberline {7.{1}}Turning on LEDs depending on the potentiometer threshold}{136}\protected@file@percent } -\newlabel{83@xvr}{{}{136}} -\newlabel{83@vr}{{}{136}} +\newlabel{79@xvr}{{}{136}} +\newlabel{79@vr}{{}{136}} \newlabel{sci:pot-100}{{7.{1}}{136}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/pot/scilab/pot\textendash threshold.sce}{136}\protected@file@percent } \@writefile{toc}{\contentsline {section}{\numberline {7.5}Reading the potentiometer from Xcos}{136}\protected@file@percent } \@writefile{lof}{\contentsline {figure}{\numberline {7.3}{\ignorespaces Turning LEDs on through Xcos depending on the potentiometer threshold}}{137}\protected@file@percent } -\newlabel{85@xvr}{{}{137}} -\newlabel{85@vr}{{}{137}} +\newlabel{81@xvr}{{}{137}} +\newlabel{81@vr}{{}{137}} \newlabel{fig:pot-threshold}{{7.3}{137}} \@writefile{toc}{\contentsline {paragraph}{Exercise:}{137}\protected@file@percent } \@writefile{toc}{\contentsline {section}{\numberline {7.6}Reading the potentiometer from Python}{137}\protected@file@percent } \@writefile{toc}{\contentsline {subsection}{\numberline {7.6.1}Reading the potentiometer}{137}\protected@file@percent } \@writefile{lot}{\contentsline {table}{\numberline {7.1}{\ignorespaces Xcos parameters to turn on different LEDs depending on the potentiometer value\relax }}{138}\protected@file@percent } \newlabel{tab:pot-threshold}{{7.1}{138}} -\newlabel{86@xvr}{{}{138}} -\newlabel{86@vr}{{}{138}} +\newlabel{82@xvr}{{}{138}} +\newlabel{82@vr}{{}{138}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/pot/python/pot\textendash threshold.py}{138}\protected@file@percent } \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/pot/python/pot\textendash threshold.py}{139}\protected@file@percent } \@writefile{toc}{\contentsline {subsection}{\numberline {7.6.2}Python Code}{139}\protected@file@percent } @@ -834,8 +851,8 @@ \@writefile{pyd}{\addvspace {10pt}} \@writefile{thm}{\contentsline {pymass}{{Python Code}{7.{1}}{}}{139}\protected@file@percent } \@writefile{pyd}{\contentsline {section}{\numberline {7.{1}}Turning on LEDs depending on the potentiometer threshold}{139}\protected@file@percent } -\newlabel{87@xvr}{{}{139}} -\newlabel{87@vr}{{}{139}} +\newlabel{83@xvr}{{}{139}} +\newlabel{83@vr}{{}{139}} \newlabel{py:pot-100}{{7.{1}}{139}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/pot/python/pot\textendash threshold.py}{139}\protected@file@percent } \@writefile{toc}{\contentsline {section}{\numberline {7.7}Reading the potentiometer from Julia}{140}\protected@file@percent } @@ -847,8 +864,8 @@ \@writefile{juliad}{\addvspace {10pt}} \@writefile{thm}{\contentsline {juliamass}{{Julia Code}{7.{1}}{}}{141}\protected@file@percent } \@writefile{juliad}{\contentsline {section}{\numberline {7.{1}}Turning on LEDs depending on the potentiometer threshold}{141}\protected@file@percent } -\newlabel{88@xvr}{{}{141}} -\newlabel{88@vr}{{}{141}} +\newlabel{84@xvr}{{}{141}} +\newlabel{84@vr}{{}{141}} \newlabel{julia:pot-100}{{7.{1}}{141}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/pot/julia/pot\textendash threshold.jl}{141}\protected@file@percent } \@writefile{toc}{\contentsline {section}{\numberline {7.8}Reading the potentiometer from OpenModelica}{141}\protected@file@percent } @@ -860,8 +877,8 @@ \@writefile{OpenModelicad}{\addvspace {10pt}} \@writefile{thm}{\contentsline {OpenModelicamass}{{OpenModelica Code}{7.{1}}{}}{142}\protected@file@percent } \@writefile{OpenModelicad}{\contentsline {section}{\numberline {7.{1}}Turning on LEDs depending on the potentiometer threshold}{142}\protected@file@percent } -\newlabel{89@xvr}{{}{142}} -\newlabel{89@vr}{{}{142}} +\newlabel{85@xvr}{{}{142}} +\newlabel{85@vr}{{}{142}} \newlabel{OpenModelica:pot-100}{{7.{1}}{142}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/pot/OpenModelica/pot\textendash threshold.mo}{142}\protected@file@percent } \citation{therm-wiki} @@ -901,14 +918,14 @@ \@writefile{ard}{\addvspace {10pt}} \@writefile{thm}{\contentsline {ardmass}{{Arduino Code}{8.{1}}{}}{149}\protected@file@percent } \@writefile{ard}{\contentsline {section}{\numberline {8.{1}}Read and display the thermistor values}{149}\protected@file@percent } -\newlabel{90@xvr}{{}{149}} -\newlabel{90@vr}{{}{149}} +\newlabel{86@xvr}{{}{149}} +\newlabel{86@vr}{{}{149}} \newlabel{ard:therm-read}{{8.{1}}{149}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/thermistor/arduino/therm\textendash read/therm\textendash read.ino}{149}\protected@file@percent } \@writefile{thm}{\contentsline {ardmass}{{Arduino Code}{8.{2}}{}}{150}\protected@file@percent } \@writefile{ard}{\contentsline {section}{\numberline {8.{2}}Turning the buzzer on and off using thermistor values}{150}\protected@file@percent } -\newlabel{91@xvr}{{}{150}} -\newlabel{91@vr}{{}{150}} +\newlabel{87@xvr}{{}{150}} +\newlabel{87@vr}{{}{150}} \newlabel{ard:therm-buzzer}{{8.{2}}{150}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/thermistor/arduino/therm\textendash buzzer/therm\textendash buzzer.ino}{150}\protected@file@percent } \@writefile{toc}{\contentsline {section}{\numberline {8.4}Interfacing the Thermistor from Scilab}{150}\protected@file@percent } @@ -921,41 +938,41 @@ \@writefile{cod}{\addvspace {10pt}} \@writefile{thm}{\contentsline {codemass}{{Scilab Code}{8.{1}}{}}{152}\protected@file@percent } \@writefile{cod}{\contentsline {section}{\numberline {8.{1}}Read and display the thermistor values}{152}\protected@file@percent } -\newlabel{92@xvr}{{}{152}} -\newlabel{92@vr}{{}{152}} +\newlabel{88@xvr}{{}{152}} +\newlabel{88@vr}{{}{152}} \newlabel{sci:therm-read}{{8.{1}}{152}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/thermistor/scilab/therm\textendash read.sce}{152}\protected@file@percent } \@writefile{thm}{\contentsline {codemass}{{Scilab Code}{8.{2}}{}}{152}\protected@file@percent } \@writefile{cod}{\contentsline {section}{\numberline {8.{2}}Turning the buzzer on and off using thermistor values}{152}\protected@file@percent } -\newlabel{93@xvr}{{}{152}} -\newlabel{93@vr}{{}{152}} +\newlabel{89@xvr}{{}{152}} +\newlabel{89@vr}{{}{152}} \newlabel{sci:therm-buzzer}{{8.{2}}{152}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/thermistor/scilab/therm\textendash buzzer.sce}{152}\protected@file@percent } \@writefile{lof}{\contentsline {figure}{\numberline {8.5}{\ignorespaces Xcos diagram to read thermistor values}}{153}\protected@file@percent } -\newlabel{95@xvr}{{}{153}} -\newlabel{95@vr}{{}{153}} +\newlabel{91@xvr}{{}{153}} +\newlabel{91@vr}{{}{153}} \newlabel{fig:therm-read}{{8.5}{153}} \@writefile{toc}{\contentsline {section}{\numberline {8.5}Interfacing the Thermistor from Xcos}{153}\protected@file@percent } \@writefile{lot}{\contentsline {table}{\numberline {8.1}{\ignorespaces Xcos parameters to read thermistor\relax }}{154}\protected@file@percent } \newlabel{tab:therm-read}{{8.1}{154}} -\newlabel{96@xvr}{{}{154}} -\newlabel{96@vr}{{}{154}} +\newlabel{92@xvr}{{}{154}} +\newlabel{92@vr}{{}{154}} \@writefile{lof}{\contentsline {figure}{\numberline {8.6}{\ignorespaces Output of Xcos diagram to read thermistor values}}{154}\protected@file@percent } -\newlabel{98@xvr}{{}{154}} -\newlabel{98@vr}{{}{154}} +\newlabel{94@xvr}{{}{154}} +\newlabel{94@vr}{{}{154}} \newlabel{fig:therm-read-output}{{8.6}{154}} \@writefile{lof}{\contentsline {figure}{\numberline {8.7}{\ignorespaces Xcos diagram to read the value of thermistor, which is used to turn the buzzer on or off}}{155}\protected@file@percent } -\newlabel{100@xvr}{{}{155}} -\newlabel{100@vr}{{}{155}} +\newlabel{96@xvr}{{}{155}} +\newlabel{96@vr}{{}{155}} \newlabel{fig:therm-buzzer}{{8.7}{155}} \@writefile{lof}{\contentsline {figure}{\numberline {8.8}{\ignorespaces Output of Xcos diagram to switch buzzer through thermistor values}}{155}\protected@file@percent } -\newlabel{103@xvr}{{}{155}} -\newlabel{103@vr}{{}{155}} +\newlabel{99@xvr}{{}{155}} +\newlabel{99@vr}{{}{155}} \newlabel{fig:therm-buzzer-output}{{8.8}{155}} \@writefile{lot}{\contentsline {table}{\numberline {8.2}{\ignorespaces Xcos parameters to read thermistor and switch the buzzer\relax }}{156}\protected@file@percent } \newlabel{tab:ldr-led}{{8.2}{156}} -\newlabel{101@xvr}{{}{156}} -\newlabel{101@vr}{{}{156}} +\newlabel{97@xvr}{{}{156}} +\newlabel{97@vr}{{}{156}} \@writefile{toc}{\contentsline {section}{\numberline {8.6}Interfacing the Thermistor from Python}{156}\protected@file@percent } \@writefile{toc}{\contentsline {subsection}{\numberline {8.6.1}Interfacing the Thermistor}{156}\protected@file@percent } \@writefile{toc}{\contentsline {subsection}{\numberline {8.6.2}Python Code}{157}\protected@file@percent } @@ -963,14 +980,14 @@ \@writefile{pyd}{\addvspace {10pt}} \@writefile{thm}{\contentsline {pymass}{{Python Code}{8.{1}}{}}{157}\protected@file@percent } \@writefile{pyd}{\contentsline {section}{\numberline {8.{1}}Read and display the thermistor values}{157}\protected@file@percent } -\newlabel{104@xvr}{{}{157}} -\newlabel{104@vr}{{}{157}} +\newlabel{100@xvr}{{}{157}} +\newlabel{100@vr}{{}{157}} \newlabel{py:therm-read}{{8.{1}}{157}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/thermistor/python/therm\textendash read.py}{157}\protected@file@percent } \@writefile{thm}{\contentsline {pymass}{{Python Code}{8.{2}}{}}{158}\protected@file@percent } \@writefile{pyd}{\contentsline {section}{\numberline {8.{2}}Turning the buzzer on and off using thermistor values}{158}\protected@file@percent } -\newlabel{105@xvr}{{}{158}} -\newlabel{105@vr}{{}{158}} +\newlabel{101@xvr}{{}{158}} +\newlabel{101@vr}{{}{158}} \newlabel{py:therm-buzzer}{{8.{2}}{158}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/thermistor/python/therm\textendash buzzer.py}{158}\protected@file@percent } \@writefile{toc}{\contentsline {section}{\numberline {8.7}Interfacing the Thermistor from Julia}{159}\protected@file@percent } @@ -980,14 +997,14 @@ \@writefile{juliad}{\addvspace {10pt}} \@writefile{thm}{\contentsline {juliamass}{{Julia Code}{8.{1}}{}}{159}\protected@file@percent } \@writefile{juliad}{\contentsline {section}{\numberline {8.{1}}Read and display the thermistor values}{159}\protected@file@percent } -\newlabel{106@xvr}{{}{159}} -\newlabel{106@vr}{{}{159}} +\newlabel{102@xvr}{{}{159}} +\newlabel{102@vr}{{}{159}} \newlabel{julia:therm-read}{{8.{1}}{159}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/thermistor/julia/therm\textendash read.jl}{159}\protected@file@percent } \@writefile{thm}{\contentsline {juliamass}{{Julia Code}{8.{2}}{}}{160}\protected@file@percent } \@writefile{juliad}{\contentsline {section}{\numberline {8.{2}}Turning the buzzer on and off using thermistor values}{160}\protected@file@percent } -\newlabel{107@xvr}{{}{160}} -\newlabel{107@vr}{{}{160}} +\newlabel{103@xvr}{{}{160}} +\newlabel{103@vr}{{}{160}} \newlabel{julia:therm-buzzer}{{8.{2}}{160}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/thermistor/julia/therm\textendash buzzer.jl}{160}\protected@file@percent } \@writefile{toc}{\contentsline {section}{\numberline {8.8}Interfacing the Thermistor from OpenModelica}{160}\protected@file@percent } @@ -997,14 +1014,14 @@ \@writefile{OpenModelicad}{\addvspace {10pt}} \@writefile{thm}{\contentsline {OpenModelicamass}{{OpenModelica Code}{8.{1}}{}}{161}\protected@file@percent } \@writefile{OpenModelicad}{\contentsline {section}{\numberline {8.{1}}Read and display the thermistor values}{161}\protected@file@percent } -\newlabel{108@xvr}{{}{161}} -\newlabel{108@vr}{{}{161}} +\newlabel{104@xvr}{{}{161}} +\newlabel{104@vr}{{}{161}} \newlabel{OpenModelica:therm-read}{{8.{1}}{161}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/thermistor/OpenModelica/therm\textendash read.mo}{161}\protected@file@percent } \@writefile{thm}{\contentsline {OpenModelicamass}{{OpenModelica Code}{8.{2}}{}}{162}\protected@file@percent } \@writefile{OpenModelicad}{\contentsline {section}{\numberline {8.{2}}Turning the buzzer on and off using thermistor values}{162}\protected@file@percent } -\newlabel{109@xvr}{{}{162}} -\newlabel{109@vr}{{}{162}} +\newlabel{105@xvr}{{}{162}} +\newlabel{105@vr}{{}{162}} \newlabel{OpenModelica:therm-buzzer}{{8.{2}}{162}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/thermistor/OpenModelica/therm\textendash buzzer.mo}{162}\protected@file@percent } \@writefile{toc}{\contentsline {chapter}{\numberline {9}Controlling a DC motor}{163}\protected@file@percent } @@ -1027,20 +1044,20 @@ \@writefile{ard}{\addvspace {10pt}} \@writefile{thm}{\contentsline {ardmass}{{Arduino Code}{9.{1}}{}}{167}\protected@file@percent } \@writefile{ard}{\contentsline {section}{\numberline {9.{1}}Rotating the DC motor}{167}\protected@file@percent } -\newlabel{110@xvr}{{}{167}} -\newlabel{110@vr}{{}{167}} +\newlabel{106@xvr}{{}{167}} +\newlabel{106@vr}{{}{167}} \newlabel{ard:dcmotor-clock}{{9.{1}}{167}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/dcmotor/arduino/dcmotor\textendash clock/dcmotor\textendash clock.ino}{167}\protected@file@percent } \@writefile{thm}{\contentsline {ardmass}{{Arduino Code}{9.{2}}{}}{167}\protected@file@percent } \@writefile{ard}{\contentsline {section}{\numberline {9.{2}}Rotating the DC motor in both directions}{167}\protected@file@percent } -\newlabel{111@xvr}{{}{167}} -\newlabel{111@vr}{{}{167}} +\newlabel{107@xvr}{{}{167}} +\newlabel{107@vr}{{}{167}} \newlabel{ard:dcmotor-both}{{9.{2}}{167}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/dcmotor/arduino/dcmotor\textendash both/dcmotor\textendash both.ino}{167}\protected@file@percent } \@writefile{thm}{\contentsline {ardmass}{{Arduino Code}{9.{3}}{}}{167}\protected@file@percent } \@writefile{ard}{\contentsline {section}{\numberline {9.{3}}Rotating the DC motor in both directions in a loop}{167}\protected@file@percent } -\newlabel{112@xvr}{{}{167}} -\newlabel{112@vr}{{}{167}} +\newlabel{108@xvr}{{}{167}} +\newlabel{108@vr}{{}{167}} \newlabel{ard:dcmotor-loop}{{9.{3}}{167}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/dcmotor/arduino/dcmotor\textendash loop/dcmotor\textendash loop.ino}{168}\protected@file@percent } \@writefile{toc}{\contentsline {section}{\numberline {9.3}Controlling the DC motor from Scilab}{168}\protected@file@percent } @@ -1063,69 +1080,69 @@ \@writefile{cod}{\addvspace {10pt}} \@writefile{thm}{\contentsline {codemass}{{Scilab Code}{9.{1}}{}}{171}\protected@file@percent } \@writefile{cod}{\contentsline {section}{\numberline {9.{1}}Rotating the DC motor}{171}\protected@file@percent } -\newlabel{113@xvr}{{}{171}} -\newlabel{113@vr}{{}{171}} +\newlabel{109@xvr}{{}{171}} +\newlabel{109@vr}{{}{171}} \newlabel{sci:dcmotor-clock}{{9.{1}}{171}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/dcmotor/scilab/dcmotor\textendash clock.sce}{171}\protected@file@percent } \@writefile{thm}{\contentsline {codemass}{{Scilab Code}{9.{2}}{}}{171}\protected@file@percent } \@writefile{cod}{\contentsline {section}{\numberline {9.{2}}Rotating the DC motor in both directions}{171}\protected@file@percent } -\newlabel{114@xvr}{{}{171}} -\newlabel{114@vr}{{}{171}} +\newlabel{110@xvr}{{}{171}} +\newlabel{110@vr}{{}{171}} \newlabel{sci:dcmotor-both}{{9.{2}}{171}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/dcmotor/scilab/dcmotor\textendash both.sce}{171}\protected@file@percent } \@writefile{thm}{\contentsline {codemass}{{Scilab Code}{9.{3}}{}}{171}\protected@file@percent } \@writefile{cod}{\contentsline {section}{\numberline {9.{3}}Rotating the DC motor in both directions in a loop}{171}\protected@file@percent } -\newlabel{115@xvr}{{}{171}} -\newlabel{115@vr}{{}{171}} +\newlabel{111@xvr}{{}{171}} +\newlabel{111@vr}{{}{171}} \newlabel{sci:dcmotor-loop}{{9.{3}}{171}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/dcmotor/scilab/dcmotor\textendash loop.sce}{171}\protected@file@percent } \@writefile{lof}{\contentsline {figure}{\numberline {9.4}{\ignorespaces Control of DC motor for a specified time from Xcos}}{172}\protected@file@percent } -\newlabel{117@xvr}{{}{172}} -\newlabel{117@vr}{{}{172}} +\newlabel{113@xvr}{{}{172}} +\newlabel{113@vr}{{}{172}} \newlabel{fig:dcmotor-clock}{{9.4}{172}} \@writefile{toc}{\contentsline {section}{\numberline {9.4}Controlling the DC Motor from Xcos}{172}\protected@file@percent } \@writefile{lot}{\contentsline {table}{\numberline {9.3}{\ignorespaces Xcos parameters to drive the DC motor for a specified time\relax }}{173}\protected@file@percent } \newlabel{tab:dcmotor-clock}{{9.3}{173}} -\newlabel{118@xvr}{{}{173}} -\newlabel{118@vr}{{}{173}} +\newlabel{114@xvr}{{}{173}} +\newlabel{114@vr}{{}{173}} \@writefile{thm}{\contentsline {egmass}{{Exercise}{9.{3}}{}}{173}\protected@file@percent } \@writefile{lof}{\contentsline {figure}{\numberline {9.5}{\ignorespaces Xcos control of the DC motor in forward and reverse directions}}{174}\protected@file@percent } -\newlabel{120@xvr}{{}{174}} -\newlabel{120@vr}{{}{174}} +\newlabel{116@xvr}{{}{174}} +\newlabel{116@vr}{{}{174}} \newlabel{fig:dcmotor-both}{{9.5}{174}} \@writefile{lot}{\contentsline {table}{\numberline {9.4}{\ignorespaces Xcos parameters to drive the DC motor in forward and reverse directions\relax }}{174}\protected@file@percent } \newlabel{tab:dcmotor-both}{{9.4}{174}} -\newlabel{121@xvr}{{}{174}} -\newlabel{121@vr}{{}{174}} +\newlabel{117@xvr}{{}{174}} +\newlabel{117@vr}{{}{174}} \@writefile{lof}{\contentsline {figure}{\numberline {9.6}{\ignorespaces Xcos control of the DC motor in forward and reverse directions}}{175}\protected@file@percent } -\newlabel{123@xvr}{{}{175}} -\newlabel{123@vr}{{}{175}} +\newlabel{119@xvr}{{}{175}} +\newlabel{119@vr}{{}{175}} \newlabel{fig:dcmotor-loop}{{9.6}{175}} \@writefile{toc}{\contentsline {section}{\numberline {9.5}Controlling the DC Motor from Python}{175}\protected@file@percent } \@writefile{toc}{\contentsline {subsection}{\numberline {9.5.1}Controlling the DC Motor}{175}\protected@file@percent } \@writefile{lot}{\contentsline {table}{\numberline {9.5}{\ignorespaces Xcos parameters to drive the DC motor in a loop\relax }}{176}\protected@file@percent } \newlabel{tab:dcmotor-loop}{{9.5}{176}} -\newlabel{124@xvr}{{}{176}} -\newlabel{124@vr}{{}{176}} +\newlabel{120@xvr}{{}{176}} +\newlabel{120@vr}{{}{176}} \@writefile{toc}{\contentsline {subsection}{\numberline {9.5.2}Python Code}{177}\protected@file@percent } \newlabel{sec:dcmotor-python-code}{{9.5.2}{177}} \@writefile{pyd}{\addvspace {10pt}} \@writefile{thm}{\contentsline {pymass}{{Python Code}{9.{1}}{}}{177}\protected@file@percent } \@writefile{pyd}{\contentsline {section}{\numberline {9.{1}}Rotating the DC motor}{177}\protected@file@percent } -\newlabel{125@xvr}{{}{177}} -\newlabel{125@vr}{{}{177}} +\newlabel{121@xvr}{{}{177}} +\newlabel{121@vr}{{}{177}} \newlabel{py:dcmotor-clock}{{9.{1}}{177}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/dcmotor/python/dcmotor\textendash clock.py}{177}\protected@file@percent } \@writefile{thm}{\contentsline {pymass}{{Python Code}{9.{2}}{}}{178}\protected@file@percent } \@writefile{pyd}{\contentsline {section}{\numberline {9.{2}}Rotating the DC motor in both directions}{178}\protected@file@percent } -\newlabel{126@xvr}{{}{178}} -\newlabel{126@vr}{{}{178}} +\newlabel{122@xvr}{{}{178}} +\newlabel{122@vr}{{}{178}} \newlabel{py:dcmotor-both}{{9.{2}}{178}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/dcmotor/python/dcmotor\textendash both.py}{178}\protected@file@percent } \@writefile{thm}{\contentsline {pymass}{{Python Code}{9.{3}}{}}{178}\protected@file@percent } \@writefile{pyd}{\contentsline {section}{\numberline {9.{3}}Rotating the DC motor in both directions in a loop}{178}\protected@file@percent } -\newlabel{127@xvr}{{}{179}} -\newlabel{127@vr}{{}{179}} +\newlabel{123@xvr}{{}{179}} +\newlabel{123@vr}{{}{179}} \newlabel{py:dcmotor-loop}{{9.{3}}{179}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/dcmotor/python/dcmotor\textendash loop.py}{179}\protected@file@percent } \@writefile{toc}{\contentsline {section}{\numberline {9.6}Controlling the DC Motor from Julia}{180}\protected@file@percent } @@ -1135,20 +1152,20 @@ \@writefile{juliad}{\addvspace {10pt}} \@writefile{thm}{\contentsline {juliamass}{{Julia Code}{9.{1}}{}}{180}\protected@file@percent } \@writefile{juliad}{\contentsline {section}{\numberline {9.{1}}Rotating the DC motor}{180}\protected@file@percent } -\newlabel{128@xvr}{{}{180}} -\newlabel{128@vr}{{}{180}} +\newlabel{124@xvr}{{}{180}} +\newlabel{124@vr}{{}{180}} \newlabel{julia:dcmotor-clock}{{9.{1}}{180}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/dcmotor/julia/dcmotor\textendash clock.jl}{180}\protected@file@percent } \@writefile{thm}{\contentsline {juliamass}{{Julia Code}{9.{2}}{}}{181}\protected@file@percent } \@writefile{juliad}{\contentsline {section}{\numberline {9.{2}}Rotating the DC motor in both directions}{181}\protected@file@percent } -\newlabel{129@xvr}{{}{181}} -\newlabel{129@vr}{{}{181}} +\newlabel{125@xvr}{{}{181}} +\newlabel{125@vr}{{}{181}} \newlabel{julia:dcmotor-both}{{9.{2}}{181}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/dcmotor/julia/dcmotor\textendash both.jl}{181}\protected@file@percent } \@writefile{thm}{\contentsline {juliamass}{{Julia Code}{9.{3}}{}}{181}\protected@file@percent } \@writefile{juliad}{\contentsline {section}{\numberline {9.{3}}Rotating the DC motor in both directions in a loop}{181}\protected@file@percent } -\newlabel{130@xvr}{{}{181}} -\newlabel{130@vr}{{}{181}} +\newlabel{126@xvr}{{}{181}} +\newlabel{126@vr}{{}{181}} \newlabel{julia:dcmotor-loop}{{9.{3}}{181}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/dcmotor/julia/dcmotor\textendash loop.jl}{181}\protected@file@percent } \@writefile{toc}{\contentsline {section}{\numberline {9.7}Controlling the DC Motor from OpenModelica}{181}\protected@file@percent } @@ -1158,20 +1175,20 @@ \@writefile{OpenModelicad}{\addvspace {10pt}} \@writefile{thm}{\contentsline {OpenModelicamass}{{OpenModelica Code}{9.{1}}{}}{182}\protected@file@percent } \@writefile{OpenModelicad}{\contentsline {section}{\numberline {9.{1}}Rotating the DC motor}{182}\protected@file@percent } -\newlabel{131@xvr}{{}{182}} -\newlabel{131@vr}{{}{182}} +\newlabel{127@xvr}{{}{182}} +\newlabel{127@vr}{{}{182}} \newlabel{OpenModelica:dcmotor-clock}{{9.{1}}{182}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/dcmotor/OpenModelica/dcmotor\textendash clock.mo}{182}\protected@file@percent } \@writefile{thm}{\contentsline {OpenModelicamass}{{OpenModelica Code}{9.{2}}{}}{182}\protected@file@percent } \@writefile{OpenModelicad}{\contentsline {section}{\numberline {9.{2}}Rotating the DC motor in both directions}{182}\protected@file@percent } -\newlabel{132@xvr}{{}{182}} -\newlabel{132@vr}{{}{182}} +\newlabel{128@xvr}{{}{182}} +\newlabel{128@vr}{{}{182}} \newlabel{OpenModelica:dcmotor-both}{{9.{2}}{182}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/dcmotor/OpenModelica/dcmotor\textendash both.mo}{183}\protected@file@percent } \@writefile{thm}{\contentsline {OpenModelicamass}{{OpenModelica Code}{9.{3}}{}}{183}\protected@file@percent } \@writefile{OpenModelicad}{\contentsline {section}{\numberline {9.{3}}Rotating the DC motor in both directions in a loop}{183}\protected@file@percent } -\newlabel{133@xvr}{{}{183}} -\newlabel{133@vr}{{}{183}} +\newlabel{129@xvr}{{}{183}} +\newlabel{129@vr}{{}{183}} \newlabel{OpenModelica:dcmotor-loop}{{9.{3}}{183}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/dcmotor/OpenModelica/dcmotor\textendash loop.mo}{183}\protected@file@percent } \@writefile{toc}{\contentsline {chapter}{\numberline {10}Interfacing a Servomotor}{185}\protected@file@percent } @@ -1190,26 +1207,26 @@ \@writefile{ard}{\addvspace {10pt}} \@writefile{thm}{\contentsline {ardmass}{{Arduino Code}{10.{1}}{}}{187}\protected@file@percent } \@writefile{ard}{\contentsline {section}{\numberline {10.{1}}Rotating the servomotor to a specified degree}{187}\protected@file@percent } -\newlabel{134@xvr}{{}{187}} -\newlabel{134@vr}{{}{187}} +\newlabel{130@xvr}{{}{187}} +\newlabel{130@vr}{{}{187}} \newlabel{ard:servo-init}{{10.{1}}{187}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/servo/arduino/servo\textendash init/servo\textendash init.ino}{187}\protected@file@percent } \@writefile{thm}{\contentsline {ardmass}{{Arduino Code}{10.{2}}{}}{188}\protected@file@percent } \@writefile{ard}{\contentsline {section}{\numberline {10.{2}}Rotating the servomotor to a specified degree and reversing}{188}\protected@file@percent } -\newlabel{135@xvr}{{}{188}} -\newlabel{135@vr}{{}{188}} +\newlabel{131@xvr}{{}{188}} +\newlabel{131@vr}{{}{188}} \newlabel{ard:servo-reverse}{{10.{2}}{188}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/servo/arduino/servo\textendash reverse/servo\textendash reverse.ino}{188}\protected@file@percent } \@writefile{thm}{\contentsline {ardmass}{{Arduino Code}{10.{3}}{}}{188}\protected@file@percent } \@writefile{ard}{\contentsline {section}{\numberline {10.{3}}Rotating the servomotor in increments}{188}\protected@file@percent } -\newlabel{136@xvr}{{}{188}} -\newlabel{136@vr}{{}{188}} +\newlabel{132@xvr}{{}{188}} +\newlabel{132@vr}{{}{188}} \newlabel{ard:servo-loop}{{10.{3}}{188}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/servo/arduino/servo\textendash loop/servo\textendash loop.ino}{188}\protected@file@percent } \@writefile{thm}{\contentsline {ardmass}{{Arduino Code}{10.{4}}{}}{189}\protected@file@percent } \@writefile{ard}{\contentsline {section}{\numberline {10.{4}}Rotating the servomotor through the potentiometer}{189}\protected@file@percent } -\newlabel{137@xvr}{{}{189}} -\newlabel{137@vr}{{}{189}} +\newlabel{133@xvr}{{}{189}} +\newlabel{133@vr}{{}{189}} \newlabel{ard:servo-pot}{{10.{4}}{189}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/servo/arduino/servo\textendash pot/servo\textendash pot.ino}{189}\protected@file@percent } \@writefile{toc}{\contentsline {section}{\numberline {10.3}Controlling the Servomotor through Scilab}{189}\protected@file@percent } @@ -1223,62 +1240,62 @@ \@writefile{cod}{\addvspace {10pt}} \@writefile{thm}{\contentsline {codemass}{{Scilab Code}{10.{1}}{}}{190}\protected@file@percent } \@writefile{cod}{\contentsline {section}{\numberline {10.{1}}Rotating the servomotor to a specified degree}{190}\protected@file@percent } -\newlabel{138@xvr}{{}{190}} -\newlabel{138@vr}{{}{190}} +\newlabel{134@xvr}{{}{190}} +\newlabel{134@vr}{{}{190}} \newlabel{sci:servo-init}{{10.{1}}{190}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/servo/scilab/servo\textendash init.sce}{190}\protected@file@percent } \@writefile{thm}{\contentsline {codemass}{{Scilab Code}{10.{2}}{}}{190}\protected@file@percent } \@writefile{cod}{\contentsline {section}{\numberline {10.{2}}Rotating the servomotor to a specified degree and reversing}{190}\protected@file@percent } -\newlabel{139@xvr}{{}{190}} -\newlabel{139@vr}{{}{190}} +\newlabel{135@xvr}{{}{190}} +\newlabel{135@vr}{{}{190}} \newlabel{sci:servo-reverse}{{10.{2}}{190}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/servo/scilab/servo\textendash reverse.sce}{191}\protected@file@percent } \@writefile{thm}{\contentsline {codemass}{{Scilab Code}{10.{3}}{}}{191}\protected@file@percent } \@writefile{cod}{\contentsline {section}{\numberline {10.{3}}Rotating the servomotor in steps of $20^\circ $}{191}\protected@file@percent } -\newlabel{140@xvr}{{}{191}} -\newlabel{140@vr}{{}{191}} +\newlabel{136@xvr}{{}{191}} +\newlabel{136@vr}{{}{191}} \newlabel{sci:servo-loop}{{10.{3}}{191}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/servo/scilab/servo\textendash loop.sce}{191}\protected@file@percent } \@writefile{thm}{\contentsline {codemass}{{Scilab Code}{10.{4}}{}}{191}\protected@file@percent } \@writefile{cod}{\contentsline {section}{\numberline {10.{4}}Rotating the servomotor to a degree specified by the potentiometer}{191}\protected@file@percent } -\newlabel{141@xvr}{{}{191}} -\newlabel{141@vr}{{}{191}} +\newlabel{137@xvr}{{}{191}} +\newlabel{137@vr}{{}{191}} \newlabel{sci:servo-pot}{{10.{4}}{191}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/servo/scilab/servo\textendash pot.sce}{191}\protected@file@percent } \@writefile{toc}{\contentsline {section}{\numberline {10.4}Controling the Servomotor through Xcos}{191}\protected@file@percent } \newlabel{sec:servo-xcos}{{10.4}{191}} \@writefile{lof}{\contentsline {figure}{\numberline {10.1}{\ignorespaces Rotating the servomotor by a fixed angle}}{192}\protected@file@percent } -\newlabel{143@xvr}{{}{192}} -\newlabel{143@vr}{{}{192}} +\newlabel{139@xvr}{{}{192}} +\newlabel{139@vr}{{}{192}} \newlabel{fig:servo-init}{{10.1}{192}} \@writefile{lot}{\contentsline {table}{\numberline {10.2}{\ignorespaces Parameters to rotate the servomotor by $30^\circ $\relax }}{192}\protected@file@percent } \newlabel{tab:servo-init}{{10.2}{192}} -\newlabel{144@xvr}{{}{192}} -\newlabel{144@vr}{{}{192}} +\newlabel{140@xvr}{{}{192}} +\newlabel{140@vr}{{}{192}} \@writefile{lof}{\contentsline {figure}{\numberline {10.2}{\ignorespaces Rotating the servomotor forward and then reverse}}{193}\protected@file@percent } -\newlabel{146@xvr}{{}{193}} -\newlabel{146@vr}{{}{193}} +\newlabel{142@xvr}{{}{193}} +\newlabel{142@vr}{{}{193}} \newlabel{fig:servo-reverse}{{10.2}{193}} \@writefile{lot}{\contentsline {table}{\numberline {10.3}{\ignorespaces Parameters to rotate the servomotor forward and reverse\relax }}{194}\protected@file@percent } \newlabel{tab:servo-reverse}{{10.3}{194}} -\newlabel{147@xvr}{{}{194}} -\newlabel{147@vr}{{}{194}} +\newlabel{143@xvr}{{}{194}} +\newlabel{143@vr}{{}{194}} \@writefile{lof}{\contentsline {figure}{\numberline {10.3}{\ignorespaces Rotating the servomotor in increments of $20^\circ $}}{194}\protected@file@percent } -\newlabel{149@xvr}{{}{194}} -\newlabel{149@vr}{{}{194}} +\newlabel{145@xvr}{{}{194}} +\newlabel{145@vr}{{}{194}} \newlabel{fig:servo-loop}{{10.3}{194}} \@writefile{lot}{\contentsline {table}{\numberline {10.4}{\ignorespaces Parameters to make the servomotor to sweep the entire range in increments\relax }}{195}\protected@file@percent } \newlabel{tab:servo-loop}{{10.4}{195}} -\newlabel{150@xvr}{{}{195}} -\newlabel{150@vr}{{}{195}} +\newlabel{146@xvr}{{}{195}} +\newlabel{146@vr}{{}{195}} \@writefile{lof}{\contentsline {figure}{\numberline {10.4}{\ignorespaces Rotating the servomotor as suggested by the potentiometer}}{195}\protected@file@percent } -\newlabel{152@xvr}{{}{195}} -\newlabel{152@vr}{{}{195}} +\newlabel{148@xvr}{{}{195}} +\newlabel{148@vr}{{}{195}} \newlabel{fig:servo-pot}{{10.4}{195}} \@writefile{lot}{\contentsline {table}{\numberline {10.5}{\ignorespaces Parameters to rotate the servomotor based on the input from the potentiometer\relax }}{196}\protected@file@percent } \newlabel{tab:servo-pot}{{10.5}{196}} -\newlabel{153@xvr}{{}{196}} -\newlabel{153@vr}{{}{196}} +\newlabel{149@xvr}{{}{196}} +\newlabel{149@vr}{{}{196}} \@writefile{toc}{\contentsline {section}{\numberline {10.5}Controlling the Servomotor through Python}{196}\protected@file@percent } \@writefile{toc}{\contentsline {subsection}{\numberline {10.5.1}Controlling the Servomotor}{196}\protected@file@percent } \newlabel{sec:servo-py}{{10.5.1}{196}} @@ -1290,26 +1307,26 @@ \@writefile{pyd}{\addvspace {10pt}} \@writefile{thm}{\contentsline {pymass}{{Python Code}{10.{1}}{}}{197}\protected@file@percent } \@writefile{pyd}{\contentsline {section}{\numberline {10.{1}}Rotating the servomotor to a specified degree}{197}\protected@file@percent } -\newlabel{154@xvr}{{}{197}} -\newlabel{154@vr}{{}{197}} +\newlabel{150@xvr}{{}{197}} +\newlabel{150@vr}{{}{197}} \newlabel{py:servo-init}{{10.{1}}{197}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/servo/python/servo\textendash init.py}{197}\protected@file@percent } \@writefile{thm}{\contentsline {pymass}{{Python Code}{10.{2}}{}}{198}\protected@file@percent } \@writefile{pyd}{\contentsline {section}{\numberline {10.{2}}Rotating the servomotor to a specified degree and reversing}{198}\protected@file@percent } -\newlabel{155@xvr}{{}{198}} -\newlabel{155@vr}{{}{198}} +\newlabel{151@xvr}{{}{198}} +\newlabel{151@vr}{{}{198}} \newlabel{py:servo-reverse}{{10.{2}}{198}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/servo/python/servo\textendash reverse.py}{198}\protected@file@percent } \@writefile{thm}{\contentsline {pymass}{{Python Code}{10.{3}}{}}{199}\protected@file@percent } \@writefile{pyd}{\contentsline {section}{\numberline {10.{3}}Rotating the servomotor in steps of $20^\circ $}{199}\protected@file@percent } -\newlabel{156@xvr}{{}{199}} -\newlabel{156@vr}{{}{199}} +\newlabel{152@xvr}{{}{199}} +\newlabel{152@vr}{{}{199}} \newlabel{sci:servo-loop}{{10.{3}}{199}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/servo/python/servo\textendash loop.py}{199}\protected@file@percent } \@writefile{thm}{\contentsline {pymass}{{Python Code}{10.{4}}{}}{200}\protected@file@percent } \@writefile{pyd}{\contentsline {section}{\numberline {10.{4}}Rotating the servomotor to a degree specified by the potentiometer}{200}\protected@file@percent } -\newlabel{157@xvr}{{}{200}} -\newlabel{157@vr}{{}{200}} +\newlabel{153@xvr}{{}{200}} +\newlabel{153@vr}{{}{200}} \newlabel{py:servo-pot}{{10.{4}}{200}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/servo/python/servo\textendash pot.py}{200}\protected@file@percent } \@writefile{toc}{\contentsline {section}{\numberline {10.6}Controlling the Servomotor through Julia}{201}\protected@file@percent } @@ -1323,26 +1340,26 @@ \@writefile{juliad}{\addvspace {10pt}} \@writefile{thm}{\contentsline {juliamass}{{Julia Code}{10.{1}}{}}{202}\protected@file@percent } \@writefile{juliad}{\contentsline {section}{\numberline {10.{1}}Rotating the servomotor to a specified degree}{202}\protected@file@percent } -\newlabel{158@xvr}{{}{202}} -\newlabel{158@vr}{{}{202}} +\newlabel{154@xvr}{{}{202}} +\newlabel{154@vr}{{}{202}} \newlabel{julia:servo-init}{{10.{1}}{202}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/servo/julia/servo\textendash init.jl}{202}\protected@file@percent } \@writefile{thm}{\contentsline {juliamass}{{Julia Code}{10.{2}}{}}{202}\protected@file@percent } \@writefile{juliad}{\contentsline {section}{\numberline {10.{2}}Rotating the servomotor to a specified degree and reversing}{202}\protected@file@percent } -\newlabel{159@xvr}{{}{202}} -\newlabel{159@vr}{{}{202}} +\newlabel{155@xvr}{{}{202}} +\newlabel{155@vr}{{}{202}} \newlabel{julia:servo-reverse}{{10.{2}}{202}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/servo/julia/servo\textendash reverse.jl}{202}\protected@file@percent } \@writefile{thm}{\contentsline {juliamass}{{Julia Code}{10.{3}}{}}{203}\protected@file@percent } \@writefile{juliad}{\contentsline {section}{\numberline {10.{3}}Rotating the servomotor in steps of $20^\circ $}{203}\protected@file@percent } -\newlabel{160@xvr}{{}{203}} -\newlabel{160@vr}{{}{203}} +\newlabel{156@xvr}{{}{203}} +\newlabel{156@vr}{{}{203}} \newlabel{julia:servo-loop}{{10.{3}}{203}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/servo/julia/servo\textendash loop.jl}{203}\protected@file@percent } \@writefile{thm}{\contentsline {juliamass}{{Julia Code}{10.{4}}{}}{203}\protected@file@percent } \@writefile{juliad}{\contentsline {section}{\numberline {10.{4}}Rotating the servomotor to a degree specified by the potentiometer}{203}\protected@file@percent } -\newlabel{161@xvr}{{}{203}} -\newlabel{161@vr}{{}{203}} +\newlabel{157@xvr}{{}{203}} +\newlabel{157@vr}{{}{203}} \newlabel{julia:servo-pot}{{10.{4}}{203}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/servo/julia/servo\textendash pot.jl}{203}\protected@file@percent } \@writefile{toc}{\contentsline {section}{\numberline {10.7}Controlling the Servomotor through OpenModelica}{203}\protected@file@percent } @@ -1356,26 +1373,26 @@ \@writefile{OpenModelicad}{\addvspace {10pt}} \@writefile{thm}{\contentsline {OpenModelicamass}{{OpenModelica Code}{10.{1}}{}}{204}\protected@file@percent } \@writefile{OpenModelicad}{\contentsline {section}{\numberline {10.{1}}Rotating the servomotor to a specified degree}{204}\protected@file@percent } -\newlabel{162@xvr}{{}{204}} -\newlabel{162@vr}{{}{204}} +\newlabel{158@xvr}{{}{204}} +\newlabel{158@vr}{{}{204}} \newlabel{OpenModelica:servo-init}{{10.{1}}{204}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/servo/OpenModelica/servo\textendash init.mo}{204}\protected@file@percent } \@writefile{thm}{\contentsline {OpenModelicamass}{{OpenModelica Code}{10.{2}}{}}{205}\protected@file@percent } \@writefile{OpenModelicad}{\contentsline {section}{\numberline {10.{2}}Rotating the servomotor to a specified degree and reversing}{205}\protected@file@percent } -\newlabel{163@xvr}{{}{205}} -\newlabel{163@vr}{{}{205}} +\newlabel{159@xvr}{{}{205}} +\newlabel{159@vr}{{}{205}} \newlabel{OpenModelica:servo-reverse}{{10.{2}}{205}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/servo/OpenModelica/servo\textendash reverse.mo}{205}\protected@file@percent } \@writefile{thm}{\contentsline {OpenModelicamass}{{OpenModelica Code}{10.{3}}{}}{206}\protected@file@percent } \@writefile{OpenModelicad}{\contentsline {section}{\numberline {10.{3}}Rotating the servomotor in steps of $20^\circ $}{206}\protected@file@percent } -\newlabel{164@xvr}{{}{206}} -\newlabel{164@vr}{{}{206}} +\newlabel{160@xvr}{{}{206}} +\newlabel{160@vr}{{}{206}} \newlabel{OpenModelica:servo-loop}{{10.{3}}{206}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/servo/OpenModelica/servo\textendash loop.mo}{206}\protected@file@percent } \@writefile{thm}{\contentsline {OpenModelicamass}{{OpenModelica Code}{10.{4}}{}}{206}\protected@file@percent } \@writefile{OpenModelicad}{\contentsline {section}{\numberline {10.{4}}Rotating the servomotor to a degree specified by the potentiometer}{206}\protected@file@percent } -\newlabel{165@xvr}{{}{206}} -\newlabel{165@vr}{{}{206}} +\newlabel{161@xvr}{{}{206}} +\newlabel{161@vr}{{}{206}} \newlabel{OpenModelica:servo-pot}{{10.{4}}{206}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/servo/OpenModelica/servo\textunderscore pot.mo}{207}\protected@file@percent } \@writefile{toc}{\contentsline {chapter}{\numberline {11}Implementation of Modbus Protocol}{209}\protected@file@percent } @@ -1428,13 +1445,13 @@ \@writefile{ard}{\addvspace {10pt}} \@writefile{thm}{\contentsline {ardmass}{{Arduino Code}{11.{1}}{}}{221}\protected@file@percent } \@writefile{ard}{\contentsline {section}{\numberline {11.{1}}First 10 lines of the firmware for Modbus Energy Meter experiment}{221}\protected@file@percent } -\newlabel{168@xvr}{{}{221}} -\newlabel{168@vr}{{}{221}} +\newlabel{164@xvr}{{}{221}} +\newlabel{164@vr}{{}{221}} \newlabel{ard:firmware-modbus}{{11.{1}}{221}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/modbus/arduino/send\textunderscore packet.ino}{221}\protected@file@percent } \@writefile{lof}{\contentsline {figure}{\numberline {11.14}{\ignorespaces Xcos diagram to read Energy Meter values}}{222}\protected@file@percent } -\newlabel{167@xvr}{{}{222}} -\newlabel{167@vr}{{}{222}} +\newlabel{163@xvr}{{}{222}} +\newlabel{163@vr}{{}{222}} \newlabel{fig:mod-read}{{11.14}{222}} \@writefile{lot}{\contentsline {table}{\numberline {11.5}{\ignorespaces Xcos parameters to read Energy Meter\relax }}{222}\protected@file@percent } \newlabel{tab:mod-xcos-read}{{11.5}{222}} @@ -1443,26 +1460,26 @@ \@writefile{cod}{\addvspace {10pt}} \@writefile{thm}{\contentsline {codemass}{{Scilab Code}{11.{1}}{}}{223}\protected@file@percent } \@writefile{cod}{\contentsline {section}{\numberline {11.{1}}First 10 lines of the function for scifunc block}{223}\protected@file@percent } -\newlabel{169@xvr}{{}{223}} -\newlabel{169@vr}{{}{223}} +\newlabel{165@xvr}{{}{223}} +\newlabel{165@vr}{{}{223}} \newlabel{sci:current-modbus}{{11.{1}}{223}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/modbus/scilab/read\textunderscore val.sce}{223}\protected@file@percent } \@writefile{thm}{\contentsline {codemass}{{Scilab Code}{11.{2}}{}}{223}\protected@file@percent } \@writefile{cod}{\contentsline {section}{\numberline {11.{2}}First 10 lines of the code for Single Phase Current Output}{223}\protected@file@percent } -\newlabel{170@xvr}{{}{223}} -\newlabel{170@vr}{{}{223}} +\newlabel{166@xvr}{{}{223}} +\newlabel{166@vr}{{}{223}} \newlabel{sci:current-modbus}{{11.{2}}{223}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/modbus/scilab/read\textunderscore current.sci}{223}\protected@file@percent } \@writefile{thm}{\contentsline {codemass}{{Scilab Code}{11.{3}}{}}{223}\protected@file@percent } \@writefile{cod}{\contentsline {section}{\numberline {11.{3}}First 10 lines of the code for Single Phase Voltage Output}{223}\protected@file@percent } -\newlabel{171@xvr}{{}{223}} -\newlabel{171@vr}{{}{223}} +\newlabel{167@xvr}{{}{223}} +\newlabel{167@vr}{{}{223}} \newlabel{sci:voltage-modbus}{{11.{3}}{223}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/modbus/scilab/read\textunderscore voltage.sci}{223}\protected@file@percent } \@writefile{thm}{\contentsline {codemass}{{Scilab Code}{11.{4}}{}}{224}\protected@file@percent } \@writefile{cod}{\contentsline {section}{\numberline {11.{4}}First 10 lines of the code for Single Phase Active Power Output}{224}\protected@file@percent } -\newlabel{172@xvr}{{}{224}} -\newlabel{172@vr}{{}{224}} +\newlabel{168@xvr}{{}{224}} +\newlabel{168@vr}{{}{224}} \newlabel{sci:modbus-power}{{11.{4}}{224}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/modbus/scilab/read\textunderscore active\textunderscore power.sci}{224}\protected@file@percent } \@writefile{toc}{\contentsline {subsection}{\numberline {11.7.3}Python Code}{224}\protected@file@percent } @@ -1470,20 +1487,20 @@ \@writefile{pyd}{\addvspace {10pt}} \@writefile{thm}{\contentsline {pymass}{{Python Code}{11.{1}}{}}{224}\protected@file@percent } \@writefile{pyd}{\contentsline {section}{\numberline {11.{1}}Code for Single Phase Current Output}{224}\protected@file@percent } -\newlabel{173@xvr}{{}{224}} -\newlabel{173@vr}{{}{224}} +\newlabel{169@xvr}{{}{224}} +\newlabel{169@vr}{{}{224}} \newlabel{py:current-modbus}{{11.{1}}{224}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/modbus/python/read\textunderscore current.py}{224}\protected@file@percent } \@writefile{thm}{\contentsline {pymass}{{Python Code}{11.{2}}{}}{224}\protected@file@percent } \@writefile{pyd}{\contentsline {section}{\numberline {11.{2}}Code for Single Phase Voltage Output}{224}\protected@file@percent } -\newlabel{174@xvr}{{}{224}} -\newlabel{174@vr}{{}{224}} +\newlabel{170@xvr}{{}{224}} +\newlabel{170@vr}{{}{224}} \newlabel{py:voltage-modbus}{{11.{2}}{224}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/modbus/python/read\textunderscore voltage.py}{224}\protected@file@percent } \@writefile{thm}{\contentsline {pymass}{{Python Code}{11.{3}}{}}{225}\protected@file@percent } \@writefile{pyd}{\contentsline {section}{\numberline {11.{3}}Code for Single Phase Active Power Output}{225}\protected@file@percent } -\newlabel{175@xvr}{{}{225}} -\newlabel{175@vr}{{}{225}} +\newlabel{171@xvr}{{}{225}} +\newlabel{171@vr}{{}{225}} \newlabel{py:modbus-power}{{11.{3}}{225}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/modbus/python/read\textunderscore active\textunderscore power.py}{225}\protected@file@percent } \@writefile{toc}{\contentsline {subsection}{\numberline {11.7.4}Julia Code}{225}\protected@file@percent } @@ -1491,20 +1508,20 @@ \@writefile{juliad}{\addvspace {10pt}} \@writefile{thm}{\contentsline {juliamass}{{Julia Code}{11.{1}}{}}{225}\protected@file@percent } \@writefile{juliad}{\contentsline {section}{\numberline {11.{1}}Code for Single Phase Current Output}{225}\protected@file@percent } -\newlabel{176@xvr}{{}{225}} -\newlabel{176@vr}{{}{225}} +\newlabel{172@xvr}{{}{225}} +\newlabel{172@vr}{{}{225}} \newlabel{julia:current-modbus}{{11.{1}}{225}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/modbus/julia/readCurrent.jl}{225}\protected@file@percent } \@writefile{thm}{\contentsline {juliamass}{{Julia Code}{11.{2}}{}}{225}\protected@file@percent } \@writefile{juliad}{\contentsline {section}{\numberline {11.{2}}Code for Single Phase Voltage Output}{225}\protected@file@percent } -\newlabel{177@xvr}{{}{225}} -\newlabel{177@vr}{{}{225}} +\newlabel{173@xvr}{{}{225}} +\newlabel{173@vr}{{}{225}} \newlabel{julia:voltage-modbus}{{11.{2}}{225}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/modbus/julia/readVoltage.jl}{225}\protected@file@percent } \@writefile{thm}{\contentsline {juliamass}{{Julia Code}{11.{3}}{}}{226}\protected@file@percent } \@writefile{juliad}{\contentsline {section}{\numberline {11.{3}}First 10 lines of the code for Single Phase Active Power Output}{226}\protected@file@percent } -\newlabel{178@xvr}{{}{226}} -\newlabel{178@vr}{{}{226}} +\newlabel{174@xvr}{{}{226}} +\newlabel{174@vr}{{}{226}} \newlabel{julia:modbus-power}{{11.{3}}{226}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/modbus/julia/readPower.jl}{226}\protected@file@percent } \@writefile{toc}{\contentsline {subsection}{\numberline {11.7.5}OpenModelica Code}{226}\protected@file@percent } @@ -1512,21 +1529,21 @@ \@writefile{OpenModelicad}{\addvspace {10pt}} \@writefile{thm}{\contentsline {OpenModelicamass}{{OpenModelica Code}{11.{1}}{}}{226}\protected@file@percent } \@writefile{OpenModelicad}{\contentsline {section}{\numberline {11.{1}}Code for Single Phase Current Output}{226}\protected@file@percent } -\newlabel{179@xvr}{{}{226}} -\newlabel{179@vr}{{}{226}} +\newlabel{175@xvr}{{}{226}} +\newlabel{175@vr}{{}{226}} \newlabel{OpenModelica:current-modbus}{{11.{1}}{226}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/modbus/OpenModelica/readCurrent.mo}{226}\protected@file@percent } \@writefile{thm}{\contentsline {OpenModelicamass}{{OpenModelica Code}{11.{2}}{}}{226}\protected@file@percent } \@writefile{OpenModelicad}{\contentsline {section}{\numberline {11.{2}}Code for Single Phase Voltage Output}{226}\protected@file@percent } -\newlabel{180@xvr}{{}{226}} -\newlabel{180@vr}{{}{226}} +\newlabel{176@xvr}{{}{226}} +\newlabel{176@vr}{{}{226}} \newlabel{OpenModelica:voltage-modbus}{{11.{2}}{226}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/modbus/OpenModelica/readVoltage.mo}{226}\protected@file@percent } \bibdata{bibliography.bib} \@writefile{thm}{\contentsline {OpenModelicamass}{{OpenModelica Code}{11.{3}}{}}{227}\protected@file@percent } \@writefile{OpenModelicad}{\contentsline {section}{\numberline {11.{3}}Code for Single Phase Active Power Output}{227}\protected@file@percent } -\newlabel{181@xvr}{{}{227}} -\newlabel{181@vr}{{}{227}} +\newlabel{177@xvr}{{}{227}} +\newlabel{177@vr}{{}{227}} \newlabel{OpenModelica:modbus-power}{{11.{3}}{227}} \@writefile{lol}{\contentsline {lstlisting}{/home/fossee/Desktop/floss-scilab-arduino/user-code/modbus/OpenModelica/readPower.mo}{227}\protected@file@percent } \bibcite{CNES-Scilab}{1} diff --git a/floss-arduino.fdb_latexmk b/floss-arduino.fdb_latexmk index cd129e6..aac633b 100644 --- a/floss-arduino.fdb_latexmk +++ b/floss-arduino.fdb_latexmk @@ -1,14 +1,19 @@ # Fdb version 3 -["bibtex floss-arduino"] 1619403271 "floss-arduino.aux" "floss-arduino.bbl" "floss-arduino" 1619519864 +["bibtex floss-arduino"] 1619674906 "floss-arduino.aux" "floss-arduino.bbl" "floss-arduino" 1619675949 "/usr/share/texlive/texmf-dist/bibtex/bst/base/unsrt.bst" 1292289607 18030 1376b4b231b50c66211e47e42eda2875 "" "bibliography.bib" 1619058609 4121 e0d02327e4bb995867623cd1f708046e "" - "floss-arduino.aux" 1619519863 130107 69b980419001beb2b0ce53c0ede79ce2 "pdflatex" + "floss-arduino.aux" 1619675611 133477 c13c32d352b7fa40123b0235037b65b4 "pdflatex" (generated) - "floss-arduino.blg" "floss-arduino.bbl" -["pdflatex"] 1619519847 "/home/fossee/Desktop/floss-scilab-arduino/floss-arduino.tex" "/home/fossee/Desktop/floss-scilab-arduino/floss-arduino.pdf" "floss-arduino" 1619519864 + "floss-arduino.blg" +["makeindex floss-arduino.idx"] 1619674264 "floss-arduino.idx" "floss-arduino.ind" "floss-arduino" 1619675949 + "floss-arduino.idx" 1619675611 187 127d22f171683959438710553c1aeb57 "pdflatex" + (generated) + "floss-arduino.ind" + "floss-arduino.ilg" +["pdflatex"] 1619675603 "/home/fossee/Desktop/floss-scilab-arduino/floss-arduino.tex" "/home/fossee/Desktop/floss-scilab-arduino/floss-arduino.pdf" "floss-arduino" 1619675949 "/etc/texmf/web2c/texmf.cnf" 1602253014 475 c0e671620eb5563b2130f56340a5fde8 "" - "/home/fossee/Desktop/floss-scilab-arduino/floss-arduino.aux" 1619519863 130107 69b980419001beb2b0ce53c0ede79ce2 "" + "/home/fossee/Desktop/floss-scilab-arduino/floss-arduino.aux" 1619675611 133477 c13c32d352b7fa40123b0235037b65b4 "" "/home/fossee/Desktop/floss-scilab-arduino/floss-arduino.tex" 1619403261 4558 99e8133d713ce68a01e2f2b59b0d6baf "" "/usr/share/texlive/texmf-dist/fonts/enc/dvips/base/8r.enc" 1165713224 4850 80dc9bab7f31fb78a000ccfed0e27cab "" "/usr/share/texlive/texmf-dist/fonts/map/fontname/texfonts.map" 1577235249 3524 cb3e574dea2d1052e39280babc910dc8 "" @@ -133,24 +138,25 @@ "/usr/share/texmf/web2c/texmf.cnf" 1581979058 38841 ce3692aa899bb693b90b87eaa5d4d84e "" "/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map" 1604540077 4770781 1ed1abab22da9c3e2cc82e4db562318b "" "/var/lib/texmf/web2c/pdftex/pdflatex.fmt" 1604540101 8258883 e8330f8aa4fe7c6cdcf08bf0b72237fd "" - "floss-arduino.OpenModelicad" 1619519863 2299 89eee2271cf7b6651bb4ffc3b6e57071 "pdflatex" - "floss-arduino.ard" 1619519863 2084 6bad0e124799c33541dc2b8409055e82 "pdflatex" - "floss-arduino.aux" 1619519863 130107 69b980419001beb2b0ce53c0ede79ce2 "pdflatex" - "floss-arduino.bbl" 1619403271 2654 051fbb0ca9f90e7ce7d2577998098d98 "bibtex floss-arduino" - "floss-arduino.cod" 1619519863 2527 f3b2244ff032ebce91381284aaa5aaa3 "pdflatex" - "floss-arduino.juliad" 1619519863 2320 e3c6bb82c7cd9a87ee701d208aa3f761 "pdflatex" - "floss-arduino.lof" 1619519863 13137 11910ce6ccd75cea8cf16eea6248064b "pdflatex" - "floss-arduino.lot" 1619519863 3702 f2a1f5c0b1c8ea14ff4cfe4ae4542a36 "pdflatex" - "floss-arduino.pyd" 1619519863 2327 d827140ebdb728e756c9fcce7221bf61 "pdflatex" + "floss-arduino.OpenModelicad" 1619675611 2299 89eee2271cf7b6651bb4ffc3b6e57071 "pdflatex" + "floss-arduino.ard" 1619675611 2084 6bad0e124799c33541dc2b8409055e82 "pdflatex" + "floss-arduino.aux" 1619675611 133477 c13c32d352b7fa40123b0235037b65b4 "pdflatex" + "floss-arduino.bbl" 1619674906 2654 051fbb0ca9f90e7ce7d2577998098d98 "bibtex floss-arduino" + "floss-arduino.cod" 1619675611 2527 f3b2244ff032ebce91381284aaa5aaa3 "pdflatex" + "floss-arduino.ind" 1619674264 228 406d6b8e82a74b8f88d07279eacd2e35 "makeindex floss-arduino.idx" + "floss-arduino.juliad" 1619675611 2320 c70b6baf76ef5bc16ca500c45852fa10 "pdflatex" + "floss-arduino.lof" 1619675611 13142 4b96ebb01c777be59117c6dfd7be482f "pdflatex" + "floss-arduino.lot" 1619675611 3702 f2a1f5c0b1c8ea14ff4cfe4ae4542a36 "pdflatex" + "floss-arduino.pyd" 1619675611 2332 c5208dff91448c4eea3e3ffebb6bf647 "pdflatex" "floss-arduino.tex" 1619403261 4558 99e8133d713ce68a01e2f2b59b0d6baf "" - "floss-arduino.toc" 1619519863 15542 fb05de791c4ca3fd940dd9d8123499fb "pdflatex" + "floss-arduino.toc" 1619675611 15542 cdf96d287f44222c7cc31ea895beb509 "pdflatex" "suppl/acr.tex" 1615963613 1926 fd6481c4666ee0d60331b7d4cc24b645 "" "suppl/intro.tex" 1615963613 3437 b09628cf9e20fe17fa65b37a5997653c "" "suppl/styles.tex" 1615963613 8143 aa3280f0b59c8631fe8ec44895c9e871 "" "tools/arduino-firmware/arduino-firmware.ino" 1615963613 34362 dce80fc83f2a12c5a28422b7712bc3ac "" "tools/julia/test_firmware.jl" 1619056276 168 3aaf8bf98ff271a626085f256b5bbbc9 "" - "tools/openmodelica/test_firmware.mo" 1619400452 616 087d18e8525d7f7e7b49bc700b2d08e4 "" - "tools/python/test_firmware.py" 1619119844 702 b3a122a1ebadec0840b6fc550c5e4e97 "" + "tools/openmodelica/windows//test_firmware.mo" 1619499532 616 087d18e8525d7f7e7b49bc700b2d08e4 "" + "tools/python/test_firmware.py" 1619660611 702 075224ba07fdcb46e41c20e2e4c001be "" "tools/scilab/test_firmware.sce" 1619392691 121 068cb1b11cc5bef7c9f9ddaa09316c22 "" "tools/shield/pcb_board_V1p2.png" 1615963613 39034 e737286dfaa03f083b37af936149ad4d "" "tools/shield/shield-V1p2.jpg" 1615963613 221681 3be329dcc0590284c83508bfc96ede10 "" @@ -211,12 +217,12 @@ "user-code/ldr/scilab/ldr-read.sce" 1615963614 365 2baf1b4875c7cad242e65a3708abc113 "" "user-code/led/OpenModelica/led-blue-delay.mo" 1619402012 1038 e68c66c652fb55ef6e6e7826db23784a "" "user-code/led/OpenModelica/led-blue-red.mo" 1619402018 1153 936d3de74c2858225d14f194e8dad81b "" - "user-code/led/OpenModelica/led-blue.mo" 1619402001 797 41e35c788c1181860958bd528270b5f2 "" + "user-code/led/OpenModelica/led-blue.mo" 1619664517 797 637792619e79706e15fa30426a6fb517 "" "user-code/led/OpenModelica/led-green-blink.mo" 1619402026 1092 2cf4b168f1de4b87c38b18892c3a5e35 "" - "user-code/led/arduino/led-blue-delay/led-blue-delay.ino" 1615963614 131 e1d65f6bf12ce001f58bce4b6329eb63 "" - "user-code/led/arduino/led-blue-red/led-blue-red.ino" 1615963614 209 b38328526259cf1e17b49c57c444af0b "" - "user-code/led/arduino/led-blue/led-blue.ino" 1615963614 97 4006c8c86295abd9738d078b66a4a9e2 "" - "user-code/led/arduino/led-green-blink/led-green-blink.ino" 1615963614 367 d039d0b254aa0be872e45337dbc97184 "" + "user-code/led/arduino/led-blue-delay/led-blue-delay.ino" 1619653754 134 a265af0df0c837b3860a1bd8f4f17db3 "" + "user-code/led/arduino/led-blue-red/led-blue-red.ino" 1619653892 215 db5fdea678579e2b65dbcaddcca033c6 "" + "user-code/led/arduino/led-blue/led-blue.ino" 1619653669 99 25f30fcd7cc7d7b6b9aa222deff00437 "" + "user-code/led/arduino/led-green-blink/led-green-blink.ino" 1619653924 375 d859b4f26e521d4c1afe19f92c8a1ebe "" "user-code/led/figures/arduino-shield.JPG" 1615963614 6411797 2af753c9693c789bfeac0924e48d8062 "" "user-code/led/figures/led-blue-delay.png" 1615963614 24224 74fb9d7d47c0e80095ffd6941b94d7ed "" "user-code/led/figures/led-blue-red.png" 1615963614 33412 93a5fd2d5f2d8434e507136db11da0fc "" @@ -226,19 +232,19 @@ "user-code/led/figures/led_output.png" 1615963614 4933000 3daaef0abe81c66166eaa3fd911c9b66 "" "user-code/led/figures/rgb-led-bb.png" 1617583787 241915 7c5374def5f441085b2d93294dde7979 "" "user-code/led/figures/schematic.png" 1615963614 34562 2b5d2cb148a99242ffb4343097ced0a0 "" - "user-code/led/julia/led-blue-delay.jl" 1617923870 207 8a24e990eb002c6a4cf928b4f8ccb078 "" + "user-code/led/julia/led-blue-delay.jl" 1619663062 213 dd9c8a8b157baac9432478c33b8aa14e "" "user-code/led/julia/led-blue-red.jl" 1617923932 320 02d5d14ebbd49cd33b25a9828492945c "" - "user-code/led/julia/led-blue.jl" 1617923605 166 56d4924e6b7ef1cf57697194acb4e2a1 "" - "user-code/led/julia/led-green-blink.jl" 1617924319 243 1268c421bda565d0155d8da74276243f "" - "user-code/led/led.tex" 1619402170 43411 44688d61fae0e4f52adac537917fa9e5 "" - "user-code/led/python/led-blue-delay.py" 1567596780 833 babefa03765e8de3166a7183bb9dea89 "" - "user-code/led/python/led-blue-red.py" 1567596768 1027 6d7d523452db15fd0dc6861ba415eb9b "" - "user-code/led/python/led-blue.py" 1606995624 735 58dfc81f1d62cfc75e56cc9c3485031b "" - "user-code/led/python/led-green-blink.py" 1617229276 790 a24c9d2a3c5eea736979846513ca943d "" - "user-code/led/scilab/led-blue-delay.sce" 1619400747 296 dc571fad7e86d3264301dc3de67ab806 "" - "user-code/led/scilab/led-blue-red.sce" 1615963614 522 35bdc246bc0acd9abb88f82797fb02d1 "" - "user-code/led/scilab/led-blue.sce" 1619400737 257 77b591aba40f3774647c6b377db83a30 "" - "user-code/led/scilab/led-green-blink.sce" 1619401084 475 6f4d44735a8dd64f1ba9b6fd22b923b2 "" + "user-code/led/julia/led-blue.jl" 1619662025 170 c9cc13e4fb6e898855537bb9e1f2a787 "" + "user-code/led/julia/led-green-blink.jl" 1619663087 249 d785472e844af87c34e32322ccb211e2 "" + "user-code/led/led.tex" 1619675949 46886 06bfa7a5ec243765f9446b7dd1d08158 "" + "user-code/led/python/led-blue-delay.py" 1619660150 805 9c5bde89850fc3b25ced778dfafe1dcf "" + "user-code/led/python/led-blue-red.py" 1619660175 1039 339cefbe997737f931646cba049b8d12 "" + "user-code/led/python/led-blue.py" 1619658381 723 be6248a455119500e6930030c0c92250 "" + "user-code/led/python/led-green-blink.py" 1619660188 800 32d638187fbc636f2341d462458ae87c "" + "user-code/led/scilab/led-blue-delay.sce" 1619654724 306 971bfdb5febffab85ff7e39d9486f19f "" + "user-code/led/scilab/led-blue-red.sce" 1619654755 534 9ed44e179f5f8f2d1833438c6e950670 "" + "user-code/led/scilab/led-blue.sce" 1619654435 264 54ed7e9095e17363e0ce5fb00cade1d1 "" + "user-code/led/scilab/led-green-blink.sce" 1619654799 484 6075a3408ac416b1a08b9812441b114f "" "user-code/modbus/OpenModelica/readCurrent.mo" 1615963614 415 303989413cadae961b297f9b27e7fea0 "" "user-code/modbus/OpenModelica/readPower.mo" 1615963614 435 3f5615fb24b7ddbe58cdd8e1bef132ae "" "user-code/modbus/OpenModelica/readVoltage.mo" 1615963614 415 6e1ebbf05cf22f407c8164397a270067 "" @@ -359,7 +365,7 @@ "user-code/sw-env/figures/win-command-prompt.png" 1619057483 18481 e5638717dbbb0533251e1adcbc9b10f0 "" "user-code/sw-env/figures/windows-cmd.png" 1619057155 18559 6c4f07f73f86b74127aa8c76e23f3285 "" "user-code/sw-env/figures/xcos-help.png" 1615963614 87275 3c9b5157ebebe381cd7b5281cdd28482 "" - "user-code/sw-env/sw-env.tex" 1619519847 91046 e1c4d550ba605d0fcf83e61cf05634c3 "" + "user-code/sw-env/sw-env.tex" 1619663671 91043 a59d8a3e5595ba95d1262f4180baa1f8 "" "user-code/thermistor/OpenModelica/therm-buzzer.mo" 1619403721 1236 1f7c67893d838969538060ecfe0ab777 "" "user-code/thermistor/OpenModelica/therm-read.mo" 1619403730 992 a6a3e7a260be69141ff1a6be804a9ae5 "" "user-code/thermistor/arduino/therm-buzzer/therm-buzzer.ino" 1615963614 389 c4216c80dfb4f1f23b090c94fd181a05 "" @@ -382,18 +388,18 @@ "user-code/thermistor/scilab/therm-read.sce" 1615963614 382 5e743c25b50f9d961a2939ce81d7b633 "" "user-code/thermistor/thermistor.tex" 1618567312 25838 1f7c3824e3c28084af6bca0235c3226f "" (generated) - "floss-arduino.lof" - "floss-arduino.log" - "floss-arduino.lot" - "floss-arduino.cod" + "floss-arduino.aux" "floss-arduino.pyd" - "floss-arduino.toc" "floss-arduino.juliad" - "floss-arduino.ard" "floss-arduino.pdf" + "floss-arduino.thm" "floss-arduino.idx" + "floss-arduino.cod" + "floss-arduino.ard" + "floss-arduino.toc" + "floss-arduino.lot" + "floss-arduino.lof" + "/home/fossee/Desktop/floss-scilab-arduino/floss-arduino.pdf" + "floss-arduino.log" "floss-arduino.OpenModelicad" - "floss-arduino.thm" - "floss-arduino.aux" "/home/fossee/Desktop/floss-scilab-arduino/floss-arduino.log" - "/home/fossee/Desktop/floss-scilab-arduino/floss-arduino.pdf" diff --git a/floss-arduino.fls b/floss-arduino.fls index b33537a..79cb162 100644 --- a/floss-arduino.fls +++ b/floss-arduino.fls @@ -374,9 +374,9 @@ INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/om-sim- INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/om-toolbox-loaded.png INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/om-toolbox-loaded.png INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/om-toolbox-loaded.png -INPUT /home/fossee/Desktop/floss-scilab-arduino/tools/openmodelica/test_firmware.mo -INPUT /home/fossee/Desktop/floss-scilab-arduino/tools/openmodelica/test_firmware.mo -INPUT /home/fossee/Desktop/floss-scilab-arduino/tools/openmodelica/test_firmware.mo +INPUT /home/fossee/Desktop/floss-scilab-arduino/tools/openmodelica/windows//test_firmware.mo +INPUT /home/fossee/Desktop/floss-scilab-arduino/tools/openmodelica/windows//test_firmware.mo +INPUT /home/fossee/Desktop/floss-scilab-arduino/tools/openmodelica/windows//test_firmware.mo INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/led.tex INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/led.tex INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/figures/led.png @@ -464,6 +464,30 @@ INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/figures/led-green- INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue.py INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue.py INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue.py +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue.py +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue.py +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue.py +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue.py +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue.py +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue.py +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue.py +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue.py +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue.py +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue.py +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue.py +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue.py +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue.py +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue.py +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue.py +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue-delay.py +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue-delay.py +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue-delay.py +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue-delay.py +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue-delay.py +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue-delay.py +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue.py +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue.py +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue.py INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue-delay.py INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue-delay.py INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue-delay.py @@ -476,6 +500,24 @@ INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-green-b INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led-blue.jl INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led-blue.jl INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led-blue.jl +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led-blue.jl +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led-blue.jl +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led-blue.jl +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led-blue.jl +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led-blue.jl +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led-blue.jl +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led-blue.jl +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led-blue.jl +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led-blue.jl +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led-blue-delay.jl +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led-blue-delay.jl +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led-blue-delay.jl +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led-blue-delay.jl +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led-blue-delay.jl +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led-blue-delay.jl +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led-blue.jl +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led-blue.jl +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led-blue.jl INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led-blue-delay.jl INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led-blue-delay.jl INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led-blue-delay.jl @@ -488,6 +530,24 @@ INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led-green-bl INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led-blue.mo INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led-blue.mo INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led-blue.mo +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led-blue.mo +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led-blue.mo +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led-blue.mo +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led-blue.mo +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led-blue.mo +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led-blue.mo +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led-blue.mo +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led-blue.mo +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led-blue.mo +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led-blue-delay.mo +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led-blue-delay.mo +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led-blue-delay.mo +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led-blue-delay.mo +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led-blue-delay.mo +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led-blue-delay.mo +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led-blue.mo +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led-blue.mo +INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led-blue.mo INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led-blue-delay.mo INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led-blue-delay.mo INPUT /home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led-blue-delay.mo diff --git a/floss-arduino.juliad b/floss-arduino.juliad index 3df1b52..21e1b09 100644 --- a/floss-arduino.juliad +++ b/floss-arduino.juliad @@ -1,9 +1,9 @@ \contentsline {section}{\numberline {3.{1}}A Julia source file to check whether the firmware is properly installed or not}{56}% \addvspace {10pt} \contentsline {section}{\numberline {4.{1}}Turning on the LED}{90}% -\contentsline {section}{\numberline {4.{2}}Turning on the blue LED and turning it off after two seconds}{91}% -\contentsline {section}{\numberline {4.{3}}Turning on blue and red LEDs for 5 seconds and then turning them off one by one}{91}% -\contentsline {section}{\numberline {4.{4}}Blinking the green LED}{91}% +\contentsline {section}{\numberline {4.{2}}Turning on the blue LED and turning it off after two seconds}{90}% +\contentsline {section}{\numberline {4.{3}}Turning on blue and red LEDs for 5 seconds and then turning them off one by one}{90}% +\contentsline {section}{\numberline {4.{4}}Blinking the green LED}{90}% \addvspace {10pt} \contentsline {section}{\numberline {5.{1}}Read the status of the pushbutton and displaying on the serial monitor}{109}% \contentsline {section}{\numberline {5.{2}}Turning the LED on or off depending on the pushbutton}{110}% diff --git a/floss-arduino.lof b/floss-arduino.lof index 9b54ccb..f9cc51b 100644 --- a/floss-arduino.lof +++ b/floss-arduino.lof @@ -60,7 +60,7 @@ \addvspace {10\p@ } \contentsline {figure}{\numberline {4.1}{\ignorespaces Light Emitting Diode\relax }}{69}% \contentsline {figure}{\numberline {4.2}{\ignorespaces Internal connection diagram for LED on the shield\relax }}{70}% -\contentsline {figure}{\numberline {4.3}{\ignorespaces Connecting Arduino and Shield\relax }}{70}% +\contentsline {figure}{\numberline {4.3}{\ignorespaces Connecting Arduino Uno\ and shield\relax }}{70}% \contentsline {figure}{\numberline {4.4}{\ignorespaces Interfacing an RGB LED with Arduino Uno using a breadboard\relax }}{71}% \contentsline {figure}{\numberline {4.5}{\ignorespaces LED experiments directly on Arduino Uno\ board, without the shield\relax }}{74}% \contentsline {figure}{\numberline {4.6}{\ignorespaces Turning the blue LED on through Xcos}}{79}% diff --git a/floss-arduino.log b/floss-arduino.log index 62224ac..689a5d9 100644 --- a/floss-arduino.log +++ b/floss-arduino.log @@ -1,4 +1,4 @@ -This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019/Debian) (preloaded format=pdflatex 2020.11.5) 27 APR 2021 16:08 +This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019/Debian) (preloaded format=pdflatex 2020.11.5) 29 APR 2021 11:29 entering extended mode restricted \write18 enabled. %&-line parsing enabled. @@ -1102,7 +1102,7 @@ fvm/m/n/10.95 pip show pyserial [45] [46] (/home/fossee/Desktop/floss-scilab-arduino/tools/python/test_firmware.py) -Underfull \vbox (badness 7030) has occurred while \output is active [] +Underfull \vbox (badness 10000) has occurred while \output is active [] [47] </home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/julia-downl @@ -1112,7 +1112,7 @@ download.png Graphic file (type png) <use /home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/julia-d ownload.png> Package pdftex.def Info: /home/fossee/Desktop/floss-scilab-arduino/user-code/sw --env/figures/julia-download.png used on input line 1162. +-env/figures/julia-download.png used on input line 1163. (pdftex.def) Requested size: 397.48499pt x 164.34962pt. </home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/julia-windo ws-install.png, id=304, 756.8275pt x 632.3625pt> @@ -1121,7 +1121,7 @@ windows-install.png Graphic file (type png) <use /home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/julia-w indows-install.png> Package pdftex.def Info: /home/fossee/Desktop/floss-scilab-arduino/user-code/sw --env/figures/julia-windows-install.png used on input line 1169. +-env/figures/julia-windows-install.png used on input line 1170. (pdftex.def) Requested size: 258.36281pt x 215.86882pt. [48] [49 </home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/ju @@ -1134,7 +1134,7 @@ repl-windows.png Graphic file (type png) <use /home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/julia-r epl-windows.png> Package pdftex.def Info: /home/fossee/Desktop/floss-scilab-arduino/user-code/sw --env/figures/julia-repl-windows.png used on input line 1217. +-env/figures/julia-repl-windows.png used on input line 1218. (pdftex.def) Requested size: 397.48499pt x 225.70088pt. </home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/julia-pkg-w indows.png, id=315, 1353.055pt x 768.8725pt> @@ -1143,7 +1143,7 @@ pkg-windows.png Graphic file (type png) <use /home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/julia-p kg-windows.png> Package pdftex.def Info: /home/fossee/Desktop/floss-scilab-arduino/user-code/sw --env/figures/julia-pkg-windows.png used on input line 1226. +-env/figures/julia-pkg-windows.png used on input line 1227. (pdftex.def) Requested size: 397.48499pt x 225.86513pt. [50] @@ -1152,13 +1152,13 @@ LaTeX Warning: Text page 51 contains only floats. [51 </home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/julia-r epl-windows.png> </home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/fi gures/julia-pkg-windows.png>] -Overfull \hbox (5.34262pt too wide) in paragraph at lines 1250--1252 +Overfull \hbox (5.34262pt too wide) in paragraph at lines 1251--1253 []\T1/cmr/m/n/10.95 First, up-date your sys-tem. Open the Ter-mi-nal. Type \T1/ fvm/m/n/10.95 sudo apt-get update [] -Overfull \hbox (12.2196pt too wide) in paragraph at lines 1267--1271 +Overfull \hbox (12.2196pt too wide) in paragraph at lines 1268--1272 \T1/fvm/m/n/10.95 sudo ln -s /opt/julia-1.6.0/bin/julia /usr/local/bin/julia [] @@ -1170,7 +1170,7 @@ terminal-repl.png Graphic file (type png) <use /home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/julia-t erminal-repl.png> Package pdftex.def Info: /home/fossee/Desktop/floss-scilab-arduino/user-code/sw --env/figures/julia-terminal-repl.png used on input line 1298. +-env/figures/julia-terminal-repl.png used on input line 1299. (pdftex.def) Requested size: 397.48499pt x 274.37646pt. [53] </home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/julia-pkg.p @@ -1180,7 +1180,7 @@ pkg.png Graphic file (type png) <use /home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/julia-p kg.png> Package pdftex.def Info: /home/fossee/Desktop/floss-scilab-arduino/user-code/sw --env/figures/julia-pkg.png used on input line 1328. +-env/figures/julia-pkg.png used on input line 1329. (pdftex.def) Requested size: 397.48499pt x 274.37646pt. Underfull \vbox (badness 3219) has occurred while \output is active [] @@ -1197,10 +1197,10 @@ delica-run-anyway.png Graphic file (type png) <use /home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/openmod elica-run-anyway.png> Package pdftex.def Info: /home/fossee/Desktop/floss-scilab-arduino/user-code/sw --env/figures/openmodelica-run-anyway.png used on input line 1428. +-env/figures/openmodelica-run-anyway.png used on input line 1430. (pdftex.def) Requested size: 258.36281pt x 238.55693pt. -Overfull \hbox (13.35912pt too wide) in paragraph at lines 1433--1439 +Overfull \hbox (13.35912pt too wide) in paragraph at lines 1435--1441 []\T1/cmr/m/n/10.95 Once Open-Mod-el-ica has been in-stalled, Open-Mod-el-ica C on-nec-tion Ed-i-tor (OMEdit) [] @@ -1212,7 +1212,7 @@ File: /home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/OMEdit <use /home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/OMEdit- libraries.png> Package pdftex.def Info: /home/fossee/Desktop/floss-scilab-arduino/user-code/sw --env/figures/OMEdit-libraries.png used on input line 1452. +-env/figures/OMEdit-libraries.png used on input line 1454. (pdftex.def) Requested size: 365.46649pt x 300.32292pt. [57] [58 </home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/op enmodelica-run-anyway.png>] @@ -1223,7 +1223,7 @@ File: /home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/OMEdit <use /home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/OMEdit- UI.png> Package pdftex.def Info: /home/fossee/Desktop/floss-scilab-arduino/user-code/sw --env/figures/OMEdit-UI.png used on input line 1484. +-env/figures/OMEdit-UI.png used on input line 1486. (pdftex.def) Requested size: 397.48499pt x 238.5865pt. [59 </home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/OMEdit -libraries.png>] @@ -1234,7 +1234,7 @@ n-model.png Graphic file (type png) <use /home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/om-open -model.png> Package pdftex.def Info: /home/fossee/Desktop/floss-scilab-arduino/user-code/sw --env/figures/om-open-model.png used on input line 1498. +-env/figures/om-open-model.png used on input line 1500. (pdftex.def) Requested size: 397.48499pt x 289.94313pt. </home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/om-Modeling .png, id=359, 1368.11125pt x 791.95876pt> @@ -1243,7 +1243,7 @@ eling.png Graphic file (type png) <use /home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/om-Mode ling.png> Package pdftex.def Info: /home/fossee/Desktop/floss-scilab-arduino/user-code/sw --env/figures/om-Modeling.png used on input line 1505. +-env/figures/om-Modeling.png used on input line 1507. (pdftex.def) Requested size: 397.48499pt x 230.08511pt. </home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/om-modeling -views.png, id=360, 673.01437pt x 373.395pt> @@ -1252,7 +1252,7 @@ eling-views.png Graphic file (type png) <use /home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/om-mode ling-views.png> Package pdftex.def Info: /home/fossee/Desktop/floss-scilab-arduino/user-code/sw --env/figures/om-modeling-views.png used on input line 1513. +-env/figures/om-modeling-views.png used on input line 1515. (pdftex.def) Requested size: 397.48499pt x 220.52904pt. </home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/om-text-vie w.png, id=361, 1370.11874pt x 796.9775pt> @@ -1261,7 +1261,7 @@ t-view.png Graphic file (type png) <use /home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/om-text -view.png> Package pdftex.def Info: /home/fossee/Desktop/floss-scilab-arduino/user-code/sw --env/figures/om-text-view.png used on input line 1521. +-env/figures/om-text-view.png used on input line 1523. (pdftex.def) Requested size: 397.48499pt x 231.20267pt. [60 </home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/OMEdit -UI.png>] @@ -1272,7 +1272,7 @@ ulate.png Graphic file (type png) <use /home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/om-simu late.png> Package pdftex.def Info: /home/fossee/Desktop/floss-scilab-arduino/user-code/sw --env/figures/om-simulate.png used on input line 1550. +-env/figures/om-simulate.png used on input line 1552. (pdftex.def) Requested size: 397.48499pt x 220.52904pt. </home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/om-sim-succ ess.png, id=367, 647.41875pt x 516.93124pt> @@ -1281,7 +1281,7 @@ File: /home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/om-sim <use /home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/om-sim- success.png> Package pdftex.def Info: /home/fossee/Desktop/floss-scilab-arduino/user-code/sw --env/figures/om-sim-success.png used on input line 1557. +-env/figures/om-sim-success.png used on input line 1559. (pdftex.def) Requested size: 397.48499pt x 317.37051pt. [61 </home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/om-ope n-model.png>] @@ -1297,20 +1297,20 @@ LaTeX Warning: Text page 63 contains only floats. [63 </home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/om-text -view.png> </home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/ om-simulate.png>] -Overfull \hbox (0.4131pt too wide) in paragraph at lines 1568--1575 +Overfull \hbox (0.4131pt too wide) in paragraph at lines 1570--1577 \T1/fvm/m/n/10.95 openmodelica/windows \T1/cmr/m/n/10.95 or \T1/fvm/m/n/10.95 O rigin/tools/openmodelica/linux \T1/cmr/m/n/10.95 di-rec-tory, [] [64 </home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/om-sim- success.png>] -Overfull \hbox (4.19868pt too wide) in paragraph at lines 1586--1588 +Overfull \hbox (4.19868pt too wide) in paragraph at lines 1588--1590 []\T1/cmr/m/n/10.95 Navigate to \T1/fvm/m/n/10.95 Origin/tools/openmodelica/win dows \T1/cmr/m/n/10.95 or \T1/fvm/m/n/10.95 Origin/tools/ [] -Overfull \hbox (5.89722pt too wide) in paragraph at lines 1588--1594 +Overfull \hbox (5.89722pt too wide) in paragraph at lines 1590--1598 \T1/cmr/m/n/10.95 el-ica_Synchronous, Mod-el-ica_DeviceDrivers, and one model t est_firmware.mo. [] @@ -1322,12 +1322,16 @@ lbox-loaded.png Graphic file (type png) <use /home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/om-tool box-loaded.png> Package pdftex.def Info: /home/fossee/Desktop/floss-scilab-arduino/user-code/sw --env/figures/om-toolbox-loaded.png used on input line 1614. +-env/figures/om-toolbox-loaded.png used on input line 1615. (pdftex.def) Requested size: 178.86702pt x 404.66306pt. -[65] [66 </home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figures/om --toolbox-loaded.png>] -(/home/fossee/Desktop/floss-scilab-arduino/tools/openmodelica/test_firmware.mo) -) (./user-code/led/led.tex [67] [68 + +LaTeX Warning: Reference `load-om-toolbox' on page 65 undefined on input line 1 +636. + +[65] +(/home/fossee/Desktop/floss-scilab-arduino/tools/openmodelica/windows//test_fir +mware.mo [66 </home/fossee/Desktop/floss-scilab-arduino/user-code/sw-env/figure +s/om-toolbox-loaded.png>])) (./user-code/led/led.tex [67] [68 ] Chapter 4. @@ -1337,7 +1341,7 @@ File: /home/fossee/Desktop/floss-scilab-arduino/user-code/led/figures/led.png G raphic file (type png) <use /home/fossee/Desktop/floss-scilab-arduino/user-code/led/figures/led.png> Package pdftex.def Info: /home/fossee/Desktop/floss-scilab-arduino/user-code/le -d/figures/led.png used on input line 51. +d/figures/led.png used on input line 52. (pdftex.def) Requested size: 79.49577pt x 44.74203pt. </home/fossee/Desktop/floss-scilab-arduino/user-code/led/figures/schematic.png, id=404, 415.5525pt x 456.70625pt> @@ -1346,7 +1350,7 @@ File: /home/fossee/Desktop/floss-scilab-arduino/user-code/led/figures/schematic <use /home/fossee/Desktop/floss-scilab-arduino/user-code/led/figures/schematic. png> Package pdftex.def Info: /home/fossee/Desktop/floss-scilab-arduino/user-code/le -d/figures/schematic.png used on input line 64. +d/figures/schematic.png used on input line 65. (pdftex.def) Requested size: 178.86702pt x 196.58194pt. [69 </home/fossee/Desktop/floss-scilab-arduino/user-code/led/figures/led.png>] </home/fossee/Desktop/floss-scilab-arduino/user-code/led/figures/arduino-shield @@ -1356,7 +1360,7 @@ hield.JPG Graphic file (type jpg) <use /home/fossee/Desktop/floss-scilab-arduino/user-code/led/figures/arduino-sh ield.JPG> Package pdftex.def Info: /home/fossee/Desktop/floss-scilab-arduino/user-code/le -d/figures/arduino-shield.JPG used on input line 78. +d/figures/arduino-shield.JPG used on input line 79. (pdftex.def) Requested size: 178.86702pt x 134.15085pt. [70 </home/fossee/Desktop/floss-scilab-arduino/user-code/led/figures/schematic. @@ -1369,7 +1373,7 @@ b.png Graphic file (type png) <use /home/fossee/Desktop/floss-scilab-arduino/user-code/led/figures/rgb-led-bb .png> Package pdftex.def Info: /home/fossee/Desktop/floss-scilab-arduino/user-code/le -d/figures/rgb-led-bb.png used on input line 106. +d/figures/rgb-led-bb.png used on input line 107. (pdftex.def) Requested size: 357.73405pt x 187.14034pt. [71 </home/fossee/Desktop/floss-scilab-arduino/user-code/led/figures/rgb-led-b b.png>] @@ -1388,10 +1392,10 @@ t.png Graphic file (type png) <use /home/fossee/Desktop/floss-scilab-arduino/user-code/led/figures/led_output .png> Package pdftex.def Info: /home/fossee/Desktop/floss-scilab-arduino/user-code/le -d/figures/led_output.png used on input line 195. +d/figures/led_output.png used on input line 196. (pdftex.def) Requested size: 357.73405pt x 229.47339pt. LaTeX Font Info: Trying to load font information for T1+cmss on input line 2 -07. +08. (/usr/share/texlive/texmf-dist/tex/latex/base/t1cmss.fd File: t1cmss.fd 2019/12/16 v2.5j Standard LaTeX font definitions @@ -1427,10 +1431,10 @@ png Graphic file (type png) <use /home/fossee/Desktop/floss-scilab-arduino/user-code/led/figures/led-blue.p ng> Package pdftex.def Info: /home/fossee/Desktop/floss-scilab-arduino/user-code/le -d/figures/led-blue.png used on input line 393. +d/figures/led-blue.png used on input line 394. (pdftex.def) Requested size: 178.86702pt x 193.29965pt. -Overfull \hbox (4.77844pt too wide) in paragraph at lines 409--418 +Overfull \hbox (4.77844pt too wide) in paragraph at lines 410--419 [][] [] @@ -1442,10 +1446,10 @@ delay.png Graphic file (type png) <use /home/fossee/Desktop/floss-scilab-arduino/user-code/led/figures/led-blue-d elay.png> Package pdftex.def Info: /home/fossee/Desktop/floss-scilab-arduino/user-code/le -d/figures/led-blue-delay.png used on input line 428. +d/figures/led-blue-delay.png used on input line 429. (pdftex.def) Requested size: 178.86702pt x 192.53517pt. -Overfull \hbox (4.77844pt too wide) in paragraph at lines 443--455 +Overfull \hbox (4.77844pt too wide) in paragraph at lines 444--456 [][] [] @@ -1458,10 +1462,10 @@ red.png Graphic file (type png) <use /home/fossee/Desktop/floss-scilab-arduino/user-code/led/figures/led-blue-r ed.png> Package pdftex.def Info: /home/fossee/Desktop/floss-scilab-arduino/user-code/le -d/figures/led-blue-red.png used on input line 466. +d/figures/led-blue-red.png used on input line 467. (pdftex.def) Requested size: 178.86702pt x 247.45784pt. -Overfull \hbox (13.85292pt too wide) in paragraph at lines 482--499 +Overfull \hbox (13.85292pt too wide) in paragraph at lines 483--500 [][] [] @@ -1474,10 +1478,10 @@ File: /home/fossee/Desktop/floss-scilab-arduino/user-code/led/figures/led-green <use /home/fossee/Desktop/floss-scilab-arduino/user-code/led/figures/led-green- blink.png> Package pdftex.def Info: /home/fossee/Desktop/floss-scilab-arduino/user-code/le -d/figures/led-green-blink.png used on input line 509. +d/figures/led-green-blink.png used on input line 510. (pdftex.def) Requested size: 178.86702pt x 182.13731pt. -Overfull \hbox (4.77844pt too wide) in paragraph at lines 524--537 +Overfull \hbox (4.77844pt too wide) in paragraph at lines 525--538 [][] [] @@ -1487,44 +1491,53 @@ Overfull \vbox (31.42311pt too high) has occurred while \output is active [] [82 </home/fossee/Desktop/floss-scilab-arduino/user-code/led/figures/led-green- -blink.png>] [83] -Underfull \hbox (badness 10000) in paragraph at lines 613--617 - - [] - - -Underfull \hbox (badness 10000) in paragraph at lines 618--619 - - [] - - -Underfull \hbox (badness 10000) in paragraph at lines 632--635 - - [] - -[84] +blink.png>] +(/home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue.py) +(/home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue.py) +(/home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue.py) +[83] +(/home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue.py) +(/home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue.py) +(/home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue.py) +(/home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue-delay. +py) +(/home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue-delay. +py) [84] (/home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue.py [85]) (/home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue-delay. -py [86]) +py) (/home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-blue-red.py -[87]) +[86]) (/home/fossee/Desktop/floss-scilab-arduino/user-code/led/python/led-green-blink -.py [88]) [89] +.py [87]) [88] +(/home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led-blue.jl) +(/home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led-blue.jl) +(/home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led-blue.jl) +(/home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led-blue.jl) +(/home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led-blue-delay.j +l) +(/home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led-blue-delay.j +l) [89] (/home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led-blue.jl) -[90] (/home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led-blue-delay.j l) (/home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led-blue-red.jl) (/home/fossee/Desktop/floss-scilab-arduino/user-code/led/julia/led-green-blink. -jl) [91] -Overfull \hbox (2.4842pt too wide) in paragraph at lines 840--841 -[]\T1/cmr/m/n/10.95 sComm.close_serial(1) : This closes the pre-de-fined se-ria -l port which is presently - [] - -[92] +jl [90]) +(/home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led-blue. +mo) +(/home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led-blue. +mo) +(/home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led-blue. +mo) [91] +(/home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led-blue. +mo) +(/home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led-blue- +delay.mo) +(/home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led-blue- +delay.mo) [92] (/home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led-blue. mo) (/home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led-blue- @@ -1532,9 +1545,7 @@ delay.mo [93]) (/home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led-blue- red.mo [94]) (/home/fossee/Desktop/floss-scilab-arduino/user-code/led/OpenModelica/led-green --blink.mo)) (./user-code/push/push.tex [95] [96 - -] +-blink.mo) [95]) (./user-code/push/push.tex [96] Chapter 5. </home/fossee/Desktop/floss-scilab-arduino/user-code/push/figures/pushbutton-co nn.png, id=511, 415.5525pt x 438.63875pt> @@ -1554,7 +1565,9 @@ g> Package pdftex.def Info: /home/fossee/Desktop/floss-scilab-arduino/user-code/pu sh/figures/switch.png used on input line 72. (pdftex.def) Requested size: 397.48499pt x 209.64827pt. -[97] +[97 + +] Underfull \vbox (badness 3098) has occurred while \output is active [] [98 </home/fossee/Desktop/floss-scilab-arduino/user-code/push/figures/pushbutt @@ -2558,10 +2571,10 @@ LaTeX Warning: There were multiply-defined labels. ) Here is how much of TeX's memory you used: - 9792 strings out of 481239 - 212749 string characters out of 5920377 + 9827 strings out of 481239 + 215869 string characters out of 5920377 742688 words of memory out of 5000000 - 24329 multiletter control sequences out of 15000+600000 + 24324 multiletter control sequences out of 15000+600000 554670 words of font info for 69 fonts, out of 8000000 for 9000 1143 hyphenation exceptions out of 8191 50i,11n,53p,467b,1826s stack positions out of 5000i,500n,10000p,200000b,80000s @@ -2588,7 +2601,7 @@ sr/share/texmf/fonts/type1/public/cm-super/sfrm1000.pfb></usr/share/texmf/fonts /type1/public/cm-super/sfrm1095.pfb></usr/share/texmf/fonts/type1/public/cm-sup er/sfsi1095.pfb></usr/share/texmf/fonts/type1/public/cm-super/sfss1095.pfb></us r/share/texmf/fonts/type1/public/cm-super/sfti1095.pfb> -Output written on floss-arduino.pdf (254 pages, 26607527 bytes). +Output written on floss-arduino.pdf (254 pages, 26608779 bytes). PDF statistics: 1134 PDF objects out of 1200 (max. 8388607) 660 compressed objects within 7 object streams diff --git a/floss-arduino.pdf b/floss-arduino.pdf Binary files differindex d5939d3..c241f15 100644 --- a/floss-arduino.pdf +++ b/floss-arduino.pdf diff --git a/floss-arduino.pyd b/floss-arduino.pyd index b13dd9b..4cbcfe2 100644 --- a/floss-arduino.pyd +++ b/floss-arduino.pyd @@ -1,10 +1,10 @@ \addvspace {10pt} \contentsline {section}{\numberline {3.{1}}A Python script to check whether the firmware is properly installed or not}{47}% \addvspace {10pt} -\contentsline {section}{\numberline {4.{1}}Turning on the LED through Python}{85}% +\contentsline {section}{\numberline {4.{1}}Turning on the blue LED through Python}{85}% \contentsline {section}{\numberline {4.{2}}Turning on the blue LED and turning it off after two seconds}{86}% -\contentsline {section}{\numberline {4.{3}}Turning on blue and red LEDs for 5 seconds and then turning them off one by one}{87}% -\contentsline {section}{\numberline {4.{4}}Blinking the green LED}{88}% +\contentsline {section}{\numberline {4.{3}}Turning on blue and red LEDs for 5 seconds and then turning them off one by one}{86}% +\contentsline {section}{\numberline {4.{4}}Blinking the green LED}{87}% \addvspace {10pt} \contentsline {section}{\numberline {5.{1}}Read the status of the pushbutton and displaying on the serial monitor}{107}% \contentsline {section}{\numberline {5.{2}}Turning the LED on or off depending on the pushbutton}{107}% diff --git a/floss-arduino.thm b/floss-arduino.thm index eab2e3a..df8edee 100644 --- a/floss-arduino.thm +++ b/floss-arduino.thm @@ -14,14 +14,15 @@ \contentsline {codemass}{{Scilab Code}{4.{3}}{}}{78}% \contentsline {codemass}{{Scilab Code}{4.{4}}{}}{78}% \contentsline {egmass}{{Exercise}{4.{3}}{}}{81}% +\contentsline {egmass}{{Exercise}{4.{4}}{}}{85}% \contentsline {pymass}{{Python Code}{4.{1}}{}}{85}% \contentsline {pymass}{{Python Code}{4.{2}}{}}{86}% -\contentsline {pymass}{{Python Code}{4.{3}}{}}{87}% -\contentsline {pymass}{{Python Code}{4.{4}}{}}{88}% +\contentsline {pymass}{{Python Code}{4.{3}}{}}{86}% +\contentsline {pymass}{{Python Code}{4.{4}}{}}{87}% \contentsline {juliamass}{{Julia Code}{4.{1}}{}}{90}% -\contentsline {juliamass}{{Julia Code}{4.{2}}{}}{91}% -\contentsline {juliamass}{{Julia Code}{4.{3}}{}}{91}% -\contentsline {juliamass}{{Julia Code}{4.{4}}{}}{91}% +\contentsline {juliamass}{{Julia Code}{4.{2}}{}}{90}% +\contentsline {juliamass}{{Julia Code}{4.{3}}{}}{90}% +\contentsline {juliamass}{{Julia Code}{4.{4}}{}}{90}% \contentsline {OpenModelicamass}{{OpenModelica Code}{4.{1}}{}}{93}% \contentsline {OpenModelicamass}{{OpenModelica Code}{4.{2}}{}}{93}% \contentsline {OpenModelicamass}{{OpenModelica Code}{4.{3}}{}}{94}% diff --git a/floss-arduino.toc b/floss-arduino.toc index 9056f4f..b4d5968 100644 --- a/floss-arduino.toc +++ b/floss-arduino.toc @@ -55,7 +55,7 @@ \contentsline {subsection}{\numberline {3.6.2}Downloading and installing on GNU/Linux Ubuntu}{58}% \contentsline {subsection}{\numberline {3.6.3}Simulating models in OpenModelica}{58}% \contentsline {subsection}{\numberline {3.6.4}OpenModelica Arduino toolbox}{64}% -\contentsline {subsection}{\numberline {3.6.5}Firmware}{66}% +\contentsline {subsection}{\numberline {3.6.5}Firmware}{65}% \contentsline {chapter}{\numberline {4}Interfacing a Light Emitting Diode}{69}% \contentsline {section}{\numberline {4.1}Preliminaries}{69}% \contentsline {section}{\numberline {4.2}Connecting an RGB LED with Arduino Uno\ using a breadboard}{71}% @@ -71,11 +71,11 @@ \contentsline {section}{\numberline {4.6}Lighting the LED from Python}{82}% \contentsline {subsection}{\numberline {4.6.1}Lighting the LED}{82}% \contentsline {subsection}{\numberline {4.6.2}Python Code}{85}% -\contentsline {section}{\numberline {4.7}Lighting the LED from Julia}{89}% -\contentsline {subsection}{\numberline {4.7.1}Lighting the LED}{89}% +\contentsline {section}{\numberline {4.7}Lighting the LED from Julia}{88}% +\contentsline {subsection}{\numberline {4.7.1}Lighting the LED}{88}% \contentsline {subsection}{\numberline {4.7.2}Julia Code}{90}% -\contentsline {section}{\numberline {4.8}Lighting the LED from OpenModelica}{92}% -\contentsline {subsection}{\numberline {4.8.1}Lighting the LED}{92}% +\contentsline {section}{\numberline {4.8}Lighting the LED from OpenModelica}{91}% +\contentsline {subsection}{\numberline {4.8.1}Lighting the LED}{91}% \contentsline {subsection}{\numberline {4.8.2}OpenModelica Code}{93}% \contentsline {chapter}{\numberline {5}Interfacing a Pushbutton}{97}% \contentsline {section}{\numberline {5.1}Preliminaries}{97}% diff --git a/tools/openmodelica/windows/Arduino.mo b/tools/openmodelica/windows/Arduino.mo index 519a631..b65137e 100644 --- a/tools/openmodelica/windows/Arduino.mo +++ b/tools/openmodelica/windows/Arduino.mo @@ -1,1719 +1,1719 @@ -package Arduino
- extends Arduino.SerialCommunication.Icons.GenericICPackage;
-
- package SerialCommunication "Serial Communication Package for Arduino"
- extends Arduino.SerialCommunication.Icons.FunctionLayerIcon;
- import ModelicaReference.Operators;
-
- package Functions
- extends Modelica.Icons.Package;
- import Modelica;
-
- function open_serial "Command to initialize the serial port which is connected to Arduino"
- extends Modelica.Icons.Function;
- input Integer handle, port, baudrate;
- output Integer OK;
-
- external OK = open_serial(handle, port, baudrate) annotation(
- Library = "SerialComm");
- annotation(
- Documentation(info = "<html>
-<h4>Syntax</h4>
-<blockquote><pre>
-Arduino.SerialCommunication.Functions.<b>open_serial</b>(handle,port,baudrate);
-</pre></blockquote>
-<h4>Description</h4>
-<p>
-Establishes a serial communication using port number \"port\".To connect to the Arduino board, check the port number from the device manager or check it from the Arduino software.
-</p>
-</html>"));
- end open_serial;
-
- function read_serial "read characters from serial port"
- extends Modelica.Icons.Function;
- input Integer handle;
- input Integer size;
- output Integer r_OK;
- protected
- Integer buf[size + 1];
-
- external r_OK = read_serial(handle, buf, size) annotation(
- Library = "SerialComm");
- annotation(
- Documentation(info = "<html>
-<h4>Syntax</h4>
-<blockquote><pre>
-Arduino.SerialCommunication.Functions.<b>read_serial</b>(handle,size);
-</pre></blockquote>
-<h4>Description</h4>
-<p>The translation setting of openserial can come in the way, affecting the number of characters effectively read. If that is the case, omitting the parameter n might be a bad idea, as scilab can hang. This would happen if the input stream contains CR or LF characters which are filtered out: in such cases serialstatus counts them, but readserial does not see them and keeps wating (if the blocking mode of openserial was true) until the total number is received.
-</p>
-</html>"));
- end read_serial;
-
- function write_serial "write to the serial port"
- extends Modelica.Icons.Function;
- input Integer handle;
- input String str;
- input Integer size;
- output Integer w_OK;
-
- external w_OK = write_serial(handle, str, size) annotation(
- Library = "SerialComm");
- annotation(
- Documentation(info = "<html>
-<h4>Syntax</h4>
-<blockquote><pre>
-Arduino.SerialCommunication.Functions.<b>write_serial</b>(handle,str,size);
-</pre></blockquote>
-<h4>Description</h4>
-<p>No end of line character is appended to the string; the user might have to add it if the device being talked to requires it. The Tcl command puts -nonewline is used. In addition, the translation mode of openserial can come into way.
-</p>
-</html>"));
- end write_serial;
-
- function close_serial "Command to close the serial port which is connected to Arduino"
- extends Modelica.Icons.Function;
- input Integer handle;
- output Integer c_OK;
-
- external c_OK = close_serial(handle) annotation(
- Library = "SerialComm");
- annotation(
- Documentation(info = "<html>
-<h4>Syntax</h4>
-<blockquote><pre>
-Arduino.SerialCommunication.Functions.<b>close_serial</b>(handle);
-</pre></blockquote>
-<h4>Description</h4>
-<p>Closes the port for serial communication specified by \"handle\".It is important to close the serial port after use, else the port would be busy and restart of Scilab might required to connect to it again.
-</p>
-</html>"));
- end close_serial;
-
- function status_serial "get status of the serial port"
- extends Modelica.Icons.Function;
- input Integer handle;
- output Integer stat_OK;
- protected
- Integer bytes[2];
-
- external stat_OK = status_serial(handle, bytes) annotation(
- Library = "SerialComm");
- annotation(
- Documentation(info = "<html>
-<h4>Syntax</h4>
-<blockquote><pre>
-Arduino.SerialCommunication.Functions.<b>status_serial</b>(handle);
-</pre></blockquote>
-<h4>Description</h4>
-<p>Provides status of serial communication channel specified by \"handle\".Get some information about the number of characters present in the input and output buffers of the serial port, and about the status lines (DTS, CTS, etc.).The translation setting of openserial can come in the way. If the input stream contains CR or LF characters which are filtered out, openserial counts them but readserial does not see them.
-</p>
-</html>"));
- end status_serial;
-
- function cmd_digital_out "Command to sent out digital signal to a connected Arduino board"
- extends Modelica.Icons.Function;
- input Integer h, pin_no, val;
- output Integer digital_w_OK;
-
- external digital_w_OK = cmd_digital_out(h, pin_no, val) annotation(
- Library = "SerialComm");
- annotation(
- Documentation(info = "<html>
-<h4>Syntax</h4>
-<blockquote><pre>
-Arduino.SerialCommunication.Functions.<b>cmd_digital_out</b>(handle,pin_no,value);
-</pre></blockquote>
-<h4>Description</h4>
-<p>The Arduino board has a set of logical ports (digital) that are used for writing or reading data from a component.
-To map a UNO, ports 2-13 are available (0 and 1 are used for serial transmission). For MEGA board, ports 2-53 are available. The port takes the low logic level (0) or logic high (1) which corresponds to the reference voltage.
-</p>
-</html>"));
- end cmd_digital_out;
-
- function cmd_digital_in "Command to read in digital signal from a connected Arduino board"
- extends Modelica.Icons.Function;
- input Integer h, pin_no;
- output Integer digital_in;
-
- external digital_in = cmd_digital_in(h, pin_no) annotation(
- Library = "SerialComm");
- annotation(
- Documentation(info = "<html>
-<h4>Syntax</h4>
-<blockquote><pre>
-Arduino.SerialCommunication.Functions.<b>cmd_digital_in</b>(handle,pin_no);
-</pre></blockquote>
-<h4>Description</h4>
-<p>The Arduino board has a set of logical ports (digital) that are used for writing or reading data from a component.
-To map a UNO, ports 2-13 are available (0 and 1 are used for serial transmission). For MEGA board, ports 2-53 are available. The port takes the low logic level (0) or logic high (1) which corresponds to the reference voltage.
-</p>
-</html>"));
- end cmd_digital_in;
-
- function delay "Provides delay.Suspends Openmodelica."
- extends Modelica.Icons.Function;
- input Integer t;
-
- external delay(t) annotation(
- Library = "SerialComm");
- annotation(
- Documentation(info = "<html>
- <h4>Syntax</h4>
- <blockquote><pre>
- Arduino.SerialCommunication.Functions.<b>delay</b>(milliseconds);
- </pre></blockquote>
- <h4>Description</h4>
- <p>Delay process for specified number of miliseconds specified by the argument. The actual suspension time may be longer because of other activities in the system, or because of the time spent in processing the call.
- </p>
- </html>"));
- end delay;
-
- function cmd_analog_in "Command to read in analog signal from a connected Arduino board"
- extends Modelica.Icons.Function;
- input Integer h, pin_no;
- output Integer val;
-
- external val = cmd_analog_in(h, pin_no) annotation(
- Library = "SerialComm");
- annotation(
- Documentation(info = "<html>
-<h4>Syntax</h4>
-<blockquote><pre>
-Arduino.SerialCommunication.Functions.<b>cmd_analog_in</b>(handle,pin_no);
-</pre></blockquote>
-<h4>Description</h4>
-<p>Arduino UNO board has 6 analog input ports (A0 to A5), the Arduino Mega board has 16 analog input ports (A0 to A15). The 10 bits channels convert the analog input from 0 to 5 volts, to a digital value between 0 and 1023.
-</p>
-</html>"));
- end cmd_analog_in;
-
- function cmd_analog_out "Command to sent out analog signal to a connected Arduino board"
- extends Modelica.Icons.Function;
- input Integer h, pin_no;
- input Real val;
- output Integer analog_w_OK;
-
- external analog_w_OK = cmd_analog_out(h, pin_no, val) annotation(
- Library = "SerialComm");
- annotation(
- Documentation(info = "<html>
-<h4>Syntax</h4>
-<blockquote><pre>
-Arduino.SerialCommunication.Functions.<b>cmd_analog_out</b>(handle,pin_no,val);
-</pre></blockquote>
-<h4>Description</h4>
-<p>The analog outputs of the Arduino Uno is available at the pins 3,5,6,9,10 and 11, while on the Mega board, the outputs are on pins 1-13 and 44-46. It is a bit misleading to use the term 'analog output', because in order to generate this output while minimizing energy losses, the Arduino uses PWM (Pulse Width Modulation) available on these ports. By varying the duty cycle of the PWM is altered the average voltage across the component connected to this port, which has the effect of having a analog output voltage.
-The input port accepts the value from 0 to 255 which is correspoding to the duty cycle of 0 to 100%. In other words, sending 0 to the block will generate 0 V output at the port, 127 generates 2.5V and 255 generates 5V. (the port is 8 bits, so the resolutions of output would be 2^8 =256).
-</p>
-</html>"));
- end cmd_analog_out;
-
- function cmd_analog_in_volt "Command to read in analog signal from a connected Arduino board"
- extends Modelica.Icons.Function;
- input Integer h, pin_no;
- output Integer val;
-
- external val = cmd_analog_in_volt(h, pin_no) annotation(
- Library = "SerialComm");
- annotation(
- Documentation(info = "<html>
- <h4>Syntax</h4>
- <blockquote><pre>
- Arduino.SerialCommunication.Functions.<b>cmd_analog_in_volt</b>(handle,pin_no);
- </pre></blockquote>
- <h4>Description</h4>
- <p>Arduino UNO board has 6 analog input ports (A0 to A5), the Arduino Mega board has 16 analog input ports (A0 to A15). The 10 bits channels convert the analog input from 0 to 5 volts, to a digital value between 0 and 1023. This function scale the reading to 0-5 so the user could get the measured voltage directly.
- </p>
- </html>"));
- end cmd_analog_in_volt;
-
- function cmd_analog_out_volt "Command to sent out analog signal to a connected Arduino board"
- extends Modelica.Icons.Function;
- input Integer h, pin_no;
- input Real val;
- output Integer analog_v_wOK;
-
- external analog_v_wOK = cmd_analog_out_volt(h, pin_no, val) annotation(
- Library = "SerialComm");
- annotation(
- Documentation(info = "<html>
- <h4>Syntax</h4>
- <blockquote><pre>
- Arduino.SerialCommunication.Functions.<b>cmd_analog_out_volt</b>(handle,pin_no,val);
- </pre></blockquote>
- <h4>Description</h4>
- <p>The analog outputs of the Arduino Uno is available at the pins 3,5,6,9,10 and 11, while on the Mega board, the outputs are on pins 1-13 and 44-46. It is a bit misleading to use the term 'analog output', because in order to generate this output while minimizing energy losses, the Arduino uses PWM (Pulse Width Modulation) available on these ports. By varying the duty cycle of the PWM is altered the average voltage across the component connected to this port, which has the effect of having a analog output voltage.
- </p>
- </html>"));
- end cmd_analog_out_volt;
-
- function cmd_dcmotor_setup "Command to setup pins to control DC motor"
- extends Modelica.Icons.Function;
- input Integer handle, driver_type, motor_no, pin1, pin2;
-
- external cmd_dcmotor_setup(handle, driver_type, motor_no, pin1, pin2) annotation(
- Library = "SerialComm");
- annotation(
- Documentation(info = "<html>
- <h4>Syntax</h4>
- <blockquote><pre>
- Arduino.SerialCommunication.Functions.<b>cmd_dcmotor_setup</b>(handle,driver_type,motor_no,pin_no1,pin_no2);
- </pre></blockquote>
- <h4>Description</h4>
- <p>Arduino board does not deliver enough power, so it is necessary to use a H-bridge circuit/IC to control the motor. There are several types of H-bridge IC that do not all operate on the same principle. For example, the L298 requires the use of a PWM signal with current sense. The L293 uses two PWM to set the speed and direction. Ready-to-use Shields are also available.
- Remember that the PWM is 8-bit (0 to 255). The input of the block could accept any value, but it would saturate at +- 255.
- </p>
- </html>"));
- end cmd_dcmotor_setup;
-
- function cmd_dcmotor_run "Command to run DC motor after setting up"
- extends Modelica.Icons.Function;
- input Integer handle, motor_no, val;
-
- external cmd_dcmotor_run(handle, motor_no, val) annotation(
- Library = "SerialComm");
- annotation(
- Documentation(info = "<html>
- <h4>Syntax</h4>
- <blockquote><pre>
- Arduino.SerialCommunication.Functions.<b>cmd_dcmotor_run</b>(handle,motor_no,value);
- </pre></blockquote>
- <h4>Description</h4>
- <p>Arduino board does not deliver enough power, so it is necessary to use a H-bridge circuit/IC to control the motor. There are several types of H-bridge IC that do not all operate on the same principle. For example, the L298 requires the use of a PWM signal with current sense. The L293 uses two PWM to set the speed and direction. Ready-to-use Shields are also available.
- Remember that the PWM is 8-bit (0 to 255). The input of the block could accept any value, but it would saturate at +- 255.
- </p>
- </html>"));
- end cmd_dcmotor_run;
-
- function cmd_dcmotor_release "Command to release pins which have setup for DC motor"
- extends Modelica.Icons.Function;
- input Integer handle, motor_no;
-
- external cmd_dcmotor_release(handle, motor_no) annotation(
- Library = "SerialComm");
- annotation(
- Documentation(info = "<html>
- <h4>Syntax</h4>
- <blockquote><pre>
- Arduino.SerialCommunication.Functions.<b>cmd_dcmotor_release</b>(handle,motor_no);
- </pre></blockquote>
- <h4>Description</h4>
- <p>Arduino board does not deliver enough power, so it is necessary to use a H-bridge circuit/IC to control the motor. There are several types of H-bridge IC that do not all operate on the same principle. For example, the L298 requires the use of a PWM signal with current sense. The L293 uses two PWM to set the speed and direction. Ready-to-use Shields are also available.
- Remember that the PWM is 8-bit (0 to 255). The input of the block could accept any value, but it would saturate at +- 255.
- </p>
- </html>"));
- end cmd_dcmotor_release;
-
- function cmd_servo_attach "Command to attach servo motor to Arduino"
- extends Modelica.Icons.Function;
- input Integer handle, servo_no;
-
- external cmd_servo_attach(handle, servo_no) annotation(
- Library = "SerialComm");
- annotation(
- Documentation(info = "<html>
- <h4>Syntax</h4>
- <blockquote><pre>
- Arduino.SerialCommunication.Functions.<b>cmd_servo_attach</b>(handle,servo_no);
- </pre></blockquote>
- <h4>Description</h4>
- <p>A servomotor is an rotary actuator consist of an electric motor, gears, a potentiometer and an analogue or digital electronics for control. The servomotor usualy used for a position control application (or speed for continuous rotation servos).
- The user must give the command of the position setpoint or desired speed. This command is sent to the actuator in pulses spaced by 10 to 20 ms. The coding of these pulses is made such that a pulse of 1.5 ms corresponding to the centered position (rest), a pulse of 1 ms corresponds to an angle of 90° in the anticlockwise direction, and a pulse 2 ms corresponds to an angle of 90° clockwise. All other pulse widths give intermediate values​​.
- A servomotor for continuous rotation, the pulse width control the rotational speed and the direction. It is recommended to use a voltage regulator to power the servomotor instead of using the Arduino board power. For simplicity, the function takes an input commnad in degrees from 0 to 180. Two actuators can be controlled with this toolbox. (modified version of 3 motors available)
- </p>
- </html>"));
- end cmd_servo_attach;
-
- function cmd_servo_move "Command to run servo motor which has been setup"
- extends Modelica.Icons.Function;
- input Integer handle, servo_no, val;
-
- external cmd_servo_move(handle, servo_no, val) annotation(
- Library = "SerialComm");
- annotation(
- Documentation(info = "<html>
- <h4>Syntax</h4>
- <blockquote><pre>
- Arduino.SerialCommunication.Functions.<b>cmd_servo_move</b>(handle,servo_no,value);
- </pre></blockquote>
- <h4>Description</h4>
- <p>A servomotor is an rotary actuator consist of an electric motor, gears, a potentiometer and an analogue or digital electronics for control. The servomotor usualy used for a position control application (or speed for continuous rotation servos).
- The user must give the command of the position setpoint or desired speed. This command is sent to the actuator in pulses spaced by 10 to 20 ms. The coding of these pulses is made such that a pulse of 1.5 ms corresponding to the centered position (rest), a pulse of 1 ms corresponds to an angle of 90° in the anticlockwise direction, and a pulse 2 ms corresponds to an angle of 90° clockwise. All other pulse widths give intermediate values​​.
- A servomotor for continuous rotation, the pulse width control the rotational speed and the direction. It is recommended to use a voltage regulator to power the servomotor instead of using the Arduino board power. For simplicity, the function takes an input commnad in degrees from 0 to 180. Two actuators can be controlled with this toolbox. (modified version of 3 motors available)
- </p>
- </html>"));
- end cmd_servo_move;
-
- function cmd_servo_detach "Command to release the pin which has been setup for servo motor"
- extends Modelica.Icons.Function;
- input Integer handle, servo_no;
-
- external cmd_servo_attach(handle, servo_no) annotation(
- Library = "SerialComm");
- annotation(
- Documentation(info = "<html>
- <h4>Syntax</h4>
- <blockquote><pre>
- Arduino.SerialCommunication.Functions.<b>cmd_servo_detach</b>(handle,servo_no);
- </pre></blockquote>
- <h4>Description</h4>
- <p>A servomotor is an rotary actuator consist of an electric motor, gears, a potentiometer and an analogue or digital electronics for control. The servomotor usualy used for a position control application (or speed for continuous rotation servos).
- The user must give the command of the position setpoint or desired speed. This command is sent to the actuator in pulses spaced by 10 to 20 ms. The coding of these pulses is made such that a pulse of 1.5 ms corresponding to the centered position (rest), a pulse of 1 ms corresponds to an angle of 90° in the anticlockwise direction, and a pulse 2 ms corresponds to an angle of 90° clockwise. All other pulse widths give intermediate values​​.
- A servomotor for continuous rotation, the pulse width control the rotational speed and the direction. It is recommended to use a voltage regulator to power the servomotor instead of using the Arduino board power. For simplicity, the function takes an input commnad in degrees from 0 to 180. Two actuators can be controlled with this toolbox. (modified version of 3 motors available)
- </p>
- </html>"));
- end cmd_servo_detach;
-
- function ieeesingle2num "ieee-745 floating point converter"
- extends Modelica.Icons.Function;
- input String hexa;
- output Real y;
-
- external y = ieeesingle2num(hexa) annotation(
- Library = "SerialComm");
- annotation(
- Documentation(info = "<html>
-<h4>Syntax</h4>
-<blockquote><pre>
-Arduino.SerialCommunication.Functions.<b>ieeesingle2num</b>(hexa);
-</pre></blockquote>
-<h4>Description</h4>
-<p>Converts an hexadecimal integer to ieee single precision format
- </p>
-</html>"));
- end ieeesingle2num;
-
- function math_floor "Floor function"
- extends Modelica.Icons.Function;
- input Real x;
- output Integer y;
-
- external y = mfloor(x) annotation(
- Library = "SerialComm");
- annotation(
- Documentation(info = "<html>
- <h4>Syntax</h4>
- <blockquote><pre>
- Arduino.SerialCommunication.Functions.<b>math_floor</b>(x);
- </pre></blockquote>
- <h4>Description</h4>
- <p>Returns the greatest integer less than or equal to x
- </p>
- </html>"));
- end math_floor;
-
- package MDD_Servo
- extends Modelica.Icons.Package;
-
- class Init
- extends ExternalObject;
-
- function constructor "Return device handle"
- extends .Modelica.Icons.Function;
- import Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions;
- import Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types;
- import sComm = Arduino.SerialCommunication.Functions;
- import Arduino.SerialCommunication.Functions.MDD_Servo;
- input sComm.Types.Servo_no servo_no;
- output sComm.Functions.MDD_Servo.Init servo;
-
- external "C" servo = MDD_avr_servo_initialize(servo_no) annotation(
- Include = "#include \"/home/souradip/OpenModelica/Resources/Include/MDDAVRServo.h\"");
- end constructor;
-
- function destructor "Destructor"
- extends .Modelica.Icons.Function;
- import Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types;
- import sComm = Arduino.SerialCommunication.Functions;
- import Arduino.SerialCommunication.Functions.MDD_Servo;
- input sComm.Types.Servo_no servo_no "Device handle";
-
- external "C" MDD_avr_servo_finalize(servo_no) annotation(
- Include = "#include \"/home/souradip/OpenModelica/Resources/Include/MDDAVRServo.h\"");
- end destructor;
- end Init;
-
- function Move
- extends Modelica.Icons.Function;
- import sComm = Arduino.SerialCommunication.Functions;
- input sComm.Functions.MDD_Servo.Init servo;
- input Integer value;
-
- external "C" MDD_avr_servo_move(servo, value) annotation(
- Include = "#include \"/home/souradip/OpenModelica/Resources/Include/MDDAVRServo.h\"");
- end Move;
- end MDD_Servo;
- end Functions;
-
- package Examples
- extends Modelica.Icons.ExamplesPackage;
-
- package led
- extends Modelica.Icons.ExamplesPackage;
-
- model led_blue "Turn on Blue LED"
- extends Modelica.Icons.Example;
- import sComm = Arduino.SerialCommunication.Functions;
- import strm = Modelica.Utilities.Streams;
- Integer ok(fixed = false);
- Integer digital_out(fixed = false);
- Integer c_ok(fixed = false);
- algorithm
- when initial() then
- ok := sComm.open_serial(1, 2, 115200) "At port 2 with baudrate of 115200";
- if ok <> 0 then
- strm.print("Check the serial port and try again");
- else
- sComm.delay(1000);
- digital_out := sComm.cmd_digital_out(1, 9, 1) "This will turn ON the blue LED";
- end if;
- c_ok := sComm.close_serial(1) "To close the connection safely";
- end when;
-//strm.print(String(time));
- annotation(
- experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 10));
- end led_blue;
-
- model led_blue_delay "Turn on Blue LED for a period of 2 seconds"
- extends Modelica.Icons.Example;
- import sComm = Arduino.SerialCommunication.Functions;
- import strm = Modelica.Utilities.Streams;
- Integer ok(fixed = false);
- Integer digital_out(fixed = false);
- Integer c_ok(fixed = false);
- algorithm
- when initial() then
- ok := sComm.open_serial(1, 2, 115200) "At port 2 with baudrate of 115200";
- sComm.delay(2000);
- if ok <> 0 then
- strm.print("Check the serial port and try again");
- else
- digital_out := sComm.cmd_digital_out(1, 9, 1) "This will turn the blue LED";
- sComm.delay(2000) "let the blue LED be on for two seconds";
- digital_out := sComm.cmd_digital_out(1, 9, 0) "turn off blue LED";
- sComm.delay(2000) "let the blue LED be off for two seconds";
- end if;
- c_ok := sComm.close_serial(1) "To close the connection safely";
- end when;
-//strm.print(String(time));
- annotation(
- experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 10));
- end led_blue_delay;
-
- model led_blue_red "Turn on Red & Blue LED"
- extends Modelica.Icons.Example;
- import sComm = Arduino.SerialCommunication.Functions;
- import strm = Modelica.Utilities.Streams;
- Integer ok(fixed = false);
- Integer digital_out(fixed = false);
- Integer c_ok(fixed = false);
- algorithm
- when initial() then
- ok := sComm.open_serial(1, 2, 115200) "At port 2 with baudrate of 115200";
- sComm.delay(2000);
- if ok <> 0 then
- strm.print("Check the serial port and try again");
- else
- digital_out := sComm.cmd_digital_out(1, 9, 1) "This will turn the blue LED";
- digital_out := sComm.cmd_digital_out(1, 11, 1) "This will turn the red LED";
- sComm.delay(5000) "Delay for 5 seconds";
- digital_out := sComm.cmd_digital_out(1, 9, 0) "This turns off the blue Led";
- sComm.delay(3000) "Delay for 3 seconds";
- digital_out := sComm.cmd_digital_out(1, 11, 0) "This turns off the red Led";
- end if;
- c_ok := sComm.close_serial(1) "To close the connection safely";
- end when;
-//strm.print(String(time));
- annotation(
- experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 10));
- end led_blue_red;
-
- model led_green_blink "This will turn on and turn off the green LED for every second for 5 times"
- extends Modelica.Icons.Example;
- import sComm = Arduino.SerialCommunication.Functions;
- import strm = Modelica.Utilities.Streams;
- Integer ok(fixed = false);
- Integer digital_out(fixed = false);
- Integer c_ok(fixed = false);
- algorithm
- when initial() then
- ok := sComm.open_serial(1, 2, 115200) "At port 2 with baudrate of 115200";
- sComm.delay(2000);
- if ok <> 0 then
- strm.print("Check the serial port and try again");
- else
- for i in 1:10 loop
- digital_out := sComm.cmd_digital_out(1, 10, 1) "This will turn off the green LED";
- sComm.delay(1000) "Delay for 1 second";
- digital_out := sComm.cmd_digital_out(1, 10, 0) "This turns the green Led";
- sComm.delay(1000) "Delay for 1 second";
- end for;
- end if;
- c_ok := sComm.close_serial(1) "To close the connection safely";
- end when;
-// strm.print(String(time));
- annotation(
- experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 10));
- end led_green_blink;
- end led;
-
- package push
- extends Modelica.Icons.ExamplesPackage;
-
- model led_push_button "Conrolling LED with PushButton"
- extends Modelica.Icons.Example;
- import sComm = Arduino.SerialCommunication.Functions;
- import strm = Modelica.Utilities.Streams;
- Integer ok(fixed = false);
- Integer digital_in(fixed = false);
- Integer digital_out(fixed = false);
- Integer c_ok(fixed = false);
- algorithm
- when initial() then
- ok := sComm.open_serial(1, 2, 115200) "At port 2 with baudrate of 115200";
- sComm.delay(2000);
- end when;
- if ok <> 0 then
- strm.print("Unable to open serial port, please check");
- else
- digital_in := sComm.cmd_digital_in(1, 12) "";
- if digital_in == 0 then
- strm.print("0");
- digital_out := sComm.cmd_digital_out(1, 9, 0) "This will turn OFF the blue LED";
- sComm.delay(200);
- else
- strm.print("1");
- digital_out := sComm.cmd_digital_out(1, 9, 1) "This will turn ON the blue LED";
- sComm.delay(200);
- end if;
- end if;
-//for i in 1:1000 loop
-//end for;
-// strm.print(String(time));
- when terminal() then
- c_ok := sComm.close_serial(1) "To close the connection safely";
- end when;
- annotation(
- experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 0.1));
- end led_push_button;
-
- model push_button_status "Checking Status of PushButton"
- extends Modelica.Icons.Example;
- import sComm = Arduino.SerialCommunication.Functions;
- import strm = Modelica.Utilities.Streams;
- Integer ok(fixed = false);
- Integer digital_in(fixed = false);
- Integer c_ok(fixed = false);
- algorithm
- when initial() then
- ok := sComm.open_serial(1, 2, 115200) "At port 2 with baudrate of 115200";
- end when;
- if ok <> 0 then
- strm.print("Unable to open serial port, please check");
- else
- digital_in := sComm.cmd_digital_in(1, 12);
- if digital_in == 0 then
- strm.print("0");
- sComm.delay(200);
- else
- strm.print("1");
- sComm.delay(200);
- end if;
- end if;
-//for i in 1:1000 loop
-//end for;
- when terminal() then
- c_ok := sComm.close_serial(1) "To close the connection safely";
- end when;
-//sComm.cmd_arduino_meter(digital_in);
- annotation(
- experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 0.1));
- end push_button_status;
- end push;
-
- package ldr
- extends Modelica.Icons.ExamplesPackage;
-
- model ldr_led "LED indicating light sensor readings"
- extends Modelica.Icons.Example;
- import sComm = Arduino.SerialCommunication.Functions;
- import strm = Modelica.Utilities.Streams;
- Integer ok(fixed = false);
- Integer analog_in(fixed = false);
- Integer digital_out(fixed = false);
- Integer c_ok(fixed = false);
- algorithm
- when initial() then
- ok := sComm.open_serial(1, 2, 115200) "At port 2 with baudrate of 115200";
- sComm.delay(2000);
- end when;
- if ok <> 0 then
- strm.print("Unable to open serial port, please check");
- else
- analog_in := sComm.cmd_analog_in(1, 5) "read analog pin 5 (ldr)";
- strm.print("LDR Readings: " + String(analog_in));
- if analog_in < 300 then
- digital_out := sComm.cmd_digital_out(1, 9, 1) "Turn ON LED";
- else
- digital_out := sComm.cmd_digital_out(1, 9, 0) "Turn OFF LED";
- end if;
- sComm.delay(500);
- end if;
-//strm.print(String(time));
- when time >= 10 then
- c_ok := sComm.close_serial(1) "To close the connection safely";
- end when;
-//Setting Threshold value of 300
- annotation(
- experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 0.2));
- end ldr_led;
-
- model ldr_read "Reading light intensity using ldr"
- extends Modelica.Icons.Example;
- import sComm = Arduino.SerialCommunication.Functions;
- import strm = Modelica.Utilities.Streams;
- Integer ok(fixed = false);
- Integer analog_in(fixed = false);
- Integer c_ok(fixed = false);
- algorithm
- when initial() then
- ok := sComm.open_serial(1, 2, 115200) "At port 2 with baudrate of 115200";
- sComm.delay(2000);
- end when;
- if ok <> 0 then
- strm.print("Unable to open serial port, please check");
- else
- analog_in := sComm.cmd_analog_in(1, 5) "read analog pin 5 (ldr)";
- strm.print("LDR Readings: " + String(analog_in));
- sComm.delay(500);
- end if;
- when time >= 10 then
- c_ok := sComm.close_serial(1) "To close the connection safely";
- end when;
- annotation(
- experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 1));
- end ldr_read;
- end ldr;
-
- package pot
- extends Modelica.Icons.ExamplesPackage;
-
- model pot_threshold
- extends Modelica.Icons.Example;
- import sComm = Arduino.SerialCommunication.Functions;
- import strm = Modelica.Utilities.Streams;
- Integer ok(fixed = false);
- Integer analog_in(fixed = false);
- Integer digital_out(fixed = false);
- Integer c_ok(fixed = false);
- algorithm
- when initial() then
- ok := sComm.open_serial(1, 2, 115200) "At port 2 with baudrate of 115200";
- end when;
- if ok <> 0 then
- strm.print("Unable to open serial port, please check");
- else
- analog_in := sComm.cmd_analog_in(1, 2) "read analog pin 2";
- strm.print("Potentiometer Readings: " + String(analog_in));
- if analog_in >= 0 and analog_in < 320 then
- digital_out := sComm.cmd_digital_out(1, 11, 1) "Turn ON LED";
- sComm.delay(1000);
- digital_out := sComm.cmd_digital_out(1, 11, 0) "Turn OFF LED";
- elseif analog_in >= 320 and analog_in <= 900 then
- digital_out := sComm.cmd_digital_out(1, 10, 1) "Turn ON LED";
- sComm.delay(1000);
- digital_out := sComm.cmd_digital_out(1, 10, 0) "Turn OFF LED";
- elseif analog_in > 900 and analog_in <= 1023 then
- digital_out := sComm.cmd_digital_out(1, 9, 1) "Turn ON LED";
- sComm.delay(1000);
- digital_out := sComm.cmd_digital_out(1, 9, 0) "Turn OFF LED";
- end if;
- end if;
- digital_out := sComm.cmd_digital_out(1, 9, 0) "Turn OFF LED";
- digital_out := sComm.cmd_digital_out(1, 10, 0) "Turn OFF LED";
- digital_out := sComm.cmd_digital_out(1, 11, 0) "Turn OFF LED";
-//Threshold 1
-//Threshold 2
- when time >= 10 then
- c_ok := sComm.close_serial(1) "To close the connection safely";
- end when;
- annotation(
- experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 1));
- end pot_threshold;
- end pot;
-
- package thermistor
- extends Modelica.Icons.ExamplesPackage;
-
- model therm_buzzer "Sound buzzer depending on thermistor readings"
- extends Modelica.Icons.Example;
- import sComm = Arduino.SerialCommunication.Functions;
- import strm = Modelica.Utilities.Streams;
- Integer ok(fixed = false);
- Integer analog_in(fixed = false);
- Integer digital_out(fixed = false);
- Integer c_ok(fixed = false);
- algorithm
- when initial() then
- ok := sComm.open_serial(1, 2, 115200) "At port 2 with baudrate of 115200";
- sCOmm.delay(2000);
- end when;
- if ok <> 0 then
- strm.print("Unable to open serial port, please check");
- else
- analog_in := sComm.cmd_analog_in(1, 4) "read analog pin 4";
- strm.print("Thermistor Readings: " + String(analog_in));
- if analog_in > 550 then
- digital_out := sComm.cmd_digital_out(1, 3, 1) "Turn ON Buzzer";
- else
- digital_out := sComm.cmd_digital_out(1, 3, 0) "Turn OFF Buzzer";
- end if;
- sComm.delay(500);
- end if;
-//for i in 1:500 loop
-//end for;
-//Run for 500 iterations
-//Setting Threshold value of 500
- when terminal() then
- c_ok := sComm.close_serial(1) "To close the connection safely";
- end when;
- annotation(
- experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 0.1));
- end therm_buzzer;
-
- model therm_read "Thermistor Readings"
- extends Modelica.Icons.Example;
- import sComm = Arduino.SerialCommunication.Functions;
- import strm = Modelica.Utilities.Streams;
- Integer ok(fixed = false);
- Integer analog_in(fixed = false);
- Integer c_ok(fixed = false);
- algorithm
- when initial() then
- ok := sComm.open_serial(1, 2, 115200) "At port 2 with baudrate of 115200";
- sComm.delay(2000);
- end when;
- if ok <> 0 then
- strm.print("Unable to open serial port, please check");
- else
- analog_in := sComm.cmd_analog_in(1, 4) "read analog pin 5 (ldr)";
- strm.print("Thermistor Readings: " + String(analog_in));
- sComm.delay(500);
- end if;
- when terminal() then
- c_ok := sComm.close_serial(1) "To close the connection safely";
- end when;
- annotation(
- experiment(StartTime = 0, StopTime = 20, Tolerance = 1e-6, Interval = 1));
- end therm_read;
- end thermistor;
-
- package dcmotor
- extends Modelica.Icons.ExamplesPackage;
-
- model dcmotor_clock "Rotate DC Motor clockwise"
- extends Modelica.Icons.Example;
- import sComm = Arduino.SerialCommunication.Functions;
- import strm = Modelica.Utilities.Streams;
- Integer ok(fixed = false);
- Integer c_ok(fixed = false);
- algorithm
- when initial() then
- ok := sComm.open_serial(1, 2, 115200) "COM port is 2 and baud rate is 115200";
- sComm.delay(2000);
- if ok <> 0 then
- strm.print("Unable to open serial port, please check");
- else
- sComm.delay(1000);
- sComm.cmd_dcmotor_setup(1, 3, 1, 9, 10) "Setup DC motor of type 3 (L293D), motor 1, pin 9 and 10";
- sComm.cmd_dcmotor_run(1, 1, 100) "Motor 1 runs at PWM 100";
- sComm.delay(3000) "This is allowed to continue for 3 seconds";
- sComm.cmd_dcmotor_release(1, 1) "Motor 1 is released";
- end if;
- c_ok := sComm.close_serial(1) "To close the connection safely";
- end when;
- annotation(
- experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 10));
- end dcmotor_clock;
-
- model dcmotor_both "Rotate DC Motor in both directions"
- extends Modelica.Icons.Example;
- import sComm = Arduino.SerialCommunication.Functions;
- import strm = Modelica.Utilities.Streams;
- Integer ok(fixed = false);
- Integer c_ok(fixed = false);
- algorithm
- when initial() then
- ok := sComm.open_serial(1, 2, 115200) "COM port is 2 and baud rate is 115200";
- sComm.delay(2000);
- if ok <> 0 then
- strm.print("Unable to open serial port, please check");
- else
- sComm.cmd_dcmotor_setup(1, 3, 1, 9, 10) "Setup DC motor of type 3 (L293D), motor 1, pin 9 and 10";
- sComm.cmd_dcmotor_run(1, 1, 100) "Motor 1 runs at PWM 100";
- sComm.delay(3000) "for 3 seconds";
- sComm.cmd_dcmotor_run(1, 1, -100) "Motor 1 runs at PWM -100 in reverse direction";
- sComm.delay(2000) "for 2 seconds";
- sComm.cmd_dcmotor_release(1, 1) "Motor 1 is released";
- end if;
- c_ok := sComm.close_serial(1) "To close the connection safely";
- end when;
- annotation(
- experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 10));
- end dcmotor_both;
-
- model dcmotor_loop "Rotate DC Motor in both directions in a loop"
- extends Modelica.Icons.Example;
- import sComm = Arduino.SerialCommunication.Functions;
- import strm = Modelica.Utilities.Streams;
- Integer ok(fixed = false);
- Integer c_ok(fixed = false);
- algorithm
- when initial() then
- ok := sComm.open_serial(1, 2, 115200) "COM port is 2 and baud rate is 115200";
- sComm.delay(2000);
- if ok <> 0 then
- strm.print("Unable to open serial port, please check");
- else
- sComm.cmd_dcmotor_setup(1, 3, 1, 9, 10) "Setup DC motor of type 3 (L293D), motor 1, pins 9 and 10";
- for i in 1:4 loop
- sComm.cmd_dcmotor_run(1, 1, 100) "Motor 1 runs at PWM 100";
- sComm.delay(3000) "for 3 seconds";
- sComm.cmd_dcmotor_run(1, 1, 0) "Halt the motor";
- sComm.delay(2000) "for 2 seconds";
- sComm.cmd_dcmotor_run(1, 1, -100) "Run it at PWM 100 in reverse direction";
- sComm.delay(2000) "for 2 seconds";
- end for;
- sComm.cmd_dcmotor_release(1, 1) "Motor 1 is released";
- end if;
- c_ok := sComm.close_serial(1) "To close the connection safely";
- end when;
- annotation(
- experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 10));
- end dcmotor_loop;
- end dcmotor;
-
- package servo
- extends Modelica.Icons.ExamplesPackage;
-
- model servo_init "Rotate Servo Motor "
- extends Modelica.Icons.Example;
- import sComm = Arduino.SerialCommunication.Functions;
- import strm = Modelica.Utilities.Streams;
- Integer ok(fixed = false);
- Integer c_ok(fixed = false);
- algorithm
- when initial() then
- ok := sComm.open_serial(1, 2, 115200) "COM port is 2 and baud rate is 115200";
- if ok <> 0 then
- strm.print("Check the serial port and try again");
- else
- sComm.cmd_servo_attach(1, 1) "To attach the motor to pin 9 of servo1";
- sComm.cmd_servo_move(1, 1, 30) "tell servo to rotate by 30 degrees";
- sComm.delay(3000);
- end if;
- c_ok := sComm.close_serial(1) "To close the connection safely";
- end when;
-//sComm.cmd_servo_detach(1,1);
- annotation(
- experiment(StartTime = 0, StopTime = 5, Tolerance = 1e-6, Interval = 5));
- end servo_init;
-
- model servo_loop "Rotate servo motor by 20 degrees 10 times"
- extends Modelica.Icons.Example;
- import sComm = Arduino.SerialCommunication.Functions;
- import strm = Modelica.Utilities.Streams;
- Integer ok(fixed = false);
- Integer c_ok(fixed = false);
- Integer angle(fixed = true);
- algorithm
- when initial() then
- ok := sComm.open_serial(1, 2, 115200) "COM port is 2 and baud rate is 115200";
- if ok <> 0 then
- strm.print("Check the serial port and try again");
- else
- sComm.cmd_servo_attach(1, 1) "Attach motor to pin 9. 1 means pin 9.";
- sComm.delay(2000);
- angle := 20 "Angle by which it has to move";
- for i in 1:10 loop
- sComm.cmd_servo_move(1, 1, angle * i) "tell servo to rotate by 20 degrees";
- sComm.delay(1000) "waits for a sec";
- end for;
- sComm.cmd_servo_detach(1, 1) "Detach the motor";
- end if;
- c_ok := sComm.close_serial(1) "To close the connection safely";
- end when;
- annotation(
- experiment(StartTime = 0, StopTime = 5, Tolerance = 1e-6, Interval = 5));
- end servo_loop;
-
- model servo_reverse
- extends Modelica.Icons.Example;
- import sComm = Arduino.SerialCommunication.Functions;
- import strm = Modelica.Utilities.Streams;
- Integer ok(fixed = false);
- Integer c_ok(fixed = false);
- algorithm
- when initial() then
- ok := sComm.open_serial(1, 2, 115200) "COM port is 2 and baud rate is 115200";
- sComm.delay(2000);
- if ok <> 0 then
- strm.print("Check the serial port and try again");
- else
- sComm.cmd_servo_attach(1, 1) "Attach the motor to pin 9. 1 means 9";
- sComm.cmd_servo_move(1, 1, 90) "Move the servo to 90 degree";
- sComm.delay(1000) "be there for one second";
- sComm.cmd_servo_move(1, 1, 45) "Move the servo to 45 degree";
- sComm.delay(1000) "be there for one second";
- sComm.cmd_servo_detach(1, 1) "Detach the motor";
- sComm.delay(1000);
- end if;
- c_ok := sComm.close_serial(1) "To close the connection safely";
- end when;
- annotation(
- experiment(StartTime = 0, StopTime = 5, Tolerance = 1e-6, Interval = 5));
- end servo_reverse;
-
- model servo_pot "Control Servo Motor using Potentiometer"
- extends Modelica.Icons.Example;
- import sComm = Arduino.SerialCommunication.Functions;
- import strm = Modelica.Utilities.Streams;
- Integer ok(fixed = false);
- Integer c_ok(fixed = false);
- Integer analog_in(fixed = false);
- algorithm
- when initial() then
- ok := sComm.open_serial(1, 2, 115200) "COM port is 2 and baud rate is 115200";
- sComm.delay(2000);
- if ok <> 0 then
- strm.print("Check the serial port and try again");
- else
- sComm.cmd_servo_attach(1, 1) "Attach the motor to pin 9";
- sComm.delay(2000);
- for i in 1:5000 loop
- analog_in := sComm.cmd_analog_in(1, 2) "Read potentiometer value";
- sComm.cmd_servo_move(1, 1, analog_in) "Command the servo motor";
- sComm.delay(1000) "sleep for 1000 milliseconds";
- end for;
- sComm.cmd_servo_detach(1, 1) "Detach the motor";
- end if;
- analog_in := sComm.math_floor(analog_in * (180 / 1023)) "Scale Potentiometer value to 0-180";
- c_ok := sComm.close_serial(1) "To close the connection safely";
- end when;
-//5,000 itterations
-//strm.print(String(analog_in));
- annotation(
- experiment(StartTime = 0, StopTime = 5, Tolerance = 1e-6, Interval = 5));
- end servo_pot;
- end servo;
-
- package modbus
- extends Modelica.Icons.ExamplesPackage;
-
- function read_voltage
- extends Modelica.Icons.Function;
-
- external read_voltage() annotation(
- Library = "SerialComm");
- annotation(
- Documentation(info = "<html>
- <h4>Syntax</h4>
- <blockquote><pre>
- Arduino.SerialCommunication.Examples.modbus.<b>read_voltage</b>();
- </pre></blockquote>
- <h4>Description</h4>
- <p>
- </p>
- </html>"));
- end read_voltage;
-
- function read_current
- extends Modelica.Icons.Function;
-
- external read_current() annotation(
- Library = "SerialComm");
- annotation(
- Documentation(info = "<html>
- <h4>Syntax</h4>
- <blockquote><pre>
- Arduino.SerialCommunication.Examples.modbus.<b>read_current</b>();
- </pre></blockquote>
- <h4>Description</h4>
- <p>
- </p>
- </html>"));
- end read_current;
-
- function read_val
- extends Modelica.Icons.Function;
- input Integer addr_byte;
- output Real p;
-
- external p = read_val(addr_byte) annotation(
- Library = "SerialComm");
- annotation(
- Documentation(info = "<html>
- <h4>Syntax</h4>
- <blockquote><pre>
- Arduino.SerialCommunication.Examples.modbus.<b>read_val</b>(address_byte);
- </pre></blockquote>
- <h4>Description</h4>
- <p>
- </p>
- </html>"));
- end read_val;
-
- function read_active_power
- extends Modelica.Icons.Function;
-
- external read_active_power() annotation(
- Library = "SerialComm");
- annotation(
- Documentation(info = "<html>
- <h4>Syntax</h4>
- <blockquote><pre>
- Arduino.SerialCommunication.Examples.modbus.<b>read_active_power</b>();
- </pre></blockquote>
- <h4>Description</h4>
- <p>
- </p>
- </html>"));
- end read_active_power;
-
- model modbus_test
- extends Modelica.Icons.Example;
- import sComm = Arduino.SerialCommunication.Functions;
- import modbus = Arduino.SerialCommunication.Examples.modbus;
- //Integer ok(fixed = false);
- //Integer c_ok(fixed = false);
- algorithm
- when initial() then
- modbus.read_voltage();
- modbus.read_current();
- modbus.read_active_power();
- sComm.delay(2000);
- end when;
-//ok:=sComm.open_serial(1,2,9600);
-//c_ok:=sComm.close_serial(1);
- end modbus_test;
- end modbus;
- end Examples;
-
- package MDD_Examples "Interfacing arduino with OpenModelica using Modelica Device Drivers"
- extends Modelica.Icons.ExamplesPackage;
-
- package MDD_led
- extends Modelica.Icons.ExamplesPackage;
-
- model MDD_led_blue ""
- extends Modelica.Icons.Example;
- inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
- Placement(visible = true, transformation(origin = {-40, 40}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
- Placement(visible = true, transformation(origin = {39, 41}, extent = {{-17, -17}, {17, 17}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'1', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation(
- Placement(visible = true, transformation(origin = {39, -21}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
- Modelica.Blocks.Sources.BooleanExpression booleanExpression1(y = true) annotation(
- Placement(visible = true, transformation(origin = {-41, -21}, extent = {{-15, -17}, {15, 17}}, rotation = 0)));
- equation
- connect(booleanExpression1.y, digitalWriteBoolean1.u) annotation(
- Line(points = {{-24, -20}, {14, -20}, {14, -20}, {16, -20}}, color = {255, 0, 255}));
- annotation(
- Documentation(info = "<html>
- <h4>Syntax</h4>
- <blockquote><pre>
- Arduino.SerialCommunication.MDD_Examples.MDD_led.<b>MDD-led_blue</b>();
- </pre></blockquote>
- <h4>Description</h4>
- <p>
- </p>
- </html>"));
- end MDD_led_blue;
-
- model MDD_led_blue_delay
- extends Modelica.Icons.Example;
- inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
- Placement(visible = true, transformation(origin = {-40, 40}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
- Placement(visible = true, transformation(origin = {31, 41}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'1', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation(
- Placement(visible = true, transformation(origin = {41, -17}, extent = {{-17, -17}, {17, 17}}, rotation = 0)));
- Modelica.Blocks.Sources.BooleanExpression booleanExpression1(y = if time < 5 then true else false) annotation(
- Placement(visible = true, transformation(origin = {-27, -16}, extent = {{-21, -16}, {21, 16}}, rotation = 0)));
- equation
- connect(booleanExpression1.y, digitalWriteBoolean1.u) annotation(
- Line(points = {{-4, -16}, {20, -16}}, color = {255, 0, 255}));
- end MDD_led_blue_delay;
-
- model MDD_led_blink
- extends Modelica.Icons.Example;
- inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
- Placement(visible = true, transformation(origin = {-45, 71}, extent = {{-23, -23}, {23, 23}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'5', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation(
- Placement(visible = true, transformation(origin = {42, -22}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
- Placement(visible = true, transformation(origin = {23, 71}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
- Modelica.Blocks.Sources.BooleanExpression booleanExpression1(y = mod(time, 2) >= 1) annotation(
- Placement(visible = true, transformation(origin = {-24, -21}, extent = {{-16, -15}, {16, 15}}, rotation = 0)));
- equation
- connect(booleanExpression1.y, digitalWriteBoolean1.u) annotation(
- Line(points = {{-6, -21}, {16, -21}, {16, -22}, {18, -22}}, color = {255, 0, 255}));
- end MDD_led_blink;
-
- model MDD_led_blue_red
- extends Modelica.Icons.Example;
- inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
- Placement(visible = true, transformation(origin = {-47, 47}, extent = {{-21, -21}, {21, 21}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'1', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation(
- Placement(visible = true, transformation(origin = {38, -16}, extent = {{-16, -16}, {16, 16}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
- Placement(visible = true, transformation(origin = {40, 44}, extent = {{-18, -18}, {18, 18}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean2(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'3', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation(
- Placement(visible = true, transformation(origin = {38, -62}, extent = {{-16, -16}, {16, 16}}, rotation = 0)));
- Modelica.Blocks.Sources.BooleanExpression booleanExpression1(y = if time < 1 then true else false) annotation(
- Placement(visible = true, transformation(origin = {-32, -16}, extent = {{-18, -14}, {18, 14}}, rotation = 0)));
- Modelica.Blocks.Sources.BooleanExpression booleanExpression2(y = if time < 1.6 then true else false) annotation(
- Placement(visible = true, transformation(origin = {-32, -62}, extent = {{-18, -16}, {18, 16}}, rotation = 0)));
- equation
- connect(digitalWriteBoolean2.u, booleanExpression2.y) annotation(
- Line(points = {{18, -62}, {-12, -62}, {-12, -62}, {-12, -62}}, color = {255, 0, 255}));
- connect(booleanExpression2.y, digitalWriteBoolean2.u) annotation(
- Line(points = {{-12, -62}, {18, -62}, {18, -62}, {18, -62}}, color = {255, 0, 255}));
- connect(booleanExpression1.y, digitalWriteBoolean1.u) annotation(
- Line(points = {{-12, -16}, {18, -16}, {18, -16}, {18, -16}}, color = {255, 0, 255}));
- end MDD_led_blue_red;
-
- model MDD_led_green_blink
- extends Modelica.Icons.Example;
- inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
- Placement(visible = true, transformation(origin = {-40, 40}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'2', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation(
- Placement(visible = true, transformation(origin = {46, -30}, extent = {{-18, -18}, {18, 18}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
- Placement(visible = true, transformation(origin = {39, 39}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
- Modelica.Blocks.Sources.BooleanExpression booleanExpression1(y = mod(time, 2) >= 1) annotation(
- Placement(visible = true, transformation(origin = {-17, -30}, extent = {{-15, -14}, {15, 14}}, rotation = 0)));
- equation
- connect(booleanExpression1.y, digitalWriteBoolean1.u) annotation(
- Line(points = {{0, -30}, {24, -30}, {24, -30}, {24, -30}}, color = {255, 0, 255}));
- end MDD_led_green_blink;
- end MDD_led;
-
- package MDD_push
- extends Modelica.Icons.ExamplesPackage;
-
- model MDD_led_push_button
- extends Modelica.Icons.Example;
- inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
- Placement(visible = true, transformation(origin = {-38, 40}, extent = {{-18, -18}, {18, 18}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'1', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation(
- Placement(visible = true, transformation(origin = {64, -26}, extent = {{-16, -16}, {16, 16}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer1) annotation(
- Placement(visible = true, transformation(origin = {39, 41}, extent = {{-17, -17}, {17, 17}}, rotation = 0)));
- Modelica.Blocks.Logical.LogicalSwitch logicalSwitch1 annotation(
- Placement(visible = true, transformation(origin = {16, -26}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- Modelica.Blocks.Sources.BooleanExpression booleanExpression1(y = true) annotation(
- Placement(visible = true, transformation(origin = {-20, 8}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- Modelica.Blocks.Sources.BooleanExpression booleanExpression2(y = false) annotation(
- Placement(visible = true, transformation(origin = {-18, -62}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalReadBoolean digitalReadBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'4', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.D) annotation(
- Placement(visible = true, transformation(origin = {-60, -26}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- equation
- connect(logicalSwitch1.y, digitalWriteBoolean1.u) annotation(
- Line(points = {{28, -26}, {44, -26}, {44, -26}, {44, -26}}, color = {255, 0, 255}));
- connect(digitalReadBoolean1.y, logicalSwitch1.u2) annotation(
- Line(points = {{-48, -26}, {2, -26}, {2, -26}, {4, -26}}, color = {255, 0, 255}));
- connect(booleanExpression1.y, logicalSwitch1.u1) annotation(
- Line(points = {{-8, 8}, {-2, 8}, {-2, -18}, {4, -18}, {4, -18}}, color = {255, 0, 255}));
- connect(booleanExpression2.y, logicalSwitch1.u3) annotation(
- Line(points = {{-6, -62}, {-2, -62}, {-2, -34}, {4, -34}, {4, -34}}, color = {255, 0, 255}));
- end MDD_led_push_button;
-
- model MDD_push_button_status
- extends Modelica.Icons.Example;
- inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
- Placement(visible = true, transformation(origin = {-43, 43}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
- Placement(visible = true, transformation(origin = {20, 42}, extent = {{-18, -18}, {18, 18}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalReadBoolean digitalReadBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'4', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation(
- Placement(visible = true, transformation(origin = {-39, -19}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
- Modelica.Blocks.Interaction.Show.BooleanValue booleanValue1(use_activePort = true) annotation(
- Placement(visible = true, transformation(origin = {31, -19}, extent = {{-15, -17}, {15, 17}}, rotation = 0)));
- equation
- connect(digitalReadBoolean1.y, booleanValue1.activePort) annotation(
- Line(points = {{-18, -18}, {14, -18}, {14, -18}, {14, -18}}, color = {255, 0, 255}));
- end MDD_push_button_status;
- end MDD_push;
-
- package MDD_ldr
- extends Modelica.Icons.ExamplesPackage;
-
- model MDD_ldr_led
- extends Modelica.Icons.Example;
- inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
- Placement(visible = true, transformation(origin = {-45, 65}, extent = {{-21, -21}, {21, 21}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
- Placement(visible = true, transformation(origin = {40, 60}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'1', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation(
- Placement(visible = true, transformation(origin = {79, -23}, extent = {{-17, -17}, {17, 17}}, rotation = 0)));
- Modelica.Blocks.Sources.BooleanExpression booleanExpression1(y = true) annotation(
- Placement(visible = true, transformation(origin = {-60, 12}, extent = {{-14, -16}, {14, 16}}, rotation = 0)));
- Modelica.Blocks.Sources.BooleanExpression booleanExpression2 annotation(
- Placement(visible = true, transformation(origin = {-59, -79}, extent = {{-13, -17}, {13, 17}}, rotation = 0)));
- Modelica.Blocks.Logical.LogicalSwitch logicalSwitch1 annotation(
- Placement(visible = true, transformation(origin = {28, -22}, extent = {{-16, -16}, {16, 16}}, rotation = 0)));
- Modelica.Blocks.Logical.GreaterThreshold greaterThreshold1(threshold = 600) annotation(
- Placement(visible = true, transformation(origin = {-21, -23}, extent = {{-11, -11}, {11, 11}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.ADC adc(analogPort = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPort.A5, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPrescaler.'1/128', voltageReference = 1024, voltageReferenceSelect = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.VRefSelect.Internal) annotation(
- Placement(visible = true, transformation(origin = {-72, -22}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
- equation
- connect(adc.y, greaterThreshold1.u) annotation(
- Line(points = {{-50, -22}, {-34, -22}}, color = {0, 0, 127}));
- connect(greaterThreshold1.y, logicalSwitch1.u2) annotation(
- Line(points = {{-8, -22}, {8, -22}, {8, -22}, {8, -22}}, color = {255, 0, 255}));
- connect(logicalSwitch1.y, digitalWriteBoolean1.u) annotation(
- Line(points = {{46, -22}, {58, -22}, {58, -22}, {58, -22}}, color = {255, 0, 255}));
- connect(booleanExpression1.y, logicalSwitch1.u1) annotation(
- Line(points = {{-44, 12}, {8, 12}, {8, -10}, {8, -10}}, color = {255, 0, 255}));
- connect(booleanExpression2.y, logicalSwitch1.u3) annotation(
- Line(points = {{-44, -78}, {6, -78}, {6, -34}, {8, -34}}, color = {255, 0, 255}));
- end MDD_ldr_led;
-
- model MDD_ldr_read
- extends Modelica.Icons.Example;
- inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
- Placement(visible = true, transformation(origin = {-37, 39}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
- Placement(visible = true, transformation(origin = {50, 38}, extent = {{-22, -22}, {22, 22}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.ADC adc(analogPort = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPort.A5, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPrescaler.'1/128', voltageReference = 1024, voltageReferenceSelect = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.VRefSelect.Internal) annotation(
- Placement(visible = true, transformation(origin = {-39, -17}, extent = {{-17, -17}, {17, 17}}, rotation = 0)));
- Modelica.Blocks.Interaction.Show.RealValue realValue1(use_numberPort = true) annotation(
- Placement(visible = true, transformation(origin = {30, -17}, extent = {{-18, -17}, {18, 17}}, rotation = 0)));
- equation
- connect(adc.y, realValue1.numberPort) annotation(
- Line(points = {{-20, -17}, {7, -17}}, color = {0, 0, 127}));
- end MDD_ldr_read;
- end MDD_ldr;
-
- package MDD_pot
- extends Modelica.Icons.ExamplesPackage;
-
- model MDD_pot_threshold ""
- extends Modelica.Icons.Example;
- inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
- Placement(visible = true, transformation(origin = {-79, 79}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
- Placement(visible = true, transformation(origin = {80, 80}, extent = {{-18, -18}, {18, 18}}, rotation = 0)));
- Modelica.Blocks.Logical.Switch switch11 annotation(
- Placement(visible = true, transformation(origin = {2, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- Modelica.Blocks.Logical.Switch switch12 annotation(
- Placement(visible = true, transformation(origin = {10, -64}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- Modelica.Blocks.Logical.Greater greater1 annotation(
- Placement(visible = true, transformation(origin = {42, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- Modelica.Blocks.Logical.Greater greater2 annotation(
- Placement(visible = true, transformation(origin = {36, 70}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'1', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation(
- Placement(visible = true, transformation(origin = {82, 40}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean2(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'2', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation(
- Placement(visible = true, transformation(origin = {82, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean3(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'3', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation(
- Placement(visible = true, transformation(origin = {82, -64}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- Modelica.Blocks.Logical.GreaterEqualThreshold greaterEqualThreshold1(threshold = 0) annotation(
- Placement(visible = true, transformation(origin = {-42, 44}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- Modelica.Blocks.Logical.GreaterEqualThreshold greaterEqualThreshold2(threshold = 320) annotation(
- Placement(visible = true, transformation(origin = {-42, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- Modelica.Blocks.Logical.GreaterEqualThreshold greaterEqualThreshold3(threshold = 900) annotation(
- Placement(visible = true, transformation(origin = {-40, -64}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- Modelica.Blocks.Sources.RealExpression realExpression1(y = 0) annotation(
- Placement(visible = true, transformation(origin = {-40, -92}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- Modelica.Blocks.Sources.RealExpression realExpression2(y = 1) annotation(
- Placement(visible = true, transformation(origin = {-44, 84}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- Modelica.Blocks.Logical.Switch switch1 annotation(
- Placement(visible = true, transformation(origin = {0, 70}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- Modelica.Blocks.Math.RealToBoolean realToBoolean1(threshold = 0.5) annotation(
- Placement(visible = true, transformation(origin = {44, -64}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.ADC adc(analogPort = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPort.A2, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPrescaler.'1/128', voltageReference = 1024, voltageReferenceSelect = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.VRefSelect.Internal) annotation(
- Placement(visible = true, transformation(origin = {-88, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- equation
- connect(adc.y, greaterEqualThreshold1.u) annotation(
- Line(points = {{-76, 0}, {-70, 0}, {-70, 46}, {-54, 46}}, color = {0, 0, 127}));
- connect(greaterEqualThreshold1.y, switch1.u2) annotation(
- Line(points = {{-31, 46}, {-24, 46}, {-24, 70}, {-12, 70}}, color = {255, 0, 255}));
- connect(adc.y, greaterEqualThreshold3.u) annotation(
- Line(points = {{-76, 0}, {-70, 0}, {-70, -64}, {-52, -64}, {-52, -64}}, color = {0, 0, 127}));
- connect(adc.y, greaterEqualThreshold2.u) annotation(
- Line(points = {{-76, 0}, {-54, 0}, {-54, 0}, {-54, 0}}, color = {0, 0, 127}));
- connect(realToBoolean1.y, digitalWriteBoolean3.u) annotation(
- Line(points = {{56, -64}, {70, -64}, {70, -64}, {70, -64}}, color = {255, 0, 255}));
- connect(switch12.y, realToBoolean1.u) annotation(
- Line(points = {{22, -64}, {32, -64}, {32, -64}, {32, -64}}, color = {0, 0, 127}));
- connect(realExpression1.y, switch1.u3) annotation(
- Line(points = {{-28, -92}, {-16, -92}, {-16, 62}, {-12, 62}, {-12, 62}}, color = {0, 0, 127}));
- connect(realExpression2.y, switch1.u1) annotation(
- Line(points = {{-32, 84}, {-20, 84}, {-20, 78}, {-12, 78}, {-12, 78}}, color = {0, 0, 127}));
- connect(switch1.y, greater2.u1) annotation(
- Line(points = {{12, 70}, {22, 70}, {22, 70}, {24, 70}}, color = {0, 0, 127}));
- connect(greater1.y, digitalWriteBoolean2.u) annotation(
- Line(points = {{54, 0}, {70, 0}}, color = {255, 0, 255}));
- connect(switch11.y, greater2.u2) annotation(
- Line(points = {{14, 0}, {18, 0}, {18, 62}, {24, 62}, {24, 62}}, color = {0, 0, 127}));
- connect(switch11.y, greater1.u1) annotation(
- Line(points = {{14, 0}, {30, 0}}, color = {0, 0, 127}));
- connect(switch12.y, greater1.u2) annotation(
- Line(points = {{22, -64}, {22, -64}, {22, -8}, {30, -8}, {30, -8}}, color = {0, 0, 127}));
- connect(greaterEqualThreshold2.y, switch11.u2) annotation(
- Line(points = {{-30, 0}, {-10, 0}, {-10, 0}, {-10, 0}}, color = {255, 0, 255}));
- connect(greater2.y, digitalWriteBoolean1.u) annotation(
- Line(points = {{48, 70}, {56, 70}, {56, 40}, {70, 40}, {70, 40}}, color = {255, 0, 255}));
- connect(realExpression2.y, switch12.u1) annotation(
- Line(points = {{-32, 84}, {-20, 84}, {-20, -56}, {-2, -56}, {-2, -56}}, color = {0, 0, 127}));
- connect(realExpression2.y, switch11.u1) annotation(
- Line(points = {{-32, 84}, {-20, 84}, {-20, 8}, {-10, 8}, {-10, 8}}, color = {0, 0, 127}));
- connect(realExpression1.y, switch11.u3) annotation(
- Line(points = {{-28, -92}, {-16, -92}, {-16, -8}, {-10, -8}, {-10, -8}}, color = {0, 0, 127}));
- connect(realExpression1.y, switch12.u3) annotation(
- Line(points = {{-28, -92}, {-16, -92}, {-16, -72}, {-2, -72}, {-2, -72}}, color = {0, 0, 127}));
- connect(greaterEqualThreshold3.y, switch12.u2) annotation(
- Line(points = {{-28, -64}, {-2, -64}, {-2, -64}, {-2, -64}}, color = {255, 0, 255}));
- annotation(
- Documentation(info = "<html>
- <h4>Syntax</h4>
- <blockquote><pre>
- Arduino.SerialCommunication.MDD_Examples.MDD_pot.<b>MDD_pot_threshold</b>();
- </pre></blockquote>
- <h4>Description</h4>
- <p>Voltage reference used to represent 10 bit precision(1024) of ADC along with prescaling by by 128.Internal voltage reference is applied to adc.
- </p>
- </html>"));
- end MDD_pot_threshold;
- end MDD_pot;
-
- package MDD_thermistor
- extends Modelica.Icons.ExamplesPackage;
-
- model MDD_therm_read
- extends Modelica.Icons.Example;
- inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
- Placement(visible = true, transformation(origin = {-40, 40}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
- Placement(visible = true, transformation(origin = {40, 42}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.ADC adc(analogPort = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPort.A4, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPrescaler.'1/128', voltageReference = 1024, voltageReferenceSelect = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.VRefSelect.Internal) annotation(
- Placement(visible = true, transformation(origin = {-40, -20}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
- Modelica.Blocks.Interaction.Show.RealValue realValue1(use_numberPort = true) annotation(
- Placement(visible = true, transformation(origin = {39, -21}, extent = {{-15, -19}, {15, 19}}, rotation = 0)));
- equation
- connect(adc.y, realValue1.numberPort) annotation(
- Line(points = {{-18, -20}, {20, -20}, {20, -20}, {22, -20}}, color = {0, 0, 127}));
- end MDD_therm_read;
-
- model MDD_therm_buzzer
- extends Modelica.Icons.Example;
- inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
- Placement(visible = true, transformation(origin = {-61, 61}, extent = {{-21, -21}, {21, 21}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.ADC adc(analogPort = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPort.A4, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPrescaler.'1/128', voltageReference = 1024, voltageReferenceSelect = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.VRefSelect.Internal) annotation(
- Placement(visible = true, transformation(origin = {-68, 1.77636e-15}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
- Placement(visible = true, transformation(origin = {41, 61}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
- Modelica.Blocks.Interaction.Show.RealValue realValue1(use_numberPort = true) annotation(
- Placement(visible = true, transformation(origin = {12, -56}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'3', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.D) annotation(
- Placement(visible = true, transformation(origin = {78, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- Modelica.Blocks.Logical.LogicalSwitch logicalSwitch1 annotation(
- Placement(visible = true, transformation(origin = {40, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- Modelica.Blocks.Sources.BooleanExpression booleanExpression1(y = false) annotation(
- Placement(visible = true, transformation(origin = {10, -32}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- Modelica.Blocks.Sources.BooleanExpression booleanExpression2(y = true) annotation(
- Placement(visible = true, transformation(origin = {10, 32}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- Modelica.Blocks.Logical.GreaterEqualThreshold greaterEqualThreshold1(threshold = 550) annotation(
- Placement(visible = true, transformation(origin = {-4, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- equation
- connect(greaterEqualThreshold1.y, logicalSwitch1.u2) annotation(
- Line(points = {{8, 0}, {28, 0}, {28, 0}, {28, 0}}, color = {255, 0, 255}));
- connect(adc.y, greaterEqualThreshold1.u) annotation(
- Line(points = {{-46, 0}, {-16, 0}, {-16, 0}, {-16, 0}}, color = {0, 0, 127}));
- connect(adc.y, realValue1.numberPort) annotation(
- Line(points = {{-46, 0}, {-32, 0}, {-32, -56}, {0, -56}}, color = {0, 0, 127}));
- connect(logicalSwitch1.y, digitalWriteBoolean1.u) annotation(
- Line(points = {{52, 0}, {66, 0}, {66, 0}, {66, 0}}, color = {255, 0, 255}));
- connect(booleanExpression2.y, logicalSwitch1.u1) annotation(
- Line(points = {{22, 32}, {24, 32}, {24, 8}, {28, 8}, {28, 8}}, color = {255, 0, 255}));
- connect(booleanExpression1.y, logicalSwitch1.u3) annotation(
- Line(points = {{22, -32}, {24, -32}, {24, -8}, {28, -8}, {28, -8}}, color = {255, 0, 255}));
- end MDD_therm_buzzer;
- end MDD_thermistor;
-
- package MDD_dcmotor
- extends Modelica.Icons.ExamplesPackage;
-
- model MDD_dcmotor_clock
- extends Modelica.Icons.Example;
- inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
- Placement(visible = true, transformation(origin = {-40, 40}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
- Placement(visible = true, transformation(origin = {39, 41}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.PWM pwm(fastPWM = true, initialValues = {0}, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerPrescaler.'1/1024', timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer1, timerNumbers = {Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerNumber.A}) annotation(
- Placement(visible = true, transformation(origin = {51, -3}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
- Modelica.Blocks.Sources.IntegerExpression integerExpression1(y = if time < 5 then 100 else 0) annotation(
- Placement(visible = true, transformation(origin = {-40, -3}, extent = {{-16, -13}, {16, 13}}, rotation = 0)));
- equation
- connect(pwm.u[1], integerExpression1.y) annotation(
- Line(points = {{28, -3}, {-22, -3}}, color = {255, 127, 0}, thickness = 0.5));
- end MDD_dcmotor_clock;
-
- model MDD_dcmotor_both
- extends Modelica.Icons.Example;
- inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
- Placement(visible = true, transformation(origin = {-40, 60}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
- Placement(visible = true, transformation(origin = {56, 60}, extent = {{-18, -18}, {18, 18}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.PWM pwm(fastPWM = true, initialValues = {0}, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerPrescaler.'1/1024', timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer1, timerNumbers = {Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerNumber.A}) annotation(
- Placement(visible = true, transformation(origin = {54, 1.77636e-15}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
- Modelica.Blocks.Sources.IntegerExpression integerExpression1(y = if mod(time, 5) >= 2.5 then 100 else 0) annotation(
- Placement(visible = true, transformation(origin = {-41, 3.55271e-15}, extent = {{-23, -20}, {23, 20}}, rotation = 0)));
- Modelica.Blocks.Sources.IntegerExpression integerExpression2(y = if mod(time, 5) < 2.5 then 100 else 0) annotation(
- Placement(visible = true, transformation(origin = {-39, -48}, extent = {{-23, -20}, {23, 20}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.PWM pwm1(fastPWM = true, initialValues = {0}, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerPrescaler.'1/1024', timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer1, timerNumbers = {Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerNumber.B}) annotation(
- Placement(visible = true, transformation(origin = {54, -48}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
- equation
- connect(integerExpression2.y, pwm1.u[1]) annotation(
- Line(points = {{-14, -48}, {28, -48}, {28, -48}, {30, -48}}, color = {255, 127, 0}));
- connect(integerExpression1.y, pwm.u[1]) annotation(
- Line(points = {{-16, 0}, {28, 0}, {28, 0}, {30, 0}}, color = {255, 127, 0}));
- end MDD_dcmotor_both;
-
- model MDD_dcmotor_loop
- extends Modelica.Icons.Example;
- inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
- Placement(visible = true, transformation(origin = {-40, 62}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
- Placement(visible = true, transformation(origin = {40, 60}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.PWM pwm(fastPWM = true, initialValues = {0}, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerPrescaler.'1/1024', timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer1, timerNumbers = {Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerNumber.A}) annotation(
- Placement(visible = true, transformation(origin = {44, 16}, extent = {{-16, -16}, {16, 16}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.PWM pwm1(fastPWM = true, initialValues = {0}, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerPrescaler.'1/1024', timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer1, timerNumbers = {Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerNumber.B}) annotation(
- Placement(visible = true, transformation(origin = {44, -30}, extent = {{-16, -16}, {16, 16}}, rotation = 0)));
- Modelica.Blocks.Sources.IntegerExpression integerExpression1(y = if time < 3 then 100 else 0) annotation(
- Placement(visible = true, transformation(origin = {-53, 16}, extent = {{-17, -16}, {17, 16}}, rotation = 0)));
- Modelica.Blocks.Sources.IntegerExpression integerExpression2(y = if time >= 3 then 100 else 0) annotation(
- Placement(visible = true, transformation(origin = {-52, -30}, extent = {{-16, -14}, {16, 14}}, rotation = 0)));
- equation
- connect(integerExpression2.y, pwm1.u[1]) annotation(
- Line(points = {{-34, -30}, {24, -30}}, color = {255, 127, 0}));
- connect(integerExpression1.y, pwm.u[1]) annotation(
- Line(points = {{-34, 16}, {24, 16}}, color = {255, 127, 0}));
- end MDD_dcmotor_loop;
- end MDD_dcmotor;
-
- package MDD_servo
- extends Modelica.Icons.ExamplesPackage;
-
- model MDD_servo_init
- extends Modelica.Icons.Example;
- inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
- Placement(visible = true, transformation(origin = {-40, 40}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
- Placement(visible = true, transformation(origin = {61, 41}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
- Modelica.Blocks.Sources.IntegerExpression integerExpression1(y = 30) annotation(
- Placement(visible = true, transformation(origin = {-39, -7}, extent = {{-15, -15}, {15, 15}}, rotation = 0)));
- Arduino.SerialCommunication.Blocks.Servo Servo(prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerPrescaler.'1/1024', servo_no = Arduino.SerialCommunication.Types.Servo_no.'1', timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer1) annotation(
- Placement(visible = true, transformation(origin = {36, -8}, extent = {{-18, -18}, {18, 18}}, rotation = 0)));
- equation
- connect(integerExpression1.y, Servo.u) annotation(
- Line(points = {{-22.5, -7}, {14, -7}, {14, -8}}, color = {255, 127, 0}));
- end MDD_servo_init;
-
- model MDD_servo_loop
- extends Modelica.Icons.Example;
- inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
- Placement(visible = true, transformation(origin = {-41, 41}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1 annotation(
- Placement(visible = true, transformation(origin = {39, 41}, extent = {{-17, -17}, {17, 17}}, rotation = 0)));
- Modelica.Blocks.Math.Gain gain1(k = 20) annotation(
- Placement(visible = true, transformation(origin = {38, -6}, extent = {{-14, -14}, {14, 14}}, rotation = 0)));
- Modelica.Blocks.Sources.Clock clock1(offset = 0, startTime = 0) annotation(
- Placement(visible = true, transformation(origin = {-74, 2}, extent = {{-18, -18}, {18, 18}}, rotation = 0)));
- Modelica.Blocks.Logical.LessEqual lessEqual1 annotation(
- Placement(visible = true, transformation(origin = {-58, -50}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- Modelica.Blocks.Logical.Switch switch1 annotation(
- Placement(visible = true, transformation(origin = {-22, -6}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- Modelica.Blocks.Sources.IntegerExpression integerExpression1(y = 0) annotation(
- Placement(visible = true, transformation(origin = {-30, -42}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- Modelica.Blocks.Sources.IntegerExpression integerExpression2(y = 10) annotation(
- Placement(visible = true, transformation(origin = {-84, -84}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- Modelica.Blocks.Math.RealToInteger realToInteger1 annotation(
- Placement(visible = true, transformation(origin = {4, -34}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- Blocks.Servo Servo(prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerPrescaler.'1/1024', servo_no = 1, timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
- Placement(visible = true, transformation(origin = {78, -6}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- equation
- connect(gain1.y, Servo.u) annotation(
- Line(points = {{54, -6}, {66, -6}, {66, -6}, {66, -6}}, color = {0, 0, 127}));
- connect(integerExpression2.y, lessEqual1.u2) annotation(
- Line(points = {{-73, -84}, {-64, -84}, {-64, -68}, {-84, -68}, {-84, -58}, {-70, -58}}, color = {255, 127, 0}));
- connect(realToInteger1.y, gain1.u) annotation(
- Line(points = {{16, -34}, {16, -6}, {21, -6}}, color = {255, 127, 0}));
- connect(clock1.y, lessEqual1.u1) annotation(
- Line(points = {{-54, 2}, {-50, 2}, {-50, -32}, {-84, -32}, {-84, -50}, {-70, -50}, {-70, -50}}, color = {0, 0, 127}));
- connect(clock1.y, switch1.u1) annotation(
- Line(points = {{-54, 2}, {-34, 2}}, color = {0, 0, 127}));
- connect(integerExpression1.y, switch1.u3) annotation(
- Line(points = {{-18, -42}, {-16, -42}, {-16, -24}, {-40, -24}, {-40, -14}, {-34, -14}, {-34, -14}}, color = {255, 127, 0}));
- connect(lessEqual1.y, switch1.u2) annotation(
- Line(points = {{-46, -50}, {-44, -50}, {-44, -6}, {-34, -6}, {-34, -6}}, color = {255, 0, 255}));
- connect(switch1.y, realToInteger1.u) annotation(
- Line(points = {{-10, -6}, {-8, -6}, {-8, -34}, {-8, -34}}, color = {0, 0, 127}));
- end MDD_servo_loop;
-
- model MDD_servo_pot
- extends Modelica.Icons.Example;
- inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
- Placement(visible = true, transformation(origin = {-40, 60}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
- Placement(visible = true, transformation(origin = {39, 61}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.ADC adc(analogPort = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPort.A2, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPrescaler.'1/128', voltageReference = 1023, voltageReferenceSelect = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.VRefSelect.Internal) annotation(
- Placement(visible = true, transformation(origin = {-52, -10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- Modelica.Blocks.Math.RealToInteger realToInteger1 annotation(
- Placement(visible = true, transformation(origin = {-4, -10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- Blocks.Servo Servo(prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerPrescaler.'1/1024', servo_no = 1, timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
- Placement(visible = true, transformation(origin = {46, -10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- equation
- connect(realToInteger1.y, Servo.u) annotation(
- Line(points = {{8, -10}, {34, -10}, {34, -10}, {34, -10}}, color = {255, 127, 0}));
- connect(adc.y, realToInteger1.u) annotation(
- Line(points = {{-40, -10}, {-16, -10}, {-16, -10}, {-16, -10}}, color = {0, 0, 127}));
- end MDD_servo_pot;
-
- model MDD_servo_reverse
- extends Modelica.Icons.Example;
- inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
- Placement(visible = true, transformation(origin = {-59, 61}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
- Placement(visible = true, transformation(origin = {55, 61}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
- Modelica.Blocks.Sources.IntegerExpression integerExpression1(y = 90) annotation(
- Placement(visible = true, transformation(origin = {-44, 0}, extent = {{-22, -22}, {22, 22}}, rotation = 0)));
- Blocks.Servo Servo(prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerPrescaler.'1/1024', servo_no = 1, timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
- Placement(visible = true, transformation(origin = {26, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- equation
- connect(integerExpression1.y, Servo.u) annotation(
- Line(points = {{-20, 0}, {14, 0}, {14, 0}, {14, 0}}, color = {255, 127, 0}));
- end MDD_servo_reverse;
- end MDD_servo;
-
- package MDD_modbus
- extends Modelica.Icons.ExamplesPackage;
-
- model MDD_read_val
- extends Modelica.Icons.Example;
- inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation(
- Placement(visible = true, transformation(origin = {-45, 67}, extent = {{-15, -15}, {15, 15}}, rotation = 0)));
- Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation(
- Placement(visible = true, transformation(origin = {28, 68}, extent = {{-12, -12}, {12, 12}}, rotation = 0)));
- Modelica.Blocks.MathInteger.MultiSwitch multiSwitch1(expr = {86, 88, 78}, nu = 3, use_pre_as_default = true, y_default = 0) annotation(
- Placement(visible = true, transformation(origin = {-32.6577, -10}, extent = {{-10.0019, -22}, {30.0056, 22}}, rotation = 0)));
- Modelica.Blocks.Sources.BooleanExpression booleanExpression1 annotation(
- Placement(visible = true, transformation(origin = {-78, -12}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- Modelica.Blocks.Interaction.Show.RealValue realValue1 annotation(
- Placement(visible = true, transformation(origin = {60, -10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- Blocks.Read_Val read_Val1 annotation(
- Placement(visible = true, transformation(origin = {26, -10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- equation
- connect(read_Val1.y, realValue1.numberPort) annotation(
- Line(points = {{38, -10}, {48, -10}, {48, -10}, {48, -10}}, color = {0, 0, 127}));
- connect(multiSwitch1.y, read_Val1.u) annotation(
- Line(points = {{-2, -10}, {14, -10}, {14, -10}, {14, -10}}, color = {255, 127, 0}));
- end MDD_read_val;
- end MDD_modbus;
- end MDD_Examples;
-
- package Blocks
- extends Modelica.Icons.Package;
-
- model Servo
- extends Modelica.Blocks.Icons.Block;
- import Modelica_DeviceDrivers.EmbeddedTargets.AVR;
- import sComm = Arduino.SerialCommunication.Functions;
- outer Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu;
- constant AVR.Types.TimerSelect timer annotation(
- Dialog(enable = true, tab = "General", group = "Constants"));
- constant AVR.Types.TimerPrescaler prescaler "Pre-scaler for the clock." annotation(
- Dialog(enable = true, tab = "General", group = "Constants"));
- constant sComm.Types.Servo_no servo_no annotation(
- Dialog(enable = true, tab = "General", group = "Constants"));
- Modelica.Blocks.Interfaces.IntegerInput u "Connector of Servo input signals (integer 0..255)" annotation(
- Placement(transformation(extent = {{-140, -20}, {-100, 20}})));
- protected
- AVR.Functions.Timers.Timer clock = AVR.Functions.Timers.Timer(timer, prescaler, clearTimerOnMatch = true);
- sComm.Functions.MDD_Servo.Init servo = sComm.Functions.MDD_Servo.Init(servo_no);
- algorithm
- sComm.Functions.MDD_Servo.Move(servo, u);
- annotation(
- defaultComponentName = "Servo",
- Icon(graphics = {Text(extent = {{-95, -95}, {95, 95}}, textString = "Servo %servo_no", fontName = "Arial")}));
- end Servo;
-
- model Read_Val
- extends Modelica.Blocks.Interfaces.SISO;
- import Modelica_DeviceDrivers.EmbeddedTargets.AVR;
- import sComm = Arduino.SerialCommunication.Functions;
- outer Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu;
- annotation(
- defaultComponentName = "Read_Val",
- Icon(graphics = {Text(extent = {{-95, -95}, {95, 95}}, textString = "Read_Val", fontName = "Arial")}));
- end Read_Val;
- end Blocks;
-
- type Types
- extends Modelica.Icons.TypesPackage;
- type Servo_no = enumeration('1' "Servo1", '2' "Servo2") "Servo ID";
- end Types;
-
- package Icons "Collection of icons used for library components"
- extends Modelica.Icons.IconsPackage;
-
- partial package GenericICPackage "Icon with a generic IC"
- annotation(
- Icon(coordinateSystem(preserveAspectRatio = true, extent = {{-100, -100}, {100, 100}}), graphics = {Bitmap(extent = {{-95, -95}, {95, 95}}, fileName = "Resources/Images/Icons/tqfp32.png", rotation = 0)}),
- Documentation(info = "<html>
-<p>
-This partial class is intended to design a <em>default icon for microcontrollers</em>.
-</p>
-</html>"));
- end GenericICPackage;
-
- partial block GenericIC "Icon with a generic IC"
- annotation(
- Icon(coordinateSystem(preserveAspectRatio = true, extent = {{-100, -100}, {100, 100}}), graphics = {Bitmap(extent = {{-95, -95}, {95, 95}}, fileName = "Resources/Images/Icons/tqfp32.png", rotation = 0)}),
- Documentation(info = "<html>
-<p>
-This partial class is intended to design a <em>default icon for microcontrollers</em>.
-</p>
-</html>"));
- end GenericIC;
-
- partial package FunctionLayerIcon "Icon for packages that represent the function layer"
- extends Modelica.Icons.Package;
- annotation(
- Icon(coordinateSystem(preserveAspectRatio = false, extent = {{-100, -100}, {100, 100}}), graphics = {Text(lineColor = {128, 128, 128}, extent = {{-90, -90}, {90, 90}}, textString = "f"), Ellipse(lineColor = {128, 128, 128}, extent = {{-80, -80}, {80, 80}})}),
- Documentation(info = "<html>
-<p>This icon indicates Modelica functions.</p>
-</html>"));
- end FunctionLayerIcon;
- annotation(
- preferredView = "info",
- Documentation(info = "<html>
-<p>
-A collection of basic icons to be used for different elements of the library.
-</p>
-</html>"));
- end Icons;
- annotation(
- Documentation(info = "<html>
-<h4>Description</h4>
-<p>
-A serial communication package for hardware interfacing.
-</p>
-</html>"));
- end SerialCommunication;
- annotation(
- uses(Modelica_DeviceDrivers(version = "1.5.0"), Modelica(version = "3.2.2")));
-end Arduino;
+package Arduino + extends Arduino.SerialCommunication.Icons.GenericICPackage; + + package SerialCommunication "Serial Communication Package for Arduino" + extends Arduino.SerialCommunication.Icons.FunctionLayerIcon; + import ModelicaReference.Operators; + + package Functions + extends Modelica.Icons.Package; + import Modelica; + + function open_serial "Command to initialize the serial port which is connected to Arduino" + extends Modelica.Icons.Function; + input Integer handle, port, baudrate; + output Integer OK; + + external OK = open_serial(handle, port, baudrate) annotation( + Library = "SerialComm"); + annotation( + Documentation(info = "<html> +<h4>Syntax</h4> +<blockquote><pre> +Arduino.SerialCommunication.Functions.<b>open_serial</b>(handle,port,baudrate); +</pre></blockquote> +<h4>Description</h4> +<p> +Establishes a serial communication using port number \"port\".To connect to the Arduino board, check the port number from the device manager or check it from the Arduino software. +</p> +</html>")); + end open_serial; + + function read_serial "read characters from serial port" + extends Modelica.Icons.Function; + input Integer handle; + input Integer size; + output Integer r_OK; + protected + Integer buf[size + 1]; + + external r_OK = read_serial(handle, buf, size) annotation( + Library = "SerialComm"); + annotation( + Documentation(info = "<html> +<h4>Syntax</h4> +<blockquote><pre> +Arduino.SerialCommunication.Functions.<b>read_serial</b>(handle,size); +</pre></blockquote> +<h4>Description</h4> +<p>The translation setting of openserial can come in the way, affecting the number of characters effectively read. If that is the case, omitting the parameter n might be a bad idea, as scilab can hang. This would happen if the input stream contains CR or LF characters which are filtered out: in such cases serialstatus counts them, but readserial does not see them and keeps wating (if the blocking mode of openserial was true) until the total number is received. +</p> +</html>")); + end read_serial; + + function write_serial "write to the serial port" + extends Modelica.Icons.Function; + input Integer handle; + input String str; + input Integer size; + output Integer w_OK; + + external w_OK = write_serial(handle, str, size) annotation( + Library = "SerialComm"); + annotation( + Documentation(info = "<html> +<h4>Syntax</h4> +<blockquote><pre> +Arduino.SerialCommunication.Functions.<b>write_serial</b>(handle,str,size); +</pre></blockquote> +<h4>Description</h4> +<p>No end of line character is appended to the string; the user might have to add it if the device being talked to requires it. The Tcl command puts -nonewline is used. In addition, the translation mode of openserial can come into way. +</p> +</html>")); + end write_serial; + + function close_serial "Command to close the serial port which is connected to Arduino" + extends Modelica.Icons.Function; + input Integer handle; + output Integer c_OK; + + external c_OK = close_serial(handle) annotation( + Library = "SerialComm"); + annotation( + Documentation(info = "<html> +<h4>Syntax</h4> +<blockquote><pre> +Arduino.SerialCommunication.Functions.<b>close_serial</b>(handle); +</pre></blockquote> +<h4>Description</h4> +<p>Closes the port for serial communication specified by \"handle\".It is important to close the serial port after use, else the port would be busy and restart of Scilab might required to connect to it again. +</p> +</html>")); + end close_serial; + + function status_serial "get status of the serial port" + extends Modelica.Icons.Function; + input Integer handle; + output Integer stat_OK; + protected + Integer bytes[2]; + + external stat_OK = status_serial(handle, bytes) annotation( + Library = "SerialComm"); + annotation( + Documentation(info = "<html> +<h4>Syntax</h4> +<blockquote><pre> +Arduino.SerialCommunication.Functions.<b>status_serial</b>(handle); +</pre></blockquote> +<h4>Description</h4> +<p>Provides status of serial communication channel specified by \"handle\".Get some information about the number of characters present in the input and output buffers of the serial port, and about the status lines (DTS, CTS, etc.).The translation setting of openserial can come in the way. If the input stream contains CR or LF characters which are filtered out, openserial counts them but readserial does not see them. +</p> +</html>")); + end status_serial; + + function cmd_digital_out "Command to sent out digital signal to a connected Arduino board" + extends Modelica.Icons.Function; + input Integer h, pin_no, val; + output Integer digital_w_OK; + + external digital_w_OK = cmd_digital_out(h, pin_no, val) annotation( + Library = "SerialComm"); + annotation( + Documentation(info = "<html> +<h4>Syntax</h4> +<blockquote><pre> +Arduino.SerialCommunication.Functions.<b>cmd_digital_out</b>(handle,pin_no,value); +</pre></blockquote> +<h4>Description</h4> +<p>The Arduino board has a set of logical ports (digital) that are used for writing or reading data from a component. +To map a UNO, ports 2-13 are available (0 and 1 are used for serial transmission). For MEGA board, ports 2-53 are available. The port takes the low logic level (0) or logic high (1) which corresponds to the reference voltage. +</p> +</html>")); + end cmd_digital_out; + + function cmd_digital_in "Command to read in digital signal from a connected Arduino board" + extends Modelica.Icons.Function; + input Integer h, pin_no; + output Integer digital_in; + + external digital_in = cmd_digital_in(h, pin_no) annotation( + Library = "SerialComm"); + annotation( + Documentation(info = "<html> +<h4>Syntax</h4> +<blockquote><pre> +Arduino.SerialCommunication.Functions.<b>cmd_digital_in</b>(handle,pin_no); +</pre></blockquote> +<h4>Description</h4> +<p>The Arduino board has a set of logical ports (digital) that are used for writing or reading data from a component. +To map a UNO, ports 2-13 are available (0 and 1 are used for serial transmission). For MEGA board, ports 2-53 are available. The port takes the low logic level (0) or logic high (1) which corresponds to the reference voltage. +</p> +</html>")); + end cmd_digital_in; + + function delay "Provides delay.Suspends Openmodelica." + extends Modelica.Icons.Function; + input Integer t; + + external delay(t) annotation( + Library = "SerialComm"); + annotation( + Documentation(info = "<html> + <h4>Syntax</h4> + <blockquote><pre> + Arduino.SerialCommunication.Functions.<b>delay</b>(milliseconds); + </pre></blockquote> + <h4>Description</h4> + <p>Delay process for specified number of miliseconds specified by the argument. The actual suspension time may be longer because of other activities in the system, or because of the time spent in processing the call. + </p> + </html>")); + end delay; + + function cmd_analog_in "Command to read in analog signal from a connected Arduino board" + extends Modelica.Icons.Function; + input Integer h, pin_no; + output Integer val; + + external val = cmd_analog_in(h, pin_no) annotation( + Library = "SerialComm"); + annotation( + Documentation(info = "<html> +<h4>Syntax</h4> +<blockquote><pre> +Arduino.SerialCommunication.Functions.<b>cmd_analog_in</b>(handle,pin_no); +</pre></blockquote> +<h4>Description</h4> +<p>Arduino UNO board has 6 analog input ports (A0 to A5), the Arduino Mega board has 16 analog input ports (A0 to A15). The 10 bits channels convert the analog input from 0 to 5 volts, to a digital value between 0 and 1023. +</p> +</html>")); + end cmd_analog_in; + + function cmd_analog_out "Command to sent out analog signal to a connected Arduino board" + extends Modelica.Icons.Function; + input Integer h, pin_no; + input Real val; + output Integer analog_w_OK; + + external analog_w_OK = cmd_analog_out(h, pin_no, val) annotation( + Library = "SerialComm"); + annotation( + Documentation(info = "<html> +<h4>Syntax</h4> +<blockquote><pre> +Arduino.SerialCommunication.Functions.<b>cmd_analog_out</b>(handle,pin_no,val); +</pre></blockquote> +<h4>Description</h4> +<p>The analog outputs of the Arduino Uno is available at the pins 3,5,6,9,10 and 11, while on the Mega board, the outputs are on pins 1-13 and 44-46. It is a bit misleading to use the term 'analog output', because in order to generate this output while minimizing energy losses, the Arduino uses PWM (Pulse Width Modulation) available on these ports. By varying the duty cycle of the PWM is altered the average voltage across the component connected to this port, which has the effect of having a analog output voltage. +The input port accepts the value from 0 to 255 which is correspoding to the duty cycle of 0 to 100%. In other words, sending 0 to the block will generate 0 V output at the port, 127 generates 2.5V and 255 generates 5V. (the port is 8 bits, so the resolutions of output would be 2^8 =256). +</p> +</html>")); + end cmd_analog_out; + + function cmd_analog_in_volt "Command to read in analog signal from a connected Arduino board" + extends Modelica.Icons.Function; + input Integer h, pin_no; + output Integer val; + + external val = cmd_analog_in_volt(h, pin_no) annotation( + Library = "SerialComm"); + annotation( + Documentation(info = "<html> + <h4>Syntax</h4> + <blockquote><pre> + Arduino.SerialCommunication.Functions.<b>cmd_analog_in_volt</b>(handle,pin_no); + </pre></blockquote> + <h4>Description</h4> + <p>Arduino UNO board has 6 analog input ports (A0 to A5), the Arduino Mega board has 16 analog input ports (A0 to A15). The 10 bits channels convert the analog input from 0 to 5 volts, to a digital value between 0 and 1023. This function scale the reading to 0-5 so the user could get the measured voltage directly. + </p> + </html>")); + end cmd_analog_in_volt; + + function cmd_analog_out_volt "Command to sent out analog signal to a connected Arduino board" + extends Modelica.Icons.Function; + input Integer h, pin_no; + input Real val; + output Integer analog_v_wOK; + + external analog_v_wOK = cmd_analog_out_volt(h, pin_no, val) annotation( + Library = "SerialComm"); + annotation( + Documentation(info = "<html> + <h4>Syntax</h4> + <blockquote><pre> + Arduino.SerialCommunication.Functions.<b>cmd_analog_out_volt</b>(handle,pin_no,val); + </pre></blockquote> + <h4>Description</h4> + <p>The analog outputs of the Arduino Uno is available at the pins 3,5,6,9,10 and 11, while on the Mega board, the outputs are on pins 1-13 and 44-46. It is a bit misleading to use the term 'analog output', because in order to generate this output while minimizing energy losses, the Arduino uses PWM (Pulse Width Modulation) available on these ports. By varying the duty cycle of the PWM is altered the average voltage across the component connected to this port, which has the effect of having a analog output voltage. + </p> + </html>")); + end cmd_analog_out_volt; + + function cmd_dcmotor_setup "Command to setup pins to control DC motor" + extends Modelica.Icons.Function; + input Integer handle, driver_type, motor_no, pin1, pin2; + + external cmd_dcmotor_setup(handle, driver_type, motor_no, pin1, pin2) annotation( + Library = "SerialComm"); + annotation( + Documentation(info = "<html> + <h4>Syntax</h4> + <blockquote><pre> + Arduino.SerialCommunication.Functions.<b>cmd_dcmotor_setup</b>(handle,driver_type,motor_no,pin_no1,pin_no2); + </pre></blockquote> + <h4>Description</h4> + <p>Arduino board does not deliver enough power, so it is necessary to use a H-bridge circuit/IC to control the motor. There are several types of H-bridge IC that do not all operate on the same principle. For example, the L298 requires the use of a PWM signal with current sense. The L293 uses two PWM to set the speed and direction. Ready-to-use Shields are also available. + Remember that the PWM is 8-bit (0 to 255). The input of the block could accept any value, but it would saturate at +- 255. + </p> + </html>")); + end cmd_dcmotor_setup; + + function cmd_dcmotor_run "Command to run DC motor after setting up" + extends Modelica.Icons.Function; + input Integer handle, motor_no, val; + + external cmd_dcmotor_run(handle, motor_no, val) annotation( + Library = "SerialComm"); + annotation( + Documentation(info = "<html> + <h4>Syntax</h4> + <blockquote><pre> + Arduino.SerialCommunication.Functions.<b>cmd_dcmotor_run</b>(handle,motor_no,value); + </pre></blockquote> + <h4>Description</h4> + <p>Arduino board does not deliver enough power, so it is necessary to use a H-bridge circuit/IC to control the motor. There are several types of H-bridge IC that do not all operate on the same principle. For example, the L298 requires the use of a PWM signal with current sense. The L293 uses two PWM to set the speed and direction. Ready-to-use Shields are also available. + Remember that the PWM is 8-bit (0 to 255). The input of the block could accept any value, but it would saturate at +- 255. + </p> + </html>")); + end cmd_dcmotor_run; + + function cmd_dcmotor_release "Command to release pins which have setup for DC motor" + extends Modelica.Icons.Function; + input Integer handle, motor_no; + + external cmd_dcmotor_release(handle, motor_no) annotation( + Library = "SerialComm"); + annotation( + Documentation(info = "<html> + <h4>Syntax</h4> + <blockquote><pre> + Arduino.SerialCommunication.Functions.<b>cmd_dcmotor_release</b>(handle,motor_no); + </pre></blockquote> + <h4>Description</h4> + <p>Arduino board does not deliver enough power, so it is necessary to use a H-bridge circuit/IC to control the motor. There are several types of H-bridge IC that do not all operate on the same principle. For example, the L298 requires the use of a PWM signal with current sense. The L293 uses two PWM to set the speed and direction. Ready-to-use Shields are also available. + Remember that the PWM is 8-bit (0 to 255). The input of the block could accept any value, but it would saturate at +- 255. + </p> + </html>")); + end cmd_dcmotor_release; + + function cmd_servo_attach "Command to attach servo motor to Arduino" + extends Modelica.Icons.Function; + input Integer handle, servo_no; + + external cmd_servo_attach(handle, servo_no) annotation( + Library = "SerialComm"); + annotation( + Documentation(info = "<html> + <h4>Syntax</h4> + <blockquote><pre> + Arduino.SerialCommunication.Functions.<b>cmd_servo_attach</b>(handle,servo_no); + </pre></blockquote> + <h4>Description</h4> + <p>A servomotor is an rotary actuator consist of an electric motor, gears, a potentiometer and an analogue or digital electronics for control. The servomotor usualy used for a position control application (or speed for continuous rotation servos). + The user must give the command of the position setpoint or desired speed. This command is sent to the actuator in pulses spaced by 10 to 20 ms. The coding of these pulses is made such that a pulse of 1.5 ms corresponding to the centered position (rest), a pulse of 1 ms corresponds to an angle of 90° in the anticlockwise direction, and a pulse 2 ms corresponds to an angle of 90° clockwise. All other pulse widths give intermediate values​​. + A servomotor for continuous rotation, the pulse width control the rotational speed and the direction. It is recommended to use a voltage regulator to power the servomotor instead of using the Arduino board power. For simplicity, the function takes an input commnad in degrees from 0 to 180. Two actuators can be controlled with this toolbox. (modified version of 3 motors available) + </p> + </html>")); + end cmd_servo_attach; + + function cmd_servo_move "Command to run servo motor which has been setup" + extends Modelica.Icons.Function; + input Integer handle, servo_no, val; + + external cmd_servo_move(handle, servo_no, val) annotation( + Library = "SerialComm"); + annotation( + Documentation(info = "<html> + <h4>Syntax</h4> + <blockquote><pre> + Arduino.SerialCommunication.Functions.<b>cmd_servo_move</b>(handle,servo_no,value); + </pre></blockquote> + <h4>Description</h4> + <p>A servomotor is an rotary actuator consist of an electric motor, gears, a potentiometer and an analogue or digital electronics for control. The servomotor usualy used for a position control application (or speed for continuous rotation servos). + The user must give the command of the position setpoint or desired speed. This command is sent to the actuator in pulses spaced by 10 to 20 ms. The coding of these pulses is made such that a pulse of 1.5 ms corresponding to the centered position (rest), a pulse of 1 ms corresponds to an angle of 90° in the anticlockwise direction, and a pulse 2 ms corresponds to an angle of 90° clockwise. All other pulse widths give intermediate values​​. + A servomotor for continuous rotation, the pulse width control the rotational speed and the direction. It is recommended to use a voltage regulator to power the servomotor instead of using the Arduino board power. For simplicity, the function takes an input commnad in degrees from 0 to 180. Two actuators can be controlled with this toolbox. (modified version of 3 motors available) + </p> + </html>")); + end cmd_servo_move; + + function cmd_servo_detach "Command to release the pin which has been setup for servo motor" + extends Modelica.Icons.Function; + input Integer handle, servo_no; + + external cmd_servo_attach(handle, servo_no) annotation( + Library = "SerialComm"); + annotation( + Documentation(info = "<html> + <h4>Syntax</h4> + <blockquote><pre> + Arduino.SerialCommunication.Functions.<b>cmd_servo_detach</b>(handle,servo_no); + </pre></blockquote> + <h4>Description</h4> + <p>A servomotor is an rotary actuator consist of an electric motor, gears, a potentiometer and an analogue or digital electronics for control. The servomotor usualy used for a position control application (or speed for continuous rotation servos). + The user must give the command of the position setpoint or desired speed. This command is sent to the actuator in pulses spaced by 10 to 20 ms. The coding of these pulses is made such that a pulse of 1.5 ms corresponding to the centered position (rest), a pulse of 1 ms corresponds to an angle of 90° in the anticlockwise direction, and a pulse 2 ms corresponds to an angle of 90° clockwise. All other pulse widths give intermediate values​​. + A servomotor for continuous rotation, the pulse width control the rotational speed and the direction. It is recommended to use a voltage regulator to power the servomotor instead of using the Arduino board power. For simplicity, the function takes an input commnad in degrees from 0 to 180. Two actuators can be controlled with this toolbox. (modified version of 3 motors available) + </p> + </html>")); + end cmd_servo_detach; + + function ieeesingle2num "ieee-745 floating point converter" + extends Modelica.Icons.Function; + input String hexa; + output Real y; + + external y = ieeesingle2num(hexa) annotation( + Library = "SerialComm"); + annotation( + Documentation(info = "<html> +<h4>Syntax</h4> +<blockquote><pre> +Arduino.SerialCommunication.Functions.<b>ieeesingle2num</b>(hexa); +</pre></blockquote> +<h4>Description</h4> +<p>Converts an hexadecimal integer to ieee single precision format + </p> +</html>")); + end ieeesingle2num; + + function math_floor "Floor function" + extends Modelica.Icons.Function; + input Real x; + output Integer y; + + external y = mfloor(x) annotation( + Library = "SerialComm"); + annotation( + Documentation(info = "<html> + <h4>Syntax</h4> + <blockquote><pre> + Arduino.SerialCommunication.Functions.<b>math_floor</b>(x); + </pre></blockquote> + <h4>Description</h4> + <p>Returns the greatest integer less than or equal to x + </p> + </html>")); + end math_floor; + + package MDD_Servo + extends Modelica.Icons.Package; + + class Init + extends ExternalObject; + + function constructor "Return device handle" + extends .Modelica.Icons.Function; + import Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions; + import Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types; + import sComm = Arduino.SerialCommunication.Functions; + import Arduino.SerialCommunication.Functions.MDD_Servo; + input sComm.Types.Servo_no servo_no; + output sComm.Functions.MDD_Servo.Init servo; + + external "C" servo = MDD_avr_servo_initialize(servo_no) annotation( + Include = "#include \"/home/souradip/OpenModelica/Resources/Include/MDDAVRServo.h\""); + end constructor; + + function destructor "Destructor" + extends .Modelica.Icons.Function; + import Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types; + import sComm = Arduino.SerialCommunication.Functions; + import Arduino.SerialCommunication.Functions.MDD_Servo; + input sComm.Types.Servo_no servo_no "Device handle"; + + external "C" MDD_avr_servo_finalize(servo_no) annotation( + Include = "#include \"/home/souradip/OpenModelica/Resources/Include/MDDAVRServo.h\""); + end destructor; + end Init; + + function Move + extends Modelica.Icons.Function; + import sComm = Arduino.SerialCommunication.Functions; + input sComm.Functions.MDD_Servo.Init servo; + input Integer value; + + external "C" MDD_avr_servo_move(servo, value) annotation( + Include = "#include \"/home/souradip/OpenModelica/Resources/Include/MDDAVRServo.h\""); + end Move; + end MDD_Servo; + end Functions; + + package Examples + extends Modelica.Icons.ExamplesPackage; + + package led + extends Modelica.Icons.ExamplesPackage; + + model led_blue "Turn on Blue LED" + extends Modelica.Icons.Example; + import sComm = Arduino.SerialCommunication.Functions; + import strm = Modelica.Utilities.Streams; + Integer ok(fixed = false); + Integer digital_out(fixed = false); + Integer c_ok(fixed = false); + algorithm + when initial() then + ok := sComm.open_serial(1, 2, 115200) "At port 2 with baudrate of 115200"; + if ok <> 0 then + strm.print("Check the serial port and try again"); + else + sComm.delay(1000); + digital_out := sComm.cmd_digital_out(1, 9, 1) "This will turn ON the blue LED"; + end if; + c_ok := sComm.close_serial(1) "To close the connection safely"; + end when; +//strm.print(String(time)); + annotation( + experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 10)); + end led_blue; + + model led_blue_delay "Turn on Blue LED for a period of 2 seconds" + extends Modelica.Icons.Example; + import sComm = Arduino.SerialCommunication.Functions; + import strm = Modelica.Utilities.Streams; + Integer ok(fixed = false); + Integer digital_out(fixed = false); + Integer c_ok(fixed = false); + algorithm + when initial() then + ok := sComm.open_serial(1, 2, 115200) "At port 2 with baudrate of 115200"; + sComm.delay(2000); + if ok <> 0 then + strm.print("Check the serial port and try again"); + else + digital_out := sComm.cmd_digital_out(1, 9, 1) "This will turn the blue LED"; + sComm.delay(2000) "let the blue LED be on for two seconds"; + digital_out := sComm.cmd_digital_out(1, 9, 0) "turn off blue LED"; + sComm.delay(2000) "let the blue LED be off for two seconds"; + end if; + c_ok := sComm.close_serial(1) "To close the connection safely"; + end when; +//strm.print(String(time)); + annotation( + experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 10)); + end led_blue_delay; + + model led_blue_red "Turn on Red & Blue LED" + extends Modelica.Icons.Example; + import sComm = Arduino.SerialCommunication.Functions; + import strm = Modelica.Utilities.Streams; + Integer ok(fixed = false); + Integer digital_out(fixed = false); + Integer c_ok(fixed = false); + algorithm + when initial() then + ok := sComm.open_serial(1, 2, 115200) "At port 2 with baudrate of 115200"; + sComm.delay(2000); + if ok <> 0 then + strm.print("Check the serial port and try again"); + else + digital_out := sComm.cmd_digital_out(1, 9, 1) "This will turn the blue LED"; + digital_out := sComm.cmd_digital_out(1, 11, 1) "This will turn the red LED"; + sComm.delay(5000) "Delay for 5 seconds"; + digital_out := sComm.cmd_digital_out(1, 9, 0) "This turns off the blue Led"; + sComm.delay(3000) "Delay for 3 seconds"; + digital_out := sComm.cmd_digital_out(1, 11, 0) "This turns off the red Led"; + end if; + c_ok := sComm.close_serial(1) "To close the connection safely"; + end when; +//strm.print(String(time)); + annotation( + experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 10)); + end led_blue_red; + + model led_green_blink "This will turn on and turn off the green LED for every second for 5 times" + extends Modelica.Icons.Example; + import sComm = Arduino.SerialCommunication.Functions; + import strm = Modelica.Utilities.Streams; + Integer ok(fixed = false); + Integer digital_out(fixed = false); + Integer c_ok(fixed = false); + algorithm + when initial() then + ok := sComm.open_serial(1, 2, 115200) "At port 2 with baudrate of 115200"; + sComm.delay(2000); + if ok <> 0 then + strm.print("Check the serial port and try again"); + else + for i in 1:10 loop + digital_out := sComm.cmd_digital_out(1, 10, 1) "This will turn off the green LED"; + sComm.delay(1000) "Delay for 1 second"; + digital_out := sComm.cmd_digital_out(1, 10, 0) "This turns the green Led"; + sComm.delay(1000) "Delay for 1 second"; + end for; + end if; + c_ok := sComm.close_serial(1) "To close the connection safely"; + end when; +// strm.print(String(time)); + annotation( + experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 10)); + end led_green_blink; + end led; + + package push + extends Modelica.Icons.ExamplesPackage; + + model led_push_button "Conrolling LED with PushButton" + extends Modelica.Icons.Example; + import sComm = Arduino.SerialCommunication.Functions; + import strm = Modelica.Utilities.Streams; + Integer ok(fixed = false); + Integer digital_in(fixed = false); + Integer digital_out(fixed = false); + Integer c_ok(fixed = false); + algorithm + when initial() then + ok := sComm.open_serial(1, 2, 115200) "At port 2 with baudrate of 115200"; + sComm.delay(2000); + end when; + if ok <> 0 then + strm.print("Unable to open serial port, please check"); + else + digital_in := sComm.cmd_digital_in(1, 12) ""; + if digital_in == 0 then + strm.print("0"); + digital_out := sComm.cmd_digital_out(1, 9, 0) "This will turn OFF the blue LED"; + sComm.delay(200); + else + strm.print("1"); + digital_out := sComm.cmd_digital_out(1, 9, 1) "This will turn ON the blue LED"; + sComm.delay(200); + end if; + end if; +//for i in 1:1000 loop +//end for; +// strm.print(String(time)); + when terminal() then + c_ok := sComm.close_serial(1) "To close the connection safely"; + end when; + annotation( + experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 0.1)); + end led_push_button; + + model push_button_status "Checking Status of PushButton" + extends Modelica.Icons.Example; + import sComm = Arduino.SerialCommunication.Functions; + import strm = Modelica.Utilities.Streams; + Integer ok(fixed = false); + Integer digital_in(fixed = false); + Integer c_ok(fixed = false); + algorithm + when initial() then + ok := sComm.open_serial(1, 2, 115200) "At port 2 with baudrate of 115200"; + end when; + if ok <> 0 then + strm.print("Unable to open serial port, please check"); + else + digital_in := sComm.cmd_digital_in(1, 12); + if digital_in == 0 then + strm.print("0"); + sComm.delay(200); + else + strm.print("1"); + sComm.delay(200); + end if; + end if; +//for i in 1:1000 loop +//end for; + when terminal() then + c_ok := sComm.close_serial(1) "To close the connection safely"; + end when; +//sComm.cmd_arduino_meter(digital_in); + annotation( + experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 0.1)); + end push_button_status; + end push; + + package ldr + extends Modelica.Icons.ExamplesPackage; + + model ldr_led "LED indicating light sensor readings" + extends Modelica.Icons.Example; + import sComm = Arduino.SerialCommunication.Functions; + import strm = Modelica.Utilities.Streams; + Integer ok(fixed = false); + Integer analog_in(fixed = false); + Integer digital_out(fixed = false); + Integer c_ok(fixed = false); + algorithm + when initial() then + ok := sComm.open_serial(1, 2, 115200) "At port 2 with baudrate of 115200"; + sComm.delay(2000); + end when; + if ok <> 0 then + strm.print("Unable to open serial port, please check"); + else + analog_in := sComm.cmd_analog_in(1, 5) "read analog pin 5 (ldr)"; + strm.print("LDR Readings: " + String(analog_in)); + if analog_in < 300 then + digital_out := sComm.cmd_digital_out(1, 9, 1) "Turn ON LED"; + else + digital_out := sComm.cmd_digital_out(1, 9, 0) "Turn OFF LED"; + end if; + sComm.delay(500); + end if; +//strm.print(String(time)); + when time >= 10 then + c_ok := sComm.close_serial(1) "To close the connection safely"; + end when; +//Setting Threshold value of 300 + annotation( + experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 0.2)); + end ldr_led; + + model ldr_read "Reading light intensity using ldr" + extends Modelica.Icons.Example; + import sComm = Arduino.SerialCommunication.Functions; + import strm = Modelica.Utilities.Streams; + Integer ok(fixed = false); + Integer analog_in(fixed = false); + Integer c_ok(fixed = false); + algorithm + when initial() then + ok := sComm.open_serial(1, 2, 115200) "At port 2 with baudrate of 115200"; + sComm.delay(2000); + end when; + if ok <> 0 then + strm.print("Unable to open serial port, please check"); + else + analog_in := sComm.cmd_analog_in(1, 5) "read analog pin 5 (ldr)"; + strm.print("LDR Readings: " + String(analog_in)); + sComm.delay(500); + end if; + when time >= 10 then + c_ok := sComm.close_serial(1) "To close the connection safely"; + end when; + annotation( + experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 1)); + end ldr_read; + end ldr; + + package pot + extends Modelica.Icons.ExamplesPackage; + + model pot_threshold + extends Modelica.Icons.Example; + import sComm = Arduino.SerialCommunication.Functions; + import strm = Modelica.Utilities.Streams; + Integer ok(fixed = false); + Integer analog_in(fixed = false); + Integer digital_out(fixed = false); + Integer c_ok(fixed = false); + algorithm + when initial() then + ok := sComm.open_serial(1, 2, 115200) "At port 2 with baudrate of 115200"; + end when; + if ok <> 0 then + strm.print("Unable to open serial port, please check"); + else + analog_in := sComm.cmd_analog_in(1, 2) "read analog pin 2"; + strm.print("Potentiometer Readings: " + String(analog_in)); + if analog_in >= 0 and analog_in < 320 then + digital_out := sComm.cmd_digital_out(1, 11, 1) "Turn ON LED"; + sComm.delay(1000); + digital_out := sComm.cmd_digital_out(1, 11, 0) "Turn OFF LED"; + elseif analog_in >= 320 and analog_in <= 900 then + digital_out := sComm.cmd_digital_out(1, 10, 1) "Turn ON LED"; + sComm.delay(1000); + digital_out := sComm.cmd_digital_out(1, 10, 0) "Turn OFF LED"; + elseif analog_in > 900 and analog_in <= 1023 then + digital_out := sComm.cmd_digital_out(1, 9, 1) "Turn ON LED"; + sComm.delay(1000); + digital_out := sComm.cmd_digital_out(1, 9, 0) "Turn OFF LED"; + end if; + end if; + digital_out := sComm.cmd_digital_out(1, 9, 0) "Turn OFF LED"; + digital_out := sComm.cmd_digital_out(1, 10, 0) "Turn OFF LED"; + digital_out := sComm.cmd_digital_out(1, 11, 0) "Turn OFF LED"; +//Threshold 1 +//Threshold 2 + when time >= 10 then + c_ok := sComm.close_serial(1) "To close the connection safely"; + end when; + annotation( + experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 1)); + end pot_threshold; + end pot; + + package thermistor + extends Modelica.Icons.ExamplesPackage; + + model therm_buzzer "Sound buzzer depending on thermistor readings" + extends Modelica.Icons.Example; + import sComm = Arduino.SerialCommunication.Functions; + import strm = Modelica.Utilities.Streams; + Integer ok(fixed = false); + Integer analog_in(fixed = false); + Integer digital_out(fixed = false); + Integer c_ok(fixed = false); + algorithm + when initial() then + ok := sComm.open_serial(1, 2, 115200) "At port 2 with baudrate of 115200"; + sCOmm.delay(2000); + end when; + if ok <> 0 then + strm.print("Unable to open serial port, please check"); + else + analog_in := sComm.cmd_analog_in(1, 4) "read analog pin 4"; + strm.print("Thermistor Readings: " + String(analog_in)); + if analog_in > 550 then + digital_out := sComm.cmd_digital_out(1, 3, 1) "Turn ON Buzzer"; + else + digital_out := sComm.cmd_digital_out(1, 3, 0) "Turn OFF Buzzer"; + end if; + sComm.delay(500); + end if; +//for i in 1:500 loop +//end for; +//Run for 500 iterations +//Setting Threshold value of 500 + when terminal() then + c_ok := sComm.close_serial(1) "To close the connection safely"; + end when; + annotation( + experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 0.1)); + end therm_buzzer; + + model therm_read "Thermistor Readings" + extends Modelica.Icons.Example; + import sComm = Arduino.SerialCommunication.Functions; + import strm = Modelica.Utilities.Streams; + Integer ok(fixed = false); + Integer analog_in(fixed = false); + Integer c_ok(fixed = false); + algorithm + when initial() then + ok := sComm.open_serial(1, 2, 115200) "At port 2 with baudrate of 115200"; + sComm.delay(2000); + end when; + if ok <> 0 then + strm.print("Unable to open serial port, please check"); + else + analog_in := sComm.cmd_analog_in(1, 4) "read analog pin 5 (ldr)"; + strm.print("Thermistor Readings: " + String(analog_in)); + sComm.delay(500); + end if; + when terminal() then + c_ok := sComm.close_serial(1) "To close the connection safely"; + end when; + annotation( + experiment(StartTime = 0, StopTime = 20, Tolerance = 1e-6, Interval = 1)); + end therm_read; + end thermistor; + + package dcmotor + extends Modelica.Icons.ExamplesPackage; + + model dcmotor_clock "Rotate DC Motor clockwise" + extends Modelica.Icons.Example; + import sComm = Arduino.SerialCommunication.Functions; + import strm = Modelica.Utilities.Streams; + Integer ok(fixed = false); + Integer c_ok(fixed = false); + algorithm + when initial() then + ok := sComm.open_serial(1, 2, 115200) "COM port is 2 and baud rate is 115200"; + sComm.delay(2000); + if ok <> 0 then + strm.print("Unable to open serial port, please check"); + else + sComm.delay(1000); + sComm.cmd_dcmotor_setup(1, 3, 1, 9, 10) "Setup DC motor of type 3 (L293D), motor 1, pin 9 and 10"; + sComm.cmd_dcmotor_run(1, 1, 100) "Motor 1 runs at PWM 100"; + sComm.delay(3000) "This is allowed to continue for 3 seconds"; + sComm.cmd_dcmotor_release(1, 1) "Motor 1 is released"; + end if; + c_ok := sComm.close_serial(1) "To close the connection safely"; + end when; + annotation( + experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 10)); + end dcmotor_clock; + + model dcmotor_both "Rotate DC Motor in both directions" + extends Modelica.Icons.Example; + import sComm = Arduino.SerialCommunication.Functions; + import strm = Modelica.Utilities.Streams; + Integer ok(fixed = false); + Integer c_ok(fixed = false); + algorithm + when initial() then + ok := sComm.open_serial(1, 2, 115200) "COM port is 2 and baud rate is 115200"; + sComm.delay(2000); + if ok <> 0 then + strm.print("Unable to open serial port, please check"); + else + sComm.cmd_dcmotor_setup(1, 3, 1, 9, 10) "Setup DC motor of type 3 (L293D), motor 1, pin 9 and 10"; + sComm.cmd_dcmotor_run(1, 1, 100) "Motor 1 runs at PWM 100"; + sComm.delay(3000) "for 3 seconds"; + sComm.cmd_dcmotor_run(1, 1, -100) "Motor 1 runs at PWM -100 in reverse direction"; + sComm.delay(2000) "for 2 seconds"; + sComm.cmd_dcmotor_release(1, 1) "Motor 1 is released"; + end if; + c_ok := sComm.close_serial(1) "To close the connection safely"; + end when; + annotation( + experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 10)); + end dcmotor_both; + + model dcmotor_loop "Rotate DC Motor in both directions in a loop" + extends Modelica.Icons.Example; + import sComm = Arduino.SerialCommunication.Functions; + import strm = Modelica.Utilities.Streams; + Integer ok(fixed = false); + Integer c_ok(fixed = false); + algorithm + when initial() then + ok := sComm.open_serial(1, 2, 115200) "COM port is 2 and baud rate is 115200"; + sComm.delay(2000); + if ok <> 0 then + strm.print("Unable to open serial port, please check"); + else + sComm.cmd_dcmotor_setup(1, 3, 1, 9, 10) "Setup DC motor of type 3 (L293D), motor 1, pins 9 and 10"; + for i in 1:4 loop + sComm.cmd_dcmotor_run(1, 1, 100) "Motor 1 runs at PWM 100"; + sComm.delay(3000) "for 3 seconds"; + sComm.cmd_dcmotor_run(1, 1, 0) "Halt the motor"; + sComm.delay(2000) "for 2 seconds"; + sComm.cmd_dcmotor_run(1, 1, -100) "Run it at PWM 100 in reverse direction"; + sComm.delay(2000) "for 2 seconds"; + end for; + sComm.cmd_dcmotor_release(1, 1) "Motor 1 is released"; + end if; + c_ok := sComm.close_serial(1) "To close the connection safely"; + end when; + annotation( + experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 10)); + end dcmotor_loop; + end dcmotor; + + package servo + extends Modelica.Icons.ExamplesPackage; + + model servo_init "Rotate Servo Motor " + extends Modelica.Icons.Example; + import sComm = Arduino.SerialCommunication.Functions; + import strm = Modelica.Utilities.Streams; + Integer ok(fixed = false); + Integer c_ok(fixed = false); + algorithm + when initial() then + ok := sComm.open_serial(1, 2, 115200) "COM port is 2 and baud rate is 115200"; + if ok <> 0 then + strm.print("Check the serial port and try again"); + else + sComm.cmd_servo_attach(1, 1) "To attach the motor to pin 9 of servo1"; + sComm.cmd_servo_move(1, 1, 30) "tell servo to rotate by 30 degrees"; + sComm.delay(3000); + end if; + c_ok := sComm.close_serial(1) "To close the connection safely"; + end when; +//sComm.cmd_servo_detach(1,1); + annotation( + experiment(StartTime = 0, StopTime = 5, Tolerance = 1e-6, Interval = 5)); + end servo_init; + + model servo_loop "Rotate servo motor by 20 degrees 10 times" + extends Modelica.Icons.Example; + import sComm = Arduino.SerialCommunication.Functions; + import strm = Modelica.Utilities.Streams; + Integer ok(fixed = false); + Integer c_ok(fixed = false); + Integer angle(fixed = true); + algorithm + when initial() then + ok := sComm.open_serial(1, 2, 115200) "COM port is 2 and baud rate is 115200"; + if ok <> 0 then + strm.print("Check the serial port and try again"); + else + sComm.cmd_servo_attach(1, 1) "Attach motor to pin 9. 1 means pin 9."; + sComm.delay(2000); + angle := 20 "Angle by which it has to move"; + for i in 1:10 loop + sComm.cmd_servo_move(1, 1, angle * i) "tell servo to rotate by 20 degrees"; + sComm.delay(1000) "waits for a sec"; + end for; + sComm.cmd_servo_detach(1, 1) "Detach the motor"; + end if; + c_ok := sComm.close_serial(1) "To close the connection safely"; + end when; + annotation( + experiment(StartTime = 0, StopTime = 5, Tolerance = 1e-6, Interval = 5)); + end servo_loop; + + model servo_reverse + extends Modelica.Icons.Example; + import sComm = Arduino.SerialCommunication.Functions; + import strm = Modelica.Utilities.Streams; + Integer ok(fixed = false); + Integer c_ok(fixed = false); + algorithm + when initial() then + ok := sComm.open_serial(1, 2, 115200) "COM port is 2 and baud rate is 115200"; + sComm.delay(2000); + if ok <> 0 then + strm.print("Check the serial port and try again"); + else + sComm.cmd_servo_attach(1, 1) "Attach the motor to pin 9. 1 means 9"; + sComm.cmd_servo_move(1, 1, 90) "Move the servo to 90 degree"; + sComm.delay(1000) "be there for one second"; + sComm.cmd_servo_move(1, 1, 45) "Move the servo to 45 degree"; + sComm.delay(1000) "be there for one second"; + sComm.cmd_servo_detach(1, 1) "Detach the motor"; + sComm.delay(1000); + end if; + c_ok := sComm.close_serial(1) "To close the connection safely"; + end when; + annotation( + experiment(StartTime = 0, StopTime = 5, Tolerance = 1e-6, Interval = 5)); + end servo_reverse; + + model servo_pot "Control Servo Motor using Potentiometer" + extends Modelica.Icons.Example; + import sComm = Arduino.SerialCommunication.Functions; + import strm = Modelica.Utilities.Streams; + Integer ok(fixed = false); + Integer c_ok(fixed = false); + Integer analog_in(fixed = false); + algorithm + when initial() then + ok := sComm.open_serial(1, 2, 115200) "COM port is 2 and baud rate is 115200"; + sComm.delay(2000); + if ok <> 0 then + strm.print("Check the serial port and try again"); + else + sComm.cmd_servo_attach(1, 1) "Attach the motor to pin 9"; + sComm.delay(2000); + for i in 1:5000 loop + analog_in := sComm.cmd_analog_in(1, 2) "Read potentiometer value"; + sComm.cmd_servo_move(1, 1, analog_in) "Command the servo motor"; + sComm.delay(1000) "sleep for 1000 milliseconds"; + end for; + sComm.cmd_servo_detach(1, 1) "Detach the motor"; + end if; + analog_in := sComm.math_floor(analog_in * (180 / 1023)) "Scale Potentiometer value to 0-180"; + c_ok := sComm.close_serial(1) "To close the connection safely"; + end when; +//5,000 itterations +//strm.print(String(analog_in)); + annotation( + experiment(StartTime = 0, StopTime = 5, Tolerance = 1e-6, Interval = 5)); + end servo_pot; + end servo; + + package modbus + extends Modelica.Icons.ExamplesPackage; + + function read_voltage + extends Modelica.Icons.Function; + + external read_voltage() annotation( + Library = "SerialComm"); + annotation( + Documentation(info = "<html> + <h4>Syntax</h4> + <blockquote><pre> + Arduino.SerialCommunication.Examples.modbus.<b>read_voltage</b>(); + </pre></blockquote> + <h4>Description</h4> + <p> + </p> + </html>")); + end read_voltage; + + function read_current + extends Modelica.Icons.Function; + + external read_current() annotation( + Library = "SerialComm"); + annotation( + Documentation(info = "<html> + <h4>Syntax</h4> + <blockquote><pre> + Arduino.SerialCommunication.Examples.modbus.<b>read_current</b>(); + </pre></blockquote> + <h4>Description</h4> + <p> + </p> + </html>")); + end read_current; + + function read_val + extends Modelica.Icons.Function; + input Integer addr_byte; + output Real p; + + external p = read_val(addr_byte) annotation( + Library = "SerialComm"); + annotation( + Documentation(info = "<html> + <h4>Syntax</h4> + <blockquote><pre> + Arduino.SerialCommunication.Examples.modbus.<b>read_val</b>(address_byte); + </pre></blockquote> + <h4>Description</h4> + <p> + </p> + </html>")); + end read_val; + + function read_active_power + extends Modelica.Icons.Function; + + external read_active_power() annotation( + Library = "SerialComm"); + annotation( + Documentation(info = "<html> + <h4>Syntax</h4> + <blockquote><pre> + Arduino.SerialCommunication.Examples.modbus.<b>read_active_power</b>(); + </pre></blockquote> + <h4>Description</h4> + <p> + </p> + </html>")); + end read_active_power; + + model modbus_test + extends Modelica.Icons.Example; + import sComm = Arduino.SerialCommunication.Functions; + import modbus = Arduino.SerialCommunication.Examples.modbus; + //Integer ok(fixed = false); + //Integer c_ok(fixed = false); + algorithm + when initial() then + modbus.read_voltage(); + modbus.read_current(); + modbus.read_active_power(); + sComm.delay(2000); + end when; +//ok:=sComm.open_serial(1,2,9600); +//c_ok:=sComm.close_serial(1); + end modbus_test; + end modbus; + end Examples; + + package MDD_Examples "Interfacing arduino with OpenModelica using Modelica Device Drivers" + extends Modelica.Icons.ExamplesPackage; + + package MDD_led + extends Modelica.Icons.ExamplesPackage; + + model MDD_led_blue "" + extends Modelica.Icons.Example; + inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation( + Placement(visible = true, transformation(origin = {-40, 40}, extent = {{-20, -20}, {20, 20}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation( + Placement(visible = true, transformation(origin = {39, 41}, extent = {{-17, -17}, {17, 17}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'1', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation( + Placement(visible = true, transformation(origin = {39, -21}, extent = {{-19, -19}, {19, 19}}, rotation = 0))); + Modelica.Blocks.Sources.BooleanExpression booleanExpression1(y = true) annotation( + Placement(visible = true, transformation(origin = {-41, -21}, extent = {{-15, -17}, {15, 17}}, rotation = 0))); + equation + connect(booleanExpression1.y, digitalWriteBoolean1.u) annotation( + Line(points = {{-24, -20}, {14, -20}, {14, -20}, {16, -20}}, color = {255, 0, 255})); + annotation( + Documentation(info = "<html> + <h4>Syntax</h4> + <blockquote><pre> + Arduino.SerialCommunication.MDD_Examples.MDD_led.<b>MDD-led_blue</b>(); + </pre></blockquote> + <h4>Description</h4> + <p> + </p> + </html>")); + end MDD_led_blue; + + model MDD_led_blue_delay + extends Modelica.Icons.Example; + inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation( + Placement(visible = true, transformation(origin = {-40, 40}, extent = {{-20, -20}, {20, 20}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation( + Placement(visible = true, transformation(origin = {31, 41}, extent = {{-19, -19}, {19, 19}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'1', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation( + Placement(visible = true, transformation(origin = {41, -17}, extent = {{-17, -17}, {17, 17}}, rotation = 0))); + Modelica.Blocks.Sources.BooleanExpression booleanExpression1(y = if time < 5 then true else false) annotation( + Placement(visible = true, transformation(origin = {-27, -16}, extent = {{-21, -16}, {21, 16}}, rotation = 0))); + equation + connect(booleanExpression1.y, digitalWriteBoolean1.u) annotation( + Line(points = {{-4, -16}, {20, -16}}, color = {255, 0, 255})); + end MDD_led_blue_delay; + + model MDD_led_blink + extends Modelica.Icons.Example; + inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation( + Placement(visible = true, transformation(origin = {-45, 71}, extent = {{-23, -23}, {23, 23}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'5', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation( + Placement(visible = true, transformation(origin = {42, -22}, extent = {{-20, -20}, {20, 20}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation( + Placement(visible = true, transformation(origin = {23, 71}, extent = {{-19, -19}, {19, 19}}, rotation = 0))); + Modelica.Blocks.Sources.BooleanExpression booleanExpression1(y = mod(time, 2) >= 1) annotation( + Placement(visible = true, transformation(origin = {-24, -21}, extent = {{-16, -15}, {16, 15}}, rotation = 0))); + equation + connect(booleanExpression1.y, digitalWriteBoolean1.u) annotation( + Line(points = {{-6, -21}, {16, -21}, {16, -22}, {18, -22}}, color = {255, 0, 255})); + end MDD_led_blink; + + model MDD_led_blue_red + extends Modelica.Icons.Example; + inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation( + Placement(visible = true, transformation(origin = {-47, 47}, extent = {{-21, -21}, {21, 21}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'1', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation( + Placement(visible = true, transformation(origin = {38, -16}, extent = {{-16, -16}, {16, 16}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation( + Placement(visible = true, transformation(origin = {40, 44}, extent = {{-18, -18}, {18, 18}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean2(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'3', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation( + Placement(visible = true, transformation(origin = {38, -62}, extent = {{-16, -16}, {16, 16}}, rotation = 0))); + Modelica.Blocks.Sources.BooleanExpression booleanExpression1(y = if time < 1 then true else false) annotation( + Placement(visible = true, transformation(origin = {-32, -16}, extent = {{-18, -14}, {18, 14}}, rotation = 0))); + Modelica.Blocks.Sources.BooleanExpression booleanExpression2(y = if time < 1.6 then true else false) annotation( + Placement(visible = true, transformation(origin = {-32, -62}, extent = {{-18, -16}, {18, 16}}, rotation = 0))); + equation + connect(digitalWriteBoolean2.u, booleanExpression2.y) annotation( + Line(points = {{18, -62}, {-12, -62}, {-12, -62}, {-12, -62}}, color = {255, 0, 255})); + connect(booleanExpression2.y, digitalWriteBoolean2.u) annotation( + Line(points = {{-12, -62}, {18, -62}, {18, -62}, {18, -62}}, color = {255, 0, 255})); + connect(booleanExpression1.y, digitalWriteBoolean1.u) annotation( + Line(points = {{-12, -16}, {18, -16}, {18, -16}, {18, -16}}, color = {255, 0, 255})); + end MDD_led_blue_red; + + model MDD_led_green_blink + extends Modelica.Icons.Example; + inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation( + Placement(visible = true, transformation(origin = {-40, 40}, extent = {{-20, -20}, {20, 20}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'2', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation( + Placement(visible = true, transformation(origin = {46, -30}, extent = {{-18, -18}, {18, 18}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation( + Placement(visible = true, transformation(origin = {39, 39}, extent = {{-19, -19}, {19, 19}}, rotation = 0))); + Modelica.Blocks.Sources.BooleanExpression booleanExpression1(y = mod(time, 2) >= 1) annotation( + Placement(visible = true, transformation(origin = {-17, -30}, extent = {{-15, -14}, {15, 14}}, rotation = 0))); + equation + connect(booleanExpression1.y, digitalWriteBoolean1.u) annotation( + Line(points = {{0, -30}, {24, -30}, {24, -30}, {24, -30}}, color = {255, 0, 255})); + end MDD_led_green_blink; + end MDD_led; + + package MDD_push + extends Modelica.Icons.ExamplesPackage; + + model MDD_led_push_button + extends Modelica.Icons.Example; + inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation( + Placement(visible = true, transformation(origin = {-38, 40}, extent = {{-18, -18}, {18, 18}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'1', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation( + Placement(visible = true, transformation(origin = {64, -26}, extent = {{-16, -16}, {16, 16}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer1) annotation( + Placement(visible = true, transformation(origin = {39, 41}, extent = {{-17, -17}, {17, 17}}, rotation = 0))); + Modelica.Blocks.Logical.LogicalSwitch logicalSwitch1 annotation( + Placement(visible = true, transformation(origin = {16, -26}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Modelica.Blocks.Sources.BooleanExpression booleanExpression1(y = true) annotation( + Placement(visible = true, transformation(origin = {-20, 8}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Modelica.Blocks.Sources.BooleanExpression booleanExpression2(y = false) annotation( + Placement(visible = true, transformation(origin = {-18, -62}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalReadBoolean digitalReadBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'4', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.D) annotation( + Placement(visible = true, transformation(origin = {-60, -26}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + equation + connect(logicalSwitch1.y, digitalWriteBoolean1.u) annotation( + Line(points = {{28, -26}, {44, -26}, {44, -26}, {44, -26}}, color = {255, 0, 255})); + connect(digitalReadBoolean1.y, logicalSwitch1.u2) annotation( + Line(points = {{-48, -26}, {2, -26}, {2, -26}, {4, -26}}, color = {255, 0, 255})); + connect(booleanExpression1.y, logicalSwitch1.u1) annotation( + Line(points = {{-8, 8}, {-2, 8}, {-2, -18}, {4, -18}, {4, -18}}, color = {255, 0, 255})); + connect(booleanExpression2.y, logicalSwitch1.u3) annotation( + Line(points = {{-6, -62}, {-2, -62}, {-2, -34}, {4, -34}, {4, -34}}, color = {255, 0, 255})); + end MDD_led_push_button; + + model MDD_push_button_status + extends Modelica.Icons.Example; + inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation( + Placement(visible = true, transformation(origin = {-43, 43}, extent = {{-19, -19}, {19, 19}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation( + Placement(visible = true, transformation(origin = {20, 42}, extent = {{-18, -18}, {18, 18}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalReadBoolean digitalReadBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'4', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation( + Placement(visible = true, transformation(origin = {-39, -19}, extent = {{-19, -19}, {19, 19}}, rotation = 0))); + Modelica.Blocks.Interaction.Show.BooleanValue booleanValue1(use_activePort = true) annotation( + Placement(visible = true, transformation(origin = {31, -19}, extent = {{-15, -17}, {15, 17}}, rotation = 0))); + equation + connect(digitalReadBoolean1.y, booleanValue1.activePort) annotation( + Line(points = {{-18, -18}, {14, -18}, {14, -18}, {14, -18}}, color = {255, 0, 255})); + end MDD_push_button_status; + end MDD_push; + + package MDD_ldr + extends Modelica.Icons.ExamplesPackage; + + model MDD_ldr_led + extends Modelica.Icons.Example; + inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation( + Placement(visible = true, transformation(origin = {-45, 65}, extent = {{-21, -21}, {21, 21}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation( + Placement(visible = true, transformation(origin = {40, 60}, extent = {{-20, -20}, {20, 20}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'1', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation( + Placement(visible = true, transformation(origin = {79, -23}, extent = {{-17, -17}, {17, 17}}, rotation = 0))); + Modelica.Blocks.Sources.BooleanExpression booleanExpression1(y = true) annotation( + Placement(visible = true, transformation(origin = {-60, 12}, extent = {{-14, -16}, {14, 16}}, rotation = 0))); + Modelica.Blocks.Sources.BooleanExpression booleanExpression2 annotation( + Placement(visible = true, transformation(origin = {-59, -79}, extent = {{-13, -17}, {13, 17}}, rotation = 0))); + Modelica.Blocks.Logical.LogicalSwitch logicalSwitch1 annotation( + Placement(visible = true, transformation(origin = {28, -22}, extent = {{-16, -16}, {16, 16}}, rotation = 0))); + Modelica.Blocks.Logical.GreaterThreshold greaterThreshold1(threshold = 600) annotation( + Placement(visible = true, transformation(origin = {-21, -23}, extent = {{-11, -11}, {11, 11}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.ADC adc(analogPort = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPort.A5, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPrescaler.'1/128', voltageReference = 1024, voltageReferenceSelect = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.VRefSelect.Internal) annotation( + Placement(visible = true, transformation(origin = {-72, -22}, extent = {{-20, -20}, {20, 20}}, rotation = 0))); + equation + connect(adc.y, greaterThreshold1.u) annotation( + Line(points = {{-50, -22}, {-34, -22}}, color = {0, 0, 127})); + connect(greaterThreshold1.y, logicalSwitch1.u2) annotation( + Line(points = {{-8, -22}, {8, -22}, {8, -22}, {8, -22}}, color = {255, 0, 255})); + connect(logicalSwitch1.y, digitalWriteBoolean1.u) annotation( + Line(points = {{46, -22}, {58, -22}, {58, -22}, {58, -22}}, color = {255, 0, 255})); + connect(booleanExpression1.y, logicalSwitch1.u1) annotation( + Line(points = {{-44, 12}, {8, 12}, {8, -10}, {8, -10}}, color = {255, 0, 255})); + connect(booleanExpression2.y, logicalSwitch1.u3) annotation( + Line(points = {{-44, -78}, {6, -78}, {6, -34}, {8, -34}}, color = {255, 0, 255})); + end MDD_ldr_led; + + model MDD_ldr_read + extends Modelica.Icons.Example; + inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation( + Placement(visible = true, transformation(origin = {-37, 39}, extent = {{-19, -19}, {19, 19}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation( + Placement(visible = true, transformation(origin = {50, 38}, extent = {{-22, -22}, {22, 22}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.ADC adc(analogPort = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPort.A5, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPrescaler.'1/128', voltageReference = 1024, voltageReferenceSelect = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.VRefSelect.Internal) annotation( + Placement(visible = true, transformation(origin = {-39, -17}, extent = {{-17, -17}, {17, 17}}, rotation = 0))); + Modelica.Blocks.Interaction.Show.RealValue realValue1(use_numberPort = true) annotation( + Placement(visible = true, transformation(origin = {30, -17}, extent = {{-18, -17}, {18, 17}}, rotation = 0))); + equation + connect(adc.y, realValue1.numberPort) annotation( + Line(points = {{-20, -17}, {7, -17}}, color = {0, 0, 127})); + end MDD_ldr_read; + end MDD_ldr; + + package MDD_pot + extends Modelica.Icons.ExamplesPackage; + + model MDD_pot_threshold "" + extends Modelica.Icons.Example; + inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation( + Placement(visible = true, transformation(origin = {-79, 79}, extent = {{-19, -19}, {19, 19}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation( + Placement(visible = true, transformation(origin = {80, 80}, extent = {{-18, -18}, {18, 18}}, rotation = 0))); + Modelica.Blocks.Logical.Switch switch11 annotation( + Placement(visible = true, transformation(origin = {2, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Modelica.Blocks.Logical.Switch switch12 annotation( + Placement(visible = true, transformation(origin = {10, -64}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Modelica.Blocks.Logical.Greater greater1 annotation( + Placement(visible = true, transformation(origin = {42, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Modelica.Blocks.Logical.Greater greater2 annotation( + Placement(visible = true, transformation(origin = {36, 70}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'1', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation( + Placement(visible = true, transformation(origin = {82, 40}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean2(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'2', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation( + Placement(visible = true, transformation(origin = {82, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean3(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'3', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.B) annotation( + Placement(visible = true, transformation(origin = {82, -64}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Modelica.Blocks.Logical.GreaterEqualThreshold greaterEqualThreshold1(threshold = 0) annotation( + Placement(visible = true, transformation(origin = {-42, 44}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Modelica.Blocks.Logical.GreaterEqualThreshold greaterEqualThreshold2(threshold = 320) annotation( + Placement(visible = true, transformation(origin = {-42, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Modelica.Blocks.Logical.GreaterEqualThreshold greaterEqualThreshold3(threshold = 900) annotation( + Placement(visible = true, transformation(origin = {-40, -64}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Modelica.Blocks.Sources.RealExpression realExpression1(y = 0) annotation( + Placement(visible = true, transformation(origin = {-40, -92}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Modelica.Blocks.Sources.RealExpression realExpression2(y = 1) annotation( + Placement(visible = true, transformation(origin = {-44, 84}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Modelica.Blocks.Logical.Switch switch1 annotation( + Placement(visible = true, transformation(origin = {0, 70}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Modelica.Blocks.Math.RealToBoolean realToBoolean1(threshold = 0.5) annotation( + Placement(visible = true, transformation(origin = {44, -64}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.ADC adc(analogPort = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPort.A2, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPrescaler.'1/128', voltageReference = 1024, voltageReferenceSelect = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.VRefSelect.Internal) annotation( + Placement(visible = true, transformation(origin = {-88, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + equation + connect(adc.y, greaterEqualThreshold1.u) annotation( + Line(points = {{-76, 0}, {-70, 0}, {-70, 46}, {-54, 46}}, color = {0, 0, 127})); + connect(greaterEqualThreshold1.y, switch1.u2) annotation( + Line(points = {{-31, 46}, {-24, 46}, {-24, 70}, {-12, 70}}, color = {255, 0, 255})); + connect(adc.y, greaterEqualThreshold3.u) annotation( + Line(points = {{-76, 0}, {-70, 0}, {-70, -64}, {-52, -64}, {-52, -64}}, color = {0, 0, 127})); + connect(adc.y, greaterEqualThreshold2.u) annotation( + Line(points = {{-76, 0}, {-54, 0}, {-54, 0}, {-54, 0}}, color = {0, 0, 127})); + connect(realToBoolean1.y, digitalWriteBoolean3.u) annotation( + Line(points = {{56, -64}, {70, -64}, {70, -64}, {70, -64}}, color = {255, 0, 255})); + connect(switch12.y, realToBoolean1.u) annotation( + Line(points = {{22, -64}, {32, -64}, {32, -64}, {32, -64}}, color = {0, 0, 127})); + connect(realExpression1.y, switch1.u3) annotation( + Line(points = {{-28, -92}, {-16, -92}, {-16, 62}, {-12, 62}, {-12, 62}}, color = {0, 0, 127})); + connect(realExpression2.y, switch1.u1) annotation( + Line(points = {{-32, 84}, {-20, 84}, {-20, 78}, {-12, 78}, {-12, 78}}, color = {0, 0, 127})); + connect(switch1.y, greater2.u1) annotation( + Line(points = {{12, 70}, {22, 70}, {22, 70}, {24, 70}}, color = {0, 0, 127})); + connect(greater1.y, digitalWriteBoolean2.u) annotation( + Line(points = {{54, 0}, {70, 0}}, color = {255, 0, 255})); + connect(switch11.y, greater2.u2) annotation( + Line(points = {{14, 0}, {18, 0}, {18, 62}, {24, 62}, {24, 62}}, color = {0, 0, 127})); + connect(switch11.y, greater1.u1) annotation( + Line(points = {{14, 0}, {30, 0}}, color = {0, 0, 127})); + connect(switch12.y, greater1.u2) annotation( + Line(points = {{22, -64}, {22, -64}, {22, -8}, {30, -8}, {30, -8}}, color = {0, 0, 127})); + connect(greaterEqualThreshold2.y, switch11.u2) annotation( + Line(points = {{-30, 0}, {-10, 0}, {-10, 0}, {-10, 0}}, color = {255, 0, 255})); + connect(greater2.y, digitalWriteBoolean1.u) annotation( + Line(points = {{48, 70}, {56, 70}, {56, 40}, {70, 40}, {70, 40}}, color = {255, 0, 255})); + connect(realExpression2.y, switch12.u1) annotation( + Line(points = {{-32, 84}, {-20, 84}, {-20, -56}, {-2, -56}, {-2, -56}}, color = {0, 0, 127})); + connect(realExpression2.y, switch11.u1) annotation( + Line(points = {{-32, 84}, {-20, 84}, {-20, 8}, {-10, 8}, {-10, 8}}, color = {0, 0, 127})); + connect(realExpression1.y, switch11.u3) annotation( + Line(points = {{-28, -92}, {-16, -92}, {-16, -8}, {-10, -8}, {-10, -8}}, color = {0, 0, 127})); + connect(realExpression1.y, switch12.u3) annotation( + Line(points = {{-28, -92}, {-16, -92}, {-16, -72}, {-2, -72}, {-2, -72}}, color = {0, 0, 127})); + connect(greaterEqualThreshold3.y, switch12.u2) annotation( + Line(points = {{-28, -64}, {-2, -64}, {-2, -64}, {-2, -64}}, color = {255, 0, 255})); + annotation( + Documentation(info = "<html> + <h4>Syntax</h4> + <blockquote><pre> + Arduino.SerialCommunication.MDD_Examples.MDD_pot.<b>MDD_pot_threshold</b>(); + </pre></blockquote> + <h4>Description</h4> + <p>Voltage reference used to represent 10 bit precision(1024) of ADC along with prescaling by by 128.Internal voltage reference is applied to adc. + </p> + </html>")); + end MDD_pot_threshold; + end MDD_pot; + + package MDD_thermistor + extends Modelica.Icons.ExamplesPackage; + + model MDD_therm_read + extends Modelica.Icons.Example; + inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation( + Placement(visible = true, transformation(origin = {-40, 40}, extent = {{-20, -20}, {20, 20}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation( + Placement(visible = true, transformation(origin = {40, 42}, extent = {{-20, -20}, {20, 20}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.ADC adc(analogPort = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPort.A4, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPrescaler.'1/128', voltageReference = 1024, voltageReferenceSelect = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.VRefSelect.Internal) annotation( + Placement(visible = true, transformation(origin = {-40, -20}, extent = {{-20, -20}, {20, 20}}, rotation = 0))); + Modelica.Blocks.Interaction.Show.RealValue realValue1(use_numberPort = true) annotation( + Placement(visible = true, transformation(origin = {39, -21}, extent = {{-15, -19}, {15, 19}}, rotation = 0))); + equation + connect(adc.y, realValue1.numberPort) annotation( + Line(points = {{-18, -20}, {20, -20}, {20, -20}, {22, -20}}, color = {0, 0, 127})); + end MDD_therm_read; + + model MDD_therm_buzzer + extends Modelica.Icons.Example; + inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation( + Placement(visible = true, transformation(origin = {-61, 61}, extent = {{-21, -21}, {21, 21}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.ADC adc(analogPort = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPort.A4, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPrescaler.'1/128', voltageReference = 1024, voltageReferenceSelect = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.VRefSelect.Internal) annotation( + Placement(visible = true, transformation(origin = {-68, 1.77636e-15}, extent = {{-20, -20}, {20, 20}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation( + Placement(visible = true, transformation(origin = {41, 61}, extent = {{-19, -19}, {19, 19}}, rotation = 0))); + Modelica.Blocks.Interaction.Show.RealValue realValue1(use_numberPort = true) annotation( + Placement(visible = true, transformation(origin = {12, -56}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.DigitalWriteBoolean digitalWriteBoolean1(pin = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Pin.'3', port = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Port.D) annotation( + Placement(visible = true, transformation(origin = {78, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Modelica.Blocks.Logical.LogicalSwitch logicalSwitch1 annotation( + Placement(visible = true, transformation(origin = {40, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Modelica.Blocks.Sources.BooleanExpression booleanExpression1(y = false) annotation( + Placement(visible = true, transformation(origin = {10, -32}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Modelica.Blocks.Sources.BooleanExpression booleanExpression2(y = true) annotation( + Placement(visible = true, transformation(origin = {10, 32}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Modelica.Blocks.Logical.GreaterEqualThreshold greaterEqualThreshold1(threshold = 550) annotation( + Placement(visible = true, transformation(origin = {-4, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + equation + connect(greaterEqualThreshold1.y, logicalSwitch1.u2) annotation( + Line(points = {{8, 0}, {28, 0}, {28, 0}, {28, 0}}, color = {255, 0, 255})); + connect(adc.y, greaterEqualThreshold1.u) annotation( + Line(points = {{-46, 0}, {-16, 0}, {-16, 0}, {-16, 0}}, color = {0, 0, 127})); + connect(adc.y, realValue1.numberPort) annotation( + Line(points = {{-46, 0}, {-32, 0}, {-32, -56}, {0, -56}}, color = {0, 0, 127})); + connect(logicalSwitch1.y, digitalWriteBoolean1.u) annotation( + Line(points = {{52, 0}, {66, 0}, {66, 0}, {66, 0}}, color = {255, 0, 255})); + connect(booleanExpression2.y, logicalSwitch1.u1) annotation( + Line(points = {{22, 32}, {24, 32}, {24, 8}, {28, 8}, {28, 8}}, color = {255, 0, 255})); + connect(booleanExpression1.y, logicalSwitch1.u3) annotation( + Line(points = {{22, -32}, {24, -32}, {24, -8}, {28, -8}, {28, -8}}, color = {255, 0, 255})); + end MDD_therm_buzzer; + end MDD_thermistor; + + package MDD_dcmotor + extends Modelica.Icons.ExamplesPackage; + + model MDD_dcmotor_clock + extends Modelica.Icons.Example; + inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation( + Placement(visible = true, transformation(origin = {-40, 40}, extent = {{-20, -20}, {20, 20}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation( + Placement(visible = true, transformation(origin = {39, 41}, extent = {{-19, -19}, {19, 19}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.PWM pwm(fastPWM = true, initialValues = {0}, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerPrescaler.'1/1024', timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer1, timerNumbers = {Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerNumber.A}) annotation( + Placement(visible = true, transformation(origin = {51, -3}, extent = {{-19, -19}, {19, 19}}, rotation = 0))); + Modelica.Blocks.Sources.IntegerExpression integerExpression1(y = if time < 5 then 100 else 0) annotation( + Placement(visible = true, transformation(origin = {-40, -3}, extent = {{-16, -13}, {16, 13}}, rotation = 0))); + equation + connect(pwm.u[1], integerExpression1.y) annotation( + Line(points = {{28, -3}, {-22, -3}}, color = {255, 127, 0}, thickness = 0.5)); + end MDD_dcmotor_clock; + + model MDD_dcmotor_both + extends Modelica.Icons.Example; + inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation( + Placement(visible = true, transformation(origin = {-40, 60}, extent = {{-20, -20}, {20, 20}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation( + Placement(visible = true, transformation(origin = {56, 60}, extent = {{-18, -18}, {18, 18}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.PWM pwm(fastPWM = true, initialValues = {0}, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerPrescaler.'1/1024', timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer1, timerNumbers = {Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerNumber.A}) annotation( + Placement(visible = true, transformation(origin = {54, 1.77636e-15}, extent = {{-20, -20}, {20, 20}}, rotation = 0))); + Modelica.Blocks.Sources.IntegerExpression integerExpression1(y = if mod(time, 5) >= 2.5 then 100 else 0) annotation( + Placement(visible = true, transformation(origin = {-41, 3.55271e-15}, extent = {{-23, -20}, {23, 20}}, rotation = 0))); + Modelica.Blocks.Sources.IntegerExpression integerExpression2(y = if mod(time, 5) < 2.5 then 100 else 0) annotation( + Placement(visible = true, transformation(origin = {-39, -48}, extent = {{-23, -20}, {23, 20}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.PWM pwm1(fastPWM = true, initialValues = {0}, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerPrescaler.'1/1024', timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer1, timerNumbers = {Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerNumber.B}) annotation( + Placement(visible = true, transformation(origin = {54, -48}, extent = {{-20, -20}, {20, 20}}, rotation = 0))); + equation + connect(integerExpression2.y, pwm1.u[1]) annotation( + Line(points = {{-14, -48}, {28, -48}, {28, -48}, {30, -48}}, color = {255, 127, 0})); + connect(integerExpression1.y, pwm.u[1]) annotation( + Line(points = {{-16, 0}, {28, 0}, {28, 0}, {30, 0}}, color = {255, 127, 0})); + end MDD_dcmotor_both; + + model MDD_dcmotor_loop + extends Modelica.Icons.Example; + inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation( + Placement(visible = true, transformation(origin = {-40, 62}, extent = {{-20, -20}, {20, 20}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation( + Placement(visible = true, transformation(origin = {40, 60}, extent = {{-20, -20}, {20, 20}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.PWM pwm(fastPWM = true, initialValues = {0}, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerPrescaler.'1/1024', timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer1, timerNumbers = {Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerNumber.A}) annotation( + Placement(visible = true, transformation(origin = {44, 16}, extent = {{-16, -16}, {16, 16}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.PWM pwm1(fastPWM = true, initialValues = {0}, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerPrescaler.'1/1024', timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer1, timerNumbers = {Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerNumber.B}) annotation( + Placement(visible = true, transformation(origin = {44, -30}, extent = {{-16, -16}, {16, 16}}, rotation = 0))); + Modelica.Blocks.Sources.IntegerExpression integerExpression1(y = if time < 3 then 100 else 0) annotation( + Placement(visible = true, transformation(origin = {-53, 16}, extent = {{-17, -16}, {17, 16}}, rotation = 0))); + Modelica.Blocks.Sources.IntegerExpression integerExpression2(y = if time >= 3 then 100 else 0) annotation( + Placement(visible = true, transformation(origin = {-52, -30}, extent = {{-16, -14}, {16, 14}}, rotation = 0))); + equation + connect(integerExpression2.y, pwm1.u[1]) annotation( + Line(points = {{-34, -30}, {24, -30}}, color = {255, 127, 0})); + connect(integerExpression1.y, pwm.u[1]) annotation( + Line(points = {{-34, 16}, {24, 16}}, color = {255, 127, 0})); + end MDD_dcmotor_loop; + end MDD_dcmotor; + + package MDD_servo + extends Modelica.Icons.ExamplesPackage; + + model MDD_servo_init + extends Modelica.Icons.Example; + inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation( + Placement(visible = true, transformation(origin = {-40, 40}, extent = {{-20, -20}, {20, 20}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation( + Placement(visible = true, transformation(origin = {61, 41}, extent = {{-19, -19}, {19, 19}}, rotation = 0))); + Modelica.Blocks.Sources.IntegerExpression integerExpression1(y = 30) annotation( + Placement(visible = true, transformation(origin = {-39, -7}, extent = {{-15, -15}, {15, 15}}, rotation = 0))); + Arduino.SerialCommunication.Blocks.Servo Servo(prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerPrescaler.'1/1024', servo_no = Arduino.SerialCommunication.Types.Servo_no.'1', timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer1) annotation( + Placement(visible = true, transformation(origin = {36, -8}, extent = {{-18, -18}, {18, 18}}, rotation = 0))); + equation + connect(integerExpression1.y, Servo.u) annotation( + Line(points = {{-22.5, -7}, {14, -7}, {14, -8}}, color = {255, 127, 0})); + end MDD_servo_init; + + model MDD_servo_loop + extends Modelica.Icons.Example; + inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation( + Placement(visible = true, transformation(origin = {-41, 41}, extent = {{-19, -19}, {19, 19}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1 annotation( + Placement(visible = true, transformation(origin = {39, 41}, extent = {{-17, -17}, {17, 17}}, rotation = 0))); + Modelica.Blocks.Math.Gain gain1(k = 20) annotation( + Placement(visible = true, transformation(origin = {38, -6}, extent = {{-14, -14}, {14, 14}}, rotation = 0))); + Modelica.Blocks.Sources.Clock clock1(offset = 0, startTime = 0) annotation( + Placement(visible = true, transformation(origin = {-74, 2}, extent = {{-18, -18}, {18, 18}}, rotation = 0))); + Modelica.Blocks.Logical.LessEqual lessEqual1 annotation( + Placement(visible = true, transformation(origin = {-58, -50}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Modelica.Blocks.Logical.Switch switch1 annotation( + Placement(visible = true, transformation(origin = {-22, -6}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Modelica.Blocks.Sources.IntegerExpression integerExpression1(y = 0) annotation( + Placement(visible = true, transformation(origin = {-30, -42}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Modelica.Blocks.Sources.IntegerExpression integerExpression2(y = 10) annotation( + Placement(visible = true, transformation(origin = {-84, -84}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Modelica.Blocks.Math.RealToInteger realToInteger1 annotation( + Placement(visible = true, transformation(origin = {4, -34}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Blocks.Servo Servo(prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerPrescaler.'1/1024', servo_no = 1, timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation( + Placement(visible = true, transformation(origin = {78, -6}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + equation + connect(gain1.y, Servo.u) annotation( + Line(points = {{54, -6}, {66, -6}, {66, -6}, {66, -6}}, color = {0, 0, 127})); + connect(integerExpression2.y, lessEqual1.u2) annotation( + Line(points = {{-73, -84}, {-64, -84}, {-64, -68}, {-84, -68}, {-84, -58}, {-70, -58}}, color = {255, 127, 0})); + connect(realToInteger1.y, gain1.u) annotation( + Line(points = {{16, -34}, {16, -6}, {21, -6}}, color = {255, 127, 0})); + connect(clock1.y, lessEqual1.u1) annotation( + Line(points = {{-54, 2}, {-50, 2}, {-50, -32}, {-84, -32}, {-84, -50}, {-70, -50}, {-70, -50}}, color = {0, 0, 127})); + connect(clock1.y, switch1.u1) annotation( + Line(points = {{-54, 2}, {-34, 2}}, color = {0, 0, 127})); + connect(integerExpression1.y, switch1.u3) annotation( + Line(points = {{-18, -42}, {-16, -42}, {-16, -24}, {-40, -24}, {-40, -14}, {-34, -14}, {-34, -14}}, color = {255, 127, 0})); + connect(lessEqual1.y, switch1.u2) annotation( + Line(points = {{-46, -50}, {-44, -50}, {-44, -6}, {-34, -6}, {-34, -6}}, color = {255, 0, 255})); + connect(switch1.y, realToInteger1.u) annotation( + Line(points = {{-10, -6}, {-8, -6}, {-8, -34}, {-8, -34}}, color = {0, 0, 127})); + end MDD_servo_loop; + + model MDD_servo_pot + extends Modelica.Icons.Example; + inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation( + Placement(visible = true, transformation(origin = {-40, 60}, extent = {{-20, -20}, {20, 20}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation( + Placement(visible = true, transformation(origin = {39, 61}, extent = {{-19, -19}, {19, 19}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.ADC adc(analogPort = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPort.A2, prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.AnalogPrescaler.'1/128', voltageReference = 1023, voltageReferenceSelect = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.VRefSelect.Internal) annotation( + Placement(visible = true, transformation(origin = {-52, -10}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Modelica.Blocks.Math.RealToInteger realToInteger1 annotation( + Placement(visible = true, transformation(origin = {-4, -10}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Blocks.Servo Servo(prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerPrescaler.'1/1024', servo_no = 1, timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation( + Placement(visible = true, transformation(origin = {46, -10}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + equation + connect(realToInteger1.y, Servo.u) annotation( + Line(points = {{8, -10}, {34, -10}, {34, -10}, {34, -10}}, color = {255, 127, 0})); + connect(adc.y, realToInteger1.u) annotation( + Line(points = {{-40, -10}, {-16, -10}, {-16, -10}, {-16, -10}}, color = {0, 0, 127})); + end MDD_servo_pot; + + model MDD_servo_reverse + extends Modelica.Icons.Example; + inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation( + Placement(visible = true, transformation(origin = {-59, 61}, extent = {{-19, -19}, {19, 19}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation( + Placement(visible = true, transformation(origin = {55, 61}, extent = {{-19, -19}, {19, 19}}, rotation = 0))); + Modelica.Blocks.Sources.IntegerExpression integerExpression1(y = 90) annotation( + Placement(visible = true, transformation(origin = {-44, 0}, extent = {{-22, -22}, {22, 22}}, rotation = 0))); + Blocks.Servo Servo(prescaler = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerPrescaler.'1/1024', servo_no = 1, timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation( + Placement(visible = true, transformation(origin = {26, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + equation + connect(integerExpression1.y, Servo.u) annotation( + Line(points = {{-20, 0}, {14, 0}, {14, 0}, {14, 0}}, color = {255, 127, 0})); + end MDD_servo_reverse; + end MDD_servo; + + package MDD_modbus + extends Modelica.Icons.ExamplesPackage; + + model MDD_read_val + extends Modelica.Icons.Example; + inner Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu(desiredPeriod = 0.002, platform = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.Platform.ATmega328P) annotation( + Placement(visible = true, transformation(origin = {-45, 67}, extent = {{-15, -15}, {15, 15}}, rotation = 0))); + Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.SynchronizeRealtime synchronizeRealtime1(timer = Modelica_DeviceDrivers.EmbeddedTargets.AVR.Types.TimerSelect.Timer0) annotation( + Placement(visible = true, transformation(origin = {28, 68}, extent = {{-12, -12}, {12, 12}}, rotation = 0))); + Modelica.Blocks.MathInteger.MultiSwitch multiSwitch1(expr = {86, 88, 78}, nu = 3, use_pre_as_default = true, y_default = 0) annotation( + Placement(visible = true, transformation(origin = {-32.6577, -10}, extent = {{-10.0019, -22}, {30.0056, 22}}, rotation = 0))); + Modelica.Blocks.Sources.BooleanExpression booleanExpression1 annotation( + Placement(visible = true, transformation(origin = {-78, -12}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Modelica.Blocks.Interaction.Show.RealValue realValue1 annotation( + Placement(visible = true, transformation(origin = {60, -10}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + Blocks.Read_Val read_Val1 annotation( + Placement(visible = true, transformation(origin = {26, -10}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); + equation + connect(read_Val1.y, realValue1.numberPort) annotation( + Line(points = {{38, -10}, {48, -10}, {48, -10}, {48, -10}}, color = {0, 0, 127})); + connect(multiSwitch1.y, read_Val1.u) annotation( + Line(points = {{-2, -10}, {14, -10}, {14, -10}, {14, -10}}, color = {255, 127, 0})); + end MDD_read_val; + end MDD_modbus; + end MDD_Examples; + + package Blocks + extends Modelica.Icons.Package; + + model Servo + extends Modelica.Blocks.Icons.Block; + import Modelica_DeviceDrivers.EmbeddedTargets.AVR; + import sComm = Arduino.SerialCommunication.Functions; + outer Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu; + constant AVR.Types.TimerSelect timer annotation( + Dialog(enable = true, tab = "General", group = "Constants")); + constant AVR.Types.TimerPrescaler prescaler "Pre-scaler for the clock." annotation( + Dialog(enable = true, tab = "General", group = "Constants")); + constant sComm.Types.Servo_no servo_no annotation( + Dialog(enable = true, tab = "General", group = "Constants")); + Modelica.Blocks.Interfaces.IntegerInput u "Connector of Servo input signals (integer 0..255)" annotation( + Placement(transformation(extent = {{-140, -20}, {-100, 20}}))); + protected + AVR.Functions.Timers.Timer clock = AVR.Functions.Timers.Timer(timer, prescaler, clearTimerOnMatch = true); + sComm.Functions.MDD_Servo.Init servo = sComm.Functions.MDD_Servo.Init(servo_no); + algorithm + sComm.Functions.MDD_Servo.Move(servo, u); + annotation( + defaultComponentName = "Servo", + Icon(graphics = {Text(extent = {{-95, -95}, {95, 95}}, textString = "Servo %servo_no", fontName = "Arial")})); + end Servo; + + model Read_Val + extends Modelica.Blocks.Interfaces.SISO; + import Modelica_DeviceDrivers.EmbeddedTargets.AVR; + import sComm = Arduino.SerialCommunication.Functions; + outer Modelica_DeviceDrivers.EmbeddedTargets.AVR.Blocks.Microcontroller mcu; + annotation( + defaultComponentName = "Read_Val", + Icon(graphics = {Text(extent = {{-95, -95}, {95, 95}}, textString = "Read_Val", fontName = "Arial")})); + end Read_Val; + end Blocks; + + type Types + extends Modelica.Icons.TypesPackage; + type Servo_no = enumeration('1' "Servo1", '2' "Servo2") "Servo ID"; + end Types; + + package Icons "Collection of icons used for library components" + extends Modelica.Icons.IconsPackage; + + partial package GenericICPackage "Icon with a generic IC" + annotation( + Icon(coordinateSystem(preserveAspectRatio = true, extent = {{-100, -100}, {100, 100}}), graphics = {Bitmap(extent = {{-95, -95}, {95, 95}}, fileName = "Resources/Images/Icons/tqfp32.png", rotation = 0)}), + Documentation(info = "<html> +<p> +This partial class is intended to design a <em>default icon for microcontrollers</em>. +</p> +</html>")); + end GenericICPackage; + + partial block GenericIC "Icon with a generic IC" + annotation( + Icon(coordinateSystem(preserveAspectRatio = true, extent = {{-100, -100}, {100, 100}}), graphics = {Bitmap(extent = {{-95, -95}, {95, 95}}, fileName = "Resources/Images/Icons/tqfp32.png", rotation = 0)}), + Documentation(info = "<html> +<p> +This partial class is intended to design a <em>default icon for microcontrollers</em>. +</p> +</html>")); + end GenericIC; + + partial package FunctionLayerIcon "Icon for packages that represent the function layer" + extends Modelica.Icons.Package; + annotation( + Icon(coordinateSystem(preserveAspectRatio = false, extent = {{-100, -100}, {100, 100}}), graphics = {Text(lineColor = {128, 128, 128}, extent = {{-90, -90}, {90, 90}}, textString = "f"), Ellipse(lineColor = {128, 128, 128}, extent = {{-80, -80}, {80, 80}})}), + Documentation(info = "<html> +<p>This icon indicates Modelica functions.</p> +</html>")); + end FunctionLayerIcon; + annotation( + preferredView = "info", + Documentation(info = "<html> +<p> +A collection of basic icons to be used for different elements of the library. +</p> +</html>")); + end Icons; + annotation( + Documentation(info = "<html> +<h4>Description</h4> +<p> +A serial communication package for hardware interfacing. +</p> +</html>")); + end SerialCommunication; + annotation( + uses(Modelica_DeviceDrivers(version = "1.5.0"), Modelica(version = "3.2.2"))); +end Arduino;
\ No newline at end of file diff --git a/tools/python/test_firmware.py b/tools/python/test_firmware.py index 48e81e6..b2ebcaf 100644 --- a/tools/python/test_firmware.py +++ b/tools/python/test_firmware.py @@ -1,24 +1,23 @@ import os import sys -cwd=os.getcwd() -(setpath,Examples)=os.path.split(cwd) -#print setpath +cwd = os.getcwd() +(setpath,Examples) = os.path.split(cwd) sys.path.append(setpath) from Arduino.Arduino import Arduino from time import sleep class TEST_FIRMWARE: - def __init__(self,baudrate): - self.baudrate=baudrate + def __init__(self, baudrate): + self.baudrate = baudrate self.setup() self.run() self.exit() def setup(self): - self.obj_arduino=Arduino() - self.port=self.obj_arduino.locateport() - self.obj_arduino.open_serial(1,self.port,self.baudrate) + self.obj_arduino = Arduino() + self.port = self.obj_arduino.locateport() + self.obj_arduino.open_serial(1, self.port, self.baudrate) def run(self): self.obj_arduino.checkfirmware() @@ -27,7 +26,7 @@ class TEST_FIRMWARE: self.obj_arduino.close_serial() def main(): - obj_led=TEST_FIRMWARE(115200) + obj_led = TEST_FIRMWARE(115200) if __name__== '__main__': main() diff --git a/user-code/led/OpenModelica/led-blue.mo b/user-code/led/OpenModelica/led-blue.mo index 28f3e14..5a904ed 100644 --- a/user-code/led/OpenModelica/led-blue.mo +++ b/user-code/led/OpenModelica/led-blue.mo @@ -7,7 +7,7 @@ model led_blue "Turn on Blue LED" Integer c_ok(fixed = false); algorithm when initial() then - ok := sComm.open_serial(1, 2, 115200) "At port 0 with baudrate of 115200"; + ok := sComm.open_serial(1, 2, 115200) "At port 2 with baudrate of 115200"; sComm.delay(2000); if ok <> 0 then strm.print("Check the serial port and try again"); diff --git a/user-code/led/arduino/led-blue-delay/led-blue-delay.ino b/user-code/led/arduino/led-blue-delay/led-blue-delay.ino index 0d3bd53..a2847f0 100644 --- a/user-code/led/arduino/led-blue-delay/led-blue-delay.ino +++ b/user-code/led/arduino/led-blue-delay/led-blue-delay.ino @@ -1,9 +1,9 @@ void setup() { -pinMode(9,OUTPUT); +pinMode(9, OUTPUT); Serial.begin(115200); -digitalWrite(9,HIGH); +digitalWrite(9, HIGH); delay(2000); -digitalWrite(9,LOW); +digitalWrite(9, LOW); } void loop() { } diff --git a/user-code/led/arduino/led-blue-red/led-blue-red.ino b/user-code/led/arduino/led-blue-red/led-blue-red.ino index fdb3230..bedd171 100644 --- a/user-code/led/arduino/led-blue-red/led-blue-red.ino +++ b/user-code/led/arduino/led-blue-red/led-blue-red.ino @@ -1,13 +1,13 @@ void setup() { -pinMode(9,OUTPUT); -pinMode(11,OUTPUT); +pinMode(9, OUTPUT); +pinMode(11, OUTPUT); Serial.begin(115200); -digitalWrite(9,HIGH); -digitalWrite(11,HIGH); +digitalWrite(9, HIGH); +digitalWrite(11, HIGH); delay(5000); -digitalWrite(9,LOW); +digitalWrite(9, LOW); delay(3000); -digitalWrite(11,LOW); +digitalWrite(11, LOW); } void loop() { } diff --git a/user-code/led/arduino/led-blue/led-blue.ino b/user-code/led/arduino/led-blue/led-blue.ino index 74d59a0..261b26d 100644 --- a/user-code/led/arduino/led-blue/led-blue.ino +++ b/user-code/led/arduino/led-blue/led-blue.ino @@ -1,7 +1,7 @@ void setup() { -pinMode(9,OUTPUT); +pinMode(9, OUTPUT); Serial.begin(115200); -digitalWrite(9,HIGH); +digitalWrite(9, HIGH); } void loop() { } diff --git a/user-code/led/arduino/led-green-blink/led-green-blink.ino b/user-code/led/arduino/led-green-blink/led-green-blink.ino index 1b53338..90e02b4 100644 --- a/user-code/led/arduino/led-green-blink/led-green-blink.ino +++ b/user-code/led/arduino/led-green-blink/led-green-blink.ino @@ -1,8 +1,8 @@ -int i=0; +int i = 0; void setup() { pinMode(10, OUTPUT); Serial.begin(115200); - for(i=0;i<5;i++) + for(i = 0; i < 5; i++) { digitalWrite(10, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second diff --git a/user-code/led/julia/led-blue-delay.jl b/user-code/led/julia/led-blue-delay.jl index 07904a6..7a6a5f3 100644 --- a/user-code/led/julia/led-blue-delay.jl +++ b/user-code/led/julia/led-blue-delay.jl @@ -2,8 +2,8 @@ using SerialPorts include("ArduinoTools.jl") ser = ArduinoTools.connectBoard(115200) -ArduinoTools.pinMode(ser,9,"OUTPUT") -ArduinoTools.digiWrite(ser,9,1) +ArduinoTools.pinMode(ser, 9, "OUTPUT") +ArduinoTools.digiWrite(ser, 9, 1) sleep(2) -ArduinoTools.digiWrite(ser,9,0) +ArduinoTools.digiWrite(ser, 9, 0) close(ser) diff --git a/user-code/led/julia/led-blue.jl b/user-code/led/julia/led-blue.jl index 97af22f..0bda318 100644 --- a/user-code/led/julia/led-blue.jl +++ b/user-code/led/julia/led-blue.jl @@ -2,6 +2,6 @@ using SerialPorts include("ArduinoTools.jl") ser = ArduinoTools.connectBoard(115200) -ArduinoTools.pinMode(ser,9,"OUTPUT") -ArduinoTools.digiWrite(ser,9,1) +ArduinoTools.pinMode(ser, 9, "OUTPUT") +ArduinoTools.digiWrite(ser, 9, 1) close(ser) diff --git a/user-code/led/julia/led-green-blink.jl b/user-code/led/julia/led-green-blink.jl index 8c72d1c..1e6a068 100644 --- a/user-code/led/julia/led-green-blink.jl +++ b/user-code/led/julia/led-green-blink.jl @@ -2,11 +2,11 @@ using SerialPorts include("ArduinoTools.jl") ser = ArduinoTools.connectBoard(115200) -ArduinoTools.pinMode(ser,10,"OUTPUT") +ArduinoTools.pinMode(ser, 10, "OUTPUT") for i = 1:5 - ArduinoTools.digiWrite(ser,10,1) + ArduinoTools.digiWrite(ser, 10, 1) sleep(1) - ArduinoTools.digiWrite(ser,10,0) + ArduinoTools.digiWrite(ser, 10, 0) sleep(1) end close(ser) diff --git a/user-code/led/led.tex b/user-code/led/led.tex index 02c35e4..abd4ac5 100644 --- a/user-code/led/led.tex +++ b/user-code/led/led.tex @@ -27,7 +27,8 @@ In this chapter, we will learn how to control the LEDs on the shield
and on the \arduino\ board. We will do this through the Arduino IDE,
-Scilab scripts, Scilab Xcos, Python, and OpenModelica. These are beginner level experiments,
+Scilab scripts, Scilab Xcos, Python, Julia, and OpenModelica.
+These are beginner level experiments,
and often referred to as the \emph{hello world} task of Arduino.
Although simple, controlling LED is a very important task in all
kinds of electronic boards.
@@ -76,7 +77,7 @@ putting a high voltage on the corresponding anode pin. \begin{figure}
\centering
\includegraphics[width=\smfig]{\LocLEDfig/arduino-shield.JPG}
- \caption{Connecting Arduino and Shield}
+ \caption{Connecting \arduino\ and shield}
\label{fig:uno-shield-connect}
\end{figure}
@@ -96,8 +97,8 @@ soldering. To know more about the breadboard and other electronic components, one should watch the Spoken Tutorials on Arduino as published on
{\tt https://spoken-tutorial.org/}. Ideally, one should go through all the
tutorials labeled as Basic. However, we strongly recommend the readers should
-watch the fifth and sixth tutorials, i.e., First Arduino Program and
-Arduino with Tricolor LED and Push button.
+watch the fifth and sixth tutorials, i.e., {\tt First Arduino Program} and
+{\tt Arduino with Tricolor LED and Push button}.
In case you have an RGB LED and want to connect it with \arduino\ on a breadboard,
please refer to \figref{fig:ard-rgb-bread}.
@@ -131,7 +132,7 @@ instructions given in \secref{sec:ard-start} before getting started. blue. It is extremely easy to explain this code. Recall from the
above discussion that we have to put a high voltage (5V) on pin 9 to
turn the blue light on. This is achieved by the following command:
- \lstinputlisting[firstline=3,lastline=3]
+ \lstinputlisting[firstline=4,lastline=4]
{\LocLEDardcode/led-blue/led-blue.ino}
Before that, we need to define pin 9 as the
output pin. This is achieved by the command,
@@ -143,11 +144,11 @@ instructions given in \secref{sec:ard-start} before getting started. remains on for two seconds and then turns off.
\ardref{ard:led-blue-delay} helps achieve this. In this, we
introduce a new command {\tt delay} as below:
- \lstinputlisting[firstline=4,lastline=4]
+ \lstinputlisting[firstline=5,lastline=5]
{\LocLEDardcode/led-blue-delay/led-blue-delay.ino} This delay
command halts the code for the time passed as in input argument. In
our case, it is 2,000 milliseconds, or 2 seconds. The next command,
- \lstinputlisting[firstline=5,lastline=5]
+ \lstinputlisting[firstline=6,lastline=6]
{\LocLEDardcode/led-blue-delay/led-blue-delay.ino} puts a low
voltage on pin 9 to turn it off.
@@ -178,7 +179,7 @@ instructions given in \secref{sec:ard-start} before getting started. iteration, it will turn the green LED on for a second by giving the
{\tt HIGH} signal and then turn it off for a second by giving the
{\tt LOW} signal. This cycle is carried out for a total of 5 times,
- because of the {\tt for loop}.
+ because of the {\tt for} loop.
\end{enumerate}
\paragraph{Note:}
@@ -264,13 +265,13 @@ previous section from Scilab. We will list the same four experiments, in the same order. The shield has to be attached to the \arduino\
before carrying out these experiments, as in \secref{sec:light-ard}.
The reader should go through the instructions given in
-\secref{sec:sci-start} before getting started.
+\secref{sec:sci-start} before getting started.
\begin{enumerate}
\item In the first experiment, we will light up the blue LED on the
shield. The code for this is given in \sciref{sci:led-blue}. It
begins with a command of the form
\begin{lstlisting}[style=nonumbers]
- ok = open_serial(1,PORT NUMBER,BAUD RATE)
+ ok = open_serial(1, PORT NUMBER, BAUD RATE)
\end{lstlisting}
We have used 2 for {\tt PORT NUMBER} and 115200 for {\tt BAUD RATE}.
As a result, this command becomes
@@ -287,9 +288,9 @@ The reader should go through the instructions given in terminate the program if the serial port does not open. This is
achieved using the error message of the following form:
\begin{lstlisting}[style=nonumbers]
- if ok~=0, error(Error Message in Quotes);
+ if ok ~= 0, error(Error Message in Quotes);
\end{lstlisting}
- It checks if {\tt ok=0}. If not, it flashes an error message and
+ It checks if {\tt ok = 0}. If not, it flashes an error message and
terminates. This line gets implemented in the following way in
\sciref{sci:led-blue}.
\lstinputlisting[firstline=2,lastline=2]{\LocLEDscicode/led-blue.sce}
@@ -297,7 +298,7 @@ The reader should go through the instructions given in We turn the LED on in the next line. This is achieved using a
command of the form
\begin{lstlisting}[style=nonumbers]
- cmd_digital_out(1,PIN NUMBER,VALUE)
+ cmd_digital_out(1, PIN NUMBER, VALUE)
\end{lstlisting}
As we want to turn on the blue light in the shield, as discussed in
\secref{sec:light-ard}, we choose {\tt PIN NUMBER} as 9. We can put
@@ -582,8 +583,8 @@ getting started. \begin{exercise}
Carry out the following exercise:
\begin{enumerate}
- \item Change the blink pattern for an array of LEDs
- \item Change the delays
+ \item Change the blink pattern for an array of LEDs.
+ \item Change the delays.
\end{enumerate}
\end{exercise}
@@ -593,89 +594,102 @@ getting started. In this section, we discuss how to carry out the experiments of the
previous section from Python. We will list the same four experiments,
in the same order. The shield has to be attached to the \arduino\
-before carrying out these experiments, as in \pyref{sec:light-ard}.
+before carrying out these experiments, as in \secref{sec:light-ard}.
The reader should go through the instructions given in
-\secref{sec:sci-start} before getting started.
+\secref{sec:python-start} before getting started.
\begin{enumerate}
\item In the first experiment, we will light up the blue LED on the
- shield. The code for this is given in \pyref{py:led-blue}. It begins with a command of the form
- \item Import os : This module provides a portable way of using operating system dependent functionality.
- \item Import sys : This module provides access to some variables used or maintained by the interpreter
- and to functions that interact strongly with the interpreter. It is always available.
- \item cwd=os.getcwd(): Get the current working directory
- \item (setpath,Examples)=os.path.split(cwd) :- This split the current working directory to get and set the Example folder in the PYTHONPATH variable
- \item sys.path.append(setpath) :- It appends the path to PYTHONPATH environment
- \item from Arduino.Arduino import Arduino :- All the basic functions are defined in Arduino.py.So, we have to import all the available methods from Arduino library.This command import Arduino class to acceess all the functinalities available in that class.
- \item from time import sleep :- It import the delay functionality from pyserial package
- \item class LED\_ON :- Each experiment is defined as class.This experiment
- is to switch on the blue led.Then we will initialize the parameters and functions.
- \item def \_\_init\_\_(self,baudrate) :- "\_\_init\_\_" a constructor which initialises parameteres and other functions of the class.
- \item self.baudrate=baudrate :- Here baudrate is intialized and rest of the 3 functions which will be defined later, are also initialized.\\
- self.setup() \\
- self.run() \\
- self.exit() \\
-
- Next step is to define the 1st method setup \\
- \item def setup(self):- This function locates the port to which arduino is connected and
- also opens the port for serial communication.
-
- self.obj\_arduino = Arduino() :- It creates an object of the arduino class
- through which we can call all the methods available in the base class.Here
- obj\_arduino is the object created for Arduino class.Then we will call the locateport().\\
- self.port = self.obj\_arduino.locateport() :-This method auto-detects to which port
- arduino is connected and assigns the port no. to the variable to self.port. Once
- serial port is assigned, then we will call the open\_serial() to open the serial
- port for communication.This is done in the next step \\
- self.obj\_arduino.open\_serial(1, self.port,self.baudrate) :- This opens the
- serial port and it needs 3 parameters such as :
-
- i. 1st arguement:- This is the board no. (1 by default) for every experiment \\
- ii.self.port :- This is the port no. to which arduino is connected \\
- iii.baudrate :- It sets the baudrate for serial communication \\
-
- Then we will define the 2nd method run() in which we will define pin no. to which components are connected also apply digital or analog inputs to it depending on the digital or analog nature of the component.
-
- \item def run(self):- This method is to define the functionality of the experiment \\
- self.blue=9 :- pin no. to which led is connected \\
- self.obj\_arduino.cmd\_digital\_out(1,self.blue,1) :- As led works on digital input so we will use cmd\_digital\_out() which will switch on/off the blue colour of RGB led .
- This method needs 3 parameters such as : \\
- 1st parameter:- This is the board no. (1 by default) for every experiment.
- 2nd parameter :- pin no. to which led is connected
- 3rd parameter :- It applies digital logic i.e. if 1, then switch on led
- 0, then switch off led \\
- Once all the functionalities are defined and the experiments are performed accordingly then we will close the serial port which is done by the exit function.
- \item def exit(self):- This function closes the serial port \\
- self.obj\_arduino.close\_serial() :- this function is called from Arduino class which closes the serial port properly.
-
- \item def main():- Here we will create the main method \\
- obj\_led=LED\_ON(115200) :- It creates an object of the class with baudrate of 115200.
- \item if \_\_name\_\_== '\_\_main\_\_':- At last we will check for the main module
- whether its directly run from the file or being imported from another module \\
- main() :- It calls the main module and which in turn calls the object of the
- class and performs the experiment.
+ shield. The code for this is given in \pyref{py:led-blue}. It begins with importing
+ necessary modules, as given below:
+ \lstinputlisting[firstline=1,lastline=2]{\LocLEDpycode/led-blue.py}
+
+ Here, {\tt os} module provides functions for interacting with the operating system. On the
+ other hand, the {\tt sys} module provides access to some variables used or maintained by the interpreter
+ and functions that interact strongly with the interpreter. Next, the following lines of code are used to get the current directory
+ followed by splitting it and appending the path to {\tt PYTHONPATH} environment:
+ \lstinputlisting[firstline=3,lastline=5]{\LocLEDpycode/led-blue.py}
+
+ After importing the necessary modules, following line imports the Arduino module from the Python-Arduino
+ toolbox, as explained in \secref{sec:python-toolbox}:
+ \lstinputlisting[firstline=7,lastline=7]{\LocLEDpycode/led-blue.py}
+
+ Next, we will import {\tt sleep} module, which is a function available in the package pyserial \cite{pySerial}.
+ For the sake of simplicity, we have configured each experiment as a class. In \pyref{py:led-blue},
+ we have defined the experiment as {\tt class LED\_ON}. The following lines of code
+ initilize the parameters and functions available in this class.
+ \lstinputlisting[firstline=10,lastline=15]{\LocLEDpycode/led-blue.py}
+
+ The function {\tt setup} creates an object of the Arduino class
+ through which we can call all the methods available in the base class.
+ Along with this, it locates the port to which \arduino\ is connected
+ and opens the port for serial communication. Similar to the Scilab experiments
+ given in \secref{sec:light-sci}, we require port number and BAUD RATE for opening the serial port.
+
+ % self.obj\_arduino = Arduino() :- It creates an object of the arduino class
+ % through which we can call all the methods available in the base class.Here
+ % obj\_arduino is the object created for Arduino class.Then we will call the locateport().\\
+ % self.port = self.obj\_arduino.locateport() :-This method auto-detects to which port
+ % arduino is connected and assigns the port no. to the variable to self.port. Once
+ % serial port is assigned, then we will call the open\_serial() to open the serial
+ % port for communication.This is done in the next step \\
+ % self.obj\_arduino.open\_serial(1, self.port,self.baudrate) :- This opens the
+ % serial port and it needs 3 parameters such as :
+
+ % i. 1st arguement:- This is the board no. (1 by default) for every experiment \\
+ % ii.self.port :- This is the port no. to which arduino is connected \\
+ % iii.baudrate :- It sets the baudrate for serial communication \\
+
+ % Then we will define the 2nd method run() in which we will define pin no. to which components are connected also apply digital or analog inputs to it depending on the digital or analog nature of the component.
+ The function {\tt run} is used to define the functionality of the experiment. In this experiment,
+ we have to switch on the blue LED. For this, we define the pin number (which is 9 in this case)
+ and send the required signal to this pin. Following lines are used to implement this functionality:
+ \lstinputlisting[firstline=22,lastline=24]{\LocLEDpycode/led-blue.py}
+
+
+ At last, the function {\tt exit} is invoked to close the serial port.
+ % \item def run(self):- This method is to define the functionality of the experiment \\
+ % self.blue=9 :- pin no. to which led is connected \\
+ % self.obj\_arduino.cmd\_digital\_out(1,self.blue,1) :- As led works on digital input so we will use cmd\_digital\_out() which will switch on/off the blue colour of RGB led .
+ % This method needs 3 parameters such as : \\
+ % 1st parameter:- This is the board no. (1 by default) for every experiment.
+ % 2nd parameter :- pin no. to which led is connected
+ % 3rd parameter :- It applies digital logic i.e. if 1, then switch on led
+ % 0, then switch off led \\
+ % Once all the functionalities are defined and the experiments are performed accordingly then we will close the serial port which is done by the exit function.
+ % \item def exit(self):- This function closes the serial port \\
+ % self.obj\_arduino.close\_serial() :- this function is called from Arduino class which closes the serial port properly.
+
+ Once all the parameters and functions available in {\tt class LED\_ON} have been
+ initialized, we create a main method and call it, as given below:
+ \lstinputlisting[firstline=29,lastline=33]{\LocLEDpycode/led-blue.py}
+
+ % \item def main():- Here we will create the main method \\
+ % obj\_led=LED\_ON(115200) :- It creates an object of the class with baudrate of 115200.
+ % \item if \_\_name\_\_== '\_\_main\_\_':- At last we will check for the main module
+ % whether its directly run from the file or being imported from another module \\
+ % main() :- It calls the main module and which in turn calls the object of the
+ % class and performs the experiment.
+
+ \item \pyref{py:led-blue-delay} does the same thing as what \ardref{ard:led-blue-delay} does.
+ It does two more things than what \pyref{py:led-blue} does: It makes the blue LED light up for two
+ seconds. This is achieved by the command
+ \lstinputlisting[firstline=25,lastline=25]{\LocLEDpycode/led-blue-delay.py}
+ The second thing this code does is to turn the blue LED off. This
+ is achieved by the command
+ \lstinputlisting[firstline=26,lastline=26]{\LocLEDpycode/led-blue-delay.py}
+ As evident, this line of code puts a 0 on pin 9.
+ \item \pyref{py:led-blue-red} does the same thing as what \ardref{ard:led-blue-red} does.
+ It turns blue and red LEDs on for five seconds. After that, it turns off blue
+ first. After 3 seconds, it turns off red also. So, when the program ends,
+ no LED is lit up.
+
+ \item \pyref{py:led-green-blink} does exactly what its counterpart in the Arduino IDE does.
+ It makes the green LED blink five times.
\end{enumerate}
-Python Code 4.2 does the same thing as what Arduino Code 4.2 does. It does
-two more things than what Python Code 4.1 does: It makes the blue LED light
-up for two seconds. This is achieved by the command
-
-sleep(2) //let the blue LED be on for two seconds
-
-The second thing this code does is to turn the blue LED off. This is achieved
-by the command
-
-\begin{lstlisting}[style=nonumbers]
- cmd_digital_out ( 1 , 9 , 0 ) //turn off blue LED
- \end{lstlisting}
-
-It is easy to see that this code puts a 0 on pin 9.
-
-Python Code 4.3 does the same thing as what Arduino Code 4.3 does. It turns
-blue and red LEDs on for five seconds. After that, it turns off blue first. After
-3 seconds, it turns off red also. So, when the program ends, no LED is lit up.
-
-Python Code 4.4 does exactly what its counterpart in the Arduino IDE does.
-It makes the green LED blink five times.
+\begin{exercise}
+ Repeat the exercise of the previous section.
+\end{exercise}
\subsection{Python Code}
\lstset{style=mystyle}
@@ -683,8 +697,8 @@ It makes the green LED blink five times. \addtocontents{pyd}{\protect\addvspace{\codclr}}
\begin{pycode}
- \pcaption{Turning on the LED through Python}
- {Turning on the LED through Python. Available at
+ \pcaption{Turning on the blue LED through Python}
+ {Turning on the blue LED through Python. Available at
\LocLEDpybrief{led-blue.py}.}
\label{py:led-blue}
\lstinputlisting{\LocLEDpycode/led-blue.py}
@@ -722,62 +736,47 @@ In this section, we discuss how to carry out the experiments of the previous section from Julia. We will list the same four experiments,
in the same order. The shield has to be attached to the \arduino\
before carrying out these experiments, as in \secref{sec:light-ard}.
-The reader should go through the instructions given in
-\secref{sec:sci-start} before getting started.
+The reader should go through the instructions given in \secref{sec:julia-start} before getting started.
\begin{enumerate}
\item In the first experiment, we will light up the blue LED on the
- shield. The code for this is given in Julia-code-4.1.
- It begins with a command of the form
-
- \item using SerialPorts: This imports the SerialPorts library to the current workspace
- \item include("ArduinoTools.jl") : It includes the ArduinoTools.jl to the workspce which has all the functions required to perform experiments
- \item ser = connectBoard(115200):Function that opens the first serial port among the names returned by the
- list\_serialports() function, with the specified baud rate.
-
- \item pinMode(ser,9,"OUTPUT") : pinMode function set the mode of a digital pin as INPUT or OUTPUT.It has following parametes:
- \begin{itemize}
- \item file\_des: file descriptor (SerialPort object)
- \item pin\_no: pin number
- \item mode: INPUT or OUTPUT
- \end{itemize}
- This function is similar to the pinMode function in Arduino.
-
-
- \item digiWrite(ser,9,1) : Function to send a digital signal (High(1) or Low(0)) to a connected Arduino
- board. It takes the parameters:
-
- \begin{itemize}
- \item file\_des: file descriptor (SerialPort object)
- \item pin\_no: pin number
- \item val: Digital value to be sent to pin, 0 (for LOW/0V) or 1 (for HIGH/5V)
- \end{itemize}
- It is similar to the digitalWrite function in Arduino.
+ shield. The code for this is given in \juliaref{julia:led-blue}.
+ It begins with importing the SerialPorts \cite{julia-serial-ports} package
+ and the module ArduinoTools, as given in \secref{sec:julia-toolbox}. Following lines
+ import SerialPorts and ArduinoTools:
+ \lstinputlisting[firstline=1,lastline=2]{\LocLEDjuliacode/led-blue.jl}
+
+ Next, the following line of code is used to detect the port on which \arduino\
+ is connected.
+ \lstinputlisting[firstline=4,lastline=4]{\LocLEDjuliacode/led-blue.jl}
+ Apart from detecting the port, it also opens a serial port with given BAUD RATE.
+ In this experiment, we have to put a high voltage (5V) on pin 9 to
+ turn the blue light on. This is achieved by the following command:
+ \lstinputlisting[firstline=6,lastline=6]{\LocLEDjuliacode/led-blue.jl}
+ Before that, we need to define pin 9 as the
+ output pin. This is achieved by the following command:
+ \lstinputlisting[firstline=5,lastline=5]{\LocLEDjuliacode/led-blue.jl}
+ The last line in the code closes the serial port.
+ In this Julia source file, one can observe that the blue light will be on continuously.
+\item \juliaref{julia:led-blue-delay} does the same thing as what
+ \ardref{ard:led-blue-delay} does. It does two more things than what
+ \juliaref{julia:led-blue} does: It makes the blue LED light up for two
+ seconds. This is achieved by the command
+ \lstinputlisting[firstline=7,lastline=7]{\LocLEDjuliacode/led-blue-delay.jl}
+ The second thing this code does is to turn the blue LED off. This
+ is achieved by the command
+ \lstinputlisting[firstline=8,lastline=8]{\LocLEDjuliacode/led-blue-delay.jl}
+ It is easy to see that this code puts a 0 on pin 9.
+ \item \juliaref{julia:led-blue-red} does the same thing as what
+ \ardref{ard:led-blue-red} does. It turns blue and red LEDs on for
+ five seconds. After that, it turns off blue first. After 3
+ seconds, it turns off red also. So, when the program ends, no LED is
+ lit up.
- \item close(ser) : This closes the predefined serial port which is presently opened.
+ \item \juliaref{julia:led-green-blink} does exactly what its counterpart
+ in the Arduino IDE does. It makes the green LED blink five times.
\end{enumerate}
-Julia Code 4.2 does the same thing as what Arduino Code 4.2 does. It does
-two more things than what Julia Code 4.1 does: It makes the blue LED light
-up for two seconds. This is achieved by the command
-
-sleep(2) //let the blue LED be on for two seconds
-
-The second thing this code does is to turn the blue LED off. This is achieved
-by the command
-
-\begin{lstlisting}[style=nonumbers]
- digiWrite(ser,9,0)//turn off blue LED
- \end{lstlisting}
-
-It is easy to see that this code puts a 0 on pin 9.
-
-Julia Code 4.3 does the same thing as what Arduino Code 4.3 does. It turns
-blue and red LEDs on for five seconds. After that, it turns off blue first. After
-3 seconds, it turns off red also. So, when the program ends, no LED is lit up.
-
-Julia Code 4.4 does exactly what its counterpart in the Arduino IDE does.
-It makes the green LED blink five times.
\subsection{Julia Code}
\lstset{style=mystyle}
@@ -786,7 +785,7 @@ It makes the green LED blink five times. \begin{juliacode}
\jcaption{Turning on the LED}
- {Turning on the LED. Available at
+ {Turning on the blue LED. Available at
\LocLEDjuliabrief{led-blue.jl}.}
\label{julia:led-blue}
\lstinputlisting{\LocLEDjuliacode/led-blue.jl}
@@ -803,74 +802,107 @@ It makes the green LED blink five times. \begin{juliacode}
\jcaption{Turning on blue and red LEDs for 5 seconds and then turning
- them off one by one}{Turning on bluemond red LEDs for 5 seconds and
+ them off one by one}{Turning on blue and red LEDs for 5 seconds and
then turning them off one by one. Available at
\LocLEDjuliabrief{led-blue-red.jl}.}
- \label{juila:led-bmoe-red}
+ \label{julia:led-blue-red}
\lstinputlisting{\LocLEDjuliacode/led-blue-red.jl}
\end{juliacode}
\begin{juliacode}
\jcaption{Blinking the green LED}{Blinking the green LED. Available
at \LocLEDjuliabrief{led-green-blink.jl}.}
- \label{julia:lemogreen-blink}
+ \label{julia:led-green-blink}
\lstinputlisting{\LocLEDjuliacode/led-green-blink.jl}
\end{juliacode}
+
+
\section{Lighting the LED from OpenModelica}
\subsection{Lighting the LED}
\label{sec:light-OpenModelica}
In this section, we discuss how to carry out the experiments of the
-previous section from Scilab. We will list the same four experiments,
+previous section from OpenModelica. We will list the same four experiments,
in the same order. The shield has to be attached to the \arduino\
before carrying out these experiments, as in \secref{sec:light-ard}.
The reader should go through the instructions given in
-\secref{sec:sci-start} before getting started.
+\secref{sec:OpenModelica-start} before getting started.
\begin{enumerate}
\item In the first experiment, we will light up the blue LED on the
- shield. The code for this is given in OpenModelica-code-4.1.
- It begins with a command of the form
-
- \item import sComm = Arduino.SerialCommunication.Functions: This imports the SerialPorts library to the current workspace
- \item ok := sComm.open\_serial(1, 0, 115200): Function that opens the first serial port, with the specified baud rate.
-
- \item digital\_out := sComm.cmd\_digital\_out(1, 9, 1) : This will turn on the blue led
-
- \item sComm.close\_serial(1) : This closes the predefined serial port which is presently opened.
-\end{enumerate}
-
-OpenModelica Code 4.2 does the same thing as what Arduino Code 4.2 does. It does
-two more things than what OpenMOdelica Code 4.1 does: It makes the blue LED light
-up for two seconds. This is achieved by the command
+ shield. The code for this is given in \OpenModelicaref{OpenModelica:led-blue}.
+ It begins with importing the two packages: Streams and SerialCommunication from the toolbox, as
+ given in \secref{sec:load-om-toolbox}. Following line imports this package:
+ \lstinputlisting[firstline=3,lastline=4]{\LocLEDOpenModelicacode/led-blue.mo}
-sComm.delay(2000) //let the blue LED be on for two seconds
+ We define some variables to collect the results coming from different functions. Following
+ lines are used for these:
+ \lstinputlisting[firstline=5,lastline=7]{\LocLEDOpenModelicacode/led-blue.mo}
-The second thing this code does is to turn the blue LED off. This is achieved
-by the command
-
-\begin{lstlisting}[style=nonumbers]
- digital_out := sComm.cmd_digital_out(1, 9, 0)//turn off blue LED
+ Now, we have a command of the form
+ \begin{lstlisting}[style=nonumbers]
+ ok := sComm.open_serial(1, PORT NUMBER, BAUD RATE)
\end{lstlisting}
+ We have used 2 for {\tt PORT NUMBER} and 115200 for {\tt BAUD RATE}.
+ As a result, this command becomes
+ \lstinputlisting[firstline=10,lastline=10]{\LocLEDOpenModelicacode/led-blue.mo}
+ This command is used to open the serial port. When the port is
+ opened successfully, it returns a value of 0, which gets stored in
+ the variable {\tt ok}.
+
+ Sometimes, the serial port does not open, as mentioned in the above
+ command. This is typically due to not closing the serial port
+ properly in a previous experiment. If this condition is not
+ trapped, the program will wait forever, without any information
+ about this difficulty. One way to address this difficulty is to
+ terminate the program if the serial port does not open. This is
+ achieved using the error message of the following form:
+ \begin{lstlisting}[style=nonumbers]
+ if ok <> 0 then strm.print(Error Message in Quotes);
+ \end{lstlisting}
-It is easy to see that this code puts a 0 on pin 9.
-
-OpenModelica Code 4.3 does the same thing as what Arduino Code 4.3 does. It turns
-blue and red LEDs on for five seconds. After that, it turns off blue first. After
-3 seconds, it turns off red also. So, when the program ends, no LED is lit up.
-
-OpenModelica Code 4.4 does exactly what its counterpart in the Arduino IDE does.
-It makes the green LED blink five times.
+ We turn the LED on in the upcoming lines. This is achieved using a
+ command of the form
+ \begin{lstlisting}[style=nonumbers]
+ digital_out := sComm.cmd_digital_out(1, PIN NUMBER, VALUE)
+ \end{lstlisting}
+ As we want to turn on the blue light in the shield, as discussed in
+ \secref{sec:light-ard}, we choose {\tt PIN NUMBER} as 9. We can put
+ any positive integer in the place of {\tt VALUE}. We arrive at the
+ following command:
+ \lstinputlisting[firstline=10,lastline=10]{\LocLEDOpenModelicacode/led-blue.mo}
+ Subsequently, we close the serial port and then define the simulation parameters.
+ \item \OpenModelicaref{OpenModelica:led-blue-delay} does the same thing as what
+ \ardref{ard:led-blue-delay} does. It does two more things than what
+ \OpenModelicaref{OpenModelica:led-blue} does: It makes the blue LED light up for two
+ seconds. This is achieved by the command
+ \lstinputlisting[firstline=16,lastline=16]{\LocLEDOpenModelicacode/led-blue-delay.mo}
+ The second thing this code does is to turn the blue LED off. This
+ is achieved by the command
+ \lstinputlisting[firstline=17,lastline=17]{\LocLEDOpenModelicacode/led-blue-delay.mo}
+ It is easy to see that this code puts a 0 on pin 9.
+
+ \item \OpenModelicaref{OpenModelica:led-blue-red} does the same thing as what
+ \ardref{ard:led-blue-red} does. It turns blue and red LEDs on for
+ five seconds. After that, it turns off blue first. After 3
+ seconds, it turns off red also. So, when the program ends, no LED is
+ lit up.
+
+ \item \OpenModelicaref{OpenModelica:led-green-blink} does exactly what its counterpart
+ in the Arduino IDE does. It makes the green LED blink five times.
+ \end{enumerate}
\subsection{OpenModelica Code}
+Unlike other code files, the code/ model for running experiments using OpenModelica are
+available inside the OpenModelica-Arduino toolbox, as explained in \secref{sec:load-om-toolbox}.
\lstset{style=mystyle}
\label{sec:led-OpenModelica-code}
\addtocontents{OpenModelicad}{\protect\addvspace{\codclr}}
\begin{OpenModelicacode}
\mcaption{Turning on the LED}
- {Turning on the LED. Available at
- \LocLEDOpenModelicabrief{led-blue.mo}.}
+ {Turning on the blue LED. Available at Arduino -> SerialCommunication ->
+ Examples -> led -> led\_blue.}
\label{OpenModelica:led-blue}
\lstinputlisting{\LocLEDOpenModelicacode/led-blue.mo}
\end{OpenModelicacode}
@@ -878,8 +910,8 @@ It makes the green LED blink five times. \begin{OpenModelicacode}
\mcaption{Turning on the blue LED and turning it off after two
seconds}{Turning on the blue LED and turning it off after two
- seconds. Available
- at \LocLEDOpenModelicabrief{led-blue-delay.mo}.}
+ seconds. Available at Arduino -> SerialCommunication -> Examples -> led
+ -> led\_blue\_delay.}
\label{OpenModelica:led-blue-delay}
\lstinputlisting{\LocLEDOpenModelicacode/led-blue-delay.mo}
\end{OpenModelicacode}
@@ -887,15 +919,13 @@ It makes the green LED blink five times. \begin{OpenModelicacode}
\mcaption{Turning on blue and red LEDs for 5 seconds and then turning
them off one by one}{Turning on blue and red LEDs for 5 seconds and
- then turning them off one by one. Available at
- \LocLEDOpenModelicabrief{led-blue-red.mo}.}
+ then turning them off one by one. Available at Arduino -> SerialCommunication -> Examples -> led -> led\_blue\_red.}
\label{OpenModelica:led-blue-red}
\lstinputlisting{\LocLEDOpenModelicacode/led-blue-red.mo}
\end{OpenModelicacode}
\begin{OpenModelicacode}
- \mcaption{Blinking the green LED}{Blinking the green LED. Available
- at \LocLEDOpenModelicabrief{led-green-blink.mo}.}
+ \mcaption{Blinking the green LED}{Blinking the green LED. Available at Arduino -> SerialCommunication -> Examples -> led -> led\_green\_blink.}
\label{OpenModelica:led-green-blink}
\lstinputlisting{\LocLEDOpenModelicacode/led-green-blink.mo}
\end{OpenModelicacode}
diff --git a/user-code/led/python/led-blue-delay.py b/user-code/led/python/led-blue-delay.py index 8129411..cc6aa68 100644 --- a/user-code/led/python/led-blue-delay.py +++ b/user-code/led/python/led-blue-delay.py @@ -1,8 +1,7 @@ import os import sys -cwd=os.getcwd() -(setpath,Examples)=os.path.split(cwd) -#print setpath +cwd = os.getcwd() +(setpath, Examples) = os.path.split(cwd) sys.path.append(setpath) from Arduino.Arduino import Arduino @@ -10,28 +9,27 @@ from time import sleep class LED_ON_OFF: def __init__(self,baudrate): - self.baudrate=baudrate + self.baudrate = baudrate self.setup() self.run() self.exit() def setup(self): - self.obj_arduino = Arduino() - self.port = self.obj_arduino.locateport() - self.obj_arduino.open_serial(1, self.port,self.baudrate) + self.obj_arduino = Arduino() + self.port = self.obj_arduino.locateport() + self.obj_arduino.open_serial(1, self.port, self.baudrate) def run(self): - self.blue=9 - self.obj_arduino.cmd_digital_out(1,self.blue,1) - sleep(2) - self.obj_arduino.cmd_digital_out(1,self.blue,0) + self.blue = 9 + self.obj_arduino.cmd_digital_out(1, self.blue, 1) sleep(2) + self.obj_arduino.cmd_digital_out(1, self.blue, 0) def exit(self): self.obj_arduino.close_serial() def main(): - obj_led=LED_ON_OFF(115200) + obj_led = LED_ON_OFF(115200) if __name__== '__main__': main() diff --git a/user-code/led/python/led-blue-red.py b/user-code/led/python/led-blue-red.py index e611f46..4461537 100644 --- a/user-code/led/python/led-blue-red.py +++ b/user-code/led/python/led-blue-red.py @@ -1,8 +1,7 @@ import os import sys -cwd=os.getcwd() -(setpath,Examples)=os.path.split(cwd) -#print setpath +cwd = os.getcwd() +(setpath, Examples) = os.path.split(cwd) sys.path.append(setpath) from Arduino.Arduino import Arduino @@ -11,33 +10,32 @@ from time import sleep class LED_ON_OFF_MULTICOLOR: def __init__(self,baudrate): - self.baudrate=baudrate + self.baudrate = baudrate self.setup() self.run() self.exit() - def setup(self): - self.obj_arduino=Arduino() - self.port=self.obj_arduino.locateport() - self.obj_arduino.open_serial(1,self.port,self.baudrate) + self.obj_arduino = Arduino() + self.port = self.obj_arduino.locateport() + self.obj_arduino.open_serial(1, self.port, self.baudrate) def run(self): - self.blue=9 - self.green=10 - self.red=11 - self.obj_arduino.cmd_digital_out(1,self.blue,self.baudrate) - self.obj_arduino.cmd_digital_out(1,self.red,self.baudrate) + self.blue = 9 + self.green = 10 + self.red = 11 + self.obj_arduino.cmd_digital_out(1, self.blue, self.baudrate) + self.obj_arduino.cmd_digital_out(1, self.red, self.baudrate) sleep(5) - self.obj_arduino.cmd_digital_out(1,self.blue,0) + self.obj_arduino.cmd_digital_out(1, self.blue, 0) sleep(3) - self.obj_arduino.cmd_digital_out(1,self.red,0) + self.obj_arduino.cmd_digital_out(1, self.red, 0) def exit(self): self.obj_arduino.close_serial() def main(): - obj_led=LED_ON_OFF_MULTICOLOR(115200); + obj_led = LED_ON_OFF_MULTICOLOR(115200) if __name__=='__main__': main() diff --git a/user-code/led/python/led-blue.py b/user-code/led/python/led-blue.py index cd8c009..a6b85b7 100644 --- a/user-code/led/python/led-blue.py +++ b/user-code/led/python/led-blue.py @@ -1,34 +1,33 @@ import os import sys -cwd=os.getcwd() -(setpath,Examples)=os.path.split(cwd) -#print setpath +cwd = os.getcwd() +(setpath, Examples) = os.path.split(cwd) sys.path.append(setpath) from Arduino.Arduino import Arduino from time import sleep class LED_ON: - def __init__(self,baudrate): - self.baudrate=baudrate + def __init__(self, baudrate): + self.baudrate = baudrate self.setup() self.run() self.exit() def setup(self): - self.obj_arduino = Arduino() - self.port = self.obj_arduino.locateport() - self.obj_arduino.open_serial(1, self.port,self.baudrate) + self.obj_arduino = Arduino() + self.port = self.obj_arduino.locateport() + self.obj_arduino.open_serial(1, self.port, self.baudrate) def run(self): - self.blue=9 - self.obj_arduino.cmd_digital_out(1,self.blue,1) + self.blue = 9 + self.obj_arduino.cmd_digital_out(1, self.blue, 1) def exit(self): self.obj_arduino.close_serial() def main(): - obj_led=LED_ON(115200) + obj_led = LED_ON(115200) if __name__== '__main__': main() diff --git a/user-code/led/python/led-green-blink.py b/user-code/led/python/led-green-blink.py index 23ddf62..320bc1d 100644 --- a/user-code/led/python/led-green-blink.py +++ b/user-code/led/python/led-green-blink.py @@ -1,8 +1,7 @@ import os import sys -cwd=os.getcwd() -(setpath,Examples)=os.path.split(cwd) -#print setpath +cwd = os.getcwd() +(setpath, Examples) = os.path.split(cwd) sys.path.append(setpath) from Arduino.Arduino import Arduino @@ -11,31 +10,31 @@ from time import sleep class LED_ON_OFF_LOOP: def __init__(self,baudrate): - self.baudrate=baudrate + self.baudrate = baudrate self.setup() self.run() self.exit() def setup(self): - self.obj_arduino=Arduino() - self.port=self.obj_arduino.locateport() - self.obj_arduino.open_serial(1,self.port,self.baudrate) + self.obj_arduino = Arduino() + self.port = self.obj_arduino.locateport() + self.obj_arduino.open_serial(1, self.port, self.baudrate) def run(self): - self.blue=9 - self.green=10 - self.red=11 + self.blue = 9 + self.green = 10 + self.red = 11 for i in range(5): - self.obj_arduino.cmd_digital_out(1,self.green,1) + self.obj_arduino.cmd_digital_out(1, self.green, 1) sleep(2) - self.obj_arduino.cmd_digital_out(1,self.green,0) + self.obj_arduino.cmd_digital_out(1, self.green, 0) sleep(2) def exit(self): self.obj_arduino.close_serial() def main(): - obj_led=LED_ON_OFF_LOOP(115200) + obj_led = LED_ON_OFF_LOOP(115200) if __name__=='__main__': main() diff --git a/user-code/led/scilab/led-blue-delay.sce b/user-code/led/scilab/led-blue-delay.sce index 45ac1cb..4bea782 100644 --- a/user-code/led/scilab/led-blue-delay.sce +++ b/user-code/led/scilab/led-blue-delay.sce @@ -1,6 +1,6 @@ -ok = open_serial(1,2,115200); -if ok~=0, error('Check the serial port and try again'); end -cmd_digital_out(1,9,1) // turn blue LED on +ok = open_serial(1, 2, 115200); +if ok ~= 0, error('Check the serial port and try again'); end +cmd_digital_out(1, 9, 1) // turn blue LED on sleep(2000) // let the blue LED be on for two seconds -cmd_digital_out(1,9,0) // turn off blue LED -close_serial(1) // close the connection safely +cmd_digital_out(1, 9, 0) // turn off blue LED +close_serial(1); // close the connection safely diff --git a/user-code/led/scilab/led-blue-red.sce b/user-code/led/scilab/led-blue-red.sce index 7795e06..07290ad 100644 --- a/user-code/led/scilab/led-blue-red.sce +++ b/user-code/led/scilab/led-blue-red.sce @@ -1,9 +1,9 @@ -ok=open_serial(1,2,115200); // At port 2 with baudrate of 115200 +ok = open_serial(1, 2, 115200); // At port 2 with baudrate of 115200 if ok ~= 0 error('Check the serial port and try again'); end -cmd_digital_out(1,9,1); // This turns on the blue Led -cmd_digital_out(1,11,1); // This turns on the red Led +cmd_digital_out(1, 9, 1); // This turns on the blue Led +cmd_digital_out(1, 11, 1); // This turns on the red Led sleep(5000); // Delay for 5 seconds -cmd_digital_out(1,9,0); // This turns off the blue Led +cmd_digital_out(1, 9, 0); // This turns off the blue Led sleep(3000); // Delay for 3 seconds -cmd_digital_out(1,11,0); // This turns off the red Led +cmd_digital_out(1, 11, 0); // This turns off the red Led close_serial(1); // To close the connection safely diff --git a/user-code/led/scilab/led-blue.sce b/user-code/led/scilab/led-blue.sce index c870041..6613932 100644 --- a/user-code/led/scilab/led-blue.sce +++ b/user-code/led/scilab/led-blue.sce @@ -1,4 +1,4 @@ -ok = open_serial(1,2,115200); // At port 2 with baudrate of 115200
-if ok~=0, error('Check the serial port and try again'); end
-cmd_digital_out(1,9,1) // This will turn the blue LED
-close_serial(1) // To close the connection safely
+ok = open_serial(1, 2, 115200); // At port 2 with baudrate of 115200
+if ok ~= 0, error('Check the serial port and try again'); end
+cmd_digital_out(1, 9, 1) // This will turn the blue LED
+close_serial(1); // To close the connection safely
diff --git a/user-code/led/scilab/led-green-blink.sce b/user-code/led/scilab/led-green-blink.sce index c7a24f8..0e905ee 100644 --- a/user-code/led/scilab/led-green-blink.sce +++ b/user-code/led/scilab/led-green-blink.sce @@ -1,9 +1,9 @@ -ok= open_serial(1,2,115200); // At port 2 with baudrate of 115200 +ok = open_serial(1, 2, 115200); // At port 2 with baudrate of 115200 if ok ~= 0 error('Check the serial port and try again'); end -for i=1:5 // Running for loop, 5 times - cmd_digital_out(1,10,1); // This turns on the green Led +for i = 1:5 // Running for loop, 5 times + cmd_digital_out(1, 10, 1); // This turns on the green Led sleep(1000); // Delay for 1 second - cmd_digital_out(1,10,0); // This turns off the green Led + cmd_digital_out(1, 10, 0); // This turns off the green Led sleep(1000); // Delay for 1 second end close_serial(1); // To close the connection safely diff --git a/user-code/sw-env/sw-env.tex b/user-code/sw-env/sw-env.tex index 4f7da5b..e027997 100644 --- a/user-code/sw-env/sw-env.tex +++ b/user-code/sw-env/sw-env.tex @@ -27,9 +27,9 @@ Origin/tools/julia/#1}}, see \fnrefp{fn:file-loc}} % added for julia
%%%%%%OpenModelica Starts
-\newcommand{\LocFIMOpenModelicacode}{\Origin/tools/openmodelica} %added for OpenModelica
+\newcommand{\LocFIMOpenModelicacode}{\Origin/tools/openmodelica/windows/} %added for OpenModelica
\newcommand{\LocFIMOpenModelicabrief}[1]{{\tt \seqsplit{%
- Origin/tools/openmodelica/#1}}, see \fnrefp{fn:file-loc}} % added for OpenModelica
+ Origin/tools/openmodelica/windows/#1}}, see \fnrefp{fn:file-loc}} % added for OpenModelica
%%%%%OpenModelica Ends
@@ -1077,6 +1077,7 @@ below: % \end{enumerate}
\subsection{Python Arduino toolbox}
+\label{sec:python-toolbox}
Python, by default, does not have the capability to connect to Arduino.
All such add-on functionalities are added to Python using packages.
The Python Arduino toolbox can be found inside the {\tt Origin/tools/python} directory,
@@ -1308,7 +1309,7 @@ we will use {\tt Pkg}. It is Julia's built-in package manager and handles operations such as installing, updating, and removing packages in Julia.
For installing LibSerialPort, carry out the steps given below:
\begin{enumerate}
- \item Open pen a Terminal by pressing Ctrl+Alt+T keys together. Type {\tt julia} and press Enter.
+ \item Open a Terminal by pressing Ctrl+Alt+T keys together. Type {\tt julia} and press Enter.
It should launch Julia in an interactive session (also known as a read-eval-print loop or "REPL"), as shown
in \figref{julia-repl}. When run in interactive mode, Julia displays a banner and
prompts the user for input. By default, Julia REPL appears in Julian prompt. It is the default mode of
@@ -1340,6 +1341,7 @@ is present in the list of packages being shown. To exit the interactive session, \subsection{Julia Arduino toolbox}
+\label{sec:julia-toolbox}
Julia, by default, does not have the capability to connect to Arduino.
All such add-on functionalities are added to Julia using toolboxes.
The Julia-Arduino toolbox can be found inside the {\tt Origin/tools/julia} directory,
@@ -1564,7 +1566,7 @@ Simulation finished successfully". Had there been any error in simulating the mo we would not have received this message.
-\subsection{OpenModelica Arduino toolbox}\label{load-om-toolbox}
+\subsection{OpenModelica Arduino toolbox}\label{sec:load-om-toolbox}
OpenModelica, by default, does not have the capability to connect to Arduino.
All such add-on functionalities are added to OpenModelica using toolboxes.
The OpenModelica Arduino toolbox can be found inside {\tt Origin/tools/\\openmodelica/windows} or {\tt Origin/tools/openmodelica/linux} directory,
@@ -1591,8 +1593,8 @@ Let us now see how to load the OpenModelica Arduino toolbox. If you are able to view these files, it means that OpenModelica-Arduino toolbox has been loaded successfully.
Please note that each time you launch OMEdit, you need to load this toolbox for
performing the experiments.
- \item The {\tt test\_firmware.mo} in the step \ref{itm:library} is the same file which has been mentioned in \secref{om-firmware}.
- While following \secref{om-firmware}, the readers are advised to execute (or simulate) this file (or model).
+ % \item The {\tt test\_firmware.mo} in the step \ref{itm:library} is the same file which has been mentioned in \secref{om-firmware}.
+ % While following \secref{om-firmware}, the readers are advised to execute (or simulate) this file (or model).
\item \label{itm:locate} Now, we will locate the models for running the experiments in the upcoming chapters.
Under Libraries Browser, click on the arrow before Arduino to see the
contents inside this package. Next go to SerialCommunication -> Examples.
@@ -1601,10 +1603,9 @@ Let us now see how to load the OpenModelica Arduino toolbox. \item \label{itm:simulate} For running the experiments of a particular chapter, click on the corresponding
experiment's name. Subsequently, you will find a list of experiments which you can
simulate one by one, as explained in \secref{OpenModelica-code-execution}.
- \item For each of the experiments given in the upcoming chapters, we have provided
- the OpenModelica model in {\tt Origin/user-code} folder. However, the readers
+ \item For each of the experiments using OpenModelica given in the upcoming chapters, the readers
are advised to locate the corresponding model by following the steps
- numbered \ref{itm:locate} and \ref{itm:simulate} and simulate it.
+ numbered \ref{itm:locate} and \ref{itm:simulate} and simulate it.
\end{enumerate}
|