Code Monkey home page Code Monkey logo

pid-fpga's Introduction

PID-FPGA

PID controller on an FPGA with custom RS232 addressing protocol.

alt text

To capture the motor's precise behavior, data sampling speed is synchronized with the TX module. But unfortunately, most of the serial port terminal programs, including Terminal v1.9b by Br@y++ and Termite, failed to keep up with this speed. HTerm was the only one I found that operated with no problems.

Communication Protocol

RS232:

  • Data Bits: 8
  • Stop Bits: 1
  • Parity: None
  • Baud Rate 115200

The instructions are 64-bit. The first and the last 8 bits are must be AA and BB, respectively, to ensure package integrity.
|AA|8bit address|4 bit useless|36Bit data|BB| The Numbers are fixed point 36 bit signed |1bit|26bit|9bit|

  • Accessing to address zero sets the global reset to one.
  • Address one is KP
  • Address two is KD
  • Address three is KI
  • Accessing to other addresses sets the global reset to zero.
    Examples:
    AA00xxxxxxxxxxBB // reset = 1
    AA010000000500BB // KP = 2.5
    AA020000000500BB // KD = 2.5
    AA030000000500BB // KI = 2.5
    AA0D000000FFFFBB // reset = 0

Hardware

  • Altera DE2 FPGA: EP2C35F672C6
  • DC Motor: (unknown)
  • Encoder: ARC S 050
  • Motor Driver: Custom
    alt text

Verification of The Design

  • Quartus project is verified by testbenches.
  • Overall project verified by oscilloscope measurements of the frequency of the encoder signals. The motor speed is 14.15708 RPS (7078.54/500). Which is quite close to the desired speed: 14 RPS.
    alt text
  • Motor's response to disturbances under PID control:
    alt text
    Sudden up and down jumps that created the white halo effect are not measurement errors. A misaligned encoder and motor shaft created them. If you zoom in on the plot on MATLAB, you can see that it is, in fact, a sinusoidal signal.

Possible Design Improvements and Current Flaws

  • Rotatory Encoder creates 500 pulses for every rotation. But, the calculations are done by dividing the pulse count by 512 in order to avoid a separate division circuit.
  • There is a bug in the multiplication circuit. The numbers are ~0.8% off.
  • In my hardware setup, the DC motor and the Encoder are connected via a custom imperfect shaft that causes a sinusoidal noise on the speed values.
  • After the final debugging, I forgot to change the source of the desired speed from switches to RS232. So, you have to enter the desired speed from switches.
  • Current KP, KD, and KI values are quite low. It takes a couple of seconds for the motor to reach its final value.
  • There is no integral windup protection.
  • I am a sophomore student with no Control background, so this is the best I can do in a week.

pid-fpga's People

Contributors

hakan-demirli avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.