Commit 655270ae authored by Arash Sattari's avatar Arash Sattari

w15, w19 updates

parent 0391483e
Pipeline #107716 passed with stage
in 27 seconds
......@@ -314,8 +314,51 @@
</div>
Here is a screenshot of the GUI code.
<div class="img-container"><img style="width: 600px;" src="../img/assignments/w15/3.jpg" alt=""><br><b>Figure 3. </b>GUI code.</div>
<p>
It was my first time that using <b>PyQt5</b> to build a GUI. I found a helpful series of short
<a href="https://www.youtube.com/watch?v=JBME1ZyHiP8&list=PLQVvvaa0QuDdVpDFNq4FwY9APZPGSUyR4"><b>tutorial videos</b></a> on YouTube to get start with PyQt5.
To create and show a basic window, first we need to import <i>PyQt5</i> and <i>PyQt5.QtWidgets</i> to have access to the graphical user interface. Next, we need to
create an application object to have access to the event loop. Then, we create a <i>QtWidgets</i> on the window, show the window and start the event loop by
using the <i>app.exec().</i> <br>
As can be seen in the code snapshot, I wrote the code object oriented. I created a class and named it Window, which is inherited from <i>QtGUi.QMainWindow</i>.
Next, I create an <i>__init__</i> method (Fig. 4) and set the geometry parameters inside it, and also call the <i>init_ui()</i> method, which creates widgets on the window.
</div>
</p>
<div class="img-container"><img style="width: 500px;" src="../img/assignments/w15/4.jpg" alt=""><br><br> <b>Figure 4. </b>__init__ method code.</div>
<p>
Figure 5 shows a part of <i>init_ui</i> method that makes a <i>QLable</i> to show the current time, and a <i>QPushButton</i>, which set the time for heating.
When the button is clicked, it passes through the <i>set_button_clicked</i> method.
</p>
<div class="img-container"><img style="width: 500px;" src="../img/assignments/w15/5.jpg" alt=""><br><br> <b>Figure 5. </b>Creating a QLable and QPushButton.</div>
<p>
To track the times (e.g. the current time, remaining time to start heating, etc.), I created a timer using <i>threading.Timer</i>, which runs periodically every second (Fig. 6).
</p>
<div class="img-container"><img style="width: 500px;" src="../img/assignments/w15/6.jpg" alt=""><br><br> <b>Figure 6. </b>Periodical Timer.</div>
<p>
I used pySerial to send commands over the serial port. The messages are sent to turn on and off the heater (in this case, the existing LED on the board)
and are simple, we send ‘1’ as the turn on command and ‘0’ for turn off. Here are the part of codes for sending a turn on command by the GUI to ATtiny44.
</p>
<div style="text-align:center;">
<div class="row row-centered">
<div style="height:200px;" class ="col-md-6 col-centered">
<h5>GUI (Python)</h5>
<xmp>
self.arduinoData = serial.Serial('COM4', 9600)
self.arduinoData.write(str.encode('1'))
</xmp>
</div>
<div style="height:200px;" class ="col-md-6 col-centered">
<h5>ATtiny44 (Arduino IDE)</h5>
<xmp>
SoftwareSerial mySerial(rxPin, txPin);
mySerial.begin(9600);
if (mySerial.read() == '1') {digitalWrite(ledPin, HIGH);}
</xmp>
</div>
</div>
</div>
<div class="section-content">
<a class="anchor" id="section-6"></a>
......
......@@ -154,10 +154,13 @@
<a href="#section-10" class="nav-link">Assembling</a>
</li>
<li class="nav-item">
<a href="#section-11" class="nav-link">Reflection</a>
<a href="#section-11" class="nav-link">Summary</a>
</li>
<li class="nav-item">
<a href="#section-12" class="nav-link">Files</a>
<a href="#section-12" class="nav-link">Reflection</a>
</li>
<li class="nav-item">
<a href="#section-13" class="nav-link">Files</a>
</li>
</ul>
</nav>
......@@ -427,6 +430,51 @@
<div class="section-content">
<a class="anchor" id="section-11"></a>
<h3 class="mt-4">Summary</h3>
<p>
<br>
<b>What tasks have been completed and what tasks remain?</b><br>
<br>
<b>Completed tasks:</b> Design and fabrication of the box, design and fabrication of the pole and stand, design and
integrated implementation of microcontroller board (a single PCB incorporates all elements), design, fabrication and implementation
of motorized cord reel, implementation of temperature sensor and temperature-optimized timer, implementation of HV relay,
wired serial communication to a windows-based UI, PyQt5-based desktop UI for setting up the block heater timer and remote control of cord reel,
implementation of RGB LEDs for displaying the heating status.<br>
<b>Remaining tasks:</b> Testing the already included current sensor for calculating and reporting user consumption,
testing the already included wireless connection via the WiFi IC, implementing an Android-based app to support remote wireless connection. <br>
<br>
<b>What has worked? What hasn't?</b><br>
<br>
All the above-mentioned completed tasks have been tested and worked. while building the LED display, I had to compromise and use a 12V RGB LED strip
instead of 5V addressable LED strip, which I was planning to use. This was because both The serial connection and LED control libraries
use interrupts timed with the only integrated timer available in ATTiny44 and this was causing timing issues. But the design worked well
also with the 12V RGB LEDs.<br>
<br>
<b>What questions need to be resolved?</b><br>
<br>
Can this prototype be fabricated with lower cost? Can it be implemented with material that endure outside conditions in subzero temperature?
I saw a clear need for a more sophisticated microcontroller during the development process. What are the exact specifications that the
new microcontroller should have to be able to handle all the functionalities?<br>
<br>
<b>What will happen When?</b><br>
<br>
The functionality of project is already explained in detail (here and in Final Project page).
I will add the WiFi communication, Android app, and consumption record via current sensor. Then,
I need to start thinking about if I want to continue working on this further or not?<br>
<br>
<b>What have you learned?</b><br>
<br>
The main learning outcome of this project for me was how to handle and schedule a project in a short time, to think fast, work hard and make
the right decisions and compromises to deliver a multi-dimensional project on time. I used a new method for fabricating a box with curved edges
using thin plywood (which I was thinking to try for sometime now!). While making the bill of material, I got to really find out and think about
how much the parts cost. I had a clear knowledge of electronics cost, and I had already included the cost parameter in choosing my electronics elements,
but not so much for the wooden or 3D printed parts.
<br>
</p>
</div>
<div class="section-content">
<a class="anchor" id="section-12"></a>
<h3 class="mt-4">Reflection</h3>
<p>
I have to admit that I was tested to my limits to deliver this project in time.
......@@ -436,7 +484,7 @@
</div>
<div class="section-content">
<a class="anchor" id="section-12"></a>
<a class="anchor" id="section-13"></a>
<h3 class="mt-4">Files</h3>
<b><a style="color:#fed136;" href="../files/w19/3D print.zip">3D Design</a></b> <br>
<b><a style="color:#fed136;" href="../files/w19/laserCut.zip">2D Design</a></b> <br>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment