The electrical circuit of the security alarm. Scheme of security alarm. Drawbacks, possible improvements

The article provides a diagram of a simple burglar alarm, a description of the work, resident software (firmware). The device is not difficult to assemble with your own hands. All the information you need for this is in the article.

General description of the device.

The security alarm is assembled on the PIC controller PIC12F629. This is a microcontroller with 8 pins and the price is only 0.5$. Despite its simplicity and low cost, the device provides control of two standard alarm loops. The alarm system can be used to protect large enough objects. The device is controlled by a remote control with two buttons and one LED.

Our company has moved to a new building. From the previous owners there was an old burglar alarm. It was an iron box with red LEDs and a siren above the front door and a broken electronic unit.

I installed a small circuit board in the alarm unit and turned this junk into a modern, reliable burglar alarm. At the moment it is used to protect a two-storey building with a total area of ​​250 m 2 .

So, the alarm provides:

  • Control of two standard security loops with measurement of their resistance and digital filtering of signals.
  • Remote control (two buttons and one LED):
    • turning on the alarm;
    • disabling the alarm through a secret code
    • setting a secret code (the code is stored in the internal non-volatile memory of the controller);
    • operation mode indication by remote control LED.
  • The device generates the time delays necessary for dialing the secret code, closing the doors of the room, etc.
  • When the alarm is triggered, the device turns on the sound annunciator (siren).
  • The operating mode of the device is also displayed by an external light source.

The block diagram of the security alarm looks like this.

Connected to the main security alarm unit:

  • 2 security loops with
    • NC - normally closed sensors;
    • NR - normally open sensors;
    • Rok - terminating resistors.
  • External block of the sound notification and mode indication.
  • Backup power source.
  • Power supply 12 V.

Loops of the security alarm system and connection of sensors.

To control sensors (detectors), the device uses standard security loops. Loop resistance is controlled. If the circuit resistance is greater than the upper or less than the lower threshold, an alarm is generated. Normal is the loop resistance equal to the terminating resistor (2 kOhm). Thus, if an intruder breaks the wires of the loops or closes them, the alarm will go off. In this way, it will not work to disable security sensors.

In this device, the following threshold values ​​of the loop resistance are selected.

Those. loop resistance in the range of 540 ... 5900 ohms is considered normal. If the resistance value goes out of this range, an alarm will be triggered.

Scheme of connecting sensors (detectors) to the security loop.

Both normally closed security sensors (NC) and normally open (NO) can be connected to one loop. The main thing is that in the normal state the circuit has a resistance of 2 kOhm, and when any sensor is triggered, it causes an open or short circuit.

To increase the noise immunity of the system, the device digitally filters the loop signals.

In principle, everything should be clear. Connected to the PIC12F629 microcontroller:

  • Two loops through RC chains R1-R6, C1, C2, providing
    • formation of power supply of the loop;
    • analog signal filtering;
    • matching with the input levels of the PIC controller inputs.

To determine the resistance of the loops, a microcontroller comparator is used. An internal reference voltage source is connected to the second input of the comparator. The values ​​of the reference voltage source (RH) for comparison with the upper and lower threshold resistance values ​​are set by software.

  • Through the RC chains R7-R10, C3, C4, two remote control buttons and an LED are connected through a current-limiting resistor R11. The device provides digital filtering of button signals to eliminate chatter and improve noise immunity.

It is worth explaining the purpose of the resistor R17. The GP3 input of the microcontroller has an alternative function - a 12 V supply for programming the microcircuit. Therefore, it does not have a protective diode limiting the voltage at the level of the supply voltage. At a voltage of 12 V at this pin, the microcontroller enters the programming mode. Resistor R17 reduces the voltage at the GP3 input.

  • Through two transistor switches VT1, VT2, the microcontroller controls the siren and external LED indication. Because these elements can be connected with a long cable, the transistors are protected from line surges by VD4-VD7 diodes. Transistor switches allow switching current up to 2 A.
  • A voltage of 5 V to power the PIC controller is generated by the stabilizer D2. Do not ignore the VD8 LED. Its functions include not only power indication, but also the creation of a minimum load for the microcontroller. If the PIC controller consumes current less than 2-3 mA (for example, in reset mode), then the voltage of 12 V through resistors R8, R10 can raise the microcontroller supply voltage above the allowable one.
  • The inputs for the 12 V power supply and the backup power supply are separated by diodes VD2, VD3. A Schottky diode is used as a VD2 diode in order to provide priority to the power supply when the voltages are equal to the backup power source.

I assembled the device on a 54 x 45 mm board.

Installed it in the body of the old alarm. Left only the power supply.

The remote control is made in a plastic case with dimensions of 65 x 40 mm.

Software.

The resident software is developed in assembler. The program cyclically resets all variables and registers. The program cannot hang.

You can download firmware for PIC12F629 in HEX format.

