Controlled balance car with FPGA

Implement a self balancing robot on an FPGA. Dive into system Verilog PIDs, SPI protocols and PWM controllers to self balance a two wheeled device.

The Segway is an unstable and non-linear electromechanical system.
In this project we implement a self balancing robot on an FPGA. We dive into system verilog PIDs, SPI protocols and PWM controllers to self balance a two wheeled device.

The design is based on 5 main blocks:
1. A gyro measures the robot angle
2. An Arduino reads angle and passes raw data to FPGA over SPI protocol. This is only used to translate I2C protocol to SPI protocol.
3. An FPGA is SPI slave, reads angle, calculates error and PID output, calculates PWN signal and output
4. A Motor driver gets a signal from the FPGA and passes to the motors
5. The Motors change robot angle
6. The Gyro reads new angle

The main difficulty in the project, after implementing and testing all the blocks, was jitter in the thin wires.
In order to overcome this issue, we implemented a low pass filter within the FPGA, to read the gyro measurements coming from the Arduino and remove any noise. This was possible because the Arduino works on a much lower frequency than the FPGA.

The results were promising, our robot balanced on two wheels and was robust to outside interference such as wind or event gentle taps from different directions.

In the future, we would recommend replacing the gyro with one that supports the SPI protocol and thus remove the Arduino and hopefully reduce the noise in the system.
In addition, we implemented an extra input to the PID which allows the user to input a desired angle for the robot, and thus make it drive, for this to work we just need to connect it to an input line from the FPGA.

 

 

Project Video