Processor Architecture
Unit - 4PIC Interfacing -IIQ 1) Write a short note on capture mode.A 1)In Capture mode, CCPRxH:CCPRxL captures the 16-bit value of the TMR1 register when an event occurs on pin CCPx. An event is defined as: Every falling edge Every rising edge Every 4th rising edge Every 16th rising edge An event is selected by control bits CCPxM3:CCPxM0 (CCPxCON<3:0>). When a capture is made, the interrupt request flag bit, CCPxIF, is set. The CCPxIF bit must be cleared in software.If another capture occurs before the value in register CCPRx is read, the previous captured valuewill be lost. As can be seen in Figure 14-1, a capture does not reset the 16-bit TMR1 register. This is so timer1 can also be used as the timebase for other operations. The time between two captures can easily be computed as the difference between the value of the second capture that of the first capture. When Timer1 overflows, the TMR1IF bit will be set . Q 2) Write a ccp pin configuration.A 2)In Capture mode, the CCPx pin should be configured as an input by setting its corresponding TRIS bit. The prescaler can be used to get a very fine average resolution on a constant input frequency. For example, if we have a stable input frequency and we set the prescaler to 1:16, then the total error for those 16 periods is 1 TCY. This gives an effective resolution of TCY/16, which at 20 MHzis 12.5 ns. This technique is only valid where the input frequency is “stable” over the 16 samples. Without using the prescaler (1:1), each sample would have a resolution of TCY. Timer1 must be running in timer mode or synchronized counter mode for the CCPmodule to use the capture feature. In asynchronous counter mode, the captureoperation may not work. If the CCPx pin is configured as an output, a write to the port can cause a capture 2 Changing Between Capture Modes. When the Capture mode is changed, a capture interrupt may be generated. The user should keep the CCPxIE bit clear to disable these interrupts and should clear the CCPxIF flag bit following any such change in operating mode. Q 3) Write a short note on pwm mode.A 3)In Pulse Width Modulation (PWM) mode, the CCPx pin produces up to a 10-bit resolution PWM output. Since the CCPx pin is multiplexed with the PORT data latch, the corresponding TRIS bit must be cleared to make the CCPx pin an output. Figure 14-3 shows a simplified block diagram of the CCP module in PWM mode. Fig. PWM mode PWM Period The PWM period is specified by writing to the PR2 register. The PWM period can be calculated using the following formula: PWM period = [(PR2) + 1] • 4 • TOSC • (TMR2 prescale value), specified in units of time PWM frequency (FPWM) is defined as 1 / [PWM period]. When TMR2 is equal to PR2, the following three events occur on the next increment cycle: TMR2 is cleared. The CCPx pin is set (exception: if PWM duty cycle = 0%, the CCPx pin will not be set). The PWM duty cycle is latched from CCPRxL into CCPRxH. PWM Duty Cycle The PWM duty cycle is specified by writing to the CCPRxL register and to the DCxB1:DCxB0(CCPxCON<5:4>) bits. Up to 10-bit resolution is available: the CCPRxL contains the eight MSbs and CCPxCON<5:4> contains the two LSbs. This 10-bit value is represented by DCxB9:DCxB0.The following equation is used to calculate the PWM duty cycle: PWM duty cycle = (DCxB9:DCxB0 bits value) • Tosc • (TMR2 prescale value), in units of time. The DCxB9:DCxB0 bits can be written to at any time, but the duty cycle value is not latched into CCPRxH until after a match between PR2 and TMR2 occurs (which is the end of the current period). In PWM mode, CCPRxH is a read-only register. The CCPRxH register and a 2-bit internal latch are used to double buffer the PWM duty cycle. This double buffering is essential for glitchless PWM operation. When CCPRxH and 2-bit latch match the value of TMR2 concatenated with the internal 2-bit Q clock (or two bits of the TMR2 prescaler), the CCPx pin is cleared. This is the end of the duty cycle. Maximum PWM resolution (bits) for a given PWM frequency: The Timer2 postscaler is not used in the determination of the PWM frequency. The postscaler could be used to have a servo update rate at a different frequency than the PWM output. If the PWM duty cycle value is longer than the PWM period, the CCPx pin will not be cleared. This allows a duty cycle of 100%. Q 4) Explain pwm period and pwm duty cycle.A 4) PWM PeriodThe PWM period is specified by writing to the PR2 register. The PWM period can be calculated using the following formula: PWM period = [(PR2) + 1] • 4 • TOSC • (TMR2 prescale value), specified in units of timePWM frequency (FPWM) is defined as 1 / [PWM period].When TMR2 is equal to PR2, the following three events occur on the next increment cycle: TMR2 is cleared. The CCPx pin is set (exception: if PWM duty cycle = 0%, the CCPx pin will not be set) The PWM duty cycle is latched from CCPRxL into CCPRxH PWM Duty CycleThe PWM duty cycle is specified by writing to the CCPRxL register and to the DCxB1:DCxB0 (CCPxCON<5:4>) bits. Up to 10-bit resolution is available: the CCPRxL contains the eight MSbs and CCPxCON<5:4> contains the two LSbs. This 10-bit value is represented by DCxB9:DCxB0. The following equation is used to calculate the PWM duty cycle: PWM duty cycle = (DCxB9:DCxB0 bits value) • Tosc • (TMR2 prescale value), in units of time The DCxB9:DCxB0 bits can be written to at any time, but the duty cycle value is not latched into CCPRxH until after a match between PR2 and TMR2 occurs (which is the end of the current period). In PWM mode, CCPRxH is a read-only register. The CCPRxH register and a 2-bit internal latch are used to double buffer the PWM duty cycle. This double buffering is essential for glitchless PWM operation. When CCPRxH and 2-bit latch match the value of TMR2 concatenated with the internal 2-bit Q clock (or two bits of the TMR2 prescaler), the CCPx pin is cleared. This is the end of the duty cycle. Maximum PWM resolution (bits) for a given PWM frequency: The Timer2 postscaler is not used in the determination of the PWM frequency. The postscaler could be used to have a servo update rate at a different frequency than the PWM output. If the PWM duty cycle value is longer than the PWM period, the CCPx pin will not be cleared. This allows a duty cycle of 100%. Q 5) Explain the dc motor speed control with ccp.A 5)In this paper we proposed and design a speed control system of DC Motor by using CCP module of PIC microcontroller. This system would be able to control the DC motor speed at desired speed regardless the changes of load. The speed of DC motor depends on applied voltage, armature current and applied load. Two push button switches are connected to 1st and 2nd pins of PORTD which is used to control the duty ratio of the generated PWM. Pressing the UP switch increases the duty cycle, which increases the motor speed while pressing the DOWN switch decreases the duty cycle, which decreases the motor speed. Here we use CCP1 module of PIC 16F877A to generate PWM and it is given to the enable pin of L293D. The direction of rotation of motor can be control using the 1st and 2nd pins of PORTB. There are three reasons for “Resistor is not a good choice for controlling the speed of a DC Motor”. The main problem is that the motor is a varying electrical load so a resistor can’t do this task. It needs more power during start up than in running state. It draws more current also when a mechanical load is applied to motor shaft. The resistor drops excess energy as heat. Thus it is not good for a battery powered device. We all know that motor requires more current, so resistors with higher power rating are required to drop excess energy. Q 6) What are the time reason for “resistor is not a good choice for controlling speed of a dc motor?A 6)There are three reasons for “Resistor is not a good choice for controlling the speed of a DC Motor”.• The main problem is that the motor is a varying electrical load so a resistor can’t do this task. • It needs more power during start up than in running state. It draws more current also when a mechanical load is applied to motor shaft.• The resistor drops excess energy as heat. Thus it is not good for a battery powered device.• We all know that motor requires more current, so resistors with higher power rating are required to drop excess energy.• PWM can be easily generated using the inbuilt CCP module of a PIC Microcontroller. CCP stands for Capture/Compare/PWM. CCP modules are available with a number of PIC Microcontrollers. • Most of them have more than one CCP module. MikroC Pro for PIC Microcontroller provides built in library routines for PWM which makes our task very simple. • Unipolar is easier to operate, control and also easier to get. Here in this tutorial we are interfacing Stepper Motor with PIC Microcontroller PIC16F877A.• We are using 28BYJ-48 stepper motor for this project which is cheap and easily available. It is 5V DC unipolar stepper motor.• We are also using a Module available with this motor which consist ULN2003 Stepper Motor Driver IC.• ULN2003 is a Darlington pair array, which is useful to drive this motor, since PIC microcontroller couldn’t provide enough current to drive.• ULN2003A is capable to drive 500mA of load with 600mA of peak current.Q 7) Explain the stepper motor interfacing with PIC.A 7)• Stepper Motor is a specially designed motor which rotates in steps. Speed of stepper motor depends on the rate of electrical signal applied to it. • Different patterns can control stepper motor’s direction and rotation type. • Mainly two types of stepper motors are available, Unipolar and Bipolar. Unipolar is easier to operate, control and also easier to get. • Here in this tutorial we are interfacing Stepper Motor with PIC Microcontroller PIC16F877A.• We are using 28BYJ-48 stepper motor for this project which is cheap and easily available. • It is 5V DC unipolar stepper motor. We are also using a Module available with this motor which consist ULN2003 Stepper Motor Driver IC. • ULN2003 is a Darlington pair array, which is useful to drive this motor, since PIC microcontroller couldn’t provide enough current to drive. • ULN2003A is capable to drive 500mA of load with 600mA of peak current.Q 8) Write advantages and disadvantages of SPI.A 8)ADVANTAGES• No start and stop bits, so the data can be streamed continuously without interruption• No complicated slave addressing system like I2C• Higher data transfer rate than I2C (almost twice as fast)• Separate MISO and MOSI lines, so data can be sent and received at the same timeDISADVANTAGES• Uses four wires (I2C and UARTs use two)• No acknowledgement that the data has been successfully received (I2C has this)• No form of error checking like the parity bit in UART• Only allows for a single master• Hopefully this article has given you a better understanding of SPI. Continue on to part two of this series to learn about UART driven communication, or to part three where we discuss the I2C protocol.Q 9) Explain the UART.A 9)• UART stands for Universal Asynchronous Receiver/Transmitter. • It's not a communication protocol like SPI and I2C, but a physical circuit in a microcontroller, or a stand-alone IC. • A UART's main purpose is to transmit and receive serial data.ADVANTAGES No communication protocol is perfect, but UARTs are pretty good at what they do. • Only uses two wires• No clock signal is necessary• Has a parity bit to allow for error checking• The structure of the data packet can be changed as long as both sides are set up for it• Well documented and widely used methodDISADVANTAGES• The size of the data frame is limited to a maximum of 9 bits• Doesn’t support multiple slave or multiple master systems• The baud rates of each UART must be within 10% of each other• Continue on to part three of this series, Basics of the I2C Communication Protocol to learn about another way electronic devices communicate. Or if you haven’t already, check out part one, Basics of the SPI Communication Protocol.Q 10) Write a short note on parallel transfer.A 10)• In parallel transfer, data is transferred in 8 or more lines. In this wire conductor is used for transferring data to a device that is only a few feet away.\• Serial communication is mostly used for transmitting and receiving the signal. • The 8051 microcontroller is consisting of Universal Asynchronous Receiver Transmitter (UART) used for serial communication. • The signals are transmitted and received by the Rx and Tx pins of microcontroller.• The UART take individual bytes of data and sends the individual bits in a sequential manner. • The registers are used for collecting and storing the data inside a memory.• UART is based on half-duplex protocol. Half-duplex means transferring and receiving the data, but not at the same time.Serial Vs Parallel• Data transferred by computer occurs in two ways. They are parallel and serial communication.• Parallel Communication has 8 or more lines. It is used for transfer of data to a device that is only a short distance, while serial communication is used to transfer data over a long distance.• The data is sent one bit at a time in serial communication, whereas multiple bits are sent simultaneously in parallel communication. • The difference between serial communication and parallel communication.Q 11) Explain the serial communicating programming using embedded C.A 11)Serial communication programming using embedded C: • Set the baud rate at 9600, 8-bit data and 1 stop bit. Use Timer 1 for baud rate generation. • In this lecture, basics of serial communication is discussed. • The 8051 control registers for serial communication are shown and the Serial Port programming in Embedded C.• Computer transfer data in two different ways:-• Serial transfer: In serial transfer, data is transfer to device located many meters away this method is used for long distance data transfer.• Parallel transfer: In parallel transfer, data is transferred in 8 or more lines. In this wire conductor is used for transferring data to a device that is only a few feet away.• Serial communication is mostly used for transmitting and receiving the signal. • The 8051 microcontroller is consisting of Universal Asynchronous Receiver Transmitter (UART) used for serial communication. • The signals are transmitted and received by the Rx and Tx pins of microcontroller.• The UART take individual bytes of data and sends the individual bits in a sequential manner. • The registers are used for collecting and storing the data inside a memory. UART is based on half-duplex protocol. • Half-duplex means transferring and receiving the data, but not at the same time.Serial Vs Parallel• Data transferred by computer occurs in two ways. They are parallel and serial communication.• Parallel Communication has 8 or more lines. It is used for transfer of data to a device that is only a short distance, while serial communication is used to transfer data over a long distance.• The data is sent one bit at a time in serial communication, whereas multiple bits are sent simultaneously in parallel communication. • The difference betSSSen serial communication and parallel communication.
0 matching results found