Management of the security alarm system from the panel.

The remote control is a small box with two buttons and an LED.

It is better to install it indoors near the front door. With the help of the remote control, the alarm is turned on and off, the secret code is changed.

Modes and control.

When power is first applied, the device enters ALARM OFF mode. The LED is not lit. In this mode, the device is during the working day.

To turn on the alarm (ARMED mode), you must press two buttons at once. The LED will begin to blink rapidly, and after 20 seconds the device will switch to ARMED mode, i.e. will start monitoring the state of the sensors. This is the time it takes to leave the room and close the front door.

If during this period of time (20 seconds) any button is pressed, the device will cancel the armed mode and return to the ALARM DISABLED mode. Often people remember something just before leaving the building.

20 seconds after switching on, the device will switch to the ARMED mode. In this mode, the LEDs of the remote control and the external indication unit blink approximately once per second. In the ARMED mode, the state of the sensors is monitored.

When any security sensor is triggered, the LEDs begin to flash frequently, and the alarm counts down the time after which the siren will sound. This time (30 seconds) is necessary in order to have time to turn off the alarm by typing the secret code on the remote control buttons.

There are 2 buttons on the remote control. Therefore, the code looks like a number from the numbers 1 and 2. For example, the code 121112 means that you need to press the buttons 1, 2, three times 1 and 2 in sequence. The code can have from 1 to 8 digits.

If the code is entered incorrectly or incompletely, you can press two buttons at the same time and repeat the code entry.

If the correct code is entered, the device switches to the ALARM OFF mode.

If within 30 seconds after the sensor was triggered, the correct code was not dialed, then the siren turns on. You can disable it by typing the correct code. Otherwise, the siren will sound for 33 seconds and then the unit will turn off (go into ALARM OFF mode).

It remains to explain how to set the secret code. This can only be done from the ALARM OFF mode.

Both buttons must be held down for 6 seconds. Release when the remote control LED lights up. This will mean that the device has entered the passcode setting mode.

Then wait until the LED goes out (5 sec). The device will enter the ALARM OFF mode, and the new code will be stored in the internal non-volatile memory of the microcontroller.

Because Since the microcontroller of the device is clocked from an internal generator of low accuracy, the specified time parameters may differ by ±10%.

Alarm states.

Mode State
LED
Jump condition Change to mode
ALARM DISABLED Does not glow Short press of two buttons Waiting for GUARD (20 sec).
Holding two buttons pressed for 6 seconds Setting the passcode
Waiting for security

You need to get out and close the front door.

Flashing fast Time 20 sec SECURITY
Pressing any button (cancel) ALARM DISABLED
SECURITY Flashes once per second Sensor trips
Time to turn off the alarm code (30 sec)

Necessary in order to deactivate the alarm by dialing the code

Flashing fast Correct code dialed ALARM DISABLED
Correct code not dialed within 30 seconds Siren sound
(anxiety)
Siren sound (alarm) Flashing fast Correct code dialed ALARM DISABLED
Time 33 sec ALARM DISABLED
Setting the passcode Constantly lit Code set ALARM DISABLED

In practice, work with signaling comes down to actions.

  • Leaving the room. Press two buttons at the same time and close the door within 20 seconds.
  • Upon entering the room. Within 30 seconds, dial the secret code.

Drawbacks, possible improvements.

The device can be easily modified for its specific conditions. All improvements relate only to the hardware. They do not affect software.

  • It is advisable to install two sirens. One in the outdoor indication and warning block, the other in a hard-to-reach place. The current of the transistor key (2 A) allows this to be done.
  • It would be necessary to protect the siren wires from short circuit with a transistor current stabilizer. In the presented version of the scheme, an attacker can close the wires of the siren and, when the alarm is triggered, a short circuit of the power source will occur.
  • If desired, you can connect powerful and high-voltage sources of light, sound, etc. through electromagnetic relays. The allowable current of the keys allows this, and the keys are protected against surges when switching the relay winding.
  • A battery can be used as a backup power by adding a simple charge circuit to the circuit.

Appearance of the installed alarm system.

Now only the front door sensor is connected to the device. I plan, over time, to add security sensors. Two loops are quite enough to guard our two-story building.

By the way, if only one loop is used, then a 2 kΩ resistor must be connected to the second.

There are other software options for the device on the site's forum. There you can discuss, ask questions about this project.

A fire alarm is a complex system that helps locate the source of a fire. In addition, it provides for a voice warning system, smoke removal and other important functions. Many people represent the general aspects of the operation of such equipment, but not all of them understand how violations are notified. Because of this, doubts may arise as to whether it is worth installing this system at all, as it may seem that it is not very reliable. To do this, we will take a closer look at the principle by which a fire alarm works.

How the notification works

First, let's recall what a fire alarm consists of:

  • sensory devices, i.e. detectors and sensors;
  • equipment responsible for collecting and processing information from touch devices, sensors;
  • centralized control equipment, such as a central computer.

