工业控制 | 能源技术 | 汽车电子 | 通信网络 | 安防监控 | 智能电网 | 移动手持 | 无线技术 | 家用电器 | 数字广播 | 消费电子 | 应用软件 | 其他方案

电路设计->综合电路图->综合电路图->单片机音频显示电路的制作

单片机音频显示电路的制作

作者:dolphin时间:2016-10-14

  这次的小作品是频谱显示,8*16的led显示点阵配合stc12系列单片机系统,就可以自己制作廉价的频谱显示了!关于原理图我想说的是,这是原理图,不是封装图,所以大多数IC是看不到Vcc或者Gnd的,但不代表没有,希望初学者留意。原理图是用proteus画的,信号输入端的电阻、电容是抗干扰用的,大小请根据电路的实际情况做改动
  这次的程序不是本人编写,是我师弟的设计,程序是有缺陷的,比如音效的延时,显示的效果等,有耐心的朋友可以自己修改程序,这次的作品在于分享数模转换程序和FFT算法,我也希望网友可以将完善的程序分享到网上,大家共同进步!!!?单片机音频显示电路原理图单片机音频显示电路原理图

单片机音频显示实物照片

单片机音频显示实物照片

下面是我的焊接工程,不熟悉电路布局的童鞋可以做为参考

单片机音频显示点阵正面

单片机音频显示点阵正面

单片机音频显示点阵背面

单片机音频显示点阵背面

单片机音频显示系统板正面

单片机音频显示系统板正面

单片机音频显示系统板背面

单片机音频显示系统板背面

单片机音频显示成品

单片机音频显示成品

  在这里要说的是,焊接并不算复杂,无非就是点阵的焊接耗时耗力,要是有点焊接功夫,小半天也足够了,焊接的时候千万不要弄断管脚,弯折的管脚做跳线最好不过(图3)。系统板的布局我建议大家紧凑一些,我自己焊接的时候是考虑到这板子以后可能加个时间显示什么的,所以预留了一些空间,这样以后再做点阵显示的时候就方便多了。

程序:

