Realization of body burglar alarm based on finite state machine

introduction:

This article refers to the address: http://

With the growth of car ownership, the issue of car security and anti-theft is becoming more and more important. Most cars now implement anti-thief alarm (ATA) function, mainly through ultrasonic detection to determine whether there is illegal entry [1], and then start sound and light alarm. This method can effectively detect illegal entry, but there is also the possibility of false positives, which brings great trouble to the surrounding environment. In the integrated body controller designed by the author for a certain type of vehicle, by detecting the unlocking and blocking action, the ignition state, the body state and the anti-theft state, it is comprehensively judged whether it is safely locked, whether it is violently entered, and whether it is illegally ignited, thereby realizing safety lock and anti-theft. Alarm function, this paper first introduces the working principle of the anti-theft alarm unit (hereinafter referred to as ATA) and its state machine design, and then introduces the sound and light warning, the mechanism of safe lock and its software implementation.

How ATA works:

A valid ATA unit needs to trigger the alarm alert action correctly, and avoid the inconvenience caused by the false triggering of the alarm. This is achieved by judging whether it enters the car normally and normal ignition.

First of all, when the car is locked, the user is prompted to safely lock the car through the horn and the turn signal. It can only be safe when the four door and two cover states (four door switches, hood switch, trunk switch) are all off and the ignition signal is invalid. Lock the car. After safely locking the car, it enters the anti-theft state, and monitors the status of the four doors and two covers and the ignition signal [2]. If the door or the trunk or the hood is detected without being unlocked, it is considered illegal entry, if it is detected If the ignition signal is valid, it is considered to be illegal ignition. At this time, the sound and light alarm is activated by the horn and the turn signal, and the unlocking action is performed or the ignition key ON/OFF is detected twice within 5 seconds to stop the alarm and return to the normal state. The ATA structure is shown in Figure 1:

11.jpg

Figure 1: Schematic diagram of the ATA structure

Figure 1: ATA Structure Schematic

The ATA unit performs the door lock control under the key lock and unlocking action, realizes the burglar alarm state jump in the form of the state machine, and prompts the user with the current body state along with some warning actions. And its jumps are analyzed to describe the process of state jumps, and then the design of the body state alert action is described.

ATA state machine design:

According to the use mode of the car and the need of security anti-theft, the following states are designed: normal state NORMAL, anti-theft state SECURITY, waiting to exit the anti-theft state QUIT_SECURITY, alarm state ALARM, the normal state corresponds to the state in which the car is normally used, and the anti-theft state corresponds to the safety lock After the state, waiting to exit the anti-theft state is an intermediate transient, corresponding to the situation in the anti-theft state, the user unlocks the door without opening, and the alarm state corresponds to the state of illegal entry or illegal ignition. The following describes the jumps of these four ATA states in the state machine. The state diagram is shown in Figure 2:

22.jpg

Figure 2 ATA state diagram

Figure 2: ATA State diagram

In the condition that the four doors and two covers are fully closed and the ignition signal is invalid, the key remote control lock or the front door lock, the ATA enters the SECURITY state, at this time, the monitoring of the vehicle body state and the unlocking action is started; in the SECURITY state, the four doors and two covers are detected to be opened. Or the ignition signal is valid, enter the ALARM state, then activate the audible and visual alarm, unlock in the SECURITY state, enter the QUIT_SECURITY state; QUIT_SECURITY is an intermediate transient, which lasts for at least 20s, the timeout is automatically blocked and enters the SECURITY state again, so It can prevent the user from accidentally pressing the remote unlocking key to bring about the safety problem. If the door is opened during this period, it will enter the NORMAL state; in the ALARM state, after the alarm is detected, the four doors and two covers are fully closed and the ignition signal is invalid. The SECURITY state can also be entered into a normal state by unlocking or switching the ignition signal ON/OFF twice within 5 seconds. The specific code design will not be described here.

ATA warning action:

It can be seen from the ATA state machine that the condition of the state jump is the unlocking blocking action, the four-door two-cover state and the ignition signal, and the ATA needs to prompt and alert according to these conditions during the state jump [3].

When locking the car, according to the state of the four doors and two covers and the ignition signal, it is judged whether the car can be safely locked. If it is possible, the blocking action is performed, and the turn signal flashes once and the horn sounds once; if the four doors and two covers are open or slightly In the open condition, the blocking action is not performed, and the turn signal flashes three times and the horn sounds three times, prompting the owner to check an unclosed door or trunk or hood. Unlocking is simpler, and the turn signal flashes twice to show the difference.

After the safety lock enters the anti-theft state, the BCM enters the low-power mode, and at the same time enables the four-door two-cover and the ignition signal to interrupt the wake-up function. When there is illegal entry or illegal ignition, it will pass four doors or two covers or ignition. The switching state of the signal is reflected. At this time, the CPU is awakened, and the sound and light alarm is activated at the same time - the turn signal flashes, the horn sounds for 40s, the cycle is repeated four times, and the sound and light alarm is stopped when the alarm state is exited.

For the four ATA states, the flashing mode of the alarm LED with a very small power is distinguished. The LED is off in the NORMAL state, and the SECURITY state and the ALARM state are flashed in the PWM mode with a period of 4 s and a duty cycle of 10%. In the transient QUIT_SECURITY state, the LED flashes rapidly in a period of 200ms.

The code related to the horn warning is given below, in which the code of the horn control DrivePort and the timekeeping part, TimerStart and TimerStop [4], etc., are not described here.

