Skip to content
Merged
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
11 changes: 11 additions & 0 deletions arc_design_contest/2018/XDU_Autofollowing_suitcase/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Copyright (c) 2016, Synopsys, Inc. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3) Neither the name of the Synopsys, Inc., nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
147 changes: 147 additions & 0 deletions arc_design_contest/2018/XDU_Autofollowing_suitcase/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# Auto-following Suitcase Application
This application is designed to show how to develop an **Auto-following Suitcase** using embARC.A person holding a tag in hand,three ultra-wideband anchors should be installed inside the suitcase in an equilateral triangular shape with a side length of 20cm. The distance information measured by the UWB module is transmitted to EMSK through UART.Based on the principle of three-point positioning,the azimuth between the person and the suitcase can be obtained to achieve following.This suitcase can also monitor ambient temperature and air conditions.When the distance between the trunk and the owner exceed the preset ,the trunk will stop automatically,and then sound the alarm or call the mobile phone, so you don't have to worry about losing the trunk.This design is mainly suitable for flat and open indoor applications such as airport waiting halls.

* [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)
* [DemoVideo](#demovideo)

## Introduction
**Smart Auto-following Suitcase**

### Function

- **Ambient temperature and air condition monitoring**

![image](https://github.com/Mandywualmighty/Auto-following-Suitcase-Application/blob/master/doc/screenshots/Temperature%20and%20PM2.5%20monitoring.png "Temperature and PM2.5 monitoring" )

- **obstacle avoiding**

![image](https://github.com/Mandywualmighty/Auto-following-Suitcase-Application/blob/master/doc/screenshots/obstacle%20avoiding.gif "obstacle avoiding")

- **Auto-following**

![image](https://github.com/Mandywualmighty/Auto-following-Suitcase-Application/blob/master/doc/screenshots/Auto%20following.gif "Auto-following")

- **Auto-alarm** (The device will sound the alarm when the distance between one and suitcase is longer than 4 meters, and call the mobile phone when it is longer than 5.5 meters)

![image](https://github.com/Mandywualmighty/Auto-following-Suitcase-Application/blob/master/doc/screenshots/Auto-alarm.gif)


### System Architecture

![image](https://github.com/Mandywualmighty/Auto-following-Suitcase-Application/blob/master/doc/screenshots/System%20architecture.png "System architecture")

## Hardware and Software Setup
### Required Hardware
- 1 DesignWare ARC EM Starter Kit(EMSK)
- 1 Digilent PMOD TMP2
- 1 Dust Sensor(ZPH01)
- 1 Display Screen(OLED)
- 1 Buzzer
- 1 GPRS Module(SIM900A)
- 2 Motor Driver Module(TB6612FNG)
- 4 Positioning Module(DWM1000)
- 4 Wheel
- 4 Motor
- 1 SD Card
- 3 Ultrasonic Sensor(HCSR04)

The list of hardware is shown in the picture following.

![image](https://github.com/Mandywualmighty/Auto-following-Suitcase-Application/blob/master/doc/screenshots/hardware.png)

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

### Hardware Connection
1. The EMSK implement **Auto-folowing** smart device, it will process the data returned by positioning module and ultrasonic sensor,and send instructions to motor driver module.It can also monitor temperature and dust concentration of air,we can view these data on OLED.
- Connect **Positioning module** to **J1**(Using UART interface), connect **Motor driver module** to **J3** and **J6**,connect **Ultrasonic sensor** to **J1** and **J3**.
- Connect **PMOD TMP2** to **J4**(Using IIC interface), connect **ZPH01** to **J5**(Using uart interface),connect **OLED** and **GPRS** to **J2**(Using IIC interface),connect **Buzzer** to **J6**.
2. Configure your EMSKs with proper core configuration.

## User Manual
### Before Running This Application
Download source code of **Auto-following Suitcase** from github.

The hardware resources are allocated as following table.

| Hardware Resource | Function |
| ------------------- | ------------------------------------------------------------- |
| PMOD TMP2 | Temperature sensor |
| ZPH01 | Dust sensor |
| OLED | Display screen |
| SIM900A | Send messages or call |
| TB6612FNG | Motor driver module |
| HCSR04 | Dust sensor |
| OLED | Ultrasonic sensor |
| DWM1000 | Positioning module |

- Modify mux.c (/board/emsk/common/emsk_init.c)
```
line 107: change
set_pmod_mux(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_GPIO_C | PM5_LR_SPI_M2 \
| PM6_UR_GPIO_C | PM6_LR_GPIO_A );
```
### Run This Application

Here take **EMSK2.2 - ARC EM7D** with GNU Toolset for example to show how to run this application.

#### 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 u8glib


See [ embARC Example User Guide][40], **"Options to Hard-Code in the Application Makefile"** for more detailed information about **Makefile Options**.

#### Driver

Placing the drivers' source code in `driver` folder, you can see there are subfolders for ultasonic,GPRS,ZPH01,buzzer and temperature drivers.
Placing the C source file and header file in the corresponding subfolder.

| folder/file | Function |
| ------------------- | ------------------------------|
| ultrasonic | ultrasonic driver |
| temperature | temperature driver |
| GPRS | GPRS driver |
| ZPH01 | ZPH01 driver |
| buzzer | buzzer driver |


# DemoVideo

[Link](https://v.youku.com/v_show/id_XMzYyOTY0MjcwMA==.html?x&sharefrom=android&sharekey=47f57584b11aa1e3916e149dc1b044aa0)

[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.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#include "embARC.h"
#include "embARC_debug.h"
#include "stdio.h"
#include <string.h>
#include "arc.h"
#include "GPRS.h"
#define I2C_SLAVE_ADDR2 0x01
DEV_IIC *dev_iic_gprs=NULL;
uint8_t *phoneNum = "00310038003700300030003800310033003000360031";
uint8_t *msg = "4E3B4EBAFF0C4E3B4EBAFF0C621189818DDF4E224F604E86";

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 call(void)
{

dev_iic_gprs = iic_get_dev(DW_IIC_0_ID);
dev_iic_gprs->iic_open(DEV_MASTER_MODE, IIC_SPEED_STANDARD);
dev_iic_gprs->iic_control(IIC_CMD_MST_SET_TAR_ADDR, CONV2VOID(I2C_SLAVE_ADDR2));
uint8_t i;
int8_t *cmd[2]={"ATD18829283316;\r\n",};
for(i = 0; i < 4; i++)
{
dev_iic_gprs->iic_write(cmd[i], strlen(cmd[i]));
delay_ms(100);
}
uint8_t end[]={0x1a,0x00};
dev_iic_gprs->iic_write(end, strlen(end));
printf("end1\r\n");

}

void send(uint8_t *phoneNum, uint8_t *msg)
{
dev_iic_gprs = iic_get_dev(DW_IIC_0_ID );
dev_iic_gprs->iic_open(DEV_MASTER_MODE, IIC_SPEED_STANDARD);
dev_iic_gprs->iic_control(IIC_CMD_MST_SET_TAR_ADDR, CONV2VOID(I2C_SLAVE_ADDR2));

uint8_t i;
uint8_t pnum[64];
int8_t *cmd[5]={"AT+CMGF=1\r\n", "AT+CSCS=\"UCS2\"\r\n",
"AT+CSCA?\r\n", "AT+CSMP=17,167,0,25\r\n",};
snprintf(pnum, 64, "AT+CMGS=\"%s\"\r\n", phoneNum);
for(i = 0; i < 4; i++)
{
dev_iic_gprs->iic_write(cmd[i], strlen(cmd[i]));
delay_ms(100);
}
dev_iic_gprs->iic_write(pnum, strlen(pnum));
delay_ms(100);
dev_iic_gprs->iic_write(msg, strlen(msg));
delay_ms(100);
uint8_t end[]={0x1a,0x00};
dev_iic_gprs->iic_write(end, strlen(end));
printf("end\r\n");
}

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

static void delay_ms(volatile int z);
extern void call(void);
extern void send(uint8_t *phoneNum, uint8_t *msg);
#endif /* _GPRS_H_ */
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include "embARC.h"
#include "embARC_debug.h"
#include "stdio.h"
#include "arc.h"
#include "ZPH01.h"
DEV_UART *dev_uart2 = NULL;

void uart2_init(void)
{
uint32_t baudrate1 = 9600;
dev_uart2 = uart_get_dev(DW_UART_2_ID);
dev_uart2->uart_open(baudrate1);
}

uint32_t receive_pm(void)
{
uint8_t rcv_buf[9];
uint8_t PPM[4];

uint16_t p = 0;
uint16_t p1 = 0;
float mconcentration;
uint32_t rcv_cnt;
uint32_t i = 0;
uint32_t baudrate1 = 9600;
uint32_t rd_avail = 0;
uint8_t*mm;
dev_uart2->uart_control(UART_CMD_GET_RXAVAIL, (void *)(&rd_avail));
if(rd_avail > 0){
rcv_cnt = dev_uart2->uart_read(rcv_buf, rd_avail);
if((rcv_buf[0]==0xff)&&(rcv_buf[1]==0x18))
{
mconcentration=((float)(rcv_buf[3])+((float)(rcv_buf[4]))/100.0)*20;
p=(uint16_t)mconcentration;
p1=p;
PPM[0] =p / 1000 + '0';
p= p % 1000;
PPM[1] = p / 100 + '0';
p = p % 100;
PPM[2] = p/ 10 + '0';
PPM[3] = p % 10 + '0';
mm=PPM;
// printf("ppm=%s\r\n", mm);
}
}
return p1;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef _ZPH01_H_
#define _ZPH01_H_


extern void uart2_init(void);
extern uint32_t receive_pm(void);

#endif /* _ZPH01_H_ */
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include "embARC.h"
#include "embARC_debug.h"
#include "stdio.h"
#include "arc.h"
#include "buzzer.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_C);
port_alarm->gpio_open(0x10000000);
port_alarm->gpio_control(GPIO_CMD_SET_BIT_DIR_OUTPUT, (void *)0x10000000);

port_alarm->gpio_write(0x10000000, 0x10000000);
delay_ms(1000);
port_alarm->gpio_write(0x00000000, 0x10000000);
delay_ms(1000);
EMBARC_PRINTF("beep");

}

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


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

#endif /* _BUZZER_H_ */
Loading