单片机产生正弦波

2019-03-24 17:44发布

使用stc12c5410ad的PWM功能,如何产生1KHz的正弦波?是不是产生频率一定的脉冲信号,通过程序控制脉冲信号的脉宽不同,经过RC滤波器后,就可以产生正弦波信号了?对于脉冲信号的脉宽与正弦波有什么什么关系?有公式吗?正弦波的频率与脉冲信号的频率有什么关系?如果要产生有正负半周的正弦波需要怎么做?新手请高手指点一下思路:$ ? 此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
19条回答
coney
1楼-- · 2019-03-25 23:09
我再看看啊,谢谢你哈
sjl2001
2楼-- · 2019-03-26 02:08
 精彩回答 2  元偷偷看……
coney
3楼-- · 2019-03-26 02:38
这个计算,不会是手工画图出来的吧?这样计算误差不是很大吗?你可不可以举个例子啊,就比如正弦波是1kHz,脉冲信号是100kHz,脉冲信号宽度咋个算出来?我看到一个正弦波离散值,是不是一下这个?
tosin[256]={0x80,0x83,0x86,0x89,0x8d,0x90,0x93,0x96,0x99,0x9c,0x9f,0xa2,0xa5,0xa8,0xab,0xae,0xb1,0xb4,0xb7,0xba,0xbc,0xbf,0xc2,0xc5

,0xc7,0xca,0xcc,0xcf,0xd1,0xd4,0xd6,0xd8,0xda,0xdd,0xdf,0xe1,0xe3,0xe5,0xe7,0xe9,0xea,0xec,0xee,0xef,0xf1,0xf2,0xf4,0xf5

,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfd,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0xfd

,0xfd,0xfc,0xfb,0xfa,0xf9,0xf8,0xf7,0xf6,0xf5,0xf4,0xf2,0xf1,0xef,0xee,0xec,0xea,0xe9,0xe7,0xe5,0xe3,0xe1,0xde,0xdd,0xda

,0xd8,0xd6,0xd4,0xd1,0xcf,0xcc,0xca,0xc7,0xc5,0xc2,0xbf,0xbc,0xba,0xb7,0xb4,0xb1,0xae,0xab,0xa8,0xa5,0xa2,0x9f,0x9c,0x99

,0x96,0x93,0x90,0x8d,0x89,0x86,0x83,0x80,0x80,0x7c,0x79,0x76,0x72,0x6f,0x6c,0x69,0x66,0x63,0x60,0x5d,0x5a,0x57,0x55,0x51

,0x4e,0x4c,0x48,0x45,0x43,0x40,0x3d,0x3a,0x38,0x35,0x33,0x30,0x2e,0x2b,0x29,0x27,0x25,0x22,0x20,0x1e,0x1c,0x1a,0x18,0x16

,0x15,0x13,0x11,0x10,0x0e,0x0d,0x0b,0x0a,0x09,0x08,0x07,0x06,0x05,0x04,0x03,0x02,0x02,0x01,0x00,0x00,0x00,0x00,0x00,0x00

,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02 ,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0d,0x0e,0x10,0x11,0x13,0x15

,0x16,0x18,0x1a,0x1c,0x1e,0x20,0x22,0x25,0x27,0x29,0x2b,0x2e,0x30,0x33,0x35,0x38,0x3a,0x3d,0x40,0x43,0x45,0x48,0x4c,0x4e

,0x51,0x55,0x57,0x5a,0x5d,0x60,0x63,0x66 ,0x69,0x6c,0x6f,0x72,0x76,0x79,0x7c,0x80 };
ch0721
4楼-- · 2019-03-26 06:31
这个是啥 不是DAC用的吧 PWM要用timer 来定时 有一些好一点的单片机则集成了PWM的功能 你要是想自己写定时的话 可以先做一个周期的表 计算完全可以编程实现 设定好步长就是正弦与三角波相减 大于0取高小于零取低
coney
5楼-- · 2019-03-26 07:02
 精彩回答 2  元偷偷看……
ch0721
6楼-- · 2019-03-26 11:22
等我忙完这一段的 帮你写一个 现在要赶个机械图

一周热门 更多>