Peripheral devices (have an independent design and are connected to the control panel):

  • message printer: printing service and alarm messages of the system;
  • Remote Control;
  • light annunciator;
  • sound annunciator;
  • short circuit isolating module: used to ensure that the loop loops are operational in the event of a short circuit.

There is nothing complicated in the general principle of operation: through special sensors, information is amenable to the processing program, and then output to the monitoring center responsible for security. Here, special attention should be paid to the sensors themselves, which are divided into two types.

  1. active sensors. They generate a constant signal belonging to the protected area. If it changes, they begin to react.
  2. passive sensors. Their action is based on a direct change in the environment, which is caused by fire.

In addition, sensors may differ in their mechanism of action:

  • work due to the infrared mechanism;
  • due to the magnetic red mechanism;
  • due to the combined mechanism;
  • response to glass breaking;
  • use of perimeter active switches.

Action algorithm

After the sensors have detected the source of ignition, the fire alarm starts to execute the algorithm of actions. If the circuit diagram is done correctly, then the whole algorithm will work correctly.

  1. In order for people to know about the beginning of the fire, the warning system must turn on. It can be light and sound or ordinary, that is, sound. The composition and type of notification is determined at the design stage. It depends on the area of ​​the building, its height and so on. The warning system necessarily includes illuminated signs with the inscription "exit", which help to find a way out in a smoky space.

  2. The release of all ways of evacuation of people. This is possible if there is an access control and management system (ACS). The fire alarm sends a signal to it and it, that is, the ACS, allows people in the building to leave the dangerous place without obstacles.

  3. Switching on the automatic fire extinguishing system. Three options are possible here: water fire extinguishing, water-foam, powder or gas fire extinguishing. The type is determined by the NBP, as well as by the property located at the facility. Let's take a library as an example. Imagine that the fire extinguishing in it will be carried out with foam or water. In this case, the losses from this will be the same as from the fire itself.

  4. Switching on the smoke exhaust system. This is important so that people are not poisoned by harmful substances contained in the smoke from the fire. Also, the air supply from the street should be stopped from the supply ventilation system, as it contributes to the flame fanning. All these commands are also given by an automatic fire alarm.

  5. If there are elevators in the building, they should go down to the level of the first floor and block, but before that, the doors should open.

  6. Disconnection of current consumers. Life support systems go into emergency mode. The security system itself is supplied from the UPS, that is, uninterruptible power supplies.

Alarm connection diagram

In order for all these points to be completed with high quality, it is important to correctly draw up a basic signaling connection diagram. With it, the operation of the system will be efficient and safe.

Recall that the circuit diagram is distinguished by two important points:

  • shows how to reproduce the circuit;
  • provides information about the composition of the circuit and the principles of operation, which is also useful when refining or repairing equipment.

Usually the wiring diagram is given together with the signaling kit. All aspects of equipment installation must be observed. The correct scheme and strict adherence to it will help to quickly respond to the source of fire and take all necessary actions that are aimed at saving people.

As you can see, the principle by which the operation of the fire alarm is carried out is quite simple. The main thing is that all the actions laid down in it are completed on time, since we are talking about life. This is also the main reason why it is necessary to install fire alarms in a timely and careful manner, which serves the benefit of all people.

Schematic diagram of a homemade burglar alarm on a microcontroller:

The starting element is the motion sensor LX19B (or LX19C). These are freely sold in electrical stores and are not expensive. The security alarm sensor requires a little alteration: on its board, it is necessary to cut the tracks of the closing contacts of the relay and remove two wires from them (according to the “start” signal scheme). When a person appears in the area of ​​the sensor, the “Start” contact closes on the common wire on the circuit and the countdown starts from 9 to 0 seconds. This time is displayed on the seven-segment display. During this time, using the buttons, you must dial the correct code. Only then the alarm will turn off for 30 seconds. This time is enough to enter the room and turn off the alarm from the inside.

4 buttons are used to dial the code: Key1, Key2, Key3 and Key4 All. They are pressed in the following order: 1-2-3-1-2-1. These buttons can be located anywhere on the dial pad, but must be pressed in the correct sequence. All other buttons (Key4 All) are connected in parallel. When you press any of them, the code set is reset and everything needs to be started all over again. When the time counter displays "0", the dialing of the code is prohibited. It is necessary to move away from the door or stand still until the sensor resets the time to "nine", and then dial the code again. The more buttons in the keyboard, the less likely it is to select a code.

Any car howler is used as an alarm sounder. The original circuit of the Okhrana was assembled on a common cathode indicator taken from some Chinese device. Even the smartest DataSheet does not know its name. Therefore, for convenient repetition, I redrawn the circuit, board and firmware on the more well-known (but not the brightest) ALS324A indicator, also with a common cathode. The board option can be used, for example, the one in the archive, and if desired, the button board can be changed.

