Top Banner
Mechatronics Laboratory ENGR 3390U Lab # 4 Open-Loop Control of a DC Motor System Surname Name Student Number Signature Edu, Rose 100503517 Fracz, Melissa 100487042 Lalwani, Karan 100432341
20
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript

Mechatronics LaboratoryENGR 3390ULab # 4

Open-Loop Control of a DC Motor System

Surname NameStudent NumberSignature

Edu, Rose

100503517

Fracz, Melissa

100487042

Lalwani, Karan

100432341

Omole, Olutope

100457114

Table of Contents

Executive Summary3Project Definition3Requirements3Engineering Specifications3Concept Generation3Test Plan6Discussion and Analysis8Conclusions9References9Appendix9

Executive Summary This mini project entailed programming a microcontroller DC motor system in an open loop control. The project was about demonstrating an experiment that required the movement of a cart mounted on a rack and pinion from one of the racks end to the other end in a specified manner, timing and order as will be explained further in the report. The code used in performing this tasks was generated by the students and was designed so that all the tasks were carried out by the same code. The project definition and engineering specifications as well as the test plan and concept generated while working on the project will be further discussed in the report.

Project Definition The main objective of this lab is to learn how to control a DC motor in an open loop by programming a microcontroller. The microcontroller is an integrated circuit that is made up of a small central processing unit as well as input and output ports. In this lab, we used a HC (12) commercial microcontroller made by Freescale. Also this lab would enable the understanding and demonstration of programming an IR sensor to prevent the cart from going beyond its limit of travel. The basic task of this project was to move the cart from one end to the other with two different types of delays on both sides. The cart was to come to a complete stop after completion of 4 rounds. The coding in this lab requires the use of CodeWarrior CW12 as that is where all coding would be done. The following is a list of hardware to be used for the mini project:1) Custom Built Bi-directional motor speed controller (3959 Motor Control IC)

2) Freescale (formerly Motorola) HC(S) 12 Microcontroller Board (MC68EVB912DP256) with Microcontroller Chip MC9S12DP256BCPV 3) USB Interface and Cable 4) Custom Built Cart System: Pinion: SI Precision Component S1086Z-024DS024 Rack: WM Berg R4-5 or R4-6 Motor: MicroMo 2224U012SR with Gearbox Series 23/1 (3.71:1 Reduction) and Encoder IE2-512 5) Omron IR Sensors (2X)

6) Custom Built Power Conditioning Circuit with Power Supply

Fig 1: Custom built cart System

Fig 2: Mechatronics board with microcontroller, USB interface, power supply and motor controllerFig 3 : IR sensor

Requirements

This lab requires two program codes to be made. The first part must stop the cart in motion, by having the IR sensor detect and be triggered, by programming the HC(S)12 microcontroller. The second part builds off of this first program code. The cart must be able to move in two directions and stop. Its required to start in the middle and go right, once hitting the IR sensor the cart must stop for 5 seconds. The cart then must move to the left side of the track at a constant speed and once again, stop once reaching the IR sensor, but for 10 seconds on this side of the track. This cart must make a total of four round trips of this track, doing the same stop and go motions as stated before.

Engineering Specifications The signals from PB0 and PP0, which are present on the HC(S) 12 microcontroller, control the DC motor and the TTL signal sent out from the Digital Output port PB0 controls the direction of the motor rotation. The PP0 port controls the Pulse Width Modulation (PWM) signal, which in turn controls the speed of the motor. For the DC system,1. A low TTL signal, containing a value of 0 moves the cart from right to left. 2. A high TTL signal, containing a value of 1 moves the cart from left to right.

Switching these values through digital output port PB0, will change the direction of the motor, and therefore it could be controlled accordingly. For the PWM motor speed control, the actual speed of the motor is determined by the Duty Cycle (sometimes expressed in %, or, in CodeWarrior expressed either as a number from 0 to 255, or as a combination of two numbers in milliseconds). In the case of the hardware in this lab, the lower the value the duty cycle, the higher the speed the motor rotates. A duty cycle of 0% results in full motor angular speed, while a 100% duty cycle results in the zero motor speed. On each end of the cart system, two sets of IR Sensors (Figure 4), are used to control the travelling bounds of the cart. Port A2 controls the left IR Sensors output, while PORT A3 controls the right IR Sensors output.

Concept Generation

Flow Chart

Pseudo CodePart 1 Send a low TTL signal for cart to move in a certain direction (left and right) Duty Cycle controls the carts speed If the signal sent is of 0 Volts to completely stop the cart

Part 2 Send a High TTLsignal to move in a direction (left and right) Duty Cycle controls the cart speed PA3 send a low TTL signal of 0 volts to stop the cart Cart will stop for 5 seconds (sends a low TTL signal from PA3) Low TTL signal sent to move the cart in a reverse direction (right to left) Duty Cyle moves the cart at a moderate speed PA2 sends a low TTL signal of zero to stop the cart Cart will stop for 10 seconds (continues to send a low signal from PA2) TTL high signal sent to move the cart in the opposite direction (left to right) Duty Cycle moves the cart at a moderate speed PA3 send a Low TTL signal of 0 Volts used to stop the cart Cart will stop for 5 seconds (continue to send a low signal from PA3)

Set up of program to equipment

Test Plan

We first started by figuring out how the track and sensors run, which are controlled by the codes in the program. We know there will be two outputs values, one which controls the motor direction and one which controls the motor speed. When something goes between the two slots of the IR sensor, it will be triggered, if not a high signal will be sent. The PBO port controls the direction of the cart, while the PPO controls the location by the PWM channel. The IR sensors are on PA2 and PA3. When sending a 0 to the PBO the cart will change directions and go from right to left. When sending a 1 to the PBO the cart will change directions to go from left to right. In order to figure out the period the cart was tested at different frequencies. If it was to high there would be a humming noise from the motor and if it was too low the motor speed wont speed up. The best frequency ended up being between 1-2 KHz. The period was calculated by:

This also allowed the starting pulse to be determined by the following calculation:

To set up the code three Bits were used and one PWM. Bit 1 and Bit 2 are both inputs which controls the Left and right IR sensors at PA2 and PA3 respectively. Bit 3 was an output controlling the PBO. Since Bit 1 controls the input, the Get Val function was used as seen below and setting it to zero makes the IR sensor trigger shown below:Bit1_GetVal() == 0The same function was used to for Bit 2, the other IR sensor:Bit2_GetVal() == 0Since Bit 3 control the output, and will be the direction of the cart Put Val ( ) was used. 0 was used to move the cart from the right to left, outputting a low value signal. Bit3_PutVal(0)1 was used to make to cart go from left to right, outputting a high signal. Bit3_PutVal(1)PWM was the other output, controlling the speed of the cart, using SetRatio8, where the speeds are defined by 0-255, 0 being full speed and 255 being a complete stop. In order to make the cart fully stop the following was used:PWM8_SetRatio8(255)The cart was never needed at full speed, but in order for the cart to move, some speed is needed. A middle speed was used in order to move the cart along the track:PWM8_SetRatio8(180)Once the cart is stopped, we must set the time for the cart to stop on each side. We had to test the cart and the delay to find the closest time to get to 5 seconds and 10 seconds. For the right side we use the following, which stops the cart from moving for 5 seconds:for (i=0; i < 200000; i++) For the left side we used a different time, in order to keep the cart from moving for 10 seconds:for (i=0; i < 500000; i++)In order for this to continuously run, but for 4 round trips only, the code must be within a while loop and have set criteria to do so. Since 4 loops will mean the cart will trigger the IR sensors for a total of 9 times, we used the following:while (x