CAT-1-A2-Answer Key
CAT-1-A2-Answer Key
3-Stage Pipeline
• At any time slice, 3 different instructions may occupy each of these stages, so the
hardware in each stage has to be capable of independent operations
• When the processor is executing data processing instructions , the latency = 3 cycles
and the throughput = 1 instruction/cycle
ARM Registers Organization
• 37 registers
• 31 general 32 bit registers, including PC
• 6 status registers
• In user mode - 15 general registers (R0 to R12),
counter are visible at any time –when you write user-level programs
• R13 (SP- stack pointer) - individual stack for each processor mode
• R14 (LR – Linked Register) – holds the return address of the subroutine to
continue main program
• R15 (PC – Program Counter) – fetch next instruction for execution
• The visible registers depend on the processor mode
• The other registers (the banked registers) are switched in to support IRQ, FIQ,
Supervisor, Abort and Undefined mode processing
**************************************************************************
Model design controller is designed to control the speed of the train when coming on
track.
Simple trains either run at a constant speed or use a simple speed control.
Modern model trains can make use of digital train controllers that send messages
along the tracks to the train engine.
It is a one way communication system.
The user sends messages to the train with a control box attached to the tracks. The
control box may have controls such as a throttle (a device controlling the flow of
fuel or power to an engine), emergency stop button, and so on.
Train receives its electrical power from the two rails (steel bar or continuous line of
bars laid on the ground) of the track and the control box can send signals to the
train over the tracks by modulating the power supply voltage.
• The control box sends packets over the tracks to the receiver on the train.
• The train includes analog electronics to receive bits and a control system to set the
train motor’s speed and direction based on those commands
• Each packet includes an address, so that the console can control several trains on the
same track;
• The packet also includes an Error Correction Code (ECC), to guard against
transmission errors.
• Header: It displays information such as the IP version, the packet’s length, the
source, and the destination.
• Throttle: regulating the supply of a fluid (as steam) to an engine. It is a mechanical
device used to control speed of engine.
• Inertia means an object will continue its current motion until some force causes its
speed or direction to change.
•
Requirement:
• Console can control 8 trains on single track.
• The speed of each train shall be controllable by a throttle to at least 63 different levels
in each direction (forward and reverse).
• Inertia control that allow the user to adjusts responsiveness of the train to commanded
changes in speed with at least 8 levels.
• Emergency stop button.
• An Error Detection scheme will be used to transmit messages.
Receiver: It knows how to turn the analog signals on the track into digital form.
Controller: It interpret the commands and figures out how to control the motor.
Motor interface: It defines how to generate the analog signals required to control the
motor.
Detector*: It detects analog signals on the track and converts them into digital form.
Pulser*: It turns digital commands into the analog signals required to control the
motor speed.
**************************************************************************
• Serial data communication uses two methods
– Synchronous method transfers a block of data at a time
– Asynchronous method transfers a single byte at a time
• There are special IC’s made by many manufacturers for serial communications.
– UART (universal asynchronous Receiver transmitter)
– USART (universal synchronous-asynchronous Receiver-transmitter)
Asynchronous – Start & Stop Bit
• Asynchronous serial data communication is widely used for character-oriented
transmissions
– Each character is placed in between start and stop bits, this is called
framing.
– Block-oriented data transfers use the synchronous method.
• The start bit is always one bit, but the stop bit can be one or two bits
• The start bit is always a 0 (low) and the stop bit(s) is 1 (high)
SBUF Register
• SBUF is an 8-bit register used solely for serial communication.
• For a byte data to be transferred via the TxD line, it must be placed in the SBUF
register.
• The moment a byte is written into SBUF, it is framed with the start and stop bits and
transferred serially via the TxD line.
• SBUF holds the byte of data when it is received by 8051 RxD line.
• When the bits are received serially via RxD, the 8051 deframes it by eliminating the
stop and start bits, making a byte out of the data received, and then placing it in
SBUF.
#include <reg51.h> /* Include x51 header file */
void UART_Init()
{
TMOD = 0x20; /* Timer 1, 8-bit auto reload mode */
TH1 = 0xFD; /* Load value for 9600 baud rate */
SCON = 0x50; /* Mode 1, reception enable */
TR1 = 1; /* Start timer 1 */
}
void Transmit_data(char tx_data)
{
SBUF = tx_data; /* Load char in SBUF register */
while (TI==0); /* Wait until stop bit transmit */
TI = 0; /* Clear TI flag */
}
void String(char *str)
{
int i;
for(i=0;str[i]!=0;i++) /* Send each char of string till the NULL */
{
Transmit_data(str[i]); /* Call transmit data function */
}
}
void main()
{
UART_Init(); /* UART initialize function */
String("test"); /* Transmit 'test' */
while(1);
}
***************************************************************************
4. With necessary circuit diagram explain the DAC and illustrate the characteristics of
the same
• The Microcontroller output is binary values, but application equipments display,
motor, speakers etc. work in analog signal. So we need digital to Analog converters.
• 8 bit current output monolithic DAC
• Manufactured by national semiconductor corporation
• 16 pin IC available
• 8 input lines (digital input)
• Single output
• In DAC 0808 the digital inputs are converted to current ( Iout). The current Iout is
converted into voltage using Op- amp The Current value in Iout pin is depends upon
the binary numbers at the Do – D7 inputs of the DAC 0808 and the reference current (
I ref )
R-2R DAC
• R-2R Digital-to-Analogue Converter, or DAC, is a data converter which use two
precision resistor to convert a digital binary number into an analogue output signal
proportional to the value of the digital number
• Recall that the bits of a binary number can have only one of the two values. i.e., either
0 or 1. Let the 3-bit binary input is b2b1b0.
• Here, the bits b2 denote the Most Significant Bit (MSB) and b0 denote Least
Significant Bit (LSB) respectively.
• The digital switches shown in the figure will be connected to ground, when the
corresponding input bits are equal to ‘0’. Similarly, the digital switches shown in
figure will be connected to the negative reference voltage, −VR when the
corresponding input bits are equal to ‘1’.
• It is difficult to get the generalized output voltage equation of a R-2R Ladder DAC.
But, we can find the analog output voltage values of R-2R Ladder DAC for individual
binary input combinations easily.
Advantages of a R-2R Ladder DAC
• R-2R Ladder DAC contains only two values of resistor: R and 2R. So, it is easy to
select and design more accurate resistors.
• If more number of bits are present in the digital input, then we have to include
required number of R-2R sections additionally.
Characteristics of DAC
Resolution
Accuracy
Conversion Time
Settling Time
Vfs
Output Voltage
**************************************************************************
5. Explain how DC motor is interfaced with 8051 for different duty cycle
Small DC Motor
DC motor converts electrical energy in the form of Direct Current into mechanical energy.
• In the case of the motor, the mechanical energy produced is in the form of a rotational
movement of the motor shaft.
• The direction of rotation of the shaft of the motor can be reversed by reversing the
direction of Direct Current through the motor.
• The motor can be rotated at a certain speed by applying a fixed voltage to it. If the
voltage varies, the speed of the motor varies.
• Thus, the DC motor speed can be controlled by applying varying DC voltage; whereas
the direction of rotation of the motor can be changed by reversing the direction of
current through it.
• For applying varying voltage, we can make use of the PWM technique.
• For reversing the current, we can make use of an H-Bridge circuit or motor driver ICs
that employ the H-Bridge technique or any other mechanisms.
• The speed of the DC motor is increased, when the duty cycle of the signal is high.
• Similarly, the speed of the DC motor is decreased, when the duty cycle of the signal is
low.
• By using the program, we can be able to change the duty cycle of the PWM signal and
also the motor speed may be varied.
• Normally the current produced from the microcontroller is not sufficient to drive the
DC motor effectively. Hence drivers may be connected in between the motor and
microcontroller.
• In some applications, we keep the speed of the motor as constant. For doing this, a
feedback circuit may be connected to it.
• The feedback circuit contains a speed sensor for getting the present speed of the
motor.
• According to the sensor output, the microcontroller adjusts the speed of the motor by
changing the duty cycle of the signal applied to it. Hence constant speed can be
maintained.
Let’s interface the DC motor with the AT89S52 microcontroller and control the DC motor
speed by using the Speed Increment Switch and Speed Decrement Switch connected to the
Microcontroller port and direction by using Direction Switch.
We are going to use the L293D motor driver IC to control the DC motor movement in both
directions. It has an in-built H-bridge motor drive.
• As shown in the above figure we have connected two toggle switches on the P1.0 and
P1.1 pin of the AT89S52 microcontroller to change the speed of the DC motor by
10%.
• One toggle switch at pin P1.2 controls the motor's rotating direction.
• P1.6 and P1.7 pins are used as output direction control pins. It provides control to
motor1 input pins of the L293D motor driver which rotate the motor clockwise and
anticlockwise by changing their terminal polarity.
• Speed of the DC Motor is varied through PWM Out pin P2.0.
• the timer of AT89S52 is used to to generate PWM.
**************************************************************************