If someone likes the circuit, but some other indicator is at hand, for example, with a common cathode or a common anode, I will change the signet, circuit and firmware according to your desire and possibilities. Archive with files and microcontroller firmware on the forum. If you have any questions, I will gladly answer them there. Good luck! Samopalkin

Discuss the article ALARM SCHEME

Smoke detectors are a more effective fire alarm tool because, unlike traditional thermal detectors, they are triggered before an open flame forms and a noticeable increase in room temperature. Due to the relative ease of implementation, optoelectronic smoke detectors have become widespread. They consist of a smoke chamber in which a light emitter and a photodetector are installed. The associated circuit generates a trigger signal when a significant absorption of the emitted light is detected. It is this principle of operation that underlies the considered sensor.

The smoke detector shown here is battery powered, so it should average very low microamp current to be practical. This will allow it to work for several years without the need to replace the battery. In addition, the executive circuit assumes the use of a sound emitter capable of developing a sound pressure of at least 85 dB. A typical way to ensure very low power consumption of a device that must contain sufficiently high-current elements, such as a light emitter and a photodetector, is its intermittent operation, and the duration of the pause should be many times greater than the duration of active operation.

In this case, the average consumption will be reduced to the total static consumption of the inactive circuit components. Programmable microcontrollers (MC) with the ability to switch to a micro-powerful standby mode and automatically resume active work at specified time intervals help to implement this idea. The 14-pin MSP430F2012 MCU with 2 kB of built-in Flash memory fully meets these requirements. This MK, after switching to the LPM3 standby mode, consumes a current equal to only 0.6 μA. This value also includes the current consumption of the built-in RC generator (VLO) and timer A, which allows you to continue counting time even after the MK is switched to standby mode. However, this generator is very unstable. Its frequency, depending on the ambient temperature, can vary within 4 ... 22 kHz (nominal frequency 12 kHz). Thus, in order to ensure the specified duration of pauses in the operation of the sensor, it must be possible to calibrate the VLO. For these purposes, you can use the built-in high-frequency generator - DCO, which is calibrated by the manufacturer with an accuracy of no worse than ±2.5% within the temperature range of 0...85°C.

The sensor diagram can be found in Fig. one.

Rice. one.

Here, as elements of an optical pair placed in a smoke chamber (SMOKE_CHAMBER), an LED (LED) and an infrared (IR) photodiode are used. Thanks to the operating voltage of MK 1.8 ... 3.6 V and proper calculations of other stages of the circuit, it was possible to power the circuit from two AAA batteries. To ensure the stability of the emitted light under conditions of supply with an unstabilized voltage, the operating mode of the LED is set by a current source of 100 mA, which is assembled on two transistors Q3, Q4. This current source is active when output P1.6 is set high. In the standby mode of the circuit, it is disabled (P1.6 = "0"), and the total consumption of the IR emitter stage is reduced to a negligible level of leakage current through Q3. To amplify the photodiode signal, a photocurrent amplifier circuit based on the TLV2780 op-amp was used. When choosing this op-amp, we were guided by the cost and settling time. This op-amp has a settling time of up to 3 µs, which made it possible not to use the ability it supports to switch to standby mode, and instead to control the power supply of the amplifying stage from the output of the MC (port P1.5). Thus, after turning off the amplifying stage, it does not consume any current at all, and the achieved current saving is about 1.4 μA.

To signal the activation of the smoke sensor, a sound emitter (ZI) P1 (EFBRL37C20 , ) and LED D1 are provided. ZI refers to the piezoelectric type. It is supplemented with typical switching circuit components (R8, R10, R12, D3, Q2), which provide continuous sound generation when a constant supply voltage is applied. The type of RFG used here generates a sound with a frequency of 3.9 ± 0.5 kHz. A voltage of 18 V was chosen to power the PG circuit, at which it creates a sound pressure of about 95 dB (at a distance of 10 cm) and consumes a current of about 16 mA. This voltage is generated by a boost converter assembled on the basis of the IC1 chip (TPS61040, TI). The required output voltage is set by the values ​​of the resistors R11 and R13 indicated in the diagram. The converter circuitry is also supplemented with a stage to isolate the entire load from battery power (R9, Q1) after the TPS61040 is put into standby mode (low level at the EN input). This makes it possible to exclude the flow of leakage currents into the load and, thus, to reduce the total consumption of this stage (with the RFG disabled) to the level of its own static consumption of the IC1 microcircuit (0.1 μA). The scheme also provides: button SW1 for manual switching on/off of the PG; "jumpers" for configuring the power supply circuit of the sensor circuit (JP1, JP2) and preparing the sensor for operation (JP3), as well as external power connectors at the debugging stage (X4) and connecting the adapter of the debugging system built into the MC (X1) via the two-wire interface Spy- Bi wire.

Rice. 2.

