<p>
代码全部自己原创(当然要除开ST的库,呵呵!),电路借鉴了俄罗斯版的,电路结构与原版不同之处,STM8S105产生相差90度的鉴相控制信号,同时拿出一路来给三组低通滤波器产生正弦波</p><br><p>
走了一些弯路,开始使用AD9833来产生正弦波,由于AD9833产生的正弦波与鉴相信号的频率不能完全一样,又由于是使用的积分的方法得到相量因此会造成测试结果会周期性的变化,所以才使用了三组低通滤波器来产生正弦波,滤出来的正弦波我从示波器上基本看不出来有失真,</p><br><p>
不多说了看看结果吧!</p><br><p>
图片是手机拍的大家就着看吧!</p><br><p>链接: https://pan.baidu.com/s/1q6bcC6u6DQhiP2H6N5KL9Q 提取码: jkt7 复制这段内容后打开百度 {MOD}手机App,操作更方便哦</p><br><p>
原理图,还没有改过来,上面画的还是AD9833</p><p>链接: https://pan.baidu.com/s/1gvsTzlNRhEdIjv9_uBwccQ 提取码: 5rzw</p>
<br><p>
更新一下原理图,已经改为与实际的一致了,</p><br><p>链接: https://pan.baidu.com/s/1iy8wn3i90jDQEjmOyMaocw 提取码: 3fnu</p>
<br>
<br>
<p><img src="https://www.xiaopingtou.net/data/attach/1912/92ton4d6s5ugszzf2ah7cvud3efqyydx.jpg" lazyloadthumb="1" border="0" alt=""></p><br>
<font color="green">(原文件名:调整大小 201008121252.jpg)</font> <br>
<br>
<p><img src="https://www.xiaopingtou.net/data/attach/1912/8pm8k48tv5j57jd4avcjg33imh9wwlti.jpg" lazyloadthumb="1" border="0" alt=""></p><br>
<font color="green">(原文件名:调整大小 201008121253.jpg)</font> <br>
<br>
<p><img src="https://www.xiaopingtou.net/data/attach/1912/sputmziljk01x4w75uippf29dwdr2ysi.jpg" lazyloadthumb="1" border="0" alt=""></p><br>
<font color="green">(原文件名:调整大小 201008171255.jpg)</font> <br>
<br>
<p><img src="https://www.xiaopingtou.net/data/attach/1912/9eu674z2iyoxgdv24gsh5388ut1n1xnp.jpg" lazyloadthumb="1" border="0" alt=""></p><br>
<font color="green">(原文件名:调整大小 201008191260.jpg)</font> <br>
<br>
<p><img src="https://www.xiaopingtou.net/data/attach/1912/7oyo8wnrta2wuhjx0jfeb78kirq1fact.jpg" lazyloadthumb="1" border="0" alt=""></p><br>
<font color="green">(原文件名:调整大小 201008191262.jpg)</font> <br>
<br>
<p><img src="https://www.xiaopingtou.net/data/attach/1912/1doahilsrzaljtzmlcw7n3xvtvjz0q5x.jpg" lazyloadthumb="1" border="0" alt=""></p><br>
<font color="green">(原文件名:调整大小 201008201267.jpg)</font> <br>
<br>
<p><img src="https://www.xiaopingtou.net/data/attach/1912/h7hrq9kfi8n6fx6xwdqabx1lr2pn1rx5.jpg" lazyloadthumb="1" border="0" alt=""></p><br>
<font color="green">(原文件名:调整大小 201008201268.jpg)</font> <br>
<br>
<p><img src="https://www.xiaopingtou.net/data/attach/1912/xfznh58b1bz69lpnnpxhacezon7vnb35.jpg" lazyloadthumb="1" border="0" alt=""></p><br>
<font color="green">(原文件名:调整大小 201008201269.jpg)</font> <br>
<br>
<p><img src="https://www.xiaopingtou.net/data/attach/1912/hs21zpl4k2v8aiqhfe41nlp9tzyiq5k4.jpg" lazyloadthumb="1" border="0" alt=""></p><br>
<font color="green">(原文件名:调整大小 201008201270.jpg)</font> <br>
<br>
<p><img src="https://www.xiaopingtou.net/data/attach/1912/ayq00fuapzus584h9cdig3e07juhdbu6.jpg" lazyloadthumb="1" border="0" alt=""></p><br>
<font color="green">(原文件名:调整大小 201008201271.jpg)</font> <br>
<br>
<p><img src="https://www.xiaopingtou.net/data/attach/1912/8em4rf7mn3ptzruf1s3eaerax8g7tnik.jpg" lazyloadthumb="1" border="0" alt=""></p><br>
<font color="green">(原文件名:调整大小 201008201272.jpg)</font> <br>
<br>
<p><img src="https://www.xiaopingtou.net/data/attach/1912/60mwtfbpof234nyj4z9f22j2s4xcwxh0.jpg" lazyloadthumb="1" border="0" alt=""></p><br>
<font color="green">(原文件名:调整大小 201008201273.jpg)</font> <br>
<br>
<p><img src="https://www.xiaopingtou.net/data/attach/1912/08gith5hlmwnnnabmcya2iz3mpe8q7bs.jpg" lazyloadthumb="1" border="0" alt=""></p><br>
<font color="green">(原文件名:调整大小 201008201274.jpg)</font> <br>
<br>
<p><img src="https://www.xiaopingtou.net/data/attach/1912/bwbsczg5jgahllzyo2c7l20cpqmtdasx.jpg" lazyloadthumb="1" border="0" alt=""></p><br>
<font color="green">(原文件名:调整大小 201008201275.jpg)</font> <br>
<br>
<p><img src="https://www.xiaopingtou.net/data/attach/1912/oubfveirad44c9l67r7ej7n7vcl57rbq.jpg" lazyloadthumb="1" border="0" alt=""></p><br>
<font color="green">(原文件名:调整大小 201008201276.jpg)</font> <br>
<br>
<p><img src="https://www.xiaopingtou.net/data/attach/1912/1sntnbponzufh6bol4l8z1dnhfcruvwr.jpg" lazyloadthumb="1" border="0" alt=""></p><br>
<font color="green">(原文件名:调整大小 201008201278.jpg)</font> <br>
<br>
<p><img src="https://www.xiaopingtou.net/data/attach/1912/cw63d7nswsn4ufarcf0lybknbep1lqtg.jpg" lazyloadthumb="1" border="0" alt=""></p><br>
<font color="green">(原文件名:调整大小 201008201279.jpg)</font> <br>
<br>
<p><img src="https://www.xiaopingtou.net/data/attach/1912/fbaytorvhkxswxa8znt7io4ptp06b8n2.jpg" lazyloadthumb="1" border="0" alt=""></p><br>
<font color="green">(原文件名:调整大小 201008201280.jpg)</font> <br>
<br>
<p><img src="https://www.xiaopingtou.net/data/attach/1912/mvamkxs4i3nyyq0p07ho51ya2bz9joma.jpg" lazyloadthumb="1" border="0" alt=""></p><br>
<font color="green">(原文件名:调整大小 201008201281.jpg)</font> <br>
<br>
<p><img src="https://www.xiaopingtou.net/data/attach/1912/lj0gw98myltf39tnq8cue0xg317f5b5v.jpg" lazyloadthumb="1" border="0" alt=""></p><br>
<font color="green">(原文件名:调整大小 201008201282.jpg)</font> <br>
<br>
<p><img src="https://www.xiaopingtou.net/data/attach/1912/3waiuqwjplb29782b6iuncowuky2vky6.jpg" lazyloadthumb="1" border="0" alt=""></p><br>
<font color="green">(原文件名:调整大小 201008201283.jpg)</font> <br>
<br>
<p><img src="https://www.xiaopingtou.net/data/attach/1912/7uemc95oxmxe8hdchcizql98y0lvjgzl.jpg" lazyloadthumb="1" border="0" alt=""></p><br>
<font color="green">(原文件名:调整大小 201008201284.jpg)</font> <br>
<br>
<p><img src="https://www.xiaopingtou.net/data/attach/1912/kyj6383l3o0lcbfzu1tpb9qdces5e106.jpg" lazyloadthumb="1" border="0" alt=""></p><br>
<font color="green">(原文件名:调整大小1607.jpg)</font> <p><br></p>
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
还有7135的BUSY引脚,大约3HZ的频率的方波,这个有问题,搞不清原因。
(原文件名:未命名.JPG)
-----------------------------------------------------------------------
可能是滤波器的输入阻抗不匹配造成的,可以换个阻值的电位器来调幅度或电位器后增加一级跟随。
回复【93楼】cyxavr 又一天
-----------------------------------------------------------------------
可能是滤波器的输入阻抗不匹配造成的,可以换个阻值的电位器来调幅度或电位器后增加一级跟随。
-----------------------------------------------------------------------
还有一个问题:
7135 的时钟输入为250K,我用STM32 定时器3通道4来做输入捕捉(上升沿捉一次,下降沿再捉一次,取两次差值),但捕捉到的数据老在跳变
楼主,请教一下,7135 BUSY 最长的高电平与低时间大概各为多少MS啊?
上传工程文件与原理图
没有8MHZ的晶振,我用6MHZ的,升频到54MHZ。
7135 时钟大约在500K左右,现在是知道如何设置STM32捕捉的频率!?
/*定时器5(16位)通道2 PA1(26脚)输出500k的PWM到ICL7153的CLK 脚(22脚),作为时钟信号*/
void TIM2_Out_Clk_125k_Setup(void)
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_OCInitTypeDef TIM_OCInitStructure;
u16 CCR2_Val ;
// u32 F_HZ=54000000/Prescale;
// u16 F_10kHZ= F_HZ/10000 ; //1000000/125000(125khz)=8
// u16 F_1kHZ= F_HZ/1000 ; //1000000/1000(1khz)=1000
// u16 F_100HZ= F_HZ/100 ; //1000000/100(100hz)=10000
TIM_TimeBaseStructure.TIM_Prescaler =18;// 预分频,此值+1为分频的除数 3M
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseStructure.TIM_Period = 6;
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
TIM_TimeBaseStructure.TIM_RepetitionCounter = 0;
TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
CCR2_Val=3;
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_Toggle;
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_OutputNState = TIM_OutputState_Disable;
TIM_OCInitStructure.TIM_Pulse = CCR2_Val;
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
TIM_OCInitStructure.TIM_OCNPolarity = TIM_OCPolarity_Low;//TIM_OCNPolarity_High //关闭反向通道
TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Reset;
TIM_OCInitStructure.TIM_OCNIdleState = TIM_OCIdleState_Reset;
TIM_OC2Init(TIM2, &TIM_OCInitStructure);
TIM_Cm(TIM2,ENABLE);
TIM_CtrlPWMOutputs(TIM2, ENABLE);
}
/*定时器3通道4输入捕捉*/
void TIM3_ICAP_Setup(void)
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_ICInitTypeDef TIM_ICInitStructure;
TIM_TimeBaseStructure.TIM_Period = 0xffff; // ????
TIM_TimeBaseStructure.TIM_Prescaler = 99; //分频后为54M/(99+1)=540K ???
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);
TIM_PrescalerConfig(TIM3, 99,TIM_PSCReloadMode_Immediate );
TIM_ICInitStructure.TIM_Channel = TIM_Channel_4; //选择通道4
TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising; //输入上升沿捕获
TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI; //通道方向选择
TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1; //每次检测到捕获输入就触发一次捕获
TIM_ICInitStructure.TIM_ICFilter = 0x03;//脉冲滤波
TIM_ICInit(TIM3, &TIM_ICInitStructure);
TIM_SelectInputTrigger(TIM3, TIM_TS_TI2FP2); //参考TIM结构图选择滤波后的TI1输入作为触发源,触发下面程序的复位
TIM_SelectSlaveMode(TIM3, TIM_SlaveMode_Reset); //复位模式-选中的触发输入(TRGI)的上升沿初始化计数器,并且产生一个更新线号
TIM_SelectMasterSlaveMode(TIM3, TIM_MasterSlaveMode_Enable); //启动定时器的被动触发
/* Enable the CC2 Interrupt Request */
TIM_ITConfig(TIM3, TIM_IT_CC4, ENABLE); // 打开中断
TIM_Cmd(TIM3, ENABLE);
TIM_ClearITPendingBit(TIM3, TIM_IT_CC4);
}
void TIM3_IRQHandler (void)
{
#define OFFSET7135 7657
TIM_ICInitTypeDef TIM_ICInitStructure;
if(TIM_GetITStatus(TIM3, TIM_IT_CC4) == SET)
{
TIM_ClearITPendingBit(TIM3, TIM_IT_CC4);
if(TIM3ICValue1==0)
{
TIM3ICValue1=TIM_GetCapture4(TIM3);
//test1();
TIM_ICInitStructure.TIM_Channel = TIM_Channel_4; //选择通道3
TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Falling;//输入下降沿捕获 TIM_ICPolarity_Rising;
TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI; //通道方向选择 //将TI2配置到PA1上
TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1; //每次检测到捕获输入就触发一次捕获
TIM_ICInitStructure.TIM_ICFilter = 0x03;//脉冲滤波
TIM_ICInit(TIM3, &TIM_ICInitStructure);
GPIOA->ODR ^= GPIO_Pin_12;
if(GPIO_ReadInputDataBit(ICL7135_POLE_PORT,ICL7135_POLE_PIN))//读7135 POLH引脚电平是否为高?
POLE_7135_FLAG = 1;
else
POLE_7135_FLAG = 0;
}
else
{
TIM3ICValue2=TIM_GetCapture4(TIM3);
TIM_ICInitStructure.TIM_Channel = TIM_Channel_4; //选择通道3
TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;//TIM_ICPolarity_Rising; //输入上升沿捕获
TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI; //通道方向选择 //将TI2配置到PA1上
TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1; //每次检测到捕获输入就触发一次捕获
TIM_ICInitStructure.TIM_ICFilter = 0x03;//脉冲滤波
TIM_ICInit(TIM3, &TIM_ICInitStructure);
ResultAD7135=(1.0001*(TIM3ICValue2-TIM3ICValue1-OFFSET7135))/OFFSET7135;//得到AD值
if(!POLE_7135_FLAG) ResultAD7135 = -1*ResultAD7135; //判断信号的正负
// sprintf(DisL2Buf,"7135:%.3f",ResultAD7135);//打开此处注释短接7135第9-10脚显示出的数即为 OFFSET7135
// test_ax();
// test2() ;
GPIOA->ODR ^= GPIO_Pin_15;
TIM3ICValue1 = 0;
TIM3ICValue2 = 0;
TIM3INTCount=1;
}
}
}
还有其他的看工程文件。
里面有IAR 源码文件与PDF 原理图ourdev_629986UDNIW4.zip(文件大小:584K) (原文件名:IAR STM32 LCR.zip)
一周热门 更多>