Skip to content

Digital Control Systems Laboratory Projects at University of Tehran

Notifications You must be signed in to change notification settings

Farbod-Siahkali/Digital-Control-Lab-S2-G5

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Digital Control Lab

This repository contains the source code and documentation for a lab project on digital control. The project involves an STM32 microcontroller and a DC motor.

Sessions

Session 1

In Session 1, we wrote a simple program to toggle the state of an LED on the STM32 board. Additionally, we set up an external interrupt on pin PB3 to change the blinking rate of the LED.

Session 2 - Phase 1

During this session, we continued working with external interrupts and timers. We configured an interrupt on pin PB3 to start and stop a timer. We also set up another timer to generate an interrupt at a fixed frequency.

Session 2 - Phase 2

In the second phase of Session 2, we made modifications to the code to use a different GPIO pin and timer for generating the interrupt.

Session 3

Session 3 focused on controlling the speed and direction of a DC motor using pulse-width modulation (PWM) and quadrature encoders. We implemented techniques to measure the speed and position of the motor.

Session 4

In Session 4, we utilized the step response of the motor to determine the motor's parameters (k and tau) using a method called "system identification."

Session 5 - Control of DC Motor

In the fifth session, we worked on controlling a DC motor using digital techniques. We used an STM32 microcontroller and implemented a digital control algorithm to regulate the motor's speed. The algorithm involved proportional-integral (PI) control with a setpoint of 700 RPM. We calculated the control output based on the error between the setpoint and the actual motor speed, and adjusted the motor's direction and PWM signal accordingly. The control algorithm was executed at a sampling time of 7.62 ms. The code for this session can be found in the main.c file.

Wiring

The DC motor was connected to the STM32 microcontroller as follows:

  • Connect the motor's positive terminal to the STM32's PWM output pin (TIM11 Channel 1).
  • Connect the motor's negative terminal to the GND pin of the STM32.
  • Connect the direction control pin (pin PB4) of the STM32 to the motor's direction control pin.
  • Connect the A signal pin (pin PE6) of the STM32 to the motor's quadrature encoder A signal pin.
  • Connect the encoder's common ground to the GND pin of the STM32.

Oscilloscope Picture

Oscilloscope Picture

Please refer to the picture above to see the oscilloscope waveform captured during the DC motor control process.

Contributors

  • Saba Samadi
  • Navid Dehban

About

Digital Control Systems Laboratory Projects at University of Tehran

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages