Engineering Insights

Detailed write-ups on my portfolio projects, from Embedded Systems to AI and OS Architecture.

Building an Autonomous Line-Following Robot

Robotics is the ultimate intersection of hardware and software. One of my fundamental projects during my B.S. in Electrical Engineering at FAST NUCES was designing and building a completely autonomous line-following robot from scratch. The objective was simple but the implementation required precise tuning: navigate a complex track using IR sensors without any human intervention.

Hardware Architecture

At the brain of the operation was the Arduino Uno. I selected it for its rapid prototyping capabilities and robust community support. To detect the line, I implemented an array of IR (Infrared) sensors. These sensors constantly measure the reflectivity of the surface beneath them—differentiating between the dark track line and the lighter floor.

The motor control was handled via an L298N motor driver, enabling bidirectional control of two DC motors. Power management was critical; I had to ensure the motors drew enough current without browning out the microcontroller.

Software and PID Tuning

Writing the control logic was the most challenging and rewarding part. A simple "if left sensor sees black, turn left" algorithm results in incredibly jerky and inefficient movement. To solve this, I implemented a custom algorithm inspired by PID (Proportional, Integral, Derivative) control logic.

"The key to smooth robotics isn't just knowing where you are, but predicting where the momentum will take you in the next few milliseconds."

By reading the analog values of the IR array, the robot could calculate an "error" value based on how far off-center the line was, and adjust the motor PWM (Pulse Width Modulation) speeds proportionally. This resulted in buttery-smooth cornering.

Conclusion

This project solidified my understanding of closed-loop control systems and real-time microcontroller programming. It served as a fantastic stepping stone into more complex embedded architectures.

Designing a Role-Based Smart Home Automation System with ATmega32

While Arduinos are great for prototyping, industrial and commercial applications demand bare-metal microcontroller programming. To challenge myself with low-level register manipulation in C, I designed a Smart Home Automation System utilizing the ATmega32 microcontroller.

System Overview

The project wasn't just about turning lights on and off; it was about security and hierarchy. I implemented a robust role-based access system. The system differentiates between "Admin" users and "Guest" users.

  • Admin Access: Can configure the system, add/remove guests, and control all appliances.
  • Guest Access: Can only toggle basic lighting and fan states, restricted from security controls.

Implementation Details

I interfaced a 4x4 matrix keypad for passcode entry and an alphanumeric LCD (16x2) for the user interface. Programming these peripherals required writing custom driver libraries in C, managing the GPIO (General Purpose Input/Output) registers directly rather than relying on abstracted libraries.

Authentication data (passwords and roles) was stored and retrieved from the ATmega32's internal EEPROM, ensuring that the system retained its configuration even after a power loss.

The Hardware Challenge

To safely control high-voltage AC appliances (simulated via 220V bulbs in the prototype), I designed an isolation circuit using optocouplers and mechanical relays. This ensured that any power surge on the AC side would not fry the delicate 5V DC logic of the ATmega32. This project deeply enhanced my understanding of memory management, bare-metal C programming, and power electronics isolation.

Simulating an OS: Process & Resource Management in User-Space

As an Electrical Engineer, my focus is primarily on hardware, but understanding how software interfaces with the CPU is crucial. To bridge this gap, I developed an OS Process and Resource Manager—a User-Space Operating System Simulator written entirely in C++.

Core Mechanisms Modeled

Operating systems are massive, complex beasts. For this simulator, I focused strictly on the core kernel responsibilities:

  • Process States: Implemented a state machine for processes transitioning between New, Ready, Running, Waiting, and Terminated.
  • Context Switching: Simulated saving and loading the CPU registers (Process Control Block - PCB) when swapping out processes.
  • Resource Allocation: Implemented Banker's Algorithm to handle simulated memory and peripheral requests, ensuring the system never enters a deadlock state.

Data Structures & Algorithms

Efficiency was key. I utilized custom queue structures to manage the Ready Queue and Waiting Queues. The scheduling algorithm utilized was a simulated Round-Robin with dynamic time-quantums, adjusting based on whether the process was I/O bound or CPU bound.

By building this simulator, the abstract concepts of CPU scheduling, mutexes, semaphores, and memory paging became concrete logic in my mind. It heavily influences how I write firmware today, ensuring my microcontroller code is non-blocking and resource-efficient.

Lessons Learned: My AI Internship at CyberGen

During the summer of 2025 (July - August), I had the privilege of joining CyberGen as an AI Intern. It was an eye-opening experience that took my theoretical knowledge of Python and Machine Learning and subjected it to the rigors of real-world corporate demands.

What I Worked On

My primary responsibility was assisting the senior engineering team with AI-based tasks and workflow automation. Much of the data processing tasks that took hours were ripe for automation. I developed Python scripts utilizing Pandas and NumPy to clean and preprocess massive datasets before they were fed into the training pipelines.

Furthermore, I gained hands-on experience evaluating the outputs of Large Language Models (LLMs) to ensure response accuracy and safety compliance for internal tooling.

The Biggest Takeaway

The most valuable lesson wasn't a specific coding framework, but rather the importance of data quality. An AI model is only as intelligent as the data it trains on. Garbage in, garbage out. My time at CyberGen taught me to rigorously validate datasets and treat data engineering with the same respect as algorithm design.

Practical Analog Automation: Proteus Circuit Simulations

Before soldering a single component, a robust circuit design must be simulated and stressed. I frequently use Proteus to validate my analog designs. Two of my favorite foundational analog projects are the Automatic Street Light System and the Temperature Controlled Fan.

The Automatic Street Light

This project entirely avoids microcontrollers. It relies purely on the physics of an LDR (Light Dependent Resistor) and the switching properties of BJT transistors. By setting up the LDR in a voltage divider configuration with a variable potentiometer, I created a tunable threshold. As ambient light drops, the LDR resistance spikes, altering the voltage at the transistor's base. Once the base-emitter voltage exceeds ~0.7V, the transistor saturates, triggering a relay that powers the street lamp. It's an elegant, highly reliable, and cheap analog solution.

The Temperature Controlled Fan

Similar in philosophy, this circuit utilizes an NTC Thermistor or an LM35 sensor. Using an Operational Amplifier (Op-Amp) configured as a comparator, the circuit compares the voltage from the temperature sensor against a reference voltage (set by a potentiometer).

When the temperature crosses the threshold, the Op-Amp outputs high, driving a MOSFET which in turn spins up a DC cooling fan.

These projects reinforce a core engineering philosophy: don't use a $5 microcontroller when a $0.10 Op-Amp and a sensor can do the job with zero latency and infinite reliability.