基于51单片机的正弦波发生器设计

发布时间:2023-02-09  

程序运行图:

仿真原理图:


部分程序:

#include


//接口定义

sbit DA = P1^1;

sbit CK = P1^2;

sbit CS = P1^4;


//10bit取样,1024点正弦查表数据

unsigned int code sine_dot[1024]=

{

0x200,0x203,0x206,0x209,0x20c,0x20f,0x212,0x215,0x219,0x21c,0x21f,0x222,0x225,0x228,0x22b,0x22f,0x232,

0x235,0x238,0x23b,0x23e,0x241,0x244,0x247,0x24b,0x24e,0x251,0x254,0x257,0x25a,0x25d,0x260,0x263,0x266,0x269,0x26d,0x270,

0x273,0x276,0x279,0x27c,0x27f,0x282,0x285,0x288,0x28b,0x28e,0x291,0x294,0x297,0x29a,0x29d,0x2a0,0x2a3,0x2a6,0x2a9,0x2ac,

0x2af,0x2b2,0x2b5,0x2b8,0x2bb,0x2be,0x2c0,0x2c3,0x2c6,0x2c9,0x2cc,0x2cf,0x2d2,0x2d5,0x2d7,0x2da,0x2dd,0x2e0,0x2e3,0x2e6,

0x2e8,0x2eb,0x2ee,0x2f1,0x2f4,0x2f6,0x2f9,0x2fc,0x2fe,0x301,0x304,0x307,0x309,0x30c,0x30f,0x311,0x314,0x317,0x319,0x31c,

0x31e,0x321,0x324,0x326,0x329,0x32b,0x32e,0x330,0x333,0x335,0x338,0x33a,0x33d,0x33f,0x342,0x344,0x347,0x349,0x34b,0x34e,

0x350,0x353,0x355,0x357,0x35a,0x35c,0x35e,0x360,0x363,0x365,0x367,0x369,0x36c,0x36e,0x370,0x372,0x374,0x376,0x379,0x37b,

0x37d,0x37f,0x381,0x383,0x385,0x387,0x389,0x38b,0x38d,0x38f,0x391,0x393,0x395,0x397,0x399,0x39b,0x39c,0x39e,0x3a0,0x3a2,

0x3a4,0x3a6,0x3a7,0x3a9,0x3ab,0x3ad,0x3ae,0x3b0,0x3b2,0x3b3,0x3b5,0x3b7,0x3b8,0x3ba,0x3bb,0x3bd,0x3be,0x3c0,0x3c1,0x3c3,

0x3c4,0x3c6,0x3c7,0x3c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3ab,0x3aa,0x3a8,0x3a6,

0x3a4,0x3a2,0x3a1,0x39f,0x39d,0x39b,0x399,0x397,0x395,0x393,0x392,0x390,0x38e,0x38c,0x38a,0x388,0x386,0x384,0x382,0x37f,

0x37d,0x37b,0x379,0x377,0x375,0x373,0x371,0x36e,0x36c,0x36a,0x368,0x366,0x363,0x361,0x35f,0x35c,0x35a,0x358,0x355,0x353,

0x351,0x34e,0x34c,0x34a,0x347,0x345,0x342,0x340,0x33d,0x33b,0x339,0x336,0x334,0x331,0x32e,0x32c,0x329,0x327,0x324,0x322,

0x31f,0x31d,0x31a,0x317,0x315,0x312,0x30f,0x30d,0x30a,0x307,0x305,0x302,0x2ff,0x2fc,0x2fa,0x2f7,0x2f4,0x2f1,0x2ef,0x2ec,

0x2e9,0x2e6,0x2e4,0x2e1,0x2de,0x2db,0x2d8,0x2d5,0x2d2,0x2d0,0x2cd,0x2ca,0x2c7,0x2c4,0x2c1,0x2be,0x2bb,0x2b8,0x2b6,0x2b3,

0x2b0,0x2ad,0x2aa,0x2a7,0x2a4,0x2a1,0x29e,0x29b,0x298,0x295,0x292,0x28f,0x28c,0x289,0x286,0x283,0x280,0x27d,0x27a,0x277,

0x273,0x270,0x26d,0x26a,0x267,0x264,0x261,0x25e,0x25b,0x258,0x255,0x252,0x24e,0x24b,0x248,0x245,0x242,0x23f,0x23c,0x239,

0x236,0x232,0x22f,0x22c,0x229,0x226,0x223,0x220,0x21d,0x219,0x216,0x213,0x210,0x20d,0x20a,0x207,0x203,0x200,0x1fd,0x1fa,

0x1f7,0x1f4,0x1f1,0x1ed,0x1ea,0x1e7,0x1e4,0x1e1,0x1de,0x1db,0x1d8,0x1d4,0x1d1,0x1ce,0x1cb,0x1c8,0x1c5,0x1c2,0x1bf,0x1bb,

0x1b8,0x1b5,0x1b2,0x1af,0x1ac,0x1a9,0x1a6,0x1a3,0x1a0,0x19c,0x199,0x196,0x193,0x190,0x18d,0x18a,0x187,0x184,0x181,0x17e,

0x17b,0x178,0x175,0x172,0x16f,0x16c,0x169,0x166,0x163,0x160,0x15d,0x15a,0x157,0x154,0x151,0x14e,0x14b,0x148,0x145,0x142,

0x13f,0x13c,0x13a,0x137,0x134,0x131,0x12e,0x12b,0x128,0x125,0x123,0x120,0x11d,0x11a,0x117,0x115,0x112,0x10f,0x10c,0x109,

0x107,0x104,0x101,0xff,0xfc,0xf9,0xf6,0xf4,0xf1,0xee,0xec,0xe9,0xe6,0xe4,0xe1,0xdf,0xdc,0xd9,0xd7,0xd4,0xd2,0xcf,0xcd,

0xca,0xc8,0xc5,0xc3,0xc0,0xbe,0xbb,0xb9,0xb7,0xb4,0xb2,0xaf,0xad,0xab,0xa8,0xa6,0xa4,0xa1,0x9f,0x9d,0x9b,0x98,0x96,0x94,

0x92,0x90,0x8d,0x8b,0x89,0x87,0x85,0x83,0x81,0x7f,0x7c,0x7a,0x78,0x76,0x74,0x72,0x70,0x6e,0x6d,0x6b,0x69,0x67,0x65,0x63,

0x61,0x5f,0x5e,0x5c,0x5a,0x58,0x56,0x55,0x53,0x51,0x50,0x4e,0x4c,0x4b,0x49,0x47,0x46,0x44,0x43,0x41,0x3f,0x3e,0x3c,0x3b,

0x3a,0x38,0x37,0x35,0x34,0x32,0x31,0x30,0x2e,0x2d,0x2c,0x2b,0x29,0x28,0x27,0x26,0x25,0x23,0x22,0x21,0x20,0x1f,0x1e,0x1d,

0x1c,0x1b,0x1a,0x19,0x18,0x17,0x16,0x15,0x14,0x13,0x12,0x12,0x11,0x10,0xf,0xe,0xe,0xd,0xc,0xc,0xb,0xa,0xa,0x9,0x8,0x8,0x7,

0x7,0x6,0x6,0x5,0x5,0x4,0x4,0x3,0x3,0x3,0x2,0x2,0x2,0x1,0x1,0x1,0x1,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,

0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x1,0x1,0x1,0x2,0x2,0x2,0x2,0x3,0x3,0x4,0x4,0x4,0x5,0x5,0x6,0x6,0x7,0x7,0x8,0x8,0x9,

0xa,0xa,0xb,0xc,0xc,0xd,0xe,0xf,0xf,0x10,0x11,0x12,0x13,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,

0x20,0x21,0x22,0x24,0x25,0x26,0x27,0x28,0x2a,0x2b,0x2c,0x2d,0x2f,0x30,0x31,0x33,0x34,0x36,0x37,0x38,0x3a,0x3b,0x3d,0x3e,


//数据写入

void da5615(unsigned int da)

{

unsigned char i;

da <<= 6;//10有效数据左对齐

CS = 0;

CK = 0;

for (i=0;i<12;i++)

{

DA = (bit)(da & 0x8000);

CK = 1;

}

CS = 1;

CK = 0;

}


main()

{

unsigned int j;

while(1)

{

da5615(sine_dot[j]);

if(++j > 1023) j=0;

}

}


文章来源于:电子工程世界    原文链接
本站所有转载文章系出于传递更多信息之目的,且明确注明来源,不希望被转载的媒体或个人可与我们联系,我们将立即进行删除处理。

相关文章

    电路与电子技术课程设计报告(正弦、方波-三角波、可调矩形波、可调锯齿波发生器); 本文详细介绍了电子工程实验中的直流稳压电源和信号发生器的设计过程。实验涵盖了电源变压器、整流、滤波......
    控制直接通过数字接口就可以对频率、幅度、相位等进行控制。 射频正弦波发生器系统的工作原理是基于DDS的信号产生方式,通过低通滤波器和放大器提高射频信号的频率特性和驱动能力,通过......
    任意波发生器如何输出波形、带调制的信号;首先我们打开一台SDG6000X-E和一台示波器。通过BNC连接线,连接好发生器通道1和示波器通道1。 首先设置SDG6000X-E,选择正弦波,设置:频率......
    和等边三角波的交点来决定每个脉冲的上升沿和下降沿时。等边三角波由三角波发生器产生,是变频器的基波,其频率与基波频率相同。 载波的振幅决定了脉冲的高度,载波频率确定了每个半周期内的脉冲数。正弦波......
    的组成部分。正弦波是三角波通过正弦波形成电路变换而来的。所需波形经过选取、放大后经衰减器输出。 直流偏置电路提供一个直流补偿调整,使信号发生器输出的直流成分可以进行调节。 图1 信号发生器的简化原理框图 三......
    分析直流通路,可以看书,输出信号中会叠加出来2.5V的直流信号。 输出幅值由于衰减正常比较小,因此可以在后级添加同相放大电路,这样可以将信号进行放大。 输出的波形如下所示: 方波发生器: 上面的是方波发生器......
    )。 方波发生器电路可用于产生方波。 斜坡发生器 2、有源低通滤波器-具有直流增益控制的交流积分放大器 如果基于运算放大器的积分器电路的输入是正弦波......
    调节输出电压。 具有固定振幅和频率的三角波形,以及具有等于输出频率的固定频率和可变振幅的正弦波形等这些概念,是本文阐述的实现SPWM发生器的基础。SPWM发生器如图6的框图所示。 图6. 该框图显示了SPWM发生器......
    为不同的测试应用产生各种波形。这些测试仪器中的一些用于射频测试领域,而另一些则用于音频测试,可能作为正弦波发生器等,其他用于提供脉冲,可能用于激励数字电路。信号发生器有数千种不同的应用。   然而,它们与示波器、数字......
    的频率范围以及正弦波、方波、三角波和TTL输出的特性为测试提供高品质保证。DDS技术为需要精确的信号源测量的使用者提供了合理的价格。 DDS信号发生器逐渐成为主流信号发生器,该技术简明易懂,同时......

