计步器外文

合集下载

arduino计步器原理

arduino计步器原理

arduino计步器原理摘要:1.Arduino 简介2.Arduino 计步器的原理3.Arduino 计步器的应用实例4.Arduino 计步器的发展前景正文:一、Arduino 简介Arduino 是一款易于上手的开源电子原型平台,适用于各种电子制作项目。

它包括多种不同型号的硬件开发板和相应的软件开发环境。

Arduino 语言是以setup() 开头,loop() 作为主体的一个程序构架。

setup() 用来初始化变量、管脚模式、调用库函数等等,该函数只运行一次,功能类似C 语言中的main()”。

loop() 函数是一个循环执行的函数,可以实现设备的持续运行。

二、Arduino 计步器的原理Arduino 计步器是一种基于Arduino 开发板的步数计算设备。

它的原理是利用内置的加速度传感器(如ADXL33)来检测用户的步行姿势和加速度变化,通过计算这些数据来得出步数。

一般来说,Arduino 计步器需要连接到用户的身体上,例如佩戴在手腕上,以便准确地检测到步行动作。

三、Arduino 计步器的应用实例Arduino 计步器可以广泛应用于各种场景,例如运动健身、日常出行等。

通过记录用户的步数,用户可以更好地了解自己的运动状况,从而调整运动计划。

同时,Arduino 计步器也可以与其他设备相连接,如手机、电脑等,以便用户随时查看自己的运动数据。

除此之外,Arduino 计步器还可以与其他传感器相结合,如心率传感器、血压传感器等,从而构建出更为完整的个人健康监测系统。

四、Arduino 计步器的发展前景随着人们对健康的重视程度不断提高,Arduino 计步器的市场需求也在逐步增加。

在未来,随着技术的不断发展,Arduino 计步器将会变得更加小巧轻便、功能强大,并且能够更好地与各种智能设备相结合,为用户提供更为全面和准确的健康数据。

计步器发展

计步器发展

计步器发展简介计步器(Pedometer)是一种测量个人每天行走步数和距离的设备。

它通常由一个加速度传感器和一系列算法组成,可以准确地计算出用户步行的步数和行走的距离。

计步器最早起源于20世纪70年代的日本,当时被称为“计步器表”。

随着科技的发展,计步器不断演进并逐渐成为了现代健康追踪的重要工具。

早期计步器早期的计步器采用简单的机械结构,通过计数机械零件的摆动来记录步数。

这些计步器通常需要佩戴在腰部或脚踝附近,通过摆动机械部件来感知用户的步伐。

然而,早期计步器存在着精确性不高的问题。

受制于机械结构的局限性,这些计步器容易受到其他运动或震动的干扰,导致步数计算不准确。

电子计步器的出现随着电子技术的进步,电子计步器开始逐渐取代机械计步器。

电子计步器采用了更先进的传感器和计算算法,能够更准确地监测用户的步频和步幅。

电子计步器通常配备加速度传感器,可以感知用户的运动状态。

通过记录加速度变化的频率和幅度,电子计步器可以计算出用户的步数和行走距离。

此外,电子计步器还可以提供更多的健康追踪功能。

它们可以通过接入手机应用程序或电脑软件,将数据进行同步和分析,以便用户更好地了解自己的运动状态和健康状况。

智能计步器的兴起随着智能手机和可穿戴设备的普及,智能计步器成为了一种新的趋势。

与传统计步器相比,智能计步器不仅仅可以计算步数和行走距离,还能提供更多的功能和服务。

智能计步器通常配备了更高级的传感器和计算能力,可以监测用户的心率、睡眠质量、消耗的卡路里等健康指标。

而且,它们通常可以与手机应用或其他健康管理平台进行连接,将数据进行同步和分析。

此外,智能计步器还具有更多的功能,如通知提醒、音乐控制、导航等。

它们成为了现代人追求健康生活和精致生活的必备配件。

未来发展趋势计步器作为健康追踪工具的重要一环,在未来将继续发展和演进。

首先,随着传感器技术的不断进步,计步器的精确性将得到进一步提升。

传感器可以更准确地感知用户的运动状态和身体指标,提供更精准的数据。

欧姆龙计步器的原理

欧姆龙计步器的原理

欧姆龙计步器的原理Omron pedometers are devices designed to track the number of steps taken by an individual throughout the day. These devices work on the principle of a built-in accelerometer that detects movement and converts it into step counts. 它们可以记录您的步数、距离和卡路里消耗,从而帮助您追踪自己的运动量和健康状况。

欧姆龙计步器通过内置的加速计感应器来检测身体的运动,将这些运动转换为步数。

