HC-RS04_使用一个定时器中断测距
所属分类:嵌入式/单片机/硬件编程
开发工具:C/C++
文件大小:16KB
下载次数:9
上传日期:2018-05-13 22:05:44
上 传 者:
埋没的心
说明: * 超声波测距程序
* 使用一个位定时器(定时器0模式1)和一个外部中断实现超声波测距
*
* 需要调用的函数:
* void HC_RS04_Driver(); 超声波测距驱动函数,需在【主函数】中调用
* void EchoExint0(); 回响时间计算,需在【外部中断】中调用
* void HC_RS04_Start(); 超声波开始测距触发函数,需在【定时器中断】中调用
*
* 优点:占用单片机资源少,因使用定时器中断计时回响时间,
* 不会影响的其他状态监测。使用起来方便
* 缺点:测量精度不高,测量300cm时有5cm左右的误差
*
* 晶振频率:11.0592 MHz
* 测量距离保存在 int 型全局变量 detection_range 中单位"cm"
(* ultrasonic distance measuring program
* using a bit timer (timer 0 mode 1) and an external interrupt to achieve ultrasonic ranging.
*
* the function that needs to be called:
* void HC_RS04_Driver (); the ultrasonic ranging drive function needs to be called in the main function.
* void EchoExint0 (); reverberation time calculation, called in external interrupt.
* void HC_RS04_Start (); the starting function of the ultrasonic ranging start is called in the timer interrupt.
* advantages: occupy less MCU resources, because timer interrupt time reverberation time.
* other state monitoring that will not be affected. Easy to use Disadvantages: the measurement accuracy is not high, and the error is about 5cm when measuring 300cm.
* crystal oscillator frequency: 11.0592 MHz
* measuring distance is saved in the int global variable detection_range in the unit "cm".)
文件列表:
HC-RS04_使用一个定时器中断测距\HC_RS04.c (3861, 2018-01-20)
HC-RS04_使用一个定时器中断测距\HC_RS04.h (328, 2017-09-13)
HC-RS04_使用一个定时器中断测距\HC_RS04.hex (4971, 2018-01-20)
HC-RS04_使用一个定时器中断测距\HC_RS04.uvopt (74761, 2018-05-13)
HC-RS04_使用一个定时器中断测距\HC_RS04.uvproj (13725, 2017-12-17)
HC-RS04_使用一个定时器中断测距\main.c (1164, 2018-01-20)
HC-RS04_使用一个定时器中断测距\showchar.c (1067, 2018-01-20)
HC-RS04_使用一个定时器中断测距\showchar.h (153, 2017-07-01)
HC-RS04_使用一个定时器中断测距\STARTUP.A51 (6376, 2009-05-07)
HC-RS04_使用一个定时器中断测距 (0, 2018-05-13)
近期下载者:
相关文件:
收藏者: