Team 5: DEATH Software Design Overview
Software Path Main/Startup Function –Initialize Peripherals –Setup RTI to call main program loop –Put processor to sleep until RTI fires
Main Program State Machine Based RTI based (not dependent on accurate timing) Main Program GuidancePIDSonarNetworking GPSWaypoint ReadATD Rotate Servo OpenTCP
Software Areas Guidance PID Sonar Network
Guidance Provides target for PID routine Communicate with GPS using SiRFBinary protocol Handles FIFO Waypoint queue
PID Control Proportional – Integral – Derivative Most Complex Branch Three complementary control schemes
Proportional Control Correction for set level to set point Correction factor is proportional to the error (Δ) Not accurate, results in an error offset.
Integral control Accounts for process deviation Measures ∫(Δ) over time, and corrects –∫(Δ) → 0 “Straight line over time”
Derivative control Measures how fast error is accumulating –dΔ/dt Fast error → Fast (large magnituge) correction Quick response to growing error
PID, all together now… Source: Programmable Logic Controllers, Fourth Edition, Prentice Hall PTR by John W. Webb Ronald A. Reis Accessed: webmain/D211223AE3DE7E F62F?OpenDocument
Software mechanism Read process Value (read ATD) Determine Proportional correction Update and determine integral correction Determine Derivative correction Calculate final correction Update drive Motor PWM
Pseudocode SetPoint = …// Desired process output IntegralState = 0; IntegralMax = …; IntegralMin = … // Keep track of accumulated error DerivState = 0// Keep track of derivative PGain = …; IGain = …; DGain = … // Tuning parameters PID( ) SetLevel = ReadATD(); Error = SetPoint – SetLevel Proporional= Error * PGain// Set proportional term IntegralState = IntegralState + Error // Set integral term, correct if outside bounds If( IntegralState > IntegralMax) Then IntegralState = IntegralMax Elsif( IntegralState < IntegralMin ) Then IntegralState = IntegralMin Integral = IntegralState * IGain Derivative= ( SetLevel – DerivState ) * DGain // Set derivative term DerivState = SetLevel SetPoint = Proportional + Integral – Derivative // Set new process output End PID
Sonar Sends out pulse and times with timer module Pulse code 100% ASM If obstacle found, moves into obstacle avoidance state Can rotate sonar via servo to track object while avoiding
Networking Connectionless UDP protocol to simplify coding Query/Command based protocol Common commands include New Waypoint, Start Moving, Get Location, Rotate Turret, and Fire. Video handled externally with network camera on same network
Basic States IDLE: Wait for coordinates WAIT: Accept new coordinates and wait for go MOVE: Go to coordinates in order AVOID: Obstacle avoidance
Obstacle Avoidance Substates Scan Left Scan Right Turn Tank Turn Servo Toward Waypoint Move Check Obstacle