One of the key components of an Omron pedometer is the accelerometer, which is a sensitive device that measures acceleration caused by movement. When you walk or run, the accelerometer detects the changes in acceleration and translates them into step counts. 这些计步器通常具有高灵敏度的加速计,可以检测到由您身体的运动所引起的加速度变化,从而精确计算出您的步数。

In addition to step counting, Omron pedometers may also feature other functions such as distance tracking and calorie counting. These additional features provide users with a more comprehensive overview of their daily physical activity levels. 用户还可以通过这些功能查看他们每天所走的距离和消耗的卡路里,从而更全面地了解自己的日常身体活动量。

蓝牙计步器 蓝牙4.0计步器

蓝牙计步器 蓝牙4.0计步器

健康安全一站式解决方案提供商深圳市易兴光电科技有限公司地址:广东深圳市龙华镇赖屋山村三和工业中心2栋3楼公司主页:健康安全一站式解决方案提供商深圳市易兴光电科技有限公司 地址:广东深圳市龙华镇赖屋山村三和工业中心2栋3楼 公司主页: Bluetooth 2.1+EDR 技术为了改善蓝牙技术存在配置流程复杂和设备功耗较大的问题,2009年蓝牙SIG 组织(Special Interest Group )推出了Bluetooth 2.1+EDR 版本的蓝牙技术。

1. 改善装置配对流程:由于有许多使用者在进行硬件之间的蓝牙配对时,会遭遇到许多问题,不管是单次配对,或者是永久配对,在配对的过程与必要操作过于繁杂,以往在连接过程中,需要利用个人识别码来确保连接的安全性,而改进过后的连接方式则是会自动使用数字密码来进行配对与连接。

2. 更佳的省电效果:一般来说,当2个进行连结的蓝牙装置进入待机状态之后,蓝牙装置之间仍需要透过相互的呼叫来确定彼此是否仍在联机状态,当然,也因为这样,蓝牙芯片就必须随时保持在工作状态,即使计步器的其它组件都已经进入休眠模式。

为了改善了这样这样的状况,蓝牙2.1将装置之间相互确认的讯号发送时间间隔从旧版的0.1秒延长到0.5秒左右,如此可以让蓝牙芯片的工作负载大幅降低,也可让蓝牙可以有更多的时间可以彻底休眠。

根据官方的报告,采用此技术之后,蓝牙装置在开启蓝牙联机之后的待机时间可以有效延长5倍以上。

安全和电子辐射 1. 辐射蓝牙产品的输出功率仅为1毫瓦,是微波炉使用功率的百万分之一,是移动电话(手机)功率的千分之一,而且,这些输出中也只有一小部分被人体吸收。

蓝牙计步器对人体的辐射几乎可以忽略不计,小孩和孕妇均可放心使用。

2.材料计步器采用的是ABS 无毒塑料,ABS 是丙烯腈(Acrylonitrile)-丁二烯(Butadiene)-苯乙烯(Styrene)三元嵌段共聚物,这种聚合物本身没有毒,ABS 是工程塑料,我们一般日常生活中的家电、汽车等都有用到上,像脸盆、塑料碗、保鲜膜都用PS 、PP 、PE 等ABS 塑料制成。

手机带你每天走一万步!

手机带你每天走一万步!

手机带你每天走一万步!
怎样运动才能让自己更健康?这已经成为人们最关心的话题之一。

目前流行着一种运动方式――每人每天走一万步,不过,大多数人并不清楚自己每天究竟走了多少步。

而现在,智能手机就可以直截了当地告诉你结果。

本期我们将为大家介绍三款计步器的APP应用,让我们一起动起来,每天走一万步吧!
runtastic Pedometer (runtastic计步器)v1.2.2
runtastic计步器可以持续追踪你每天行走的每一步,计算你是否达到每天1万步的运动量。

不管手机在你身边的哪个地方,裤子或夹克的口袋里,拿在手上,亦或是在你的背包或钱包里,这款应用都能自动记录你所有的步数,而且具备了计算卡路里、速度、距离、步进频率等多种功能,还可以保存你的身体数据:重量和高度准确的卡路里数,上传到runtastic的健身网站,让你轻松管理自己的运动数据。

Noom Walk:Pedometer(Noom计步器)v1.0.13 Noom计步器是一款小巧实用的计步器软件,它可以计量出你当日、本周和所有的步行资料。

使用的
时候非常省电,开着它,手机仅比平时多消耗2%的电量。

此外,它可以关联facebook或者G+的好友,了解彼此的步行情况,互相激励。

Accupedo-Pro(计步器)v3.0.3
计步器Accupedo-Pro是一款便捷的健身辅助工具,帮助您检测一天一万步的达标进度。

