<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Tanvir Singh</title>
    <description>The latest articles on DEV Community by Tanvir Singh (@tanvirsingh007).</description>
    <link>https://dev.to/tanvirsingh007</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1631923%2F6e6543cc-3adf-4007-94fc-4ca049ec93b5.jpg</url>
      <title>DEV Community: Tanvir Singh</title>
      <link>https://dev.to/tanvirsingh007</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tanvirsingh007"/>
    <language>en</language>
    <item>
      <title>What building a Self-Balancing Robot without any robotics experience taught me</title>
      <dc:creator>Tanvir Singh</dc:creator>
      <pubDate>Sun, 14 Jul 2024 20:15:07 +0000</pubDate>
      <link>https://dev.to/tanvirsingh007/what-building-a-self-balancing-robot-without-any-robotics-experience-taught-me-9f8</link>
      <guid>https://dev.to/tanvirsingh007/what-building-a-self-balancing-robot-without-any-robotics-experience-taught-me-9f8</guid>
      <description>&lt;h1&gt;
  
  
  How I Built a Self-Balancing Robot and What I Learned Along the Way
&lt;/h1&gt;

&lt;p&gt;Hey there! I'm a software developer by trade, with a background in web development and DevOps. But back in my final year of pursuing a Bachelor's in Electronics and Communication Engineering, I decided to take on a hardware project that was way outside my comfort zone. Instead of opting for something straightforward like a smart-home automation Telegram bot, I went for a challenge: building a &lt;strong&gt;Self-Balancing Robot&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's a Self-Balancing Robot?
&lt;/h2&gt;

&lt;p&gt;In case you're wondering, a Self-Balancing Robot is a two-wheeled robot that uses a gyroscope to measure its tilt. It counters the tilt by powering the stepper motors connected to its wheels. Essentially, it stays upright by constantly adjusting its position, like a mini-Segway. Sounds cool, right? But it required more than just knowing how to program an Arduino. I had to understand the mechanics of the robot, calculate the center of gravity, and get into a lot of stuff that was way beyond my usual software development realm. I was excited about the challenge!&lt;/p&gt;

&lt;h2&gt;
  
  
  The Journey Begins
&lt;/h2&gt;

&lt;p&gt;So, I started with some research. After scouring the internet, I found an open-source project on GitHub called &lt;strong&gt;BalancingWii&lt;/strong&gt;. Turns out, a lot of folks used this as a baseline for their self-balancing robots. I thought, "Great, this should make things easier." Spoiler alert: I was wrong.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Rollercoaster Ride
&lt;/h2&gt;

&lt;h3&gt;
  
  
  First Attempt
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bought Parts&lt;/strong&gt;: Ordered all the necessary components. This included a gyroscope, stepper motors, an Arduino board, motor drivers, and various other electronics.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Parts Arrived&lt;/strong&gt;: Time to get to work! Receiving all the parts was like Christmas morning, filled with excitement and anticipation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Learned to Solder&lt;/strong&gt;: First time soldering, not too shabby. I had to learn how to solder components onto a PCB, which was a new skill for me.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Edited Code&lt;/strong&gt;: Tweaked the open-source code to fit my needs. I modified the BalancingWii code to work with my specific setup and components.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Uploaded Code&lt;/strong&gt;: Hit my first snag with a driver issue. My computer wasn't recognizing the Arduino board due to a missing driver. After some digging, I found a driver that worked. Nice!&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test Run&lt;/strong&gt;: Tested the tilt functionality without a body—it worked! The gyroscope was detecting tilt and the motors were responding correctly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Major Setback&lt;/strong&gt;: I accidentally short-circuited the main board and fried everything. Oops. I learned the hard way about the importance of careful handling and proper insulation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At this point, the project was getting expensive since it was all out of my own pocket. I had to add more people to my team in order to fund the project. My college didn't fund projects, so I had to start over.&lt;/p&gt;

&lt;h3&gt;
  
  
  Second Attempt
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Ordered Parts Again&lt;/strong&gt;: New parts arrived, and I was ready for round two. I reordered the components and braced myself for another attempt.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Soldered Again&lt;/strong&gt;: Getting better at this. With practice, my soldering skills improved, resulting in cleaner and more reliable connections.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Made Adjustments&lt;/strong&gt;: Improved the robustness of the setup. I made some &lt;br&gt;
design changes to make the setup more durable and less prone to short circuits.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Test Run&lt;/strong&gt;: Things were looking good. The initial tests were promising, and the system seemed to be functioning as expected.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Fabricated Test Body&lt;/strong&gt;: Created a basic structure to test the center of balance. Using some basic materials, I built a test frame to see how well the robot could balance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Another Setback&lt;/strong&gt;: Fried a stepper motor driver this time. Ordered a replacement. This was another frustrating moment, but I didn't let it stop me.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Final Stretch
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Replaced Driver&lt;/strong&gt;: Installed the new motor driver. Once the replacement arrived, I also edited the circuit to add a voltage regulator to save prevent any over voltage.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;PID Calculations&lt;/strong&gt;: Spent a lot of time tweaking the PID settings. The Proportional-Integral-Derivative (PID) controller settings are crucial for maintaining balance, and getting them right was a matter of trial and error.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Persistent Testing&lt;/strong&gt;: Kept trying different setups until something finally clicked. I spent hours testing and adjusting, fine-tuning every aspect of the robot's behavior.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;It Worked&lt;/strong&gt;: After countless attempts and adjustments, it finally worked! Seeing the robot balance on its own was incredibly satisfying and made all the effort worth it.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Images and Videos
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Circuit Design:&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv20h199rams0spwmqff9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv20h199rams0spwmqff9.png" alt="Image description" width="652" height="475"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Soldering after a lot of iterations:&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fntrirropxfmegsauket0.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fntrirropxfmegsauket0.jpg" alt="Image description" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Body V1:&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8idfg7qoz2ukg66pmfqg.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8idfg7qoz2ukg66pmfqg.jpg" alt="Image description" width="800" height="861"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Body V2:&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2re5yk08r0ucf0zqj5uw.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2re5yk08r0ucf0zqj5uw.jpg" alt="Image description" width="800" height="978"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Body V3:&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdoorgcj3l5m8ehhys3bl.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdoorgcj3l5m8ehhys3bl.jpg" alt="Image description" width="800" height="1066"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Video: &lt;a href="https://drive.google.com/file/d/1GdOsqWXg5Akq5dRpMptgbY3xugZVGxlV/view?usp=drive_link" rel="noopener noreferrer"&gt;Google Drive Link&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Lessons Learned
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Never Give Up&lt;/strong&gt;: Persistence pays off. Even when things go wrong, keep pushing forward. Every setback is a learning opportunity, and determination is key to overcoming obstacles.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;How to Solder&lt;/strong&gt;: Gained a new skill that's pretty handy. Soldering is essential for many electronics projects, and getting good at it can open up a lot of possibilities.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Robotics&lt;/strong&gt;: Got a crash course in robotics and mechanical engineering. Building the robot gave me a deeper understanding of the principles behind robotics, including kinematics and dynamics.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Embedded C&lt;/strong&gt;: Improved my programming skills in a new language. &lt;br&gt;
Writing code for embedded systems is different from web development, and it broadened my programming horizons.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;New Outlook on Life&lt;/strong&gt;: This project taught me that stepping out of your comfort zone can lead to incredible growth and learning. Embracing challenges and tackling unfamiliar problems can be incredibly rewarding.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
    </item>
  </channel>
</rss>
