完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
您好,当我使用全桥单相逆变器的90度查找表时,我遇到了一个问题。我把整个360度分为4个90度的部分。我的问题是当我从90度移动到180度时,计时器2与PR2寄存器匹配不会触发我的端口引脚的任何输出变化,但是当我使用180度查找表时,我没有任何麻烦。由于空间限制,我需要使用90度查找表。我将附加中断服务例程代码。希望能找到一个解决方案。更多的项目描述,我使用2个半桥模式模块。PWM频率是24K,输出应该是50赫兹正弦波。关于,罗兰多
以上来自于百度翻译 以下为原文 Hello, I have a problem when I use a 90 degrees lookup table for a full bridge single phase inverter. I divided the whole 360 degrees into 4 parts of 90 degrees each. My problem is when I move from 90 degrees to 180 degrees, the timer 2 match with the PR2 register doesn't trigger any output change on my PORT pins, HOWEVER when I use a 180 degrees lookup table I don't have any trouble. I need to use the 90 degrees lookup table due to space constraints. I will attach the interrupt service routine code. Hope we can find a solution to this. More description of the project, I'm using 2 half bridge mode modules. The PWM frequency is 24K, and the output should be 50 Hz sine wave. Regards, Rolando Attachment(s) ISR.txt (1.20 KB) - downloaded 52 times |
|
相关推荐
6个回答
|
|
你没有提到你使用的是哪一个PIC。如果它有LAT寄存器,你应该写信给他们,而不是端口寄存器,以避免读取/修改/写入问题。
以上来自于百度翻译 以下为原文 You did not mention which PIC you are using. If it has LAT registers, you should be writing to them rather than the PORT registers to avoid read/modify/write problems. |
|
|
|
IM使用PIC16F1936,它具有锁存寄存器,但我不写任何端口,因为TMR2与PR2的匹配应该自动改变我的端口输出。我认为当我反转计数器和查找表向后读取时,问题就出现了。
以上来自于百度翻译 以下为原文 Im using PIC16F1936, it has LATCH registers, but I'm not writing to any PORT, since the match of TMR2 with PR2 should automatically change my PORT output. I think the problem arises when I reverse the counter and the lookup table is being read backwards. |
|
|
|
我认为你需要重新评估这个声明:从你的ISR函数:这肯定是写入PORTC寄存器。按照QHB建议,改变这些类型的语句来使用LabcBIT。
以上来自于百度翻译 以下为原文 I think you need to re-evaluate that statement: from your isr function: if(dutycycle_direction) // Initially 0 { PORTCbits.RC2 = ~ PORTCbits.RC2; PORTBbits.RB2 = ~ PORTBbits.RB2; PORTCbits.RC1 = ~ PORTCbits.RC1; PORTCbits.RC0 = ~ PORTCbits.RC0; dutycycle_direction = 0; } This is definitely writing to the PORTC register. Do as qhb suggests and change these type of statements to use the LATCbits instead. |
|
|
|
比特在这个代码中顺序地被改变:没有完整的示意图,很难说比特之间的延迟可能会引起什么问题。如果你能在一个端口中获得所有的控制位,你可以同时在GP中改变它们。
以上来自于百度翻译 以下为原文 The bits are being changed sequentially in this code: if(dutycycle_direction) // Initially 0 { PORTCbits.RC2 = ~ PORTCbits.RC2; PORTBbits.RB2 = ~ PORTBbits.RB2; PORTCbits.RC1 = ~ PORTCbits.RC1; PORTCbits.RC0 = ~ PORTCbits.RC0; dutycycle_direction = 0; } Without a full schematic, it's hard to say what issues the delay between bit changes might cause. If you could get all the control bits in one port, you could change them simultaneously as in: if(dutycycle_direction) // Initially 0 { LATCbits ^= 0x0F; // Using Port C Bits 0-3. dutycycle_direction = 0; } GP |
|
|
|
另外,我们还没有看到完整的代码。如果这些引脚是模拟模式,那么代码总是会失败。
以上来自于百度翻译 以下为原文 Plus, we have not seen the full code. If those pins are in analog mode, that code will always fail. |
|
|
|
谢谢大家,我在芯片上烧了它,使用90度查找表工作!(我检查了示波器)我还有其他问题,这个概念对我来说不太清楚:如何定义正弦波的180度到360度?(我认为这种方法的补充会起作用,但显然不起作用):(我没有纠正我的脉搏,但我想我得到了一个全波整流正弦波。
以上来自于百度翻译 以下为原文 Thanks guys, I burnt it on the chip and using the 90 degrees lookup table is working! (I checked on the oscilloscope) I have other question where this concept is not too clear to me : How to define the 180 degrees to 360 degrees of the sine wave, the negative part? (I thought this approach of one's complement will work, but apparently didn't work) :( I haven't rectified my pulses but I think I'm getting a full wave rectified sine wave. |
|
|
|
只有小组成员才能发言,加入小组>>
5189 浏览 9 评论
2009 浏览 8 评论
1933 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3181 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2232 浏览 5 评论
743浏览 1评论
629浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
512浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
642浏览 0评论
538浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-30 08:20 , Processed in 1.539666 second(s), Total 86, Slave 72 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号