完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,所有,在PIC16F83上,我有一个输入频率0~200赫兹,IOCB上的方波,5(PORTB,5),我需要转换成0 111.88 88赫兹。我有一个ISR,它给我输入的TMR1 16位值,也可以执行数学来转换比率。我把输入的TMR1H,TMR1L值乘以1000,然后DIVID。E 24位的结果是1787。数字在LCD显示器上都OK,但是如何将另一个PIC引脚(0~111.88 88赫兹)的合成频率输出到另一个设备????有什么想法吗?特里沃
以上来自于百度翻译 以下为原文 Hi all, On PIC16F883, I have an input frequency 0-200Hz, square wave on IOCB,5 (portB,5), which I need to convert to 0-111.8888Hz. I have an ISR, which gives me TMR1 16bit values for the input and also can perform the maths to convert the ratio. I multiply input TMR1H;TMR1L values by 1000 and then divide 24bit result by 1787. Numbers all OK on LCD display, but how to output resultant frequency on another PIC pin (0-111.8888Hz) to another device ??? Any ideas ? Trevor |
|
相关推荐
8个回答
|
|
|
|
|
|
|
|
|
|
感谢AIOSUE,这已经被添加到现有的项目中,已经进行了很多,所以简单的延迟是不准确的。
以上来自于百度翻译 以下为原文 Thanks aiosue, This is being added into existing project, already a lot going on, so simple delays would not be accurate. |
|
|
|
谢谢NKurzman,不太清楚你用PWM来建议什么?请扩展POSS
以上来自于百度翻译 以下为原文 Thanks NKurzman, Not quite sure what you propose using PWM ? Please expand if poss |
|
|
|
嗨,你不希望一个频率值产生一个输出方波,你将需要逆,(半)周期时间值,知道什么时候改变输出信号。在16F83设备只有1个16位定时器和2个CCP模块(时间捕获,输出定时器比较,或PWM)在PWM模式的最低频率。在PWM模式中,8位定时器被用作时基,PWM分辨率为10位。例如:如果系统振荡器频率为1 MHz,则最低PWM频率为100000赫兹/ 4/16/256=61赫兹,可以使用输出比较模式。制作一个输出脉冲信号,但这可能会导致使用Time1的冲突。我认为最简单的方法是在软件中制作一个24位定时器,使用Time2中断来增加或减缩16位整数变量,TMR2寄存器值为最不重要的8位。g和比较,或预置间隔和倒计时为零:当软件值已递减为=0时,发生定时器中断,输出信号将被改变,计数值恢复。迈西尔
以上来自于百度翻译 以下为原文 Hi, You do not want a Frequency value to create a output square wave, you will need the inverse, (half) period Time value, to know when to change the output signal. In 16F883 device there is only 1 16-bit timer and 2 CCP modules (time Capture, output timer Compare, or PWM) In PWM mode the lowest frequency that may be generated, may be too high for the purpose. In PWM mode the 8-bit timer is used as timebase, and PWM resolution is 10 bits. Example: If system oscillator frequency is 1 MHz, lowest PWM frequency would be 1000000 Hz / 4 / 16 / 256 = 61 Hz It may be possible to use output Compare mode to make a output pulse signal, but that may cause conflict in the use of Timer1. I think the easiest may be to make a 24 bit timer in software, using Timer2 interrupt to increment or decrement a 16-bit integer variable, with TMR2 register value for the least significant 8 bits. Either continously counting and comparing, or preset the interval and count down to zero: when the software value have been decremented to == 0, and timer interrupt occur, the output signal is to be changed and counting values restored. Mysil |
|
|
|
嗨,特里沃,就像你问的那样…我只想把基本知识,基本的或原始的方式。当然,它是不准确的,如果它意味着准确,但基于您的后Mult。然后,1787可以像div一样坏。5594,正如我所说的,和这个PIC或任何其他东西,永远不会是准确的,因为电子学,即使有任何错误纠正方法的反馈。随着频率的变化,温度将改变,阻抗将改变,难以控制的扰动,而不是这里的主题。你的频率0~200赫兹。只是非常慢和短的范围,所以不用担心。延迟考虑到程序的执行时间是准确的。用Frq.Mead读取输出是很方便的。我的意思是“计数器x指令周期或其他……”,无论使用的方法是什么,中断、TMRxx、任何……,无论方法是什么,执行时间必须是从上升沿到下降沿或向后的端口的计数。很容易在软件上做,汇编程序比较好。如果C,拆解代码,看看正在发生什么。简单的方法,PWM,NKurzman和MysIL笔记是目标。以防万一,在“另一个PIC”,读者PIC;读取频率的一半的HI或低脉冲或50%占空比,T / 4…再次由于电子。
以上来自于百度翻译 以下为原文 Hi Trevor, as you asked how to... I just want to put the basic knowhow, basic or primitive way. For sure it´s not accurate if it means exact but based on your post mult. and div. then by 1787 could be as bad as div. by 5594 as I said, and with this PIC or any other thing, would never ever be accurate due the electronics even if having feedback with any error correction method. As freq. change, temperature will change, impedance will change, difficult perturbations to be controlled, not the topic here. Your freq. 0-200 Hz. is just very slow and short range so don´t worry about it. Delays could be accurate taking into account time execution of the routine. Read the output with a freq. meter is one handy. I meant "a counter x instruction cycles or whatever...", by whatever the method you use, interrupts, TMRxx, any..., whatever the method is, the execution time must be the count for a bit at the port from rising edge to falling edge or backwards and it´s easy to do it in software, assembler better. If C, disassemble the code and take a look on what´s going on. The easy way, PWM, NKurzman and Mysil notes are the target. Just in case one more thing, at the "another PIC", the reader PIC; read freq. at half the T of hi or low pulse or for 50% duty cycle, T/4... again due electronics. Regards. |
|
|
|
您还没有说明输出频率必须产生什么分辨率(即什么步长)。这可能会影响实现目标的方法。
以上来自于百度翻译 以下为原文 You have not stated to what resolution the output frequency must be generated (i.e. what step size). This may affect the methods possible to achieve your goal. |
|
|
|
HTTP://WW1.MICCHIP.COM/DeLoSs/En/DeVICECD/OC0401291H.PDFSE.第11章。该芯片内置了H/W PWM
以上来自于百度翻译 以下为原文 http://ww1.microchip.com/downloads/en/DeviceDoc/40001291H.pdf see Chapter 11. the chip has built in H/W PWM |
|
|
|
只有小组成员才能发言,加入小组>>
5128 浏览 9 评论
1984 浏览 8 评论
1914 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3148 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2212 浏览 5 评论
698浏览 1评论
586浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
467浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
603浏览 0评论
495浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-2 18:15 , Processed in 1.250948 second(s), Total 95, Slave 77 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号