该应用可以自动检测步行并开始记步,而且可以智能地停止。

它还可以设置敏感度、度量单位、行走距离、日常目标等参数,并作出图标统计。

不过有些手机在休眠(待机,屏幕关闭)时不支持G-sensor,无法让该应用正常工作。

计步器工作原理

计步器工作原理

计步器工作原理计步器是一种常见的便携式电子设备,用于计算人们的步数和距离,以匡助他们追踪和监测日常步行活动。

它通常由加速度传感器、微处理器和显示屏组成。

下面将详细介绍计步器的工作原理。

1. 加速度传感器计步器的核心部件是加速度传感器,它能够感知人体的加速度变化。

加速度传感器通常采用微机电或者微机电系统(MEMS)技术创造。

它内部包含弱小的质量块和微弹簧,当人体行走时,加速度传感器会受到垂直于步行方向的加速度作用,从而引起质量块的弱小位移。

传感器通过测量位移的变化来检测步行的频率和幅度。

2. 信号处理加速度传感器会将检测到的加速度信号转换为电信号,并传送给微处理器进行进一步处理。

微处理器是计步器的大脑,它负责接收和处理传感器的信号,并根据预设的算法进行步数和距离的计算。

微处理器通常由高性能的集成电路组成,具有较强的数据处理和分析能力。

3. 算法计步器的算法是非常关键的一部份,它决定了步数和距离的准确性。

常见的算法包括峰值检测算法、阈值算法和滤波算法等。

峰值检测算法通过检测加速度信号中的峰值来确定步行的步数,阈值算法通过设置阈值来判断步行的开始和结束,滤波算法则用于滤除噪声和干扰信号。

4. 显示屏计步器通常配备有显示屏,用于显示步数、距离和其他相关信息。

显示屏可以是液晶显示屏或者LED显示屏,通过显示屏,用户可以实时查看步行数据,并进行相应的调整和分析。

5. 电源计步器通常使用电池作为电源,以提供所需的电能。

电池的容量和寿命直接影响计步器的使用时间。

普通来说,计步器的电池寿命可以达到几个月或者更长期,具体取决于使用频率和电池容量。

总结:计步器通过加速度传感器感知人体的加速度变化,经过信号处理和算法计算出步数和距离,并通过显示屏展示给用户。

它的工作原理简单明了,但准确性和稳定性需要依赖于传感器和算法的精确度。

计步器的浮现为人们提供了一种方便的方式来监测和记录步行活动,促进了健康生活方式的养成。

计步器工作原理

计步器工作原理

计步器工作原理计步器是一种常见的健康监测设备,它可以记录用户的步数、距离和消耗的卡路里等数据。

计步器的工作原理主要依靠加速度传感器和算法来实现。

一、加速度传感器计步器内部装有加速度传感器,通常采用微机电系统(MEMS)技术制造。

加速度传感器能够感知物体在三个方向上的加速度变化,通过测量人体行走时的加速度变化来判断步数。

二、步数计算算法计步器内部的算法会对加速度传感器采集到的数据进行处理和分析,从而计算出用户的步数。

常见的计步算法有以下几种:1. 阈值法:根据人体行走时的加速度变化特点,设定一个阈值,当加速度超过该阈值时,判断为一步。

但这种方法容易受到噪声的干扰,精确度较低。

2. 峰值法:通过检测加速度的峰值来判断一步的发生。

当加速度从正向变为负向时,判断为一步。

但这种方法对步幅变化较大的人不够准确。

3. 综合法:综合利用加速度传感器采集到的数据,结合运动学原理和统计学方法,通过多种算法的组合来计算步数。

这种方法相对准确度较高,适用于不同人群和运动方式。

三、数据处理和显示计步器会将采集到的步数数据进行处理和存储,并通过显示屏或连接手机APP 等方式展示给用户。

一般来说,计步器会记录每天的步数、距离、消耗的卡路里等数据,并可以进行数据的存储和导出。

四、其他功能除了计步功能,现代计步器还常常具备其他功能,如心率监测、睡眠监测、血压监测等。

这些功能通过加入相应的传感器和算法来实现,进一步提供更全面的健康监测服务。

总结:计步器通过加速度传感器和算法来实现对用户步数的计算和记录。

加速度传感器感知人体行走时的加速度变化,算法对采集到的数据进行处理和分析,计算出步数等相关数据。

计步器还可以具备其他健康监测功能,提供更全面的健康数据。

君斯达JUNSO触摸式心率计步器

君斯达JUNSO触摸式心率计步器

