Professional Documents
Culture Documents
MNM Report 2 - Merged
MNM Report 2 - Merged
MNM Report 2 - Merged
TAXILA
4th Semester
Electronic Engineering Department
(B.Sc. Electronics Engineering)
Objective:
• Write the AVR C Language Code to design of a real time threat detection
system
• Perform all simulations/hardware implementation
Introduction:
Consider a Weapons Defense System, whose job is to shoot down incoming missiles and protect
the Naval Destroyer. This Weapons Defense System consists of three subsystems: a Radar
System, a Control System and a Weapons Firing System.
The Control System (microcontroller) act as a Command and Decision System, which is a
controlling system and the Radar System and Weapons Firing System are the controlled systems.
Now we will see how this Real Time System works in a realworld scenario.
First, the Radar System continuously monitors for potential threats like incoming missiles and
measures the coordinates of the targets. It then sends these coordinates to the Control System,
which then determines the level of threat possessed by the target based on the information from
the Radar System. The Command and Decision System then calculates different parameters of
the target like speed of the missile, flight path and possible point of impact.
Based on the above parameters, the Control System then activates the Weapons Firing System,
which fires continuously until the target is destroyed.
In this example, the communication between the Command and Decision System and the
Radar system happens in real time i.e., a potential threat can occur at any time and it is
unpredictable. The second real time computing is the firing coordinates. Initially, they are
determined by the flight path of the target but are updated in real time as per the actual location
of the target.
Code:
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
// Define the memory addresses for LCD data and control ports
#define LCD_DATA_PORT PORTA
#define LCD_CONTROL_PORT PORTB
#define RS_PIN PB0
#define EN_PIN PB1
// Define the memory address for the fire pin
#define FIRE_PIN PC0
int main() {
// Initialize LCD pins as output
DDRB = 0xFF;
DDRC = (1 << FIRE_PIN);
// Initialize the LCD
LCD_Init();
// Display "Firing System" on the first line with a 100ms delay for each alphabet
LCD_Command(0x80); // Move cursor to the beginning of the first line
LCD_Data(F);
_delay_ms(150);
LCD_Data(I);
_delay_ms(150);
LCD_Data(R);
_delay_ms(150);
LCD_Data(I);
_delay_ms(150);
LCD_Data(N);
_delay_ms(150);
LCD_Data(G);
_delay_ms(150);
LCD_Data( );
_delay_ms(150);
LCD_Data(S);
_delay_ms(150);
LCD_Data(Y);
_delay_ms(150);
LCD_Data(S);
_delay_ms(150);
LCD_Data(T);
_delay_ms(150);
LCD_Data(E);
_delay_ms(150);
LCD_Data(M);
// Enable interrupts
sei();
while (1) {
// Wait for valid coordinates signal
while (!(PIND & (1 << PD0)));
// Read the coordinates from the input
unsigned char coordinates = PINA;
// Extract the x and y coordinates from the input
unsigned char x = coordinates >> 4;
unsigned char y = coordinates & 0x0F;
// Blink X and Y points of coordinates for 100ms
for (unsigned char i = 0; i < 4; i++) {
displayCoordinates(x, y, 1);
_delay_ms(50);
displayCoordinates(x, y, 0);
_delay_ms(50);
}
// Activate the firing system
PORTC |= (1 << FIRE_PIN);
}
return 0;
}
Code Explanation:
• Header Inclusions:
The code includes necessary AVR library files for I/O operations and delay functions.
• Macro Definitions:
`LCD_DATA_PORT`, `LCD_CONTROL_PORT`: Define memory addresses for LCD
data and control ports.
`RS_PIN`, `EN_PIN`: Define memory addresses for control pins of the LCD.
`FIRE_PIN`: Define memory address for the pin connected to the firing mechanism.
• LCD Initialization:
`LCD_Init()`: Initializes the LCD by sending commands to set up its configuration.
• Main Function:
Initializes necessary pins as input/output.
Initializes the LCD.
Displays "Firing System" on the first line of the LCD.
Enables interrupts.
Enters an infinite loop.
Waits for a signal indicating valid coordinates (`PIND & (1 << PD0)`).
Reads the coordinates from the input (`PINA`).
Extracts the x and y coordinates.
Blinks the x and y coordinates on the LCD.
Activates the firing system by setting the `FIRE_PIN` high (`PORTC |= (1 <<
FIRE_PIN)`).
Overall, the code initializes the LCD, waits for valid coordinates, and then activates the
firing system based on those coordinates. It seems like a simple control program for a
firing system with an LCD display for feedback.
Proteus:
Conclusion:
In conclusion, the design of a real-time threat detection system represents a critical
fusion of advanced sensor technologies, machine learning algorithms, and robust data processing
architectures to swiftly identify and respond to potential security risks. By leveraging a
combination of sensors such as cameras, motion detectors, and environmental sensors, alongside
sophisticated AI algorithms capable of recognizing patterns indicative of threats, the system can
provide rapid and accurate threat detection capabilities. Moreover, the integration of real-time
data processing and analysis enables immediate response actions, ensuring the protection of
assets and individuals in dynamic environments. As technology continues to evolve, the ongoing
refinement and adaptation of such systems will be essential in addressing emerging security
challenges and safeguarding against evolving threats.