我们与500+贴片厂合作,完美满足客户的定制需求。为品牌提供定制化的推广方案、专属产品特色页,多渠道推广,SEM/SEO精准营销以及与公众号的联合推广...详细>>

利用葫芦芯平台的卓越技术服务和新产品推广能力,原厂代理能轻松打入消费物联网(IOT)、信息与通信(ICT)、汽车及新能源汽车、工业自动化及工业物联网、装备及功率电子...详细>>

充分利用其强大的电子元器件采购流量,创新性地为这些物料提供了一个全新的窗口。我们的高效数字营销技术,不仅可以助你轻松识别与连接到需求方,更能够极大地提高“闲置物料”的处理能力,通过葫芦芯平台...详细>>

我们的目标很明确:构建一个全方位的半导体产业生态系统。成为一家全球领先的半导体互联网生态公司。目前,我们已成功打造了智能汽车、智能家居、大健康医疗、机器人和材料等五大生态领域。更为重要的是...详细>>

我们深知加工与定制类服务商的价值和重要性,因此,我们倾力为您提供最顶尖的营销资源。在我们的平台上,您可以直接接触到100万的研发工程师和采购工程师,以及10万的活跃客户群体...详细>>

凭借我们强大的专业流量和尖端的互联网数字营销技术,我们承诺为原厂提供免费的产品资料推广服务。无论是最新的资讯、技术动态还是创新产品,都可以通过我们的平台迅速传达给目标客户...详细>>

我们不止于将线索转化为潜在客户。葫芦芯平台致力于形成业务闭环,从引流、宣传到最终销售,全程跟进,确保每一个potential lead都得到妥善处理,从而大幅提高转化率。不仅如此...详细>>