#includestc12c5a.h#includeintrins.h#includebasic.htypedef unsigned char uint8;typedef unsigned int uint16;#define ADC_FLAG (14) /*ADC_中断标志*//*放大128倍后的sin整数表(128)*/ code char SIN_TAB[128]={0,6,12,18,24,30,36,42,48,54,59,65,70,75,80,85,89,94,98,102, 105,108,112,114,117,119,121,123,124,125,126,126,126,126,126,125,124,123,121,119,117,114,112,108,105,102,98,94,89,85,80,75,70,65,59,54,48,42,36,30,24,18,12,6,0,-6,-12,-18,-24,-30,-36,-42,-48,-54,-59,-65,-70,-75,-80,-85,-89,-94,-98,-102,-105,-108,-112,-114,-117,-119,-121,-123,-124,-125,-126,-126,-126,-126,-126,-125,-124,-123,-121,-119,-117,-114,-112,-108,-105,-102,-98,-94,-89,-85,-80,-75,-70,-65,-59,-54,-48,-42,-36,-30,-24,-18,-12,-6 };/*放大128倍后的cos整数表(128)*/code char COS_TAB[128]={127,126,126,125,124,123,121,119,117,114,112,108,105,102,98,94, 89,85,80,75,70,65,59,54,48,42,36,30,24,18,12,6,0,-6,-12,-18,-24,-30,-36,-42,-48,-54,-59,-65,-70,-75,-80,-85,-89,-94,-98,-102,-105,-108,-112,-114,-117,-119,-121,-123,-124,-125,-126,-126,-126,-126,-126,-125,-124,-123,-121,-119,-117,-114,-112,-108,-105,-102,-98,-94,-89,-85,-80,-75,-70,-65,-59,-54,-48,-42,-36,-30,-24,-18,-12,-6,0,6,12,18,24,30,36,42,48,54,59,65,70,75,80,85,89,94,98,102,105,108,112,114,117,119,121,123,124,125,126,126 };/*采样存储序列表*/code char LIST_TAB[128] = {0,64,32,96,16,80,48,112,8,72,40,104,24,88,56,120,4,68,36,100,20,84,52,116, 12,76,44,108,28,92,60,124,2,66,34,98,18,82,50,114,10,74,42,106,26,90,58, 122,6,70,38,102,22,86,54,118,14,78,46,110,30,94,62,126,1,65,33,97,17,81,49, 113,9,73,41,105,25,89,57,121,5,69,37,101,21,85,53,117,13,77,45,109,29,93,61, 125,3,67,35,99,19,83,51,115,11,75,43,107,27,91,59,123,7,71,39,103,23,87,55, 119,15,79,47,111,31,95,63,127};/*分级量化表*/uint8 QTY_TAB[] = {0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff};uint8 ADC_Count=0;uint8 i,j,k,b,p,anum; uint16 xdata Fft_Real[128];uint16 xdata Fft_Image[128]; // fft的虚部uint8 xdata LED_TAB[16]; //记录红色柱状/********************************************************************* 名称 : FFT* 功能 : 碟型运算转换* 输入 : 无* 输出 : 读出的值***********************************************************************/void FFT()//基2fft{ uint16 Temp_Real,Temp_Imag,temp; // 中间临时变量uint16 TEMP1 = 0,max=0;for( i=1; i=7; i++) /* for(1) */{b=1;b =(i-1); //碟式运算,用于计算隔多少行计算例如 第一极 1和2行计算for( j=0; j=b-1; j++) /* for (2) */{p=1;p = (7-i); p = p*j;for( k=j; k128; k=k+2*b) /* for (3) */{Temp_Real=Fft_Real[k];Temp_Imag=Fft_Image[k];temp=Fft_Real[k+b];Fft_Real[k]=Fft_Real[k]+((Fft_Real[k+b]*COS_TAB[p])7)+((Fft_Image[k+b]*SIN_TAB[p])7);Fft_Image[k]=Fft_Image[k]-((Fft_Real[k+b]*SIN_TAB[p])7)+((Fft_Image[k+b]*COS_TAB[p])7);Fft_Real[k+b]=Temp_Real-((Fft_Real[k+b]*COS_TAB[p])7)-((Fft_Image[k+b]*SIN_TAB[p])7);Fft_Image[k+b]=Temp_Imag+((temp*SIN_TAB[p])7)-((Fft_Image[k+b]*COS_TAB[p])7); // 移位.防止溢出. 结果已经是本值的 1/64 Fft_Real[k] = 1; Fft_Image[k] = 1;Fft_Real[k+b] = 1; Fft_Image[k+b] = 1; } }}for(j=0;j16;j++)//16分频 { TEMP1=((((Fft_Real[j+1]* Fft_Real[j+1]))+((Fft_Image[j+1]*Fft_Image[j+1])))1);//求各频段幅值if(TEMP11)TEMP1=0;LED_TAB[j]=TEMP1; if(LED_TAB[j]max)max=LED_TAB[j];}if(max 16)//分级量化{max/=16;for(j=0;j16;j++)LED_TAB[j]/=max;} }/********************************************************************* 名称 : GPIO_init* 功能 : GPIO初始化* 输入 : 无* 输出 : 读出的值***********************************************************************/void GPIO_init(){P0M0 = 1; P0M1 = 0; P0 = 0XFF; /*列*/P2M0 = 1; P2M1 = 0; P2 = 0XFF;P3M0 = 1; P3M1 = 0; P3 = 0XFF; /*行*/}/********************************************************************* 名称 : timer_Init* 功能 : 内部寄存器初始化* 输入 : 无* 输出 : 无***********************************************************************/void timer_Init(){TMOD = 0X12;TH0 = 0xb0; TL0 = 0xb0;ET0 = 1; //定时器0 打开TR0 = 0; //关闭定时器TH1 = 0xfd; TL1 = 0Xa8;ET1 = 1;TR1 = 1; EA = 1; }/********************************************************************* 名称 : adc_Init* 功能 : 内部寄存器初始化* 输入 : 无* 输出 : 无***********************************************************************/void adc_Init(){ ADC_CONTR = 0x80; //ADC电源打开_nop_();_nop_();_nop_();_nop_();P1ASF = 0x01; //0000,0001, 将 P1.0 置成模拟口AUXR1 =0xFB; //1111,1011, 令 ADRJ=0ADC_RES = 0x00; //清零寄存器ADC_RESL = 0x00;EADC = 1; //AD中断打开EA = 1; //总中断打开}/********************************************************************* 名称 : main* 功能 : 主程序* 输入 : 无* 输出 : 无***********************************************************************/void main(){uint8 i = 0;GPIO_init();timer_Init();adc_Init();while(1){ADC_Count = 0;EADC = 1;TR0 = 1;while(ADC_Count 128); //满足128点for(i=0; i128; i++) //清除虚部{Fft_Image[i] = 0;}FFT(); //FFT运算并转换为各频段幅值}}/********************************************************************* 名称 : ADC_Finish* 功能 : ADC转换完成中断服务* 输入 : 无* 输出 : 无***********************************************************************/void ADC_Finish() interrupt 5{Fft_Real[LIST_TAB[ADC_Count]] = (int)(((ADC_RES)1)+(ADC_RESL1)*2)3; /*按LIST_TAB表顺序,进行存储采样值*/if(ADC_Count = 127){ADC_Count++; /*自动增量控制*/ADC_CONTR = !ADC_FLAG;}else{EADC = 0;TR0 = 0; } }/********************************************************************* 名称 : interrupt_timer1* 功能 : 显示屏幕刷新中断服务* 输入 : 无* 输出 : 无***********************************************************************/void interrupt_timer1() interrupt 3{ static uint8 rec = 0;TH1 = 0xfd; TL1 = 0Xa8;switch(rec) //往点阵屏填充一列的数据{case 0: P0 = QTY_TAB[LED_TAB[0]]; P2 = 0;break;case 1: P0 = QTY_TAB[LED_TAB[1]]; P2 = 1;break; case 2: P0 = QTY_TAB[LED_TAB[2]]; P2 = 2;break; case 3: P0 = QTY_TAB[LED_TAB[3]]; P2 = 3;break; case 4: P0 = QTY_TAB[LED_TAB[4]]; P2 = 4;break; case 5: P0 = QTY_TAB[LED_TAB[5]]; P2 = 5;break; case 6: P0 = QTY_TAB[LED_TAB[6]]; P2 = 6;break; case 7: P0 = QTY_TAB[LED_TAB[7]]; P2 = 7;break;case 8: P0 = QTY_TAB[LED_TAB[8]]; P2 = 8;break;case 9: P0 = QTY_TAB[LED_TAB[9]]; P2 = 9;break; case 10: P0 = QTY_TAB[LED_TAB[10]]; P2 = 10;break; case 11: P0 = QTY_TAB[LED_TAB[11]]; P2 = 11;break; case 12: P0 = QTY_TAB[LED_TAB[12]]; P2 = 12;break; case 13: P0 = QTY_TAB[LED_TAB[13]]; P2 = 13;break; case 14: P0 = QTY_TAB[LED_TAB[14]]; P2 = 14;break; case 15: P0 = QTY_TAB[LED_TAB[15]]; P2 = 15;break; default:break;}rec++;if(rec 15){rec = 0;}}/********************************************************************* 名称 : Ad_Control* 功能 : 控制采样率* 输入 : 无* 输出 : 无***********************************************************************/void Ad_Control() interrupt 1{ADC_CONTR = 0xe8; //开始AD采集_nop_();_nop_();_nop_();_nop_(); }
HEX文件:
:1003EF0000060C12181E242A30363B41464B50553E:1003FF00595E6266696C70727577797B7C7D7E7EE3:10040F007E7E7E7D7C7B79777572706C6966625EAD:10041F005955504B46413B36302A241E18120C06B4:10042F0000FAF4EEE8E2DCD6D0CAC5BFBAB5B0AB7D:10043F00A7A29E9A9794908E8B89878584838282B8:10044F0082828283848587898B8E9094979A9EA2CD:10045F00A7ABB0B5BABFC5CAD0D6DCE2E8EEF4FAA6:10046F007F7E7E7D7C7B79777572706C6966625E4C:10047F005955504B46413B36302A241E18120C0654:10048F0000FAF4EEE8E2DCD6D0CAC5BFBAB5B0AB1D:10049F00A7A29E9A9794908E8B8987858483828258:1004AF0082828283848587898B8E9094979A9EA26D:1004BF00A7ABB0B5BABFC5CAD0D6DCE2E8EEF4FA46:1004CF0000060C12181E242A30363B41464B50555D:1004DF00595E6266696C70727577797B7C7D7E7E02:1004EF00004020601050307008482868185838783D:1004FF0004442464145434740C4C2C6C1C5C3C7CED:10050F0002422262125232720A4A2A6A1A5A3A7AFC:10051F0006462666165636760E4E2E6E1E5E3E7EAC:10052F0001412161115131710949296919593979EC:10053F0005452565155535750D4D2D6D1D5D3D7D9C:10054F0003432363135333730B4B2B6B1B5B3B7BAC:10055F0007472767175737770F4F2F6F1F5F3F7F5C:10087800080B0103070F1F3F7FFF010A0001080053:10002E00E4F51FF520F521F522751401751301E590:10003E001414FFE513A807088002C333D8FCF51388:10004E00E4F515E51314FFE515D39F4003020328CD:10005E00751701C374079514FFE517A807088002EA:10006E00C333D8FCF5178515F0A4F517851516E5DD:10007E0016C394804003020323E51625E02400F501:10008E0082E43400F583E0F519A3E0F51AE51625B0:10009E00E02410F582E43401F583E0F51BA3E0F5CE:1000AE001CE5162513F925E02400F582E43400F54D:1000BE0083E0FCA3E0FD8C1DF51EE51790046F9305:1000CE00FF3395E0FE120866EF7807CEC313CE130A:1000DE00D8F9FFE51625E02400F582E43400F58317:1000EE00E0FCA3E02FFBEC3EFAE925E02410F582BC:1000FE00E43401F583E0FCA3E0FDE5179003EF93F4:10010E00FF3395E0FE120866EF7807CEC313CE13C9:10011E00D8F92BFFEA3EFEE51625E02400F582E431:10012E003400F583EEF0A3EFF0E925E02400F5822C:10013E00E43400F583E0FCA3E0FDE5179003EF93B4:10014E00FF3395E0FE120866EF7807CEC313CE1389:10015E00D8F9FFE51625E02410F582E43401F58385:10016E00E0FCA3E0C39FFBEC9EFAE925E02410F52A:10017E0082E43401F583E0FCA3E0FDE51790046F03:10018E0093FF3395E0FE120866EF7807CEC313CEC9:10019E0013D8F92BFFEA3EFEE51625E02410F58272:1001AE00E43401F583EEF0A3EFF0E925E02400F549:1001BE0082E43400F583E0FCA3E0FDE51790046FC4:1001CE0093FF3395E0FE120866EF7807CEC313CE89:1001DE0013D8F9FFC3E51A9FFBE5199EFAE925E04E:1001EE002410F582E43401F583E0FCA3E0FDE5176D:1001FE009003EF93FF3395E0FE120866EF7807CE7B:10020E00C313CE13D8F9FFC3EB9FFFEA9EFEE92579:10021E00E02400F582E43400F583EEF0A3EFF0E580:10022E00179003EF93FF3395E0FEAC1DAD1E120841:10023E0066EF7807CEC313CE13D8F9251CFBE51B4A:10024E003EFAE925E02410F582E43401F583E0FC62:10025E00A3E0FDE51790046F93FF3395E0FE1208BF:10026E0066EF7807CEC313CE13D8F9FFC3EB9FFF0B:10027E00EA9EFEE925E02410F582E43401F583EED2:10028E00F0A3EFF0E51625E02400F582E43400F546:10029E0083C083C082E0C313FFA3E013D082D08358:1002AE00CFF0A3EFF0E51625E02410F582E434013B:1002BE00F583C083C082E0C313FFA3E013D082D0C6:1002CE0083CFF0A3EFF0E5162513FD25E02400F50E:1002DE0082E43400F583C083C082E0C313FFA3E041:1002EE0013D082D083CFF0A3EFF0ED25E02410F5EC:1002FE0082E43401F583C083C082E0C313FFA3E020:10030E0013D082D083CFF0A3EFF0E51325E02516AE:10031E00F51602007D05150200510514E51464085A:10032E00600302003AE4F515E51525E02412F58286:10033E00E43401F583E0FCA3E0FDFFAE0412086691:10034E00AA06AB07E51525E02402F582E43400F594:10035E0083E0FCA3E0FDFFAE04120866EF2BFFEE78:10036E003AC313F51FEF13F520C39401E51F940054:10037E005005E4F51FF52074002515F582E43401CF:10038E00F583E520F074002515F582E43401F5833C:10039E00E0FF7E00D39522EE952140048E218F2220:1003AE000515E51564107080D3E5229410E52194AF:1003BE0000402DE521C4F854F0C868F521E522C4AB:1003CE00540F48F522E4F51574002515F582E43432:1003DE0001F583E08522F084F00515E515B410E8EB:0103EE0022EC:10081B00759401E4F5937580FF759601F59575A0B8:0A082B00FF75B201F5B175B0FF22B0:10083500758912758CB0758AB0D2A9C28C758DFD7B:0A084500758BA8D2ABD28ED2AF2281:10084F0075BC8000000000759D0153A2FBE4F5BD4F:07085F00F5BED2ADD2AF22BD:1007E100E4F51812081B12083512084FE4F50AD275:1007F100ADD28CE50AC3948040F9E4F518E51825DB:10080100E02410F582E43401F583E4F0A3F0051847:0A081100E518B480E812002E80D232:03002B0002075B6E:10075B00C0E0C0F0C083C082C0D075D000C000C064:10076B0004C005C006C007E5BEC31375F002A4FDA7:10077B00AFBDEF25E0FFE433FEED2FFFE5F03EFECE:10078B00EF7803CEA2E713CE13D8F8FDAC06E50A3B:10079B009004EF93FF3395E0FEEF25E0FFEE33FE81:1007AB0074002FF58274003EF583ECF0A3EDF0E5B9:1007BB000AD3947F5007050A75BC008004C2ADC2F2:1007CB008CD007D006D005D004D000D0D0D082D0AA:0607DB0083D0F0D0E032F3:03001B0002056F6C:0D056F00C0E0C083C082C0D075D000C000C5:10057C00758DFD758BA8E508B4100040030206B814:10058C00900593F82828730205C30205D30205E3EE:10059C000205F302060302061302062302063302C7:1005AC00064202065102066002066F02067E020631:1005BC008D02069C0206AB900100E0240BF8E6F5D8:1005CC008075A0000206B8900101E0240BF8E6F556:1005DC008075A0010206B8900102E0240BF8E6F544:1005EC008075A0020206B8900103E0240BF8E6F532:1005FC008075A0030206B8900104E0240BF8E6F520:10060C008075A0040206B8900105E0240BF8E6F50D:10061C008075A0050206B8900106E0240BF8E6F5FB:10062C008075A0060206B8900107E0240BF8E6F5E9:10063C008075A0078076900108E0240BF8E6F58021:10064C0075A0088067900109E0240BF8E6F5807529:10065C00A009805890010AE0240BF8E6F58075A0FB:10066C000A804990010BE0240BF8E6F58075A00B8D:10067C00803A90010CE0240BF8E6F58075A00C8014:10068C002B90010DE0240BF8E6F58075A00D801C75:10069C0090010EE0240BF8E6F58075A00E800D900D:1006AC00010FE0240BF8E6F58075A00F0508E508AE:0806BC00D3940F400375080000:0B06C400D000D0D0D082D083D0E03234:03000B00020003ED:0800030075BCE80000000032AA:030000000206CF26:0C06CF00787FE4F6D8FD75812202071642:10086600EF8DF0A4A8F0CF8CF0A428CE8DF0A42EA6:02087600FE2260:1006DB000207E1E493A3F8E493A34003F68001F24D:1006EB0008DFF48029E493A3F85407240CC8C33320:1006FB00C4540F4420C8834004F456800146F6DFEF:10070B00E4800B0102040810204080900878E47EFE:10071B00019360BCA3FF543F30E509541FFEE493E3:10072B00A360010ECF54C025E060A840B8E493A3AA:10073B00FAE493A3F8E493A3C8C582C8CAC583CAD5:10074B00F0A3C8C582C8CAC583CADFE9DEE780BE8D:01088800006F:00000001FF






技术资讯 技术方案 技术应用 技术新品 技术前沿 行业资讯 行业方案 行业应用 行业新品 行业前沿


评论

技术专区