ME375 Lab Project Bradley Boane & Jeremy Bourque April 25, 2018
Introduction: The goal of this project was to build and program a two-wheel robot that travels forward in a straight line for a distance of 74+ inches, and then backwards in a straight line for approximately 37 inches. All movement must be completed within 30 seconds and done autonomously. To accomplish this task, a Sheepdog robot kit was used to build the robot, and the myrio device was used to control it. In order for the robot to be fully autonomous and move in a straight line, a closed-loop control with sensor feedback is utilized in LabView. The project code utilizes the Robot FPGA utility assign VI, Velocity Control Loop VI, PI Controller VI and the scaling sub-vi to accomplish the task. The PI controller was designed and implemented for the left and right motor and for forward and backward movements. A PI controller was designed through open-loop identification, verification through speed references graphs, and manual adjustment of controller gains to improve performance by reducing steady-state error and improving settling time. Once the PI controller was designed, testing was performed in order optimize the performance of the robot. Robot Configuration: Figure 1: Final Robot Configuration The Sheepdog robot (shown in Figure 1) consists of a plastic robot chassis, two wheels that are driven by motors, one caster slider, two hall-effect encoders, a motor driver circuit, the myrio used to control the robot hardware, and a lead acid 12V battery which powers the robot. The wheels of the sheepdog robot are driven by two geared brush DC motors. The one caster slider is
attached to the chassis of the robot for additional stability and mobility. The myrio device alone is not capable of supplying enough power to drive the motors with an analog output signal so an H-bridge circuit, a digital direction signal from the myrio, a digital PWM signal from the myrio, and a 12V battery are used to distribute power to the motor. A PWM signal input can adjust the motor speed by using an H-bridge and the modulated digital output channels of the myrio. The myrio s digital output is limited to +5V so the H-bridge and an external power supply is needed to allow the motor to be driven in either direction and for a wider range of speeds. The motor driver circuit which consists of the external power supply, the L298N Motor Driver Board with the H-bridge (Figure 3), and the circuit protection PCB guide (Figure 2) can be seen below in Figure 4. The Circuit Protection PCB guide protects the circuitry from being damaged due to a short circuit or overload conditions. Figure 2: Circuit Protection PCB Guide Figure 3: L298N Motor Driver Board
Figure 4: Schematic of the Motor Driver Circuit As seen in Figure 4 above, the L298N Motor Driver Board gains input power from the 12V battery and the myrio device, and outputs the power to both of the motors in order to power the robot. The H-bridge functions as a series of switches that allows current to flow through in different polarities. The direction switches are controlled by the digital direction signal from the myrio, and the speed of the motor is controlled by the digital PWM signal from the myrio. Through the H-bridge circuit, the direction and speed of the motors can be controlled with the digital outputs of the myrio. The two hall-effect sensors and magnetic discs on the motors are used to read the position and velocity of the sheepdog robot. As seen in Figure 5 below, the encoder consists of a magnetic disk and a hall-effect sensor that reads the changes in polarity of the disc s magnetic field as the motor runs. Figure 5: Hall-Effect Sensor The hall-effect sensor is placed close to the magnetic disc so that it can sense the magnetic field of the disk switching between north and south polarity. As the motor rotates, the sensor will read the changing polarity of the magnetic field as a square wave changing from 0V to 5V which the myrio can track. The myrio is able to track every transition from 0V to 5V which enables it to read the position and speed of the motors.
Controller Design: For controller design, we thought that a PI controller would be best for this application. This is because PI controllers are useful in feedback based applications. The general form of this controller is provided below in Figure 6 (right). The plant function, also provided (left), was found by taking the dynamic response of the robot s two motors. Because we tested both wheels going forwards and backwards, this led to four different plant transfer functions. Together, these equations result in four unique controllers differentiated by their gains, Kp and Ki. Figure 6: PI Controller & Measured Motor Transfer Function Forms Controller design methods such as pole placement and root locus design were attempted, but did not completely ensure that the robot goes straight. Instead, an iterative testing process was mainly used to solve for the Kp and Ki gains of the controller. Figure 7 below shows the front panel used to experimentally try different gain values. It seems that one of the motors was stronger than the other, as one of the gains turned out to be much larger. Figure 7: Example Kp and Ki Testing Code Description: The LabView project code utilizes three main VIs and one sub-vi in order to control the robot. The first needed in the project is the Robot FPGA utility assign VI. This VI communicates with the myrio to complete the feedback loop. The next VI we created was the main Velocity
Control Loop VI. This VI contains the main controls behind the robot. It accepts the desired speeds, traveling distance, and controller gains for both the forward and backwards motion. Figure 8 shows the main part of this VI, along with the FPGA reference code that calls the FPGA utility assign VI. There is also another identical control and simulation loop next to this one, but with logic for moving backwards instead of forwards. The FPGA I/O layer interacts with the start loop, the Motor Control, and the Encoders as seen below in Figure 8. The start loop initializes the duty cycle to zero and initializes the left and right encoder period to a large number (40000000) in order to get an initial velocity of 0. This then leads to the Motor Control, where the robot direction is controlled, and then the encoders so the speed and position of the robot can be tracked. The last interaction is stopping the robot, where the duty cycle is set back to zero. Figure 8: Part of Velocity Control Loop The controllers located in this VI are a subsystem created from the PI controller VI. These controllers have four inputs, the desired speed, measured speed, Ki gain, and Kp gain. The controller subsystem then outputs a PWM signal that results in straight motion of the robot. The PI controller logic is shown in Figure 9 below.
Figure 9: PI Controller Subsystem VI The last VI used in this project was a sub-vi dedicated to converting the encoder period and position into a wheel speed and wheel position, respectively. The code uses simple unit conversions and is shown below in Figure 10. The code also takes the sign of the velocity into account to show both positive and negative velocities. It also still works given an infinite velocity, in case something goes wrong in the program. Figure 10: Encoder Count Conversion The desired speeds were applied to the closed-loop systems by using a step signal with a rate limiter. This acts as a ramp input, but with a little more flexibility on what you can change. Having a ramp signal input is very important in getting the robot to move in a straight path. It was very important to ensure that our program worked autonomously. This was completed by using two control and simulation loops back to back. The first loop was run until the desired forward distance was traveled. Once that loop has been halted, the backwards loop begins immediately after. That loop ends once the desired backwards distance is reached and then also stops the entire program.
Discussion: The robot performed well after numerous manual adjustments were made to the gains of the PI controllers implemented in the Velocity Control Loop VI. In order to improve steady-state error, the controller gains were slowly adjusted while the robot was running stably at steady-state speeds. To improve performance, desired vs. measured speed charts were utilized for both the left and right motors to capture the effectiveness of the controller gains. The manual adjustments to the gains of the controller led to the robot moving forward and backwards in a relatively straight line. Due to the significant friction in the gearbox and minimal steady-state error, the robot did not perform as well as expected. Although the adjustments to the controller improved the performance, the robot still could not consistently move forward and backwards in a perfectly straight line.