Skip to content

Commit 7d1fbc9

Browse files
Built site for gh-pages
1 parent 309e2a4 commit 7d1fbc9

File tree

6 files changed

+5
-5
lines changed

6 files changed

+5
-5
lines changed

.nojekyll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
c47fb989
1+
0ba8c353

labs/lab5/images/final_calc1.jpeg

757 KB
Loading

labs/lab5/images/flowchart1.jpeg

401 KB
Loading

labs/lab5/images/schematic1.jpeg

160 KB
Loading

labs/lab5/lab5.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,15 @@ <h2 class="anchored" data-anchor-id="introduction">Introduction</h2>
163163
<h2 class="anchored" data-anchor-id="design-and-testing-methodology">Design and Testing Methodology</h2>
164164
<p>In order to approach the design of the project, I first had to look through the reference/programming manual of the STMLK324KC microcontroller, as well as the interrupt lecture slides to understand the flow of logic that needs to be configured to enable interrupts. I used some of the provided header and C files, as well as the timer configuration files from my last lab, however I removed the structs as for this lab we could directly use the stm32l432xx.h header. However, I kept the .c functions the same as it had specially defined functions to configure our clocks and flash. In terms of design for the motor calcualtions, if we trap on any of A’s edges, and B is the opposite signal then we can determine a clockwise direction of motion. Similarly, if we trap on any of B’s edges, and A is the same signal, then we are going clockwise. Otherwise, we are moving in the counter clockwise. So, I connected the input pins (PA9 –&gt; A and PA10 –&gt; B) to interrupt lines (PA9 connects to line 9, PA10 connects to line 10), adn configured the interrupts to trap on both rising and falling edges of the square-wave encoder pulse. Then, on an interrupt, it goes to that line’s IRQ interrupt handler function, where I check for the interrupt on the exact line I care about (9 in EXTI9_5 handler, and 10 in EXTI15_10 handler), clear it by writing 1 to it, and perform my calculations. Here I check for the edges of A and B on the trap to get direction (I can tell which encoder signal I trapped on based on which interrupt handler I went to/which interrupt flag bit went to 1). Then, on these interrupts I also keep a running total of the number of pulses I have in the cw and ccw directions which then gets used in my tim16 interrupt handler function. For tim16, I have the tim 16 timer configured to 1 second, after which it raises the UIF flag and traps into its tim16 interrupt handler. Once I am here, I check how many pulses I had in the second, and divide that by the motors ppr (pulses per revolution), which is 408 from the datasheet to give me angular velocity (rev/sec). I then clear the counter to start fresh for the next 1 second interval. Additionally, once I hit the interrupt handler for the timer, I set a display flag to 1, which if true in the main function, it prints out the direction and angular velocity to the debug console.</p>
165165
<p>The use of interrupts over polling techniques have different pros and cons. With interrupts, we can configure it so that as soon as an event is detected it will trap, pause all other execution, save the architectural state, and handle the interrupt before resuming normal program flow. This requires less hardware, and can almost instantaneously detect an event and handle it. Additionally, priorities can be set so that different interrupts can take precedents over others based on what may be more important. However, sometimes certain interrupts can pause all other execution, and if we want something to happen in parallel it could affect that. On the other hand, polling would require more hardware and continuous checking to determine if an event happened, and there could be a lag in when an event is detected to when it occurs, or it is possible that polling misses the event, in the case that the event happens in between a clock cycle - although unlikely if polling at high speeds.</p>
166-
<p><img src="images/flowchart.jpeg" class="img-fluid" alt="Figure 1: Flowchart with logic flow and interrupts"> Image 1 above displays the flowchart with the control logic flow, and how interrupts are handeled, and how that is built into the main function.</p>
166+
<p><img src="images/flowchart1.jpeg" class="img-fluid" alt="Figure 1: Flowchart with logic flow and interrupts"> Image 1 above displays the flowchart with the control logic flow, and how interrupts are handeled, and how that is built into the main function.</p>
167167
</section>
168168
<section id="technical-documentation" class="level2">
169169
<h2 class="anchored" data-anchor-id="technical-documentation">Technical Documentation:</h2>
170170
<p>The source code for the project can be found in the associated <a href="https://github.com/SadhviNarayanan/e155-lab5">Github repository</a></p>
171171
<section id="schematic" class="level3">
172172
<h3 class="anchored" data-anchor-id="schematic">Schematic</h3>
173-
<p><img src="images/schematic_lab5.jpeg" class="img-fluid" alt="Figure 2: Schematic of the physical circuit"> The image above is the schematic of our circuit, which is connected to our motor. Our two encoder input pulses go into pins 9 and 10, and then we connect the motor to a 5V VCC supply from our MCU, and then power the encoders with and external power source. I set up internal pull-ups on pins 9 and 10 within the MCU.</p>
174-
<p><img src="images/final_calc.jpeg" class="img-fluid" alt="Figure 3: Angular Velocity Calculations"> Figure 3 above shows the difference between the actual and expected frequencies, because of the rounding that happens when we set out values to arr.</p>
173+
<p><img src="images/schematic1.jpeg" class="img-fluid" alt="Figure 2: Schematic of the physical circuit"> The image above is the schematic of our circuit, which is connected to our motor. Our two encoder input pulses go into pins 9 and 10, and then we connect the motor to a 5V VCC supply from our MCU, and then power the encoders with and external power source. I set up internal pull-ups on pins 9 and 10 within the MCU.</p>
174+
<p><img src="images/final_calc1.jpeg" class="img-fluid" alt="Figure 3: Angular Velocity Calculations"> Figure 3 above shows the difference between the actual and expected frequencies, because of the rounding that happens when we set out values to arr.</p>
175175
</section>
176176
</section>
177177
<section id="results-and-discussion" class="level2">

sitemap.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</url>
1919
<url>
2020
<loc>https://SadhviNarayanan.github.io/hmc-e155-portfolio/labs/lab5/lab5.html</loc>
21-
<lastmod>2025-10-05T00:39:44.813Z</lastmod>
21+
<lastmod>2025-10-06T17:44:09.506Z</lastmod>
2222
</url>
2323
<url>
2424
<loc>https://SadhviNarayanan.github.io/hmc-e155-portfolio/labs/lab6/lab6.html</loc>

0 commit comments

Comments
 (0)