Sei sulla pagina 1di 6

AT M E L

A P P L I C AT I O N S

NUMBER 8

SUMMER 2007

On-Line JOURNAL
Designing an AVR Microcontroller-based Auto Security and Monitoring System
By: Hamid Reza Mohseni Nejad Azad University Of Karaj, Iran
Useful Links in this Article: Data sheets, Application Notes & Technical Documents: ATmega8535(L) Summary Datasheet ATmega8535(L) Complete Application Note Replacing AT90S8535 by ATmega8535 App. Note Migrating between ATmega8535 and ATmega16
ATMega8535 Reliability Qualification Report http://www.atmel.com/dyn/general/advanced_search_results.as p?device=1&tools=1&faqs=1&datasheets=1&appNotes=1&us erGuides=1&software=1&press=1&articles=1&flyers=1&chec kAll=1&checkAllReference=1&target=ATMEGA8535

Search, Compare and Buy Processors


http://www.embedded-developer.com/corp/191/Atmel.htm

Also, using I2C and UART communication system makes the communication with peripheral devices easier. For example, it's really easy to store information to a serial memory or load data from it. CAR SECURITY & MONITORING SYSTEMS. By taking advantages of different available sensors and having the ability of networking these sensors to a central processor, we can control the status of different parts of a car such as speed, acceleration, fuel consumption per hour, combustion temperature, room temperature and so on. In addition, it's necessary to have precise information about different parts of a car such as Battery voltage level, and oil pressure. The driver should be sure about the correct operation of all of these parts, so a controlling and monitoring circuit can be used to check these issues and after being sure about the correct operation of the desired part, it can inform the driver that the car is now ready to be started. If, before starting the car, the driver can be prompted, potential issues will be prevented. To increase the security of the car, a logging system can be used, and the car cannot be started unless the driver enters the correct password.

INTRODUCTION Using lots of capabilities that have been embedded in the AVR microcontroller series, there are a lot of facilities that a user has available to design a system with 10-12 bit multi channel ADC, RTC, different sleep mode, etc., (features that can be used in any electronic system). For instance, in each control system, time and calendar are the parameters that make the design more applicable. Also, in applications whose power supply is a battery, keeping the power consumption low is one of the more important features of the design. The Sleep Feature, causes the circuits start to process and execute instructions whenever needed and causes the consumption current to decrease as much as possible.

ATMEL APPLICATIONS

On-L L ine JOURNAL

Page 2

Figure 1-1 Block Diagram of the designed system CIRCUIT DESCRIPTION Before switching on the car, the circuit checks the battery level of the car. if the level is in the desired range, the circuit will go to the next stage. Otherwise a message will appear on the display screen to prompt the driver a bout the low battery voltage and also to show the battery value. After verifying the battery voltage level, a password should be entered by the driver through using the keypad that has been provided in the system. After correct log on to the system, the open contact of the relay will be closed and the switch path is ready to be ignited by the driver. When the car is in operation, the display screen shows the clock and the room temperature. By pressing the Menu key, the driver can access the following options. 1-Clock Setting 2-Alarm Setting 3-Password change 4-Battery level view SYSTEM BLOCK DIAGRAM Figure 1-1 illustrates the basic diagram of the system. In this system 3 Micro controllers has been used. One as master and the others serve as slaves. When the car is switched off, all the Micro controllers are in sleep mode. In AVR micro controller series, different kinds of sleep mode are available. In each of this mode some parts of Micro controller that are not needed are disabled. So the consumption current decreases. The appropriate sleep mode is chosen due to the kind of the Micro controller and its application in order to minimizing the consumption current. Table 1-1 shows the operation of each Microcontroller and sleep mode that has been considered for. When the car is off the only part that needs to be refreshed is the RTC.As it has been illustrated in figure 1-1 Master is in power save mode. This will cause Timer 2 that has been dedicated to RTC (with 32,768 HZ external crystal) can continue its normal working in sleep mode.

ATMEL APPLICATIONS

On-L L ine JOURNAL

Page 3

