Skip to content

XDU_Anti-lost_security_detection_system #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# Anti-lost security detection system

The portable outdoor travel equipment designed by us is based on sensors to collect motion information, intelligently discriminate, realize abnormal posture recognition, and can detect the distance with the guardian in real time through combined positioning to ensure the safety of the user. Compared with the machine vision-based gesture recognition method, it has the advantages of fast speed, good real-time performance and convenient carrying.

<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc -->
- [Introduction](#introduction)
- [Function](#function)
- [System Architecture](#system-architecture)
- [Hardware and Software Setup](#hardware-and-software-setup)
- [Required Hardware](#required-hardware)
- [Required Software](#required-software)
- [Hardware Connection](#hardware-connection)
- [User Manual](#user-manual)
- [Before Running This Application](#before-running-this-application)
- [Run This Application](#run-this-application)
- [Demo Video](#demo-video)
<!-- markdown-toc end -->

# Introduction
The intelligent monitoring device performs intelligent discrimination based on the sensor to collect motion information, and realizes abnormal posture recognition.
## Function
- **Shedding check mode**<br/>
The buzzer sounds an alarm when the sensor comes off.

![image](https://github.com/Zhaoyang95/Anti-lost_security_detection_system/blob/master/Screenshots/Shedding%20check.gif)
- **Posture detection mode**<br/>
The device can detect abnormal conditions such as human fall and being picked up.

![image](https://github.com/Zhaoyang95/Anti-lost_security_detection_system/blob/master/Screenshots/Posture%20detection_1.gif)
![image](https://github.com/Zhaoyang95/Anti-lost_security_detection_system/blob/master/Screenshots/Posture%20detection_2.gif)
- **GPS mode**<br/>
When the user exceeds the safe distance, the location information can be sent to the guardian's mobile phone.

![image](https://github.com/Zhaoyang95/Anti-lost_security_detection_system/blob/master/Screenshots/GPS%20mode.gif)
- **Wisdom broadcast mode**<br/>
When the user is lost, the voice mode can be switched with one button for playing the user's family information.

![image](https://github.com/Zhaoyang95/Anti-lost_security_detection_system/blob/master/Screenshots/Wisdom%20broadcast.gif)
## System Architecture
As shown in the figure below, the system consists of **three parts: input, master, and output**.
- The **input** includes a Bluetooth module, a GPS module and a JY901 nine-axis sensor module. The Bluetooth module receives the connection signal and sends it to the ARC processor; The JY901 module is responsible for detecting the motion state, The module mainly detects the acceleration change during motion and relative to the horizontal direction of the deflection condition; the GPS module is responsible for locating the user's location information and sending it to the master.
- The **master** is composed of an ARC processor. It mainly complete the processing of the data and complete the matching with the database according to the algorithm, and send the corresponding command to the output, the data processing includes through personalized calibration. Different people's movements have their own characteristics. Through personalized calibration, a database with posture characteristic information is established, which makes the system suitable for different users, and the user can customize according to individual usage.
- The **output** includes a voice synthesis module and a GPRS module. When the user exceeds the safety distance, the position information acquired by the GPS can be sent to the guardian mobile phone through the GPRS module to realize quick rescue and real-time positioning, and the family information can be reproduced in the form of voice. Convenient and timely contact with the guardian.
![image](https://github.com/Zhaoyang95/Anti-lost_security_detection_system/blob/master/Screenshots/Architecture.png)
# Hardware and Software Setup
## Required Hardware
- 1 DesignWare ARC EM Starter Kit(EMSK)
- 1 Posture sensor(JY-901)
- 1 Voice composite module(SYN6288)
- 1 Bluetooth module(E104-BT02)
- 1 GPS module(C3-470A)
- 1 GPRS module(SIM900A)
- 1 Buzzer
- 1 SD Card

## Required Software
- ARC GNU Toolset
- Serial port terminal, such as putty, tera-term or minicom

## Hardware Connection
1. The EMSK implement smart gloves,it will processe the data collected by sensors and translate gestures to corresponding sign language, we can get the corresponding sign language information by displaying text and making voice.
- Connect **Posture sensor** to **J1**(Using UART interface)
- Connect **Voice composite module** and **GPRS module** to **J2**(Using I2C interface)
- Connect **GPS module** to **J5**(Using UART interface)
- Connect **Buzzer** to **J3**(Using GPIO interface)
- Connect **Bluetooth module** to **J4**(Using I2C interface)
2. Configure your EMSKs with proper core configuration
- EMSK connection
![image](https://github.com/Zhaoyang95/Anti-lost_security_detection_system/blob/master/Screenshots/connection.jpg)

# User Manual
## Before Running This Application
Download source code of Anti-lost security detection system based on ARC processor from github.
- The hardware resources are allocated as following table.

| Hardware Resource | Functioon |
| ------------------ | ----------------------------- |
| JY-901 | Acceleration and angle sensor |
| E104-BT02 | Indoor Positioning |
| SYN6288 | Voice composite |
| C3-470A | position |
| SIM900A | send messages |

## Run This Application
Here take EMSK2.0 - ARC EM7D with GNU Toolset for example to show how to run this application.We need to use embARC bootloader to automatically load application binary for different EMSK and run. See embARC Secondary Bootloader Example for reference.
* Modify emsk_init.c (/board/emsk/common/emsk_init.c)
```
line 107: change
set_pmod_mux(mux_regs, PM1_UR_UART_0 | PM1_LR_SPI_S \
| PM2_I2C_HRI \
| PM3_GPIO_AC \
| PM4_I2C_GPIO_D \
| PM5_UR_SPI_M1 | PM5_LR_GPIO_A \
| PM6_UR_SPI_M0 | PM6_LR_GPIO_A );
to
set_pmod_mux(mux_regs, PM1_UR_UART_0 | PM1_LR_GPIO_A \
| PM2_I2C_HRI \
| PM3_GPIO_AC \
| PM4_I2C_GPIO_D \
| PM5_UR_SPI_M1 |PM5_LR_SPI_M2 \
| PM6_UR_SPI_M0 | PM6_LR_GPIO_A );
```
### Makefile
- Target options about EMSK and toolchain

```
BOARD ?= emsk
BD_VER ?= 22
CUR_CORE ?= arcem7d
TOOLCHAIN ?= gnu
```
- The relative series of the root directory, here the path of the Makefile is
```
#
# root dir of embARC
#
EMBARC_ROOT = ../../..
MID_SEL = common
```
See [ embARC Example User Guide][40], "Options to Hard-Code in the Application Makefile" for more detailed information about Makefile Options

- Driver<br/>
Placing the drivers' source code in driver folder, you can see there are subfolders for data,buletooth,buzzer,gps and gprs drivers. Placing the C source file and header file in the corresponding subfolder.

| folder/file | Function |
| ---------------- | --------------------------------------------------------- |
| data | get and deal with data from sensor |
| buletooth | Receive a connection signal and send it to the processor |
| gprs | send position information |
| buzzer | Sensor drop alarm |
| gps | Detect location information |

# Demo Video
[Link](https://v.youku.com/v_show/id_XNDI4NjQ0NTQxMg==.html?spm=a2h3j.8428770.3416059.1)


[40]: http://embarc.org/embarc_osp/doc/embARC_Document/html/page_example.html " embARC Example User Guide"


Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/* ------------------------------------------
* \version 2016-01
* \date 2019-05-20
* \author Jinyu Yang
* \function蓝牙定位模块
--------------------------------------------- */
#include <embARC.h>
#include "embARC_debug.h"
#include "embARC_toolchain.h"
#include "embARC_error.h"
#include "board.h"
#include "dev_uart.h"
#include <string.h>
#include "dev_iic.h"
#define I2C_SLAVE_ADDR2 0x02
DEV_IIC *dev_iicble=NULL;

//DEV_UART *dev_uart2 = NULL;
static void delay_ms(volatile int z) //1ms
{
volatile uint32_t x,y;
for(x=1400;x>0;x--)
for(y=z;y>0;y--);
}
int ble_comeback(char re_buf[15])
{
int ble_state;
if (re_buf[0]=='<')
if(re_buf[1]=='C')
ble_state=2;
else
ble_state=1;
return ble_state;
}

int ble(void)
{
char rcv_buf[15];
uint32_t rcv_cnt;
uint32_t rd_avail;
uint32_t baudrate =19200;//bt02
int8_t *cmd={"<STATE>"};
int8_t *cmdbk={"<DISCONNECTED>"};
int8_t state;
unsigned int i;


dev_iicble = iic_get_dev(DW_IIC_1_ID );
dev_iicble->iic_open(DEV_MASTER_MODE, IIC_SPEED_STANDARD);
dev_iicble->iic_control(IIC_CMD_MST_SET_TAR_ADDR, CONV2VOID(I2C_SLAVE_ADDR2));
delay_ms(200);
// blue init
for(i=0;i<2;i++)
{
dev_iicble->iic_write(cmd,strlen(cmd));
dev_iicble->iic_read(rcv_buf, 15);

state=ble_comeback(rcv_buf);

EMBARC_PRINTF("data is %s\r\n",rcv_buf);
EMBARC_PRINTF("state is %d\r\n",state);
//EMBARC_PRINTF("i is %d\r\n",i);


delay_ms(10);
}

return state;
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#ifndef _BLE_H_
#define _BLE_H_
extern int ble(void);
#endif /* _BLE_H_ */
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "embARC.h"
#include "embARC_debug.h"
#include "stdio.h"
#include "arc.h"
DEV_GPIO_PTR port_alarm;


static void delay_ms(volatile int z) //1ms
{
volatile uint32_t x,y;
for(x=1400;x>0;x--)
for(y=z;y>0;y--);
}

void beep(void)
{


port_alarm = gpio_get_dev(DW_GPIO_PORT_A);
port_alarm->gpio_open(0x10000);
port_alarm->gpio_control(GPIO_CMD_SET_BIT_DIR_OUTPUT, (void *)0x10000);


port_alarm->gpio_write(0x00000, 0x10000);
delay_ms(8000);
port_alarm->gpio_write(0x10000, 0x10000);
delay_ms(11000);
EMBARC_PRINTF("beep \r\n");

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef _BUZZER_H_
#define _BUZZER_H_

extern void beep(void);
static void delay_ms(volatile int z);

#endif /* _BUZZER_H_ */
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/* ------------------------------------------
* \version 2016-01
* \date 2019-05-20
* \author Renjie Cao
* \functionJY901模块
--------------------------------------------- */
#include "embARC.h"
#include "embARC_debug.h"
#include "embARC_toolchain.h"
#include "embARC_error.h"
#include "board.h"
#include "dev_uart.h"



unsigned char ucStra[6],ucStrw[6],ucStrAngle[6];
double aValue[3];
double wValue[3];
double AValue[3];
DEV_UART *dev_uart0 = NULL;

void mpu6050_isr(unsigned char ucstra[6] ,unsigned char ucStrw[6],unsigned char ucStrAngle[6],uint8_t Re_buf[33])
{
if(Re_buf[0]!=0x55) return; //第0号数据不是帧头
//重新赋值,准备下一帧数据的接收
switch(Re_buf [1])
{
case 0x51:
ucStra[0]=Re_buf[2];
ucStra[1]=Re_buf[3];
ucStra[2]=Re_buf[4];
ucStra[3]=Re_buf[5];
ucStra[4]=Re_buf[6];
ucStra[5]=Re_buf[7];
break;
}

switch(Re_buf [12])
{
case 0x52:
ucStrw[0]=Re_buf[13];
ucStrw[1]=Re_buf[14];
ucStrw[2]=Re_buf[15];
ucStrw[3]=Re_buf[16];
ucStrw[4]=Re_buf[17];
ucStrw[5]=Re_buf[18];
break;
}
switch(Re_buf [23])
{
case 0x53:
ucStrAngle[0]=Re_buf[24];
ucStrAngle[1]=Re_buf[25];
ucStrAngle[2]=Re_buf[26];
ucStrAngle[3]=Re_buf[27];
ucStrAngle[4]=Re_buf[28];
ucStrAngle[5]=Re_buf[29];
break;
}

}


static void delay_ms(volatile int z) //1ms
{
volatile uint32_t x,y;
for(x=1400;x>0;x--)
for(y=z;y>0;y--);
}

void data0(double aValue[3],double wValue[3],double AValue[3],double *Z1,double *AWM,double *A1,double *A2)
{
uint8_t rcv_buf[33];
unsigned int j;
uint32_t rcv_cnt;
uint32_t baudrate =230400 ;
uint32_t rd_avail = 0;

dev_uart0 = uart_get_dev(DW_UART_0_ID);
dev_uart0->uart_open(baudrate);
dev_uart0->uart_control(UART_CMD_GET_RXAVAIL, (void *)(&rd_avail));

if(rd_avail > 0){
rcv_cnt = dev_uart0->uart_read(rcv_buf, rd_avail);
if (rcv_cnt) {
mpu6050_isr(ucStra,ucStrw,ucStrAngle,rcv_buf);
aValue[0] = ((short)(ucStra[1]<<8| ucStra[0]))/32768.0*16;
aValue[1] = ((short)(ucStra[3]<<8| ucStra[2]))/32768.0*16;
aValue[2] = ((short)(ucStra[5]<<8| ucStra[4]))/32768.0*16;
printf("{%4.3f,%4.3f,%4.3f,",aValue[0],aValue[1],aValue[2]);

*Z1 = aValue[2];
*AWM = aValue[0]*aValue[0]+aValue[1]*aValue[1]+aValue[2]*aValue[2];
printf("AWM:%4.3f,",*AWM);

wValue[0] = ((short)(ucStrw[1]<<8| ucStrw[0]))/32768.0*2000;
wValue[1] = ((short)(ucStrw[3]<<8| ucStrw[2]))/32768.0*2000;
wValue[2] = ((short)(ucStrw[5]<<8| ucStrw[4]))/32768.0*2000;
//printf("%4.3f,%4.3f,%4.3f,",wValue[0],wValue[1],wValue[2]);

AValue[0] = ((short)(ucStrAngle[1]<<8| ucStrAngle[0]))/32768.0*180;
AValue[1] = ((short)(ucStrAngle[3]<<8| ucStrAngle[2]))/32768.0*180;
AValue[2] = ((short)(ucStrAngle[5]<<8| ucStrAngle[4]))/32768.0*180;
// printf("%4.2f,%4.2f,%4.2f},\r\n",AValue[0],AValue[1],AValue[2]);
*A1=AValue[0];
*A2=AValue[1];
printf("A1:%4.3f,",*A1);
printf("A2:%4.3f,\r\n",*A2);
}
}
}





Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#ifndef _DATA_H_
#define _DATA_H_
extern void data0(double aValue[3],double wValue[3],double AValue[3],double *Z1,double *AWM,double *A1,double *A2);
#endif /* _DATA_H_ */
Loading