Void HornTweet(HornOper mode)

{

If(SILENCE==mode){

If(SILENCE!=Alarm_spkr_cyout){

DrivePort (ALARM_SPKR_OUT, DRIVEOFF);

TimerStop(SPKR_FLASH_MS);

TimerStop(SPKR_PERIOD_3S);

TimerStop(SPKR_SHOUT_30MS);

Alarm_spkr_cyout=SILENCE;

}

}else if((TWEETONCE==mode)||(TWEETTWICE==mode)||(TWEET3TIMES==mode)){

If(mode!=Alarm_spkr_cyout){

DrivePort(ALARM_SPKR_OUT,DRIVEON);

If(TWEETONCE==mode){

TimerStart(SPKR_FLASH_MS,360,0,1);

}else if(TWEETTWICE==mode){

TimerStart(SPKR_FLASH_MS,360,0,3);

}else if(TWEET3TIMES==mode){

TimerStart(SPKR_FLASH_MS,360,0,5);

}

Alarm_spkr_cyout=mode;

}

}

}

Safety lock

Safe lock is an important part of the ATA unit, as shown in Figure 2, it is also a key trigger condition for entering the anti-theft state. Under the condition that the four doors and two covers are fully closed and the ignition signal is invalid, pressing the remote lock switch or rotating the front door key hole can trigger the safety lock. In order to avoid accidental locking of the car, it is necessary to perform certain debounce and filtering on the front door key lock switch and the remote control lock switch. The same situation is also applicable to the unlocking operation. The effect of accidental unlocking on the safety of the car is self-evident [5].

For the ATA unit, the front door key lock switch is a physical switch signal. When the remote control lock switch is pressed, the corresponding RF message is sent at regular intervals, and the RF report pressed by the remote lock switch is detected within a certain time interval. The text can determine whether the switch is pressed or released, and they are unified into a switching signal, logically corresponding to the following three variables: switch_state switch state, swon_event invalid to valid change, swoff_event valid to invalid change [6], The lock switch needs to maintain the pressing time of 150ms, which is considered to be a valid latching signal. The principle of the debounce program in this part is whether the maintenance time of the statistical switch press exceeds 150ms. The program is as follows:

CountOver=CountTimes(FRONTDOORKEY_LOCK_SWITCH, FRONTDRKEY_LOCK_150MS, &Fdkey_lock150ms_validtimes);

If(1==CountOver){

CountOver=0;

If(1==Fdkey_lock150ms_validtimes){

Fdkeydrivdr_lk_signal=1;

}

Fdkey_lock150ms_validtimes=0;

}else{

;

}

The CountTimes function looks like this:

Uchar CountTimes(SwId SwitchId, TimerId TmId, uchar* ValidTimes)

{

Uchar CountOver;

CountOver=0;

If(1==Sw[SwitchId].swon_event){

TimerStart(TmId,150,0,1);

}else if(1==Sw[SwitchId].swoff_event){

TimerStop(TmId);

}else{

;

}

If(1==TM[TmId].overflow_flag){

TM[TmId].overflow_flag=0;

CountOver=1;

If(ON==Sw[SwitchId].switch_state){

(*ValidTimes)++;

}else{

;

}

}else{

;

}

Return CountOver;

}

When the switch is pressed, the 150ms timer is started, the timer expires, and CountOver=1. At this time, it is judged whether the effective number of ValidTimes of the switch during this 150ms period is 1, and it can be judged whether the latching signal is valid.

Conclusion

The ATA unit designed in this paper interactively promotes the flow of the anti-theft alarm state in terms of man-machine operation and automobile state. The logic is strict, the function design is reasonable, the alarm is accurate and the false alarm is effectively avoided. It is a good anti-theft alarm solution. Has a very good practical value and reference.

Dustproof Junction Box

Guangdong Oujun Technology Co., Ltd. is a national high-tech enterprise established in 2006. It is a professional lighting manufacturer integrating R&D, design, production, sales and service. Specializing in the production of cord switches, high-precision connectors and other products, the products are widely used in lighting, electrical and other industries. The company's products have more than 60 patents at home and abroad, including 4 US patents and a number of national award-winning invention patents. The company covers an area of more than 13,000 square meters, has more than 180 front-line production employees, and more than 20 technical elites; realize automatic injection molding production , Integrated automatic installation and testing. With efficient production capacity, excellent quality and honest service, the company has developed into a modern enterprise that provides a full range of one-stop services.
At the beginning of the company's establishment, the business philosophy of "focus on intelligent manufacturing and dedicated service" was determined. The management has been continuously optimized and obtained the ISO9001 quality management system certification issued by the British Royal Authorized Organization SIRA; the products have respectively obtained VDE, UL, ENEC, SAA, KC, PSE, TUV, ASTA, SASO, CQC and other international safety certifications. Set up a professional testing laboratory to ensure the stability and improvement of quality under efficient production, so that product services can be brought to a higher level.
Guangdong Oujun Technology Co., Ltd. will take "continuous innovation, customer first" as its tenet, scientific management as the guide, full monitoring and tracking service, and be your best quality supporting supplier.
We sincerely look forward to working with the vast number of domestic customers to join hands in a win-win situation and create development together!

Dustproof junction box,Dustproof Cable Connectors,Junction dust Box connector,Outdoor Cable Connectors

Guangdong Ojun Technology Co., Ltd. , https://www.ojunconnector.com

Posted on