Skip to content

Commit c894211

Browse files
author
Wayne Ren
authored
Merge pull request #12 from dbHu/master
Contribute HUST_Invert-pendulum-mobile-robot Application to embARC Applications
2 parents e9c3615 + 8cc105c commit c894211

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+25189
-0
lines changed
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
# mobile_inverted_pendulum_robots
2+
This application, which implements a mobile inverted pendulum robots, is designed to show how to develop a **Motion Control** using embARC.
3+
VIDEO URL: [DEMO VIDEO][14]
4+
5+
* [Introduction](#introduction)
6+
* [Function](#function)
7+
* [System Architecture](#system-architecture)
8+
* [Hardware and Software Setup](#hardware-and-software-setup)
9+
* [Required Hardware](#required-hardware)
10+
* [Required Software](#required-software)
11+
* [Hardware Connection](#hardware-connection)
12+
* [User Manual](#user-manual)
13+
* [Before Running This Application](#before-running-this-application)
14+
* [Run This Application](#run-this-application)
15+
16+
## Introduction
17+
This project was successful in achieving a two-wheeled autonomous robot based on the inverted pendulum model.EMSK works as controller, it will deal with sensor datas and interact with user via bluetooth. We can view all data on serial terminal, and sent instructions to the robot to change its motion mode.
18+
19+
### Function
20+
- **Upright**
21+
The robot can keep itself upright even if there is a great disturbances.
22+
[![upright.gif](https://s8.postimg.cc/4lsw5oi1h/upright.gif)](https://postimg.cc/image/6qd96rjo1/)
23+
- **Linear Motion**
24+
Under upright condition, the robot has excellent ability to linear motion.
25+
[![linear_motion.gif](https://s8.postimg.cc/fwvjtyovp/linear_motion.gif)](https://postimg.cc/image/gmec6bpf5/)
26+
- **Angular Rotation**
27+
Not only linear motion, but also angular rotation can be implemented.
28+
[![angular_rotation.gif](https://s8.postimg.cc/6qd96m6rp/angular_rotation.gif)](https://postimg.cc/image/jhrfd4gjl/)
29+
- **Over the Seesaw**
30+
Based on the above, the robot can autonomously through the seesaw
31+
[![over_the_seesaw.gif](https://s8.postimg.cc/wlwzpvt6t/over_the_seesaw.gif)](https://postimg.cc/image/hd72c3zi9/)
32+
33+
### System Architecture
34+
![system architecture][4]
35+
36+
## Hardware and Software Setup
37+
### Required Hardware
38+
- 1 [DesignWare ARC EM Starter Kit(EMSK V2.3)][5]
39+
- 2 [BLE module(HC-05)][6]
40+
- 1 [USB To TTL module(CP2102)][7]
41+
- 1 [IMU module(MPU6050)][8]
42+
- 1 [Motor Driver][9]
43+
- 1 [Voltage Conversion module(7805)][10]
44+
- 1 NiCd Battery
45+
- 1 SD Card
46+
- 1 SPI to QEI AND PWM Expanding-board
47+
- 1 Robot Platform
48+
![Robot Platform][11]
49+
### Required Software
50+
- ARC GNU Toolset 2017.03
51+
- Serial port terminal, such as putty, tera-term or minicom
52+
53+
### Hardware Connection
54+
1. Connect BLE HC-05 module to Pmod J1(Using UART interface)
55+
2. Connect IMU MPU6050 module to Pmode J2(Using I2C interface)
56+
3. Connect Expansion Board to Pmode J6, J5(Using J6 SPI interface, J5 using for mechanical fixing)
57+
58+
## User Manual
59+
### Before running this application
60+
Download source code of invert-pendulum from github, and ensure install a serial port terminal and arc-gnu toolset in your PC.
61+
The hardware resources are allocated as following table.
62+
63+
| Hardware resource | Function |
64+
|-------------------|-----------------------------------|
65+
| MPU6050 | Gyroscope and acceleration sensor |
66+
| HC-05 | Provide bluetooth connection |
67+
| CP2102 | USB TO TTL |
68+
| MC7805 | Linear Voltage Regulator |
69+
| ROBOTS PLATFORM | integrated module |
70+
71+
### Run This Application
72+
Here take EMSK2.3, CUR_CORE = arcem7d with GNU Toolset for example to show how to run this application.
73+
1. We need to use embARC 2nd bootloader to automatically load application binary for different EMSK and run. See **example/bootloader Example** for reference.
74+
2. Open your serial terminal such as Tera-Term on PC, and configure it to right COM port and 115200bps.
75+
3. Interact using EMSK and serial port terminal.
76+
77+
#### makefile
78+
- Selected FreeRTOS in **/application/invered_pendulum/scr/makefile**, then you can use [FreeRTOS API][13] in your application:
79+
80+
#Selected OS
81+
OS_SEL ?= freertos
82+
83+
- Target options about EMSK and toolchain:
84+
85+
BOARD ?= emsk
86+
BD_VER ?= 23
87+
CUR_CORE ?= arcem7d
88+
TOOLCHAIN = gnu
89+
90+
- The relative series of the root directory, here the path of the makefile is
91+
**/application/invered_pendulum/scr/makefile**:
92+
93+
#
94+
# root dir of embarc
95+
#
96+
EMBARC_ROOT = ../../../..
97+
98+
- Directories of source files and header files, notice that it **is not recursive**:
99+
100+
# application source dirs
101+
APPL_CSRC_DIR = . ./TskDbg ./Queue ./TskMotor ./drivers ./TskTop ./FastMath_Table
102+
APPL_ASMSRC_DIR = .
103+
104+
# application include dirs
105+
APPL_INC_DIR = . ./TskDbg ./Queue ./TskTop ./drivers ./TskMotor ./FastMath_Table
106+
107+
See [embARC Example User Guide][14], **"Options to Hard-Code in the Application Makefile"** for more detailed information about **Makefile Options**.
108+
109+
#### Driver
110+
Placing the drivers' source code in **application/invered_pendulum/scr/drivers** folder, C source and header file in the folder.
111+
112+
| file | Function |
113+
|-----------------|---------------------------------------------|
114+
| imu.c/imu.h | get imu sensor data(int16_t raw data) |
115+
| spi.c/spi.h | transfer qei data(int16_t) and pwm(int16_t) |
116+
| timer.c/timer.h | Timer 1,2ms interrupt for motroTick |
117+
118+
#### FastMath_Table
119+
The **FastMath_Table** is used to fast atan function, ranging in -0.98rad~0.45rad(table data is 1024 times of actual angle).The table index is
120+
equal to tangent value enlarges 128 times and add 192.
121+
122+
/*
123+
* n = m << 7 + 192, y = round(x << 10)
124+
* m: tangent value
125+
* n: array index
126+
* x: atan(m)
127+
* y: array[n]
128+
*/
129+
130+
#### Queue
131+
The **Queue** realizes queue functions through linear table, type:char or int.
132+
133+
QueueInit
134+
QueueClear
135+
QueueLength
136+
EnQueue
137+
DeQueue
138+
Drawback: it implement queue by arrays, which will waste memory space and
139+
fix data type.
140+
141+
#### TskDbg
142+
The **TskDbg** mainly uses for UART transmission.
143+
144+
| file | Function |
145+
|---------------------|-----------------------------|
146+
| cmd.c/cmd.h | interact with user |
147+
| dbgUart.c/dbgUart.h | uart transfer and uart Task |
148+
149+
### TskMotor
150+
The **TskMotor** completes data processing and algorithm application.
151+
152+
#### Other
153+
The file **algorithm.s** implements algorithms through assembly instructions.
154+
The file **assert.c** is useful to handling exceptions.
155+
The file **physParmas.h** contains macro define for data factor and customize typedef struct.
156+
157+
158+
[0]: ./doc/screenshot/upright.gif "upright"
159+
[1]: ./doc/screenshot/linear_motion.gif "linear motion"
160+
[2]: ./doc/screenshot/angular_rotation.gif "angular rotation"
161+
[3]: ./doc/screenshot/over_the_seesaw.gif "over the seesaw"
162+
[4]: ./doc/screenshot/system.svg "system architecture"
163+
[5]: https://www.synopsys.com/dw/ipdir.php?ds=arc_em_starter_kit "DesignWare ARC EM Starter Kit(EMSK)"
164+
[6]: http://www.electronics-lab.com/?s=HC-05 "BLE HC-05 module"
165+
[7]: https://www.sparkfun.com/products/retired/198 "USB To TTL module"
166+
[8]: http://playground.arduino.cc/Main/MPU-6050 "IMU MPU6050 module"
167+
[9]: http://www.landzo.cn/forum.php?mod=viewthread&tid=10541&extra=page%3D1&page=1 "Motor Driver"
168+
[10]: http://www.electronics-lab.com/?s=7805 "Voltage Conversion 7805 module"
169+
[11]: ./doc/screenshot/Platform.jpg "Robot Platform"
170+
[12]: https://www.freertos.org/a00106.html "FreeRTOS API"
171+
[13]: http://embarc.org/embarc_osp/doc/embARC_Document/html/page_example.html " embARC Example User Guide"
172+
[14]: http://v.youku.com/v_show/id_XMzYzMDkzNzg3Ng==.html?spm=a2h3j.8428770.3416059.1
173+
174+
31.2 KB
Loading
33 KB
Loading
72.7 KB
Loading
25 KB
Loading
29.1 KB
Loading
38.3 KB
Loading
17.3 KB
Loading
9.27 KB
Loading
11.2 KB
Loading

0 commit comments

Comments
 (0)