Uploaded by hhy016559

Micro assignment

advertisement
Micro-Processor
Question No: 01
Show at-least 10 serial communication protocols along-with their data-rate.
Solution:
Here are ten common serial communication protocols along with their typical data
rates:
1. RS-232


Data Rate: Up to 1 Mbps
Commonly used for communication between computer serial ports and
modems.
2. RS-485


Data Rate: Up to 10 Mbps
Used in industrial and commercial applications for long-distance
communication.
3. I2C (Inter-Integrated Circuit)


Data Rate: Standard Mode (100 kbps), Fast Mode (400 kbps), Fast Mode Plus
(1 Mbps), High-Speed Mode (3.4 Mbps)
Used for short-distance communication within a single device or between ICs
on a board.
4. SPI (Serial Peripheral Interface)


Data Rate: Up to 60 Mbps (depending on the implementation)
Commonly used for short-distance communication in embedded systems.
5. UART (Universal Asynchronous Receiver/Transmitter)


Data Rate: Typically up to 1 Mbps, but some implementations support higher
speeds
Used for serial communication between microcontrollers and peripheral
devices.
6. CAN (Controller Area Network)


Data Rate: Up to 1 Mbps (Classical CAN), Up to 5 Mbps (CAN FD - Flexible
Data-rate)
Widely used in automotive and industrial automation.
7. LIN (Local Interconnect Network)


Data Rate: Up to 20 kbps
Used in automotive networks for communication between sensors and
actuators.
8. USB (Universal Serial Bus)


Data Rate: USB 1.0 (1.5 Mbps and 12 Mbps), USB 2.0 (480 Mbps), USB 3.0
(5 Gbps), USB 3.1 (10 Gbps), USB 3.2 (20 Gbps), USB4 (40 Gbps)
Widely used for communication between computers and peripheral devices.
9. Ethernet


Data Rate: 10 Mbps (Ethernet), 100 Mbps (Fast Ethernet), 1 Gbps (Gigabit
Ethernet), 10 Gbps (10 Gigabit Ethernet)
Used for network communication in LANs and WANs.
10.Wi-Fi (IEEE 802.11)


Data Rate: 802.11b (11 Mbps), 802.11a/g (54 Mbps), 802.11n (600 Mbps),
802.11ac (up to 6.77 Gbps), 802.11ax (up to 9.6 Gbps)
Wireless communication standard used for local area networking of devices
and Internet access.
Question No: 02
Write DC motor speed control code and design circuit in protues given in book
example 17-9, show the pwm signal waveform.
Solution:
#include <xc.h>
// Configuration bits for PIC18F452
#pragma config OSC = HS
// High-speed oscillator
#pragma config PWRT = OFF // Power-up Timer
#pragma config BOR = OFF // Brown-out Reset
#pragma config WDT = OFF // Watchdog Timer
#pragma config LVP = OFF // Low Voltage Programming
#pragma config DEBUG = OFF // Background Debugger
#define _XTAL_FREQ 20000000 // 20 MHz crystal oscillator
void PWM_Init() {
// Set PWM frequency
PR2 = 0xFF; // Period register
T2CON = 0b00000100; // Timer2 on, prescaler 1:1
// Set CCP1 (PWM) mode
CCP1CON = 0b00001100; // PWM mode
CCPR1L = 0x80; // Duty cycle 50%
// Set CCP1 pin as output
TRISCbits.TRISC2 = 0;
}
void PWM_Set_Duty(unsigned int duty) {
if (duty < 1024) {
CCP1CONbits.DC1B = duty & 0x03; // Set the two LSBs
CCPR1L = duty >> 2; // Set the eight MSBs
}
}
void main() {
// Initialize PWM
PWM_Init();
// Main loop
while (1) {
// Vary duty cycle from 0 to 1023
for (unsigned int duty = 0; duty <= 1023; duty++) {
PWM_Set_Duty(duty);
delay_ms(10);
}
// Vary duty cycle from 1023 to 0
for (unsigned int duty = 1023; duty > 0; duty--) {
PWM_Set_Duty(duty);
delay_ms(10);
}
}
}
Proteus:
Download