君斯达JUNSO触摸式心率计步器
佚名
【期刊名称】《文体用品与科技》
【年(卷),期】2009(000)007
【摘要】君斯达JS-210是一款采用新技术的计步器,计步更准确、更快速,并拥有触摸式测心率功能。

计步、能耗记录和计时、计距功能为您日常各种运动提供重要的数据。

触摸式测心率功能能方便的测量您的心率,这项功能对制定合适的运动强度、防止运动强度过大导致意外发生很有帮助;
【总页数】1页(P4)
【正文语种】中文
【中图分类】TM923.44
【相关文献】
1.君斯达JUNSO多功能学生专用表 [J],
2.君斯达 JUNSO学生心率测试仪 [J],
3.君斯达 JUNSO高度计(登山表) [J],
4.君斯达JUNSO心率表 [J],
5.君斯达JUNSO专业健身车表 [J],
因版权原因,仅展示原文概要,查看原文内容请购买。

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

AN-900APPLICATION NOTEOne Technology Way • P .O. Box 9106 • Norwood, MA 02062-9106, U.S.A. • Tel: 781.329.4700 • Fax: 781.461.3113 • Enhancing the Performance of Pedometers Using a Single Accelerometerby Jim ScarlettRev. 0 | Page 1 of 16The AN-602 application note examined the use of an Analog Devices, Inc. accelerometer to make a simple but relatively accurate pedometer. However, newer devices have beenintroduced that allow the use of accelerometers in more cost-sensitive applications. Thus, applications such as pedometers are finding themselves in many consumer devices such as cellular handsets.Given this trend, a closer examination was made of pedome- ters using a single accelerometer. The AN-602 technique was implemented in an attempt to duplicate its results. Though the algorithm performed well, the same accuracy was not duplicated. In particular, there was greater variation than expected from person to person, as well as when one person used a different pace and stride length. This led to an investigation of potential improvements to the algorithm used in AN-602.The tests were done using two different pedometer test boards, both utilizing an ADuC7020 ARM7® controller. One setup was a combination of the ADuC7020 microcontroller and ADXL322 accelerometer evaluation boards, with an added 16 × 2 char-acter LCD display. The other was a custom board using the ADuC7020 and an ADXL330 3-axis accelerometer, again with a 16 × 2 character LCD display. See Figure 5 for the custom board schematic.AN-602 METHODThe underlying reasoning in the AN-602 method is based on the principle that the vertical bounce in an individual’s step is directly correlated to that person’s stride length (see Figure 1).Because the angles α and θ are equal, the stride can be shown to be a multiple of the maximum vertical displacement. Differences in an individual’s leg length are accounted for, given that for the same angles the vertical displacement would be greater or smaller for taller or shorter people.Using an accelerometer, however, gives changes in acceleration rather than displacement. These acceleration measurements must be converted to a distance before they can be used. With the limited computing power available in the AN-602 setup, a simple formula was used to approximate the double integral needed for the conversion. With plenty of processing power available, an attempt was made to do the discrete integrals directly for this experiment.A simple method was chosen to calculate the integrals. After each step was determined, all of the acceleration sampleswithin that step were added to obtain a set of velocity samples. The velocity samples for each step were normalized such that the final sample was zero. They were then added together to get a value for the displacement.This technique looked promising initially, because measured distances were relatively consistent for one subject walking a course multiple times. However, the variance problem from person to person was exacerbated, as was the variance for one subject at different paces. This led to an investigation of whether the problem is with the model itself.06617-0RIGHT LEG LEFT LEG LEFT LEG RIGHT LEGFigure 1. Vertical Movement of Hip While WalkingAN-900Rev. 0 | Page 2 of 16UNDERSTANDING THE MODELThis model has two primary conditions. First, it assumes that the foot actually makes contact with the ground at a single point. Second, it assumes that the impact of each foot on the ground is perfectly elastic. Of course, neither of these is the case. The question arose of whether this can explain the large variations encountered. Based on this experiment, it is safe to state that it does explain much of the variation.To understand this, it helps to look at the measured acceleration values over several steps, shown in Figure 2. Different sources of spring in one person’s step are shown on the data.340290240190140106617-00215294357718599113127141155169ACCELLERATIONFigure 2. Acceleration Graph for Subject 1 at a Normal PaceFigure 2 demonstrates the problems encountered trying to translate acceleration measurements into an accurate distance calculation. Methods that take into account the peak-to-peak change (or even those that integrate the data) run into trouble with this type of data. The cause of this difficulty is the variation in spring in the steps of different people, or in the steps of one person using different paces from one measurement to another. Figure 3 shows the same subject with a longer and faster stride. The peak-to-peak acceleration difference is larger, and the various spring points look different. Thus, the amount of data representing spring data vs. the amount representing real data is different compared with Figure 2. However, the algorithm only sees a set of acceleration measurements and does not note the context of those measurements. The problem, therefore, is how to remove the effect of the spring in a subject’s step without removing useful data.06617-00315294357718599113127141155169ACCELERATION5000145040035030025020015010050Figure 3. Acceleration Graph for Subject 1 at a Fast PaceThere are some important differences between the two plots. The bottom part of the curve for each step is slightly narrower in Figure 3 and the tops of the curves are more consistent (fewer distinctive peaks). These differences result in a higher average value of the samples compared to the minimum and maximum sample values.For comparison purposes, review the data plot for a different individual in Figure 4. The stride length is very similar to that of Subject 1 in Figure 2. However, the data itself looks very different.06617-00415294357718599113127141155169ACCELERATION501400350300250200150100Figure 4. Acceleration Graph for Subject 2 at a Normal PaceThe stride of Subject 2 has a great deal more spring in it than that of Subject 1 (shown in Figure 2). Y et both sets of data represent roughly the same distance walked. Calculating distance solely on the peak values gives widely varying results. Using a simple double integration suffers from the same problem.AN-900Rev. 0 | Page 3 of 16SOLVING THE PROBLEM OF SPRINGAll efforts to come up with a decent solution to this problem using straightforward calculations had the same problems. This led to a series of attempts to normalize the data in a way that eliminated the spring, but all these attempts proved unsuc-cessful. The main reason seemed to be that they required some knowledge of the context of the data. In actual use, however, the system has no idea what is going on outside; all it has are data points. The solution needs to be able to operate on the data without context.A possible solution to this problem began to emerge. It was noted earlier how the data changed when going from a slower to faster pace. There is less apparent variation due to the spring with a longer, quicker stride. The result was a higher average for the sample points, with respect to the data minima and maxima. Visually, it is a little difficult to be sure of this, given the amount of bounce in the steps shown in Figure 4. But calculations showed that the average-vs.-peak values are very similar to those in Figure 2. Therefore, a possible simple algorithm was used to determine the distance walked. It is)()(min max min avg k d −−×= (1)where:d is the distance calculated. k is a constant multiplier. max is the maximum acceleration value measured within this step. min is the minimum acceleration value. avg is the average acceleration value for the step. Equation 1 is completed for each step, as determined by a different step-finding algorithm. The step-finding algorithm uses an 8-point moving average to smooth the data. It searches for a maximum peak, followed by a minimum. A step is counted when the moving average crosses the zero point, which is the overall average for the step. The data used in the distance algo-rithm takes into account the 4-point latency of the moving average.This simple solution held up well for Subject 1 over various stride lengths. It also did reasonably well with additional subjects. But some subjects produced distances that varied as much as 10% from the average measured distance for the group. This was not within the ±7.5% error band that was targeted for an uncalibrated measurement. Another solution was needed.The ratio used in the last test seemed to reflect the differences in the spring of different subjects’ steps. It made sense to try combining the two methods examined here. Going back to the original idea of using a double integral, this ratio was used as a correction factor to remove the spring data from the calcu-lation. The resulting formula is therefore∑∑−−−×=)(*)()(avg accel min avg min max k d (2)where accel represents all measured acceleration values for the step.This algorithm held up well for a variety of subjects and paces, with all variation within approximately 6%. The algorithm lends itself to easy calibration for a specific individual/pace by adjusting the Multiplier k. There is also provision within the listed code to perform an average on the stride length to smooth out step-to-step variation. The results noted here did not include the use of this averaging.In this experiment, only the X- and Y-axes were used. The 3-axis accelerometer was chosen for flexibility, and two axes were found to be adequate for the task. An ADXL323 couldbe used in place of the ADXL330. The same layout can be used for both because the pin configuration is identical except for theZ-axis output. These experiments concentrated on achieving good results for the pedometer’s distance measurement. There was no extensive work done on the step-counting algorithm beyond ensuring it works well while walking (and running), with measured steps within 1 to 2 steps of the actual number over hundreds of steps taken. However, it is possible that a simple algorithm can be fooled with nonwalking motions. Improvements can be made in that area, such as the time-window function described in AN-602. The object is to ignore steps that are outside the expected time window, while retaining the ability to adapt when the subject changes pace.SUMMARYThis application note represents the results of a single set of experiments attempting to gain decent performance from a simple pedometer that uses a single accelerometer. Some of the barriers to gaining that performance have been reviewed. The final results have met the stated accuracy goals, with the added possibility of improved accuracy with calibration. Although greater accuracy can be obtained with a more complex system (for instance, with multiple accelerometers), the algorithm provided in this application note is an excellent starting point for simple, low cost applications.AN-900Figure 5. Custom Board SchematicRev. 0 | Page 4 of 16AN-900Rev. 0 | Page 5 of 1606617-006Figure 6. Custom Board Schematic (Continued)AN-900Rev. 0 | Page 6 of 16ADuC7020 C CODEThe following three files contain the code used to implement this algorithm on the test boards using an ADuC7020 microcontroller.MAIN.CThe file main.c is used to initialize the device:/********************************************************************* Author : J Scarlett Date : Nov 2006Files : main.c, display.c, ped.c Hardware : ADuC7020Description : Implements a simple pedometer based on application note AN-602*********************************************************************/ #include <ioaduc7020.h> //Function Prototype with required function attribute.extern void Monitor_Function(void); extern void Display_Init(void);//*********************************************************************// Main Function for ADuC7020 Pedometer essentially performs startup functions //********************************************************************* int main (void) { POWKEY1 = 0x01; POWCON = 0x06;// set to 653kHz core clockPOWKEY2 = 0xF4;REFCON = 0x2; // use external reference // (connected to V DD ) //********************************************************************* // Initialize Peripherals//********************************************************************* // GPIO ConfigurationGP4DAT = 0x04000000;// P4.2 configured as an output.// LED is turned on GP0CON = 0x00000000; // GP0DAT = 0xE0000000; // 0.7, 0.6, and 0.5 are outputs// 0.7 = E, 0.5 = R/W*, 0.6 = RS GP1DAT = 0xFF000000;// All P1 pins are outputsADCCON = 0x20;// Turn ADC on but do not enableDisplay_Init(); // found in File display.c Monitor_Function(); // found in File ped.c //********************************************************************* // Main Loop//********************************************************************* while(1) { } } // main()AN-900Rev. 0 | Page 7 of 16DISPLAY.CThe file display.c contains all functions that access the display:// File "display.c"// performs all LCD display interface functions#include <ioaduc7020.h>extern char stepbcd[6]; // found in File ped.c extern char distbcd[6];// this toovoid Display_Init(void); void display_data(void); void display_data_clear(void); void char_load(int RS, int data); void delay(unsigned int cycles); int reverse_data(int data);void Display_Init() {// used once to initialize display and write// the "Steps" and "Distance" headersint rs, data;// Display initialization rs = 0;// no RAM access yetdata = 0x30;// function set: 2-line mode, display offchar_load(rs, data);data = 0x38;// function set: 2-line mode, display offchar_load(rs, data);data = 0x08;// display off, cursor off, blink offchar_load(rs, data);data = 0x01; // clear display char_load(rs, data); delay(49);// ~1.5 ms additional delay is requireddata = 0x06;// increment mode, no shiftchar_load(rs, data);data = 0x0C;// display on, cursor off, blink offchar_load(rs, data);data = 0x80;// set data address to home, just to be surechar_load(rs, data);rs = 1; // now writing to data RAM data = 0x53;// start of sequence to sendchar_load(rs, data);// "Steps Distance" for title linedata = 0x74; // "t"AN-900Rev. 0 | Page 8 of 16char_load(rs, data);data = 0x65; // "e" char_load(rs, data);data = 0x70; // "p" char_load(rs, data);data = 0x73; // "s" char_load(rs, data);data = 0x20;// " " times 3char_load(rs, data); char_load(rs, data); char_load(rs, data);data = 0x44; // "D" char_load(rs, data);data = 0x69; // "i" char_load(rs, data);data = 0x73; // "s" char_load(rs, data);data = 0x74; // "t" char_load(rs, data);data = 0x61; // "a" char_load(rs, data);data = 0x6E; // "n" char_load(rs, data);data = 0x63; // "c" char_load(rs, data);data = 0x65; // "e" char_load(rs, data);} // Display_Init()void display_data() {// displays the data contained in stepbcd[] & distbcd[]// beginning at the first and ninth characters // on row 2 of the display int i, rs, data, zero;rs = 0; // want to set address, not datadata = 0xC0;// start of second linechar_load(rs, data);AN-900Rev. 0 | Page 9 of 16rs = 1;zero = 0;for (i=5; i>=0; i--) // display steps {if ((stepbcd[i] > 0) || (zero ==1))// suppress leading zeroes,{ // but not embedded zeroes zero = 1;data = 0x30 | stepbcd[i];// numbers on display character table// begin at 0x30 char_load (rs, data); } // if } // forrs = 0; // set address data = 0xC8;// ninth character of second linechar_load(rs, data);rs = 1;zero = 0; for (i=5; i>=0; i--) // display distance { if ((distbcd[i] > 0) || (zero ==1)) { zero = 1;data = 0x30 | distbcd[i];char_load (rs, data); } // if } // for} // display_data()void display_data_clear(void) {// used to clear display data field // before new measurement int i, rs, data;rs = 0; // want to set address data = 0xC0; // start of second line char_load(rs, data); rs = 1;data =0x20;for (i=0; i<16; i++)// put spaces across Row 2char_load (rs, data);} // display_data_clear()void char_load(int rs, int data) {AN-900Rev. 0 | Page 10 of 16// signal timing assumes a core clock < 4MHz// delay at end is ~61us, to allow write to completedata = reverse_data(data); // board layout dictated reversing MSB/LSB GP1CLR = 0x00FF0000; // ensure clean slate for next character GP1SET = data << 16;// set Port 1 to new character dataif (rs) GP0SET = 0x00400000; // RS bit = 1 elseGP0CLR = 0x00400000;// RS bit = 0GP0CLR = 0x00200000;// WR bit = 0 (this is a write command)GP0SET = 0x00800000; // set E bit to begin transfer process GP0CLR = 0x00800000;// clear E bit to complete transfer processdelay(2);} // char_load()void delay(unsigned int cycles) { T2CON = 0; T2CLRI = 0; T2LD = cycles; T2CON = 0xC0;// enable Timer 2, periodic mode, 32.768 kHz while (!(IRQSIG & WAKEUP_TIMER_BIT));// wait for timeoutT2CON = 0; // disable Timer 2} // delay()int reverse_data(int data) {int i, temp;temp = 0;for (i=0; i<4; i++) {temp |= (((0x01 << i) & data) << (7 - (2 * i))); } // fill top 4 bits of tempfor (i=4; i<8; i++) {temp |= (((0x01 << i) & data) >> ((2 * i) - 7)); } // fill bottom 4 bits of tempreturn temp;} // reverse_data()PED.CThe file ped.c contains those functions used by the pedometer algorithm:// file "ped.c"// performs pedometer and misc functions#include <ioaduc7020.h>#include <math.h>#include <stdlib.h>// Function Prototype & variableschar stepbcd[6];char distbcd[6];char stepflag;float stride, avgstride, accel_dat[50];float maxavg, minavg, accel_avg, velocity, displace;float distance;int steps;void Monitor_Function(void);void get_sample(unsigned int *xdat, unsigned int *ydat, unsigned int *zdat);char IsStep(float avg, float oldavg);void display_prep(void);long int bin_to_bcd(long int bin_no);extern void display_data(void); // found in File display.cextern void display_data_clear(void); // found in File display.c// functionsvoid Monitor_Function(){flag;charunsigned int xdat, ydat, zdat;int i, cycle_count, tot_samples, avgconst = 1, latency = 4, avglen = 8;float rssdat, newmax, newmin, oldavg, newavg, avgthresh=1.0;float walkfudge = 0.0249;flag = 0;T1CON = 0; // turn off interval timer and clear any IRQ T1CLRI = 0;(1)while{if (IRQSIG & XIRQ0_BIT) // XIRQ0 button has been pressed{while(GP0DAT & 0x00010); // wait for XIRQ to be low again(!flag)if{T1CON = 0; // turn off interval timerT1CLRI = 0; // clear any timer IRQ2;=stepflagmaxavg-10000.0;=10000.0;minavg=-10000.0;newmax=10000.0;=newmin0.0;=oldavg0.0;=newavg=0;cycle_count=0;tot_samples0;=steps0.0;distance=0.0;=accel_avgvelocity = 0.0;displace = 0.0;avgstride0.0;=olddisplayfromdatacleardisplay_data_clear();//1;flag=T1LD = 1092; // ~30 Hz sample rateT1CON = 0x2C0; // 32.768 kHz clock, timer on,periodicmode//} // if not running, start.} // look for stop buttonif (GP2DAT & 0x01){while(GP2DAT & 0x01);flag = 0;} // if running, stopif (((IRQSIG & GP_TIMER_BIT) && (flag)) != 0) // wait for timeoutandflag//{0;=T1CLRIif (tot_samples > 7) // subtract first sample in sliding boxcar avg{newavg;=oldavgavglen];-accel_dat[cycle_countnewavg-=if}//get_sample(&xdat, &ydat, &zdat); // get data from accelerometerZerosubtractvalueg8192;//xdat-=8192;ydat-=rssdat = sqrt((float)(xdat*xdat + ydat*ydat)/16.0); // vector sumaccel_dat[cycle_count] = rssdat; // place current sample data in buffernewavg += rssdat; // add new sample to sliding boxcar avgavgthresh)if((abs(newavg-oldavg))<oldavg;newavg=if (rssdat > newmax)rssdat;=newmaxnewmin)<if(rssdatrssdat;newmin=tot_samples++;cycle_count++; // increment count of samples in current step8)>(tot_samplesif{oldavg))if(IsStep(newavg,{for (i = latency; i < (cycle_count - latency); i++)accel_avg += accel_dat[i];accel_avg /= (cycle_count - avglen);for (i = latency; i < (cycle_count - latency); i++){velocity += (accel_dat[i] - accel_avg);displace += velocity;} // create integration and double integration// calculate stride lengthstride = displace * (newmax - newmin) / (accel_avg - newmin);stride = sqrt(abs(stride));// use appropriate constant to get stride length*=walkfudge;stride// generate exponential average of stride length to smooth dataif (steps < 2)stride;=avgstrideelse+stride)/avgconst;=((avgconst-1)*avgstrideavgstridesteps++;avgstride;distance+=// need all data used in calculating newavgfor (i = 0; i < avglen; i++)accel_dat[i] = accel_dat[cycle_count + i - avglen];cycle_count = avglen;=-10000.0;newmax10000.0;=newmin-10000.0;maxavg==10000.0;minavgaccel_avg = 0;velocity = 0;displace = 0;display_prep();display_data();// temporaryif (GP4DAT & 0x04) // toggle LED to reflect step0x040000;GP4CLR=elseGP4SET0x040000;=} // we have a new step} // enough samples to start checking for step (need at least 8)} // if timeout} // continual loop} // Monitor_Function()void get_sample(unsigned int *xdat, unsigned int *ydat, unsigned int *zdat){// gets new samples for x, y, z axestoaveragemeasurmentsget4sums//togetheri;int*xdat = 0;*ydat = 0;*zdat = 0;for (i=0; i<15; i++){xaxis//0;ADCCP=commandcycleone//delayi++;0xA3;=ADCCON(!(ADCSTA));while*xdat += ((ADCDAT >> 16) & 0xFFF); // data is in bits 16 - 27, so shift is necessaryADCCP = 1; // y axisi++;0xA3;=ADCCON(!(ADCSTA));while*ydat += ((ADCDAT >> 16) & 0xFFF);ADCCP = 2; // z axisi++;0xA3;=ADCCON(!(ADCSTA));while*zdat += ((ADCDAT >> 16) & 0xFFF);} // for} // get_sample()char IsStep(float avg, float oldavg){// this function attempts to determine when a step is complete float step_thresh = 5.0; // used to prevent noise from fooling the algorithmif (stepflag == 2){if (avg > (oldavg + step_thresh))=1;stepflagif (avg < (oldavg - step_thresh))0;stepflag=0;return} // first time through this functionif (stepflag == 1){if ((maxavg > minavg) && (avg >((maxavg+minavg)/2)) &&((maxavg+minavg/2))))<(oldavg1;returnif (avg < (oldavg - step_thresh)){0;stepflag=>maxavg)(oldavgifoldavg;maxavg=} // slope has turned down0;return} // slope has been upif (stepflag == 0){if (avg > (oldavg + step_thresh)){1;=stepflagminavg)<if(oldavgoldavg;minavg=} // slope has turned up0;return} // slope has been down0;return} // IsStep()void display_prep(){i;intlong int temp;// convert steps to BCD values for sending to displaytemp = steps;temp = bin_to_bcd(temp); // function to convert binary//BCDtoi<6;for(i=0;i++){stepbcd[i] = (char)(0xF & temp); // load each digittemp = temp >> 4;} // for// convert distance to BCD values for sending to displaytemp = (long int)(distance); // convert float to long inttemp = bin_to_bcd(temp);for (i=0; i<6; i++){distbcd[i] = (char)(0xF & temp); // load each digittemp = temp >> 4;} // for} // display_prep()long int bin_to_bcd(long int bin_no){i;intlong int divisor, multiplier, bcd_no, temp;divisor = 100000;multiplier = 1048576;bcd_no = 0;temp = 0;if (bin_no > 999999)999999;=bin_nofor (i=0; i<6; i++)startingdigit{ //eachdeterminewithsignificantmostbin_no/divisor;temp=//bin_no -= temp*divisor; // subtract this amthexequivalentgenerate//*=multiplier;tempbcd_no += temp; // put bcd value togethertogonextdigit10;//divisor/=multiplier = multiplier >> 4;} // forbcd_no;return} // bin_to_bcd()©2007 Analog Devices, Inc. All rights reserved. Trademarks andregistered trademarks are the property of their respective owners.AN06617-0-7/07(0)。

相关文档
最新文档