Table 1-1 Every 1-second the Master wakes up from sleep mode and runs the ISP of timer2.in this interrupt service routine, second, minute and hour are updated. For reducing the calculation load from master, measurements are done by slave1. These include room temperature value, battery level value, password check and change and interfacing with external serial memory. In normal mode (when the car is on) slave1 is in sleep mode and it wakes up when it receives wake-up signal from Master. After waking up signal a command is issued by the master. Based on the command message, slave 1 does the related jobs and returns the result to the master. Table 1-2 illustrates the command message code and the description of the operation that is done by slave1. Slave 2 checks the status of switch. When switch is excited (closed or opened) slave2 wakes up from sleep mode and issues the following commands: 1-waking up the master 2-when the switch is opened the output is 1; otherwise, a zero command is sent. After checking the above command, the master goes to one of the following modes: 1-normal mode: when the switch is opened. 2-sleep mode: when the switch is closed.

Table1-2-Issued command from master and the operation that is executed by the slave 1

ATMEL APPLICATIONS

On-L L ine JOURNAL

Page 4

POWER SUPPLY AND PROTECTION The main power supply of the system is the car battery. The car battery has 12V dc voltage and 55Ah capacity. So it's possible to have some over voltage and some time high current that may affect the circuit. To protect the system against battery reversal and load dump voltage a protection device RBO4040G/T has been used. As it has shown in the schematic diagram #1 (Open attachment) this device has been used before the 5-volt voltage regulator. RELAY DRIVE CIRCUIT For opening and closing the switch path a usual relay can be used. In this way for closing and opening the contact of the relay the excite coil of the relay must be activated till it's required. So when the driver enters the correct password, the master must issue the close command of the switch path. So this command, and device that should provide the sufficient current (Transistor or FET) must be active during this time that causes the current consumption. If we use a relay with dual excite coil we can have better and safer operation. As Illustrated in the schematic circuits #2 (Open attachment) there are two excitation commands. Excite A and Excite B .For activating the Relay contact it's just necessary to do the following commands. A-Open command: Excite A=1 Delay 10 millisecond Excite A=0 B-Close command: Excite B=1 Delay 10 millisecond Excite B=0 As it can be seen from the pseudocode after each command there is a delay. This delay causes the port to settle to the 5 volt. (Port settle time). Now we can see that just in changing condition (open to close or vise) the command should be activated and the activation time is only 10ms.so we will see that the current consumption decreases considerably. MEASURING ROOM TEMPERATURE AND BATTERY VOLTAGE For measuring the room temperature, an LM 35 has been used. This sensor can measure temperature between 0-100 C. Output voltage increases 10mv for each Centigrade. This output is connected to channel 1 of slave1.

The minimum acceptable value for the car battery voltage is about 11 volt. To measure this value a voltage divider circuit with 1% precise resistors is used. (In software the decrease factor of voltage divider circuits is considered.) MEMORY For storing the password, a serial EEPROM memory, which is connected to slave1 through I2C port, has been used. Generally we can use the internal EEPROM memory of the AVR micro controller, but if we want o add some additional features and store their value, it's better to have a distinct memory. For example by using this memory, we can have a log file of all those who have logged on to the system. (authorized and unauthorized). INTERRUPT DRIVEN KEY To prevent frequent scanning the keypad and decreasing the calculation load from master, we can use an interrupt driven keypad for reading the keystrokes. Using this technique causes the master to be used in sleep mode easily. By pressing a key an external interrupt is activated. The CPU wakes up from sleep mode and process the keystroke.

CONCLUSION The structure of the designed system is such away that we can add lots of desired sensors easily and with the least change in hardware and software. Having 7 ADC channels in slave1 makes it possible to add new sensors such as acceleration, speed, and liquid leveleasily. Also monitoring process can be done more completely with these new sensors.

Power consumption is another important feature in this project. it has been tried to minimize the power consumption as much as possible. So all the micro controllers go to the sleep mode most of the time, especially when the car has been switched off. The operation that is done in off mode is just updating the clock. When the car gets on, the temperature of the room is measured each 10 second, so the other times, all the micro controllers are in sleep mode.

Atmel Wiring Diagram 1

Atmel Schematic #2

Potrebbero piacerti anche