After resetting the MK, all necessary initialization is performed, incl. calibration of the VLO generator and setting the frequency of resuming the active operation of the MC, equal to eight seconds. Following this, the MK is transferred to the economical mode of operation LPM3. In this mode, the VLO and Timer A remain in operation, and the CPU, RF sync, and other I/O modules stop working. Exiting this state is possible under two conditions: the generation of an interrupt at input P1.1, which occurs when the SW1 button is pressed, as well as the generation of a timer A interrupt, which occurs after the set eight seconds. In the P1.1 input interrupt routine, a passive delay (approximately 50 ms) is first generated to suppress the bounce, and then it is reversed to the state of the control line of the RFID, making it possible to manually control the activity of the RFID. When a timer interrupt A occurs (interrupt TA0), the procedure for digitizing the output of the photocurrent amplifier is performed in the following sequence. First, four digitizations are performed with the IR LED off, then four digitizations with the LED on. Subsequently, these digitizations are averaged. Ultimately, two variables are formed: L is the average value when the IR LED is off, and D is the average value when the IR LED is on. Quadruple digitization and their averaging are performed in order to exclude the possibility of false alarms of the sensor. For the same purpose, a further chain of "obstacles" to false triggering of the sensor is built, starting from the block for comparing variables L and D. Here the necessary triggering condition is formulated: L - D > x, where x is the trigger threshold. The value of x is chosen empirically for reasons of insensitivity (for example, to dust) and guaranteed operation when smoke enters. If the condition is not met, the LED and the RFG turn off, the sensor status flag (AF) and the counter SC are reset. After that, timer A is set to resume active work after eight seconds, and the MK is switched to LPM3 mode. If the condition is met, the state of the sensor is checked. If it has already worked (AF = "1"), then no further actions need to be performed, and the MK is immediately switched to LPM3 mode. If the sensor has not yet triggered (AF = "0"), then the counter SC is incremented in order to count the number of detected fulfillment of the trigger condition, which further improves noise immunity. A positive decision to trigger the sensor is made after detecting three trigger conditions in a row. However, to avoid over-longing the smoke delay, the standby time is reduced to four seconds after the first trigger condition and to one second after the second. The described algorithm is implemented by a program available.

In conclusion, we determine the average current consumed by the sensor. To do this, table 1 contains data for each consumer: the current consumed (I) and the duration of its consumption (t). For cyclically operating consumers, taking into account the eight-second pause, the average current consumption (μA) is I × t/8 × 10 6 . Summing up the found values, we find the average current consumed by the sensor: 2 μA. This is a very good result. For example, when using batteries with a capacity of 220 mAh, the estimated operating time (excluding self-discharge) will be about 12 years.

Table 1. Average current consumption, taking into account an eight-second pause in the operation of the sensor

Schematic diagram of a two-level security system, which is built using AVR microcontrollers of the ATMega series. 1st security level - coded lock. 2nd security level - security device. Two functional boards included in the system are based on ATmega 8535 microcontrollers.

Structural scheme

Microcontrollers (families AVR, MCS-51, etc.) with their architecture, software and hardware resources, like digital cubes, are ideal for developing various security devices, alarms, combination locks, etc.

Rice. 1. Block diagram of the security system.

The system (Fig. 1) has two main components: code lock A2, and security device A1. Security device A1 has 24 independent input lines to which limit switches S1...S24 are connected. These switches control the status of windows 01...05, doors D1, hatches L1, L2.

The number of the above objects of control can be different, and is tied to each specific room or protected perimeter.

The number of used security devices A1 and code locks A2 is also not limited by anything and is determined by the security conditions, degree of protection, features of buildings, premises, etc. It is clear that limit switches S1 ... S24 can also control those doors, access hatches to which are limited by code lock (or combination locks) A2. Schematic diagram of the code lock is shown in fig. 2.

circuit diagram

Consider the operation of the security device. External (remote) elements in relation to the device are 24 limit switches (S1 ... S24), which allow you to control the state of 24 objects (for example, a door). One limit switch controls the status of one door. If the door is closed, the limit switch is open.

The user (operator, dispatcher) can visually check the status of the door by the status of the indicator.

If the door is open, the limit switch is closed. Indicator - flashes periodically. If the door is closed, the limit switch is open. Indicator - off (off). Let the limit switch S1 be installed in door #1. Let the limit switch S2 be installed in door #2, etc.

If door No. 1 is open, indicator HL2 flashes periodically (if door No. 1 is closed, indicator HL2 is off). If door No. 2 is open, the HL3 indicator flashes periodically (if door No. 1 is closed, the HL3 indicator is off), etc.

The author will not dwell on any specific design of the installation of the limit switch, as well as the design of the device itself. The control and management interface of the device includes: toggle switches SA1, SA2, indicators HL1...HL25. Structurally, it is advisable to place all the above elements on a separate control panel.

