Tuesday, October 29, 2013

Tutorial 5 PIC Microcontroller

All the questions asked below are related to the Applications of PIC16F877A.

1. Make comparison between DC Motor and stepper motor?

 Solution
DC Motor
A DC motor usually means a permanent-magnet, direct-current (DC) motor of the sort used in toys, models, cordless tools, and robots. These motors are particularly versatile because both their speed and direction can be readily controlled; speed by the voltage or duty cycle of their power supply, and direction by its polarity.

Stepper Motor
Stepper motors work in a similar way to dc motors, but where dc motors have 1 electromagnetic coil to produce movement, stepper motors contain many. Stepper motors are controlled by turning each coil on and off in a sequence. Every time a new coil is energized, the motor rotates a few degrees, called the step angle. Repeating the sequence causes the motor to move a few more degrees and so on, resulting in a constant rotation of the motor shaft.



2. For forward and reverse motions in motor control, why 1 second of stop is inserted before running the motor?

Solution
For forward and reverse motions, 1 second of stop is inserted before running the motor, to give time to stop the on-going motion and its inertia (and reverse electromotive force development and attenuation).


3. Why motor driver or relays are used to drive the motor instead of using microcontroller to drive the motor directly?

Solution
Because the microcontroller couldn’t supply enough power to drive the motor directly. The maximum sink current of PIC 16F877A is only 25mA, and the maximum voltage is only 5V.

  
4. The circuit in figure 4 shows the controlling of motor using H-bridge. Explain how the microcontroller can be used the control the direction of the motor.



Solution

Connect pin A and B to port D of the PIC 16F877A. The motor will move forward if pin A is High and pinB is low, vice versus, if the pin A is low  and pin B is high, the motor will moves in reverse direction. If pinA and pin B are low, then the motor will stops.

  
5. Refer to figure 5, two motors are used to control front wheels and two motors are used to control rear wheels of a car. Explain how to make the car turns left or turns right?

 Solution
Turn left or right has many different operational options but the easiest one is: Run forward two right motors, front and rear, and stop two left motors, front and rear for "turn left" motion; and run forward two left motors, front and rear, and stop two right motors, front and rear for "turn right" motion.




6. For Bi-polar stepper motor control, a sequence of pulses must be supply to make the motor moves forward or reverse. As illustrated in figure 6 below, for forward step turns, the correct sequence of pulses must be provided to the coils in the order of 1 – 2 - 3 - 4 - 1. The each pulse will turn one step. Therefore, the one sequence of pulses turns four steps, or 7.5°x4 = 30°.Write a program to move the motor forward for 30o .





; 1 FORWARD sequence subroutine (will turn 4 steps)
; A B 7 6 5 4 3 2 1 0 (PORTD)
; + + --->1 1 0 0 0 0 1 0
; - + --->0 1 0 0 0 0 1 0
; - - --->0 0 0 0 0 0 1 0
; + - --->1 0 0 0 0 0 1 0


Solution
fsequence
banksel PORTD
bcf PORTD, 0x05 ;100% power (Start Condition)
movlw B'11000010' ;1st excitation with LED1 on
movwf PORTD
call delay10ms
call delay10ms ;this time delay determines
;how fast one step finishes
;longer delay slows the motor turn
banksel PORTD
movlw B'01000010' ;2nd excitation with LED1 on
movwf PORTD
call delay10ms
call delay10ms
banksel PORTD
movlw B'00000010' ;3rd excitation with LED1 on
movwf PORTD
call delay10ms
call delay10ms
banksel PORTD
movlw B'10000010' ;4th excitation with LED1 on
movwf PORTD
movlw B'11000000' ;back to the fist pulse with LEDs off
movwf PORTD
call delay10ms
call delay10ms

return






No comments:

Post a Comment