πŸ“ Project Overview

πŸš€ Project Name

PID is All You Need: Cart Pole System Design and Control with NMPC and PID

πŸ—“ Project Duration

2024.07.25 - 2024.09.27

πŸ’Ό Competition

People's Choise Award, UOS ECE IF (Innovation Fair) Competition (Prize Money $200)

πŸ§‘β€πŸ€β€πŸ§‘ Team Member and Role

  • Sewon Kim

πŸŽ₯ Demonstation

Simulation Result

Cart Pole Simulation

Physical Result


Poster

Cart Pole Poster

πŸ’Ό Competition

  • Target participants: Undergraduate students in the Department of Electrical and Computer Engineering
  • Exhibition of project outcomes developed through the application of major coursework knowledge and personal initiative
  • Only projects created by undergraduate students using their knowledge and efforts are eligible for submission
  • Material costs of up to 500,000 KRW per team are covered (personal expenses are not permitted)

🎯 Introduction

I made a physical Cart-Pole (Inverted Pendulum) system with just 272 USD and applied nonlinear model predictive control (in simulation) as well as PID control (on the physical system)!

The Cart-Pole, a classic benchmark problem in control, consists of a cart driven by a linear actuator and a pole attached via an unactuated joint. If the pole is positioned vertically, its dynamics predict it will fall due to instability. The goal of the controller is to swing the pole up and balance it above the cart. The model and controller of the inverted pendulum are foundational for many systems, including humanoid robots and SpaceX's Starship.

The process of my project can be divided into the following steps:
  1. Mechanical Design: 3D modeling using Fusion 360 to design the physical structure of the system
  2. Electronics: Select specifications for sensors, actuators, processors, and other components
  3. Motor Control: Acceleration-based control of the stepper motor
  4. Hardware Fabrication
  5. Feedback (Closed) Loop: Measure real-time defined states through actuators and sensors, or estimate them using a state observer
  6. Simulation Environment: Set up a simulation environment in Python to validate control strategies for the Cart-Pole system
  7. Control: Formulate mathematical models and optimization problems for Model Predictive Control (MPC)
  8. Experiment: Tune parameters

I won the Popular Prize at the UOS ECE Innovation Fair and presented my project to the Department of Mathematics, thanks to Professor Dohyeon Kwon’s invitation, focusing on differential equations and mathematical optimization. I received valuable advice from undergraduate students in mechanical, electrical, and computer engineering. All of it was truly enjoyable.

LinkedIn Post

πŸ’‘ Development

Electronics

- Stepper Motor: 27,000 KRW ($18.25 USD)
- Stepper Motor Driver: 25,000 KRW ($16.91 USD)
- Absolute Rotary Encoder: 75,000 KRW ($50.75 USD)
- Photo Interrupter Sensor (x2): 600 KRW ($0.41 USD)
- Raspberry Pi Pico 1: 6,400 KRW ($4.32 USD)
- Cedar Wooden Plank: 28,000 KRW ($18.96 USD)
- Wooden Rod: 2,800 KRW ($1.89 USD)
- Linear Guide: 45,913 KRW ($30.97 USD)
- Shaft Holder: 7,260 KRW ($4.91 USD)
- Timing Pulley: 1,500 KRW ($1.01 USD)
- Timing Idler: 900 KRW ($0.61 USD)
- Timing Belt: 1,412 KRW ($0.95 USD)
- Sheet Metal (Aluminum): 130,000 KRW ($87.81 USD)
- Wires, screws, and other consumables: 50,000 KRW ($33.84 USD)
Total: 401,785 won (271.66 USD)

- mass of cart : 0.123 kg (122.61g)
- length of cart : 0.045m (4.5cm)
- mass of pole : 0.089 kg (88.68g)
- length of pole : 0.4m (40cm)
- inertia of pole : 0.004 746 kg m^2
- length of rail (linear guide) : 0.72m (72cm)
- maximum magnitude of force : 1.2 N

Motor Controller, State Observer, and MPC

Motor Controller and State Observer
Non-Linear Model Predictive Control

⛰️ Reference

Nonlinear Model Predictive Control of an Inverted Pendulum

πŸ“· Photos

prize