Rice. 2. Schematic diagram of a combination lock for a security system.

The elements of the device control interface have the following purpose:

  • SA1 (SECURITY) - signaling toggle switch. When this toggle switch is set to the "ON" position, the device is armed. The device is armed, after ~ 10 sec. from the moment the SA1 toggle switch is set to the "ON" position from the "OFF" position. After arming, the alarm is triggered after ~ 10 seconds from the moment any limit switch S1...SA24 is closed.
  • SA2 - mute toggle switch. This toggle switch functions only in the door status control mode. Toggle switch SA1 must be set to the "OFF" position. When the SA2 toggle switch is set to the "ON" position, when any door is opened with a piezoelectric emitter, the BA1 emitter will immediately give out an audible signal, lasting ~ 2 seconds. If this toggle switch is in the "OFF" position, then when any door is opened, only the corresponding indicator will flash periodically, the piezoelectric emitter BA1 will be turned off.
  • HL1 - indicator of activation of the protection mode. If the device is in the "security" mode, this indicator is on, if in the "door status control" mode, this indicator is off.

The alarm is triggered - this means: relay K1 is constantly on. Conclusions 5 and 6, as well as 2 and 3 of this relay are closed. Piezoelectric emitter VA1 - turns on and off with a period of ~ 1 sec. To turn off the alarm, the SA1 toggle switch must be set to the "OFF" position.

Consider the main, functional units of the device circuit diagram. The basis of the device is the DD1 microcontroller, the operating frequency of which is set by a generator with an external resonator ZQ1 at 10 MHz.

Rice. 3. Schematic diagram of the security device on the microcontroller.

Switches SA1, SA2 are connected to the PD port of the microcontroller DD1 with a piezoelectric emitter BA1, an indicator HL1, a key on transistors VT1, VT2 to control the relay K1. Limit switches S1...S24 and indicators HL2...HL25 are connected to the ports РВ, РА, PC of the microcontroller DD1.

The power to these indicators is supplied through a switch on a VTZ transistor, which is controlled from pin 21 of the DD1 microcontroller. Resistors R10...R17, R20...R27, R28...R35 - current-limiting for indicators HL2...HL25. Resistor R8 - current limiting indicator HL1.

Relay K1 is controlled respectively from the output 14 of the microcontroller DD1. The supply voltage +12 V and +5 V is supplied to the device from the XI connector. Capacitor C5 filters the ripple in the +5 V supply circuit. Blocking capacitor C4 is in the power supply circuit of the microcontroller DD1.

There are two operating modes in the device operation algorithm: door status control mode and security mode. Consider the algorithm of the device operation in the door state control mode. Let all doors of the protected object be closed. Toggle switch SA1 in the "OFF" position.

Toggle switch SA2 in the "ON" position. After power is supplied to the device, during initialization, a log is written to all bits of the ports PB, RA, PC of the DD1 microcontroller. 1. The keys on transistors VT1 ... VT2 are closed, the -HL1 indicator is off.

Indicators HL2...HL25 are extinguished. Limit switches S1...S24 - open. From the output 21 of the microcontroller DD1, a periodic signal (meander) is generated with a period of about 1 s. If you open door no. 1, the limit switch S5 will turn on.

The HL2 indicator will flash periodically with a period of ~ 1 sec. The piezoelectric transmitter BA1 will emit a sound signal lasting ~ 3 seconds.

If you open door no. 2, the limit switch S6 will turn on. The HL2 indicator will flash periodically with a period of ~ 1 sec. The BA1 piezoelectric emitter will emit a sound signal lasting ~ 2 seconds, etc. If you set the SA2 toggle switch to the "ON" position, then when any limit switch is closed (when any door is opened), the corresponding indicator will only blink.

Consider the operation of the device in security mode. Let all doors of the protected object be closed. Toggle switch SA1 is set to the "OFF" position.

The device enters the armed mode, after ~ 10 seconds from the moment the SA1 toggle switch is set to the "ON" position. During this time, it is necessary to close all doors and leave the protected facility. It is clear if the perimeter of the protected object is large enough and in 10 seconds. If it is impossible to close all doors, then all doors must be closed before the object is armed.

If any of the limit switches S1 ... S24 is turned on in the security mode (any door will be open), then a log.0 level signal will be present at the corresponding output of the ports РВ, РА, PC of the microcontroller DD1. then after ~ 10 sec. an audible alarm will turn on (piezoelectric emitter BA1). At the same time, at pin 14, the DD1 microcontroller will set the log.0 level (the K1 relay will turn on).

If a “friend” penetrates the protected object, then it needs to set the SA1 toggle switch to the “OFF” position in ~ 10 seconds, otherwise the alarm will go off. It is clear that access to the switch SA1 should be limited.

