Hello 🤖
Hello 🤖
Hey, my name’s Ven and I’m an ECE Grad Student at Binghamton University. I enjoy hiking, camping, and going on road trips with my dog. 🚶♂️🏕️🚙🐕
Table of Contents:
- Raspberry Pi Pico keypad driver and finite state machine, 11/06/23
- Raspberry Pi Pico systick and watchdog drivers, 10/31/23
- I setup a network-wide Ad Blocker, 10/14/2022
- Cool 3D zero-pole plot I visualized in MATLAB for Signals & Systems, 10/29/2022
- My VSCode setup, 09/04/2022
Raspberry Pi Pico keypad driver and finite state machine, 11/06/23
The goal of this assignment was to code a finite state machine to output onto the terminal (using serial connection via minicom) the keys entered on a physical keypad.
The program is using the systick and watchdog drivers coded in the previous assignment. The watchdog driver resets the processor if the timer expires–it functions as a safety to restart the proessor if code gets stuck in a loop; the systick controls the timing of the main loop. In this case, the main loop restarts every 1 s. If systick stops working and the main loop takes more than 1.499999… s to loop, then the watchdog timer will expire and the processor will be reset. This is desired behavior to prevent faulty code from continually executing
Raspberry Pi Pico systick and watchdog drivers, 10/31/23
We’re learning how to write drivers in C for an M0+ ARM processor running on a Raspberry Pi Pico H in my Embedded Systems Design class.
The goal of this assignment is to set up systick and watchdog drivers, then test the watchdog driver by using a blocking function to cause the processor to restart. This is tested on the Raspberry Pi Pico H by using an LED that’s programmed in the finite state machine to blink at 0.5 Hz frequency (LED on for one second, LED off for one second; total period is 2 seconds)
The systick driver controls the timing of the main loop, which by default is set to loop every 1 second. The watchdog driver resets the processor if its timer expires. I have the watchdog timer set to expire at 1.5 seconds
At the end of my code the function, “feed_the_watchdog();” is called, which resets the watchdog timer. By default, the watchdog should not reset the processor because the timer is being reset in the code.
In this assignemnt, a blocking function is included at the top of the main loop that stops the systick from running when the push button is pressed on the Raspberry Pi Pico H, which allows the watchdog timer to expire, so the processor will continually be reset while the push button is held down.
This is demonstrated in the video as the LED flashing very fast while the push button is held down, and turning on and off every second when the button is not pressed
Cool 3D zero-pole plot I visualized in MATLAB for Signals & Systems, 10/29/2022:
We’re currently learning about calculating transfer functions, H(z), from a given (recursive/non-recursive) difference equation, y[n] = x[n], then converting the transfer function into its corresponding frequency response, H(Ω).
From the transfer function, H(z), we’re plotting its zero-pole plot on the real/imaginary plane inside a unit circle and determining whether it’s stable or not (based on whether the poles are inside the unit circle).
I was able to conceptualize all these steps and calculate them, but I had difficulty visualizing what the frequency response, H(Ω), would look like from the zero-pole plot, so I looked into using MATLAB to plot it…
After reading the MATLAB documentation (and a lot of trial and error) I got a 3D visualization of how the frequency response would look like for a given zero-pole plot!
I’m using MATLAB as a visual aid to help me conceptulaize how to go from a 2D zero-pole plot, to a 3D frequency response-zero-pole plot. My code isn’t documented because I made this post shortly after I got it working, and I wanted to share it since it’s cool.
Here’s the frequency response vs the zero-pole plot I produced from my difference equation:
Here’s the messy code I used to generate it:
Here’s the more direct zero-pole, frequency response, and phase plots:
and here’s the code I used to generate it:
I setup a network-wide Ad Blocker, 10/14/2022:
I got a Raspberry Pi 4B and used it to set up an ad blocker on my local network. The advantage of this is that it’s not device-dependent, meaning I don’t need to have an ad blocker setup on individual devices because this Raspberry Pi acts as the primary DNS server for my router (the Raspberry Pi automatically uses Google/Cloudflare {or whatever DNS service you prefer} as the next DNS server after the AdBlock filter list is applied; a DNS server tells your computer where to go when you type in a website like google.com into your web browser). It also doesn’t interfere with other ad blockers that are used locally on individual devices.
The idea is as follows: normally you need to set up an ad blocker on each of your individual devices (phone, computer, etc.) to block ads on those devices. By using this Raspberry Pi as my primary DNS server on my router, all data that goes into and out of the router first checks the filter list on my Raspberry Pi for any websites identified as ad networks or tracking links, if the link coming into or out of the router matches one of those links, it tells the router to block the connection.
Will this slow down my internet connection? No, it won’t slow down the internet at all because the filter list is just a text file of website addresses to block, there’s no other data or instructions there. The router checks if the website attempting to connect is on the list, if it is, it blocks the connection. That’s it.
This will speed up loading websites if there are ads or trackers on the website that are on the filter list, because your computer now doesn’t need to load those ads or trackers before you can see the website content!
A network-wide ad blocker isn’t perfect–it doesn’t block YouTube or Hulu ads on streaming devices because a filter list doesn’t block elements in an application, which is what the ads on YouTube and Hulu are. The ad blocker you install on a web browser does block and hide elements, so that’s why you still want to use a local ad blocker on individual devices even if you set up a Raspberry Pi as a network-wide ad blocker.
Who is this good for? Everyone, but especially for people who don’t know how to install a local ad blocker (like family members). You just set up this little device on their home network and leave it alone. Since you can SSH into the Raspberry Pi when you’re on the same local network, you can update it from your computer without needing to connect a monitor, keyboard, and mouse to the Raspberry Pi.
It won’t block everything, but it blocks a lot more than nothing, so it’s a net-positive result.
Setup was relatively simple using this guide: https://www.tomshardware.com/how-to/set-up-pi-hole-raspberry-pi
- There’s a Raspberry Pi app that formats and installs the Raspberry Pi OS onto your microSD card
- Then you plug the microSD card into the Raspberry Pi, turn it on and connect it to a monitor, keyboard, and mouse; then connect it to your Wi-Fi/ethernet
- You run: “sudo apt-get update” & “sudo apt-get upgrade -y” to update the OS
- Then install the Pi-hole adblocker using the installer from the Pi-hole website
- In the installer, you choose your static IP address for the Raspberry Pi
- You then set that IP address as your DNS address on your router (I also use Google/Cloudflare as a secondary DNS server on my router, in case the Raspberry Pi ever goes down)
- After that, you can disconnect the monitor, keyboard, and mouse because you can now connect to the Raspberry Pi through SSH since it’s on your network
- With SSH I can update the OS & ad blocker from my laptop using bash (I use MobaXterm to SSH into my Raspberry Pi)
With the device setup, I can just go to the IP address and and look at the dashboard to see what’s being blocked, the uptime/memory usage/temperature of the Raspberry Pi, add adblock filters, adjust settings, etc.
I also drilled some holes on the top of the Raspberry Pi case because it otherwise had no airflow. I installed a small heatsink on the CPU and a fan over it to keep the device cool.
My VSCode setup, 09/04/2022:
This isn’t super-important, so I set it off to the side
I figured out how to setup my VSCode debug environment for C using GDB. I’m stoked I can step through my code and be able to see the values of my variables as the code is being executed, see what’s changing in the register, AND see what stacks are being called. Prior to setting up my debug environment, I was using a standard compile & run combination with a GCC compiler, and I used GDB through a bash terminal to debug my code on the school server. My current setup is much nicer 🙂