✨ Feeling to Project

  1. ν”„λ‘œμ νŠΈλ₯Ό μ§„ν–‰ν•˜λ©΄ λ‚˜λŠ” 항상 μ†Œν”„νŠΈμ›¨μ–΄ 파트λ₯Ό λ§‘μ•˜λ‹€. ν”„λ‘œμ νŠΈλ₯Ό 많이 할지라도 ν•˜λ“œμ›¨μ–΄μ— λŒ›ν•œ 지식은 진전을 이루지 λͺ»ν–ˆλ‹€. 이번 기회λ₯Ό 톡해 ν•˜λ“œμ›¨μ–΄μ— λŒ€ν•œ 두렀움을 κ·Ήλ³΅γ…Žν•˜κ³  전문성을 κ°–μΆ”κ³  μ‹Άμ—ˆλ‹€.
  2. λ§Žμ€ ν”„λ‘œμ νŠΈλ₯Ό ν•˜λ”λΌλ„ 뢄업을 ν•˜κΈ° λ•Œλ¬Έμ— ν”„λ‘œμ νŠΈμ˜ 큰 λ°©ν–₯성을 이해함과 λ™μ‹œμ— 세뢀적인 κ²ƒκΉŒμ§€ λͺ― νŒŒμ•…ν•˜κΈ°λž€ μ–΄λ €μ› λ‹€. AλΆ€ν„° ZκΉŒμ§€ λ‚΄κ°€ μ£Όλ„ν•˜λŠ” γ…ν”„λ‘œμ νŠΈμ— λŒ€ν•œ κ°ˆλ“±μ΄ μžˆμ—ˆλ‹€.
  3. 이둠으둜만 μ•Œκ³  μžˆλŠ” MPC controller와 RL controllerλ₯Ό 직접 κ΅¬ν˜„ν•˜κ³  μ μš©ν•΄λ³΄κ³  μ‹Άμ—ˆλ‹€.
  4. 4등을 ν•΄μ„œ 인기상을 μˆ˜μƒν–ˆλ‹€. κ΅μˆ˜λ“€μ˜ 평가에 μ˜ν•΄ κ²°μ •λ˜λŠ” 1~3λ“±κ³Ό 달리, 인기상은 ν•™μƒλ“€μ˜ νˆ¬ν‘œμ— μ˜ν•΄ κ²°μ •λ˜μ—ˆλ‹€. κ΅μˆ˜λ“€μ˜ 평가 κΈ°μ€€μ—λŠ” λ“€μ§€ λͺ»ν–ˆλ˜ 것 κ°™λ‹€. 두 κ°€μ§€ λΆ€λΆ„μ—μ„œ λΆ€μ‘±ν–ˆλ˜ 것이라 μ˜ˆμƒν•œλ‹€. 첫 λ²ˆμ§ΈλŠ” μ „μ „μ»΄μ—μ„œ λ‹€λ£¨λŠ” λ²”μœ„λ₯Ό λ²—μ–΄λ‚œ 것듀을 ν¬ν•¨ν•˜κ³  μžˆμ—ˆλ‹€. 두 λ²ˆμ§ΈλŠ” ν•™λΆ€ μˆ˜μ€€μ„ λ²—μ–΄λ‚˜λŠ” λ‚΄μš©λ“€μ΄ λ§Žμ•˜λ‹€. λ‚˜λ¦„ λ‚˜μ˜ 결과와 λ°œν‘œκ°€ μ€€μˆ˜ν–ˆμŒμ—λ„ 이 λΆ€λΆ„μ—μ„œ λ‹€λ₯Έ νŒ€μ—κ²Œ λ°€λ Έλ˜ 것이라 μƒκ°ν•œλ‹€. μΉœκ΅¬λ“€μ€ κ°κ΄€μ μœΌλ‘œ κ°€μž₯ μš°μˆ˜ν–ˆμœΌλ©° λ§Žμ€ μ‚¬λžŒλ“€μ΄ 관심을 κ°€μ‘Œλ‹€κ³  ν–ˆλ‹€. 개인적으둜 1등을 ν•˜μ§€ λͺ»ν•œ 것이 μ–΅μšΈν–ˆλ‹€.
  5. ν•˜μ§€λ§Œ λ‚΄ λΆ€μŠ€κ°€ κ°€μž₯ λ§Žμ€ μ‚¬λžŒλ“€μ΄ λͺ°λ Έμ„ 만큼 λ§Žμ€ μ‚¬λžŒλ“€μ΄ λ°©λ¬Έν•΄μ£Όμ—ˆλ‹€. μΉœκ΅¬κ°€ λ§ν•˜κΈΈ λ‚˜λ₯Ό μ€‘μ‹¬μœΌλ‘œ λͺ¨λ“  사라ㅏㅁ듀이 λͺ°λ €λ“€μ—ˆλ‹€κ³  ν•œλ‹€. 이런 λŒ€νšŒμ—μ„œ μ€‘μš”ν•œ μš”μ†Œ 쀑 ν•˜λ‚˜κ°€ μ‹œκ°μ μœΌλ‘œ 자극적인 κ±Έ ν•˜λŠ” 것이닀. μ λ‹Ήνžˆ 이 μ •λ„λŠ” λ˜κ² μ§€λΌκ³  μƒκ°ν•˜λŠ” 것 μ΄μƒμœΌλ‘œ 자극적일수둝 μ’‹λ‹€.
  6. μ‹œμ—°ν•˜λŠ” κ³Όμ •μ—μ„œ μ„Έκ²Œ μΉ˜λŠ” μ‚¬λžŒμ΄ λ§Žμ•˜λ‹€. λ‚˜λŠ” ꡉμž₯히 κΈ΄ 길이의 λ§‰λŒ€λ₯Ό μ‚¬μš©ν–ˆκΈ° λ•Œλ¬Έμ— μ‚΄μ§λ§Œ 쳐도 λ§‰λŒ€μ˜ μ€‘μ‹¬μΆ•μ—λŠ” 큰 κ΄€μ„±λ ₯이 μž‘μš©ν•˜κ²Œ λ˜μ–΄ λ„˜μ–΄μ§ˆ μˆ˜λ°–μ— μ—†λ‹€. plz don’t touch.
  7. 첫 ν¬μŠ€ν„° λ°œν‘œμ˜€λ‹€. λ‹€λ₯Έ λ‚΄μš©μ€ λ‹€μ†Œ λΆ€μ‘±ν–ˆμ„μ§€λΌλ„ β€œPID is all you need” 제λͺ© ν•˜λ‚˜λŠ” λ„ˆλ¬΄ λ§ˆμŒμ— λ“ λ‹€.