文件名称:CAPTURE
- 所属分类:
- 微处理器(ARM/PowerPC等)
- 资源属性:
- [C/C++] [源码]
- 上传时间:
- 2013-06-03
- 文件大小:
- 17kb
- 下载次数:
- 0次
- 提 供 者:
- X**
- 相关连接:
- 无
- 下载说明:
- 别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容均来自于网络,请自行研究使用
PIC单片机的CCP功能
//220V的交流电源直接用电阻限流,经光耦隔离,形成脉冲送到CCP2,
//CCP2模块的捕捉功能,设置为每16个上升沿捕捉一次,相当于平均滤波,目的是为了减小误差
//TMR1计数的分频系数计算:假设电源为50Hz,即一个周期为20ms,16个周期为320ms
//320ms=320000us,单片机用4MHz晶振,指令周期为1us,设TMR1的分频系数为K:65536×K=320000
//得K=4.88,取K=8,即TMR1的预分频系数设为1:8
//电源频率计算,假设频率显示为2位小数,即频率值放大100倍,16次捕捉值为TTZ,
//则f=1000000×100/(TTZ×8/16)=200000000/TTZ-PIC microcontroller CCP function// 220V AC power directly limiting resistor, the optocoupler isolation, a pulse sent CCP2,// CCP2 module' s capture function, set to capture rising once every 16, equivalent to an average filter The purpose is to reduce the error// TMR1 counter division ratio calculation: Suppose power is 50Hz, ie a period of 20ms, 16 cycles of 320ms// 320ms = 320000us, microcontroller 4MHz crystal, the instruction cycle is 1us, setting TMR1 divider coefficient K: 65536K = 320000// get K = 4.88, take K = 8, ie the TMR1 prescaler is set to 1:8// power frequency, assuming that the frequency is displayed as two decimal that frequency value magnified 100 times, 16 times to capture value TTZ,// then f = 1000000100/(TTZ8/16) = 200000000/TTZ
//220V的交流电源直接用电阻限流,经光耦隔离,形成脉冲送到CCP2,
//CCP2模块的捕捉功能,设置为每16个上升沿捕捉一次,相当于平均滤波,目的是为了减小误差
//TMR1计数的分频系数计算:假设电源为50Hz,即一个周期为20ms,16个周期为320ms
//320ms=320000us,单片机用4MHz晶振,指令周期为1us,设TMR1的分频系数为K:65536×K=320000
//得K=4.88,取K=8,即TMR1的预分频系数设为1:8
//电源频率计算,假设频率显示为2位小数,即频率值放大100倍,16次捕捉值为TTZ,
//则f=1000000×100/(TTZ×8/16)=200000000/TTZ-PIC microcontroller CCP function// 220V AC power directly limiting resistor, the optocoupler isolation, a pulse sent CCP2,// CCP2 module' s capture function, set to capture rising once every 16, equivalent to an average filter The purpose is to reduce the error// TMR1 counter division ratio calculation: Suppose power is 50Hz, ie a period of 20ms, 16 cycles of 320ms// 320ms = 320000us, microcontroller 4MHz crystal, the instruction cycle is 1us, setting TMR1 divider coefficient K: 65536K = 320000// get K = 4.88, take K = 8, ie the TMR1 prescaler is set to 1:8// power frequency, assuming that the frequency is displayed as two decimal that frequency value magnified 100 times, 16 times to capture value TTZ,// then f = 1000000100/(TTZ8/16) = 200000000/TTZ
(系统自动生成,下载前可以参看下载内容)
下载文件列表
CAPTURE.hex
CAPTURE2.DSN
CAPTURE.C