PIC Motor Control and Serial Port Example

From Mech
Revision as of 05:07, 31 August 2007 by Hwang (talk | contribs)
Jump to navigationJump to search

Introduction

In this application, we will use a PIC 18F4431 microcontroller to implement a closed-loop lead-lag compensator that controls the velocity of a motor with an encoder. This example will cover the use of:

  • interrupts
  • reading encoders
  • pulse-width modulation
  • USART (Universal Synchronous Asynchronous Receiver/Transmitter)

Every 20 milli-seconds, the PIC will sample the encoder and run the feedback control loop. The output from the control loop is then sent to the motor to try to match the motor's speed with the target speed. To set the target speed, commands are sent from a PC's serial port to the USART on the PIC. The PIC will also print the target speed and actual speed of the motor to the terminal window of the PC.

Project Files

Wiring Diagram

Breadboard Layout

HyperTerminal