ECET 365 Week 1 Lab DeVry


Just Click on Below Link To Download This Course:
https://bit.ly/2JGyCDT

ECET 365 Week 1 Lab DeVry

Lab 1: Programming for Stepper Motors, DC Motors, and Servos Using an H-bridge
Objectives
  1. Develop software routines that control Stepper Motors, small permanent magnet DC motors, and Servos.
  2. Understand how an H-bridge can be used to control DC motors and Stepper Motors.
Parts List
  1. Smart Car Kit or Other Provided Kit (e.g. robotics kit, supplementary parts kit)
  2. Freescale Tower Kit with S12G128 CPU board or Other Provided CPU Board
  3. PC with IDE software (e.g. CodeWarrior Development Studio V5.1)
Introduction
  1. DC motors are used in the Smart Car Kit. Also used are a servo and H-Bridge. Stepper motors may be used in the Robotics Kit. The Supplementary Parts Kit may have a stepper motor.
  2. This lab explores the techniques used to interface to these devices and also how to program and control them.
Deliverables
Answer all questions in Week 1 Lab Cover Sheet here (Links to an external site.)Links to an external site..
Submit your Week 1 Lab Assignment.
You can also download the cover sheet for Week 1 Lab in the Files section of the Course Menu.
Required Software
CodeWarrior Development Studio for S12(x) V5.1
Lab Steps
STEP 1: Procedures
  1. Determine if your motor is a DC motor or a stepper motor. (Hint: DC motors are powered with two wires. Stepper motors may have four or more wires. DC motors will begin running when DC voltage is applied. Stepper motors will not run unless several pulse trains are applied. Go to the appropriate procedures below.
  2. Procedures for DC Motors
    1. Develop an interface from the CPU board to the motor.
      1. Choose a Port on the CPU board. Only one bit is required. If an H-bridge is available, connect the appropriate bit from the chosen Port to the appropriate input to the H-bridge. The double H-bridges that come with the Smart Car Kit require 4 input bits. Consult the Week 2 Lecture for ways to operate the H-bridge.
      2. If you don’t have an H-bridge, you may have to use a transistor, relay, or optical isolator to build an interface between the Port and the device. Your reading assignment in the suggested reference textbook offers many suggestions. Also, see the Week 2 Lecture.
    2. Controlling speed with program loop
      1. Start by turning the motor on by sending the appropriate byte to the Port, using a short C program.
      2. Send the appropriate byte to the Port to turn the motor off.
      3. You can now turn the motor on or off by changing the byte value in the program, recompiling, and loading the program into the CPU board.
      4. Now, however, we want to control the speed of the motor by changing the width of the bit at Port C. Do this by adding a delay program that keeps the pulse on for a 50% duty cycle. Let the period of the pulse be 200 microseconds, giving a frequency of 5 kHz. Use an endless loop in the program.
      5. Experiment with pulse widths of 25% and 75%. Note that the speed varies with the pulse width.
    3. Controlling speed with PWM registers
      1. See Week 2 Lecture for example of PWM programs that produce a pulse train with 50% duty cycle and pulse frequency of 7.7 kHz. This pulse train provided a medium speed for the Smart Car. Note that the pin PWM0 (Channel 0) is located on the Axiom S12G128 CPU board primary side pin A40.
      2. The PWMDTY0 command controls the width of the pulse.
      3. Notice that the sequence of PMW commands keeps the signal going to the PMW0 pin automatically, while the rest of the program can be doing something else. The PMW pin is connected to one H-bridge digital input.
    1. Using the H-bridge
      1. You might need to use the H-bridge to control the battery voltage to the motors. If you have a two-motor system, each motor is connected to one of the rear wheels. An H-Bridge can be used to feed the digital PWM pulse inputs to an output that is connected to the higher voltage motor system. For example, a 12-volt supply may be used by the motor, while the rest of the electronic modules might use 3.3V or 5V.
      2. In a simple Smart Car with one motor, the operator only needs one digital input that the CPU board can turn on and off. The other inputs can be hardwired to 5V or ground as appropriate.
    1. Download the Week 1 Lab Cover Sheet here and answer the questions for Step 1: Procedure.
STEP 2: Stepper Motor Procedures
ACTIVITY 1:
Examine the “Using H-Bridge to Drive Stepper Motor” in website below:
  1. Use an ohmmeter to measure the resistance of leads. This should identify the COM leads A through D winding leads.
  2. The common wires are connected to the positive side of the power supply. In many motors, +5V is sufficient. DO NOT USE +5V POWER FROM DRAGON12 PLUS BOARD. Make sure to use an external power supply.
ACTIVITY 2:
After making sure that Activity 1 works, write and run the following:
Connect a switch to PORTH and use it for clockwise or counter clockwise. Use PORTH1=0 for CW and PORTH=1 for CCW.
ACTIVITY 3:
Use two more bits of PTH (such as PORTH7 and PORTH6) DIP switches to choose the degree of rotation as shown below:
PORTH7
PORTH6

0
0
90 degrees
0
1
180
1
0
270
1
1
360
STEP 3: Procedures for Interfacing to the Servo
  1. Refer to the Smart Car Instruction Manual in the Files section of the Course Menu section of the course shell.
  2. Produce a logic pulse train with a period of about 20 milliseconds. A signal generator may be suitable. You can also write a loop program.
  3. The width of the pulse determines the position of the servo. A 0.5-millisecond pulse rotates the servo fully clockwise (about 45 degrees from the center of movement.  A 1.5-millisecond pulse rotates the servo to the opposite end of rotation. A 1.0 millisecond pulse puts the servo at the center of rotation. DO NOT SEND PULSES WIDER THAN 2 MILLISECONDS.
  4. Write a small C program that controls the Servo by providing a pulse train with controlled pulse widths. This routine will later be used to control the steering (using the servo) with an input number derived from the linear video array. See the Program Listing in Appendix A of the Smart Car Construction Manual.
  5. Complete questions for Step 3 in the Week 1 Lab Cover Sheet.


Comments

Popular Posts