If a "stranger" penetrates the protected object (through the opened door), then it needs to be in ~ 10 sec. find the SA1 switch and set it to the "OFF" position. The alarm will also turn on if any of the limit switches S1...S24 turns on for a short time (for example, close and immediately close the door). Relay contacts K1 can be used to close control circuits or power various actuators, for example, for a door lock mechanism or to turn on a siren (howler).

The developed program in assembler takes only about 0.4 KB of the program memory of the DD1 microcontroller. Unused hardware (PD6, PD7 lines) and software (about 7.6 KB) resources of the DD1 microcontroller can be used for additional options.

For example, you can install a couple of buttons and add the function of arming and disarming the device through an access code or control some other actuating devices. Having understood the program, you can replace the device parameters set programmatically:

  • blinking period of the HL1 indicator;
  • the duration of the sound signal of the piezoelectric emitter BA1 in the door status control mode;
  • the time of arming the device, as well as the delay time for turning on the alarm.

The device uses resistors S2-ZZN-0.125, any others with the same dissipation power and an error of 5% will do. Capacitor C5 type K50-35. Capacitor C1 ... C4 type K10-17a. Capacitor C4 is installed between the +5V circuit and the common conductor of the microcontroller DD1. Toggle switches SA1...SA2 type MTD1.

Relay K1, type RES48B, version RS4.590.202-01. These relays, with an operating voltage of 12 V (or with some other operating voltage), for each specific case, you can choose absolutely any, taking into account the switched current and voltage of the connected actuator.

Limit switches can be chosen absolutely any for each specific case. This can be a PKN124 button, or, for example, a waterproof travel switch of the VPK2111 type. Piezoelectric emitter VA1-HRM14AX.

Transistor VT1 - KT829A. Transistors VT2, VT3 -KT3107E. Indicator HL1 - AL307AM, red. The HL1 indicator can be replaced with any other, preferably with a maximum forward current of up to 20 mA.

Consider the operation of a code lock (hereinafter the lock) according to Figure 3. The algorithm of its operation is quite simple: in the write mode, a code is entered into the EEPROM of the microcontroller, which consists of 4 decimal digits and is typed on a 7-button keyboard. Further, for verification, the written code is read in read mode. In operating mode, the lock is waiting for the code to be entered.

The input code, the microcontroller writes to the RAM and compares it byte by byte with the code written in the EEPROM. If the codes match, then the microcontroller gives a signal for five seconds to turn on the lock opening mechanism.

In addition, the code dialing procedure can be open (the dialed code is displayed on the display, each button pressed is assigned a number on the display) and closed (when dialing the code, the same, predefined characters are displayed on the display, each pressed button is assigned a specific character, for example).

There is a separate switch for this. To activate the 4-digit code displayed on the display in the recording mode and in the operating mode, just press any button on the keyboard.

The device interface includes a scale, character-synthesizing indicator HG1, an indication unit (display) of digital seven-segment indicators HG2 ... HG4, a switch SA1, and a keyboard (buttons S1 ... S8).

Buttons S1...S7 are labeled with numbers from "1" to "7". These buttons set the input code. The S8 (P) button sets, in a cycle, one of the three operating modes: "mode No. 1", "mode No. 2", "mode No. 3". After mode No. 3, mode No. 1 is switched on.

