基于ARM9 的三轴加速度传感器动作识别装置设计

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

基于ARM9 的三轴加速度传感器动作识别装置设计
摘要:该装置以ARM9为核心,采用linux操作系统,驱动飞思卡尔的三轴陀螺仪mma7660fc 传感器采集外部动作的数据。

加以算法分析处理,即可得到方向的角度变化、震动、敲击的外部信息。

该装置可用于MP3、PDA、MID、智能手机等各种手持电子设备的人性化智能控制。

关键字:三轴加速度传感器、linux操作系统、ARM9
ARM9-based three-axis acceleration sensor device designed to identify the action
Abstract:The device to ARM9 core, using linux operating system, drivers of
three-axis gyroscope mma7660fc Freescale sensor data acquisition external action. To algorithm analysis and processing, can be obtained by changing the angle of orientation, vibration, percussion external information. The device can be used for MP3, PDA, MID, smart phones and other handheld electronic devices, human intelligent control.
Keywords: three-axis accelerometer, linux operating system, ARM9
0 引言
随着电子消费品性能和功能的不断发展,消费者对产品的各种人性化的操作的需求也不断提高,因此,在手持设备等便携电子产品上使用各种智能传感器采集外部各种信息,并用于完善设备本身功能的控制,使其更加人性化,具有现实意义。

1 装置概述
该装置由ARM9处理器结合linux操作系统,通过i2c总线驱动,获取ma7660fc采集外部动作:设备被转动方向的变化和角度的大小,和速度的快慢,震动或被敲击的数据,并进行适当的算法处理,提取出有用的控制信息。

其硬件原理图如图1所示,其软件系统结构如图2所示。

图1 I2C connection to MCU
3 软件设计
3.1 驱动核心代码分析
……
static struct timer_list *sensor_timer;
static struct work_struct sensor_work_q;
……
//定时器中断服务程序
static void sensor_timer_handler(unsigned long data)
{
//调度工作队列
if (schedule_work(&sensor_work_q) == 0) {
sensor_dbg("cannot schedule work !!!\n");
}
}
……
//注册一个内核定时器
static void sensor_timer_registertimer(struct timer_list* ptimer, unsigned int timeover )
{
init_timer(ptimer);
ptimer->expires = jiffies+msecs_to_jiffies(timeover);
ptimer->data = (unsigned long)NULL;
ptimer->function = sensor_timer_handler;
add_timer(ptimer);
}
……
//定时器中断底半部处理函数
static void sensor_fetch_thread(struct work_struct *work)
{
mma7660_sensor_get_accel();
sensor_timer_registertimer( sensor_timer, sensor_duration );
}
int __init tcc_sensor_init(void)
{
……
//初始化工作队列并将工作队列与处理函数绑定
INIT_WORK(&sensor_work_q, sensor_fetch_thread);
return 0;
}
3.2测试应用程序分析
……
#include<linux/i2c.h>
#include<linux/i2c-dev.h>
……
int main(int argc, char ** argv)
{
//打开设备文件
fd = open(/dev/sensor,O_RDWR);
……
//读数据xyz数据
ret = read(fd,&calib_data,sizeof(calib_data));
……
//读取加速度数据
ioctl(fd,IOCTL_SENSOR_GET_DATA_ACCEL,&accel);
……
//设置采样时间
ioctl(fd,IOCTL_SENSOR_SET_DELAY_ACCEL,&delay_time);
……
//读取驱动状态标志位
ioctl(fd,IOCTL_SENSOR_GET_STATE_ACCEL,&accel.resolution);
……
//设置加速度值
ioctl(fd,IOCTL_SENSOR_SET_CALIB_ACCEL,&accel);
……
//设置状态标志位
ioctl(fd,IOCTL_SENSOR_SET_STATE_ACCEL,&set_state_flag);
……
}
图2 Linux I2C 体系结构
参考文献:
【1】宋宝华设备驱动开发详解(第二版)
【2】Linux设备驱动程序(第三版)
【3】3-Axis Orientation/Motion Detection Sensor data sheetsheet of Freescale Semiconductor。

相关文档
最新文档