Element No. 1 of the HG1 indicator is on when working in mode No. 1, element No. 2 of the HG1 indicator is on when working in mode No. 2, and element No. 3 is turned on, respectively, when working in mode No. 3. On a 5-digit display (dual digital indicators indicator HG2, HG3 displays the entered code Indicator HG4 displays the characters "3" (with the lock closed) and "0" (with the lock open).

The SA1 switch sets the code display mode on the device display. If this switch is in position "1", then the code set from the keypad is displayed on the display of the device. If in position "2" (hidden mode), then when typing the code on the display of the device, symbols are displayed in each digit

In mode No. 1 (working mode), the lock is ready to enter a code to open the lock (if, of course, the code was previously written to the EEPROM). Before dialing the code, the code 0000 is indicated on the display. Element No. 1 of the HG1 indicator is on (the other elements of the HG1 indicator are off).

The HG4 indicator displays the symbol "3" (closed). Buttons S1...S7 dialed 4-digit code. The dialed code is indicated on the display. The microcontroller after pressing any of the buttons S1 ... S7 writes the received 4-bit code to the RAM and starts checking the code written in the RAM and the code written in the EEPROM. The codes are compared byte by byte.

If the comparison is successful, the microcontroller sends a signal to the lock opening actuator. For five seconds, element No. 4 of the HG1 indicator is turned on, the HG4 indicator indicates the symbol "O" (open) and the log is set. 0 on pin 21.

Five seconds later, element No. 4 of the HG1 indicator is turned off at pin 21, a log is set. 1. The display shows the code 0000 again. The HG4 indicator shows the symbol "3" (closed) again.

In mode No. 2 (write mode), the secret code is written to the EEPROM. The display shows the code 0000. Element No. 2 of the HG1 indicator is on. The HG4 indicator displays the symbol "3" (closed). The SI...S7 buttons dial the code. The dialed code is indicated on the display.

The microcontroller writes to the EEPROM the 4-digit code displayed on the display after pressing any of the buttons 51...57. After writing the code, the display will show the code 0000 again.

In mode No. 3 (the mode of checking the written code), the written secret code in EEPROM is checked. Element No. 3 of the HG1 indicator is on. The HG4 indicator displays the symbol "3" (closed). The written code in EEPROM is indicated on the display.

It is clear that access to the button S8 and switch SA1 should be limited. Structurally, this is not so difficult to do.

Consider the main, functional units of the device (Fig. 3). The basis of the device is the DD1 microcontroller, the operating frequency of which is set by an oscillator with an external resonator ZQ1 at 11.0592 MHz. The PD port of the microcontroller DD1 controls the dynamic indication.

Dynamic indication is assembled on transistors VT1 ... VT5, dual, digital, seven-segment indicators HG2, HG3 and a single digital indicator HG4. Resistors R7...R14 - current-limiting for indicator segments HG2...HG4. The codes for turning on the above indicators when the dynamic indication is operating are sent to the PC port of the DD1 microcontroller.

For the functioning of the keyboard, pin 19 (PD5) of the microcontroller DD1 is used. The elements of the bar indicator HG1 are connected to the pins of the PB port of the microcontroller DD1. Resistors R2...R5 - current-limiting elements of the indicator HG1.

Immediately after power is applied to pin 9 of the microcontroller DD1 through the RC circuit (resistor R1, capacitor C3), a system hardware reset signal is generated for the microcontroller DD1. The display shows the code 0000. Element No. 1 of the HG1 indicator is on. The HG4 indicator displays the symbol "3" (closed).

Supply voltage +5V is supplied to the device from connector XI. Capacitor C5 filters ripples in the +5 V supply circuit. Blocking capacitor C4 is on the DD1 supply circuit.

Very briefly about the program. The program uses two interrupts: Reset and timer interrupt TO, the handler of which starts from the TIM0 label. When switching to the Reset label, the stack, timer, ports, as well as flags and variables used in the program are initialized.

The TO timer generates an overflow interrupt (the TOIE0 bit is set in the TIMSK register). The timer clock prescaler is set to 64 (TCCR0 is set to 3).

In the main program, the elements of the HG1 indicator are switched on. The included elements of this indicator, as mentioned above, determine the current mode of operation of the lock. In the TO timer interrupt handler, the following is carried out: the procedure for polling the buttons S1 ... S8, the operation of dynamic indication, writing the secret code to EEPROM, reading the secret code from EEPROM, converting the binary number into a code for displaying information on the seven-segment indicators of the device, as well as the time interval duration of five seconds required to turn on the actuator of the solenoid.

In the RAM of the microcontroller from address $61 to address $70, a display buffer is organized for dynamic indication. Below is the detailed allocation of the address space in the RAM of the microcontroller.

  • $60 - address of the beginning of the RAM of the microcontroller.
  • $61...$64 - addresses where the specified code for opening the lock and the symbol "3" are stored. These addresses are displayed in mode No. 1 (buffer No. 1).
  • $66...$69 - addresses where the code read from EEPROM and the character "3" are stored. These addresses are displayed in mode No. 3 (buffer No. 2).
  • $6C...$70 - addresses where characters are stored for hidden code dialing, and the symbol "3". These addresses are displayed in mode No. 1 (buffer No. 3).

The flags involved in the program are in registers R19 (flo) and R25 (flo1).

The developed program in assembler takes about 1.2 Kb of program memory. Having understood the program, with minor modifications of the circuit diagram, using the free hardware and software resources of the DD1 microcontroller, for example, you can increase the number of digits in the display and the number of buttons or add an audible alarm.

Resistors of the S2-ZZN type are used, any others with the same dissipation power and an error of 5% are suitable. Capacitors C1 ... C4, type - K10-17a, C5 - K50-35a. connector XI type WF-4. Capacitor C4 is installed between the +5V circuit and the common conductor of the microcontroller DD2. To test the layout, the SA1 switch of the VDMZ-8 type was used.

For installation in a block housing, you can use, for example, an MTDZ type switch. The display highlights the digit indicating the symbols "3", "O" (indicator HG4) against the background of the rest of the digits of the interface. Therefore, for this category, a seven-segment green indicator HDSP-F501, indicators HG2, HG3 green DA56-11GWA are selected.

The lock and the security device do not require any configuration and adjustment. With proper installation, they start working immediately.

Source code and program firmware - Download (8 KB).

Shishkin S. V. RK-07-16.

Literature:

  1. AV Belov We create devices on micro-controllers.
  2. S. V. Shishkin. Combination lock based on microcontroller. R-10-2011.