完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
你好,我用的是MCP34和18F45。在我使用18F453与这个ADC芯片之前。效果很好。但是相同的代码不能与18F450一起使用。有一个区别。18F453与外部OSC工作在48 MHz。现在我尝试用8MHz的内部振荡器工作,这个问题是:输出不稳定,振荡范围很宽。有什么想法吗?代码://**O.N.B.I.T.**********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************μE//内振荡器KulLAN Youuz VE R6 Pi I/O OLARK KulLAN LabILIL。国际语包括“StA.h”的包括“Saa.h”的“包括”和“ADC”,包括:“LCD16.H”包含“LCD16.H”,包括:EEP。我是你的朋友。包含和lt;pHbb. h & gt;T.H“α”包括:艾伦n de i i i i Keun签署CHAR ADCL;//Adcdn A.Nangde Dyuk k字节n艾伦i de i i Ke//*********原型空隙RAKAM(未签名INTR);未签名int HARICIAHADC(未签名int CH);未签名char GonderAlSpi(无符号CHAR数据);空主(空){OSCCon=0xF2;/ /内部振荡器,8MHz CM5ILE 2:0 GRIZ0=0B10000;//TrISB= 0B000 000 111;/TrISC= 0B000 000 111;Trase= 0B00 000 1111;Delay10ktCyx(160);A1=0;A3=0;B1=0;B2=0;B3=0;/*为(i=0;I & lt;10;i++){STR=32;}*/CSY-ADC= 0;CSYRTC=γ;LCD;LCD;Con=0x07;TrISD= 0B10000;//PORTD位,3,4,5,CU K(0);7:In();//LCD ILK AyaLaLa yayl L yor Delay10ktCyx(60);LCDCMD(0x01);GoOxy(0,0);打印(“SISSTEM”);GooTyy(0,1);打印(“BasLatiLyor…”)打印(“HAZIR”);GOOTYY(0,1);打印(“1”){LCDCMD(0x01);GOOTYY(0,0);HARICIAL ADC(0);RaKAM(SONUC);Delay10ktCyx(30);}空隙RAKAM(未签名INTR){//无符号int t;//无符号INTY;未签名INTS1,S2,S3,S4;S1=(R/1000);IF(S1==0){打印(“”);}延迟10ktCyx(200);GOOTYY(0,0);= = 0和(S1=0){} LCDDATA(S2+48);}//y= t;S3=(R/10)%10;IF(S1==0;和;S2==0和;S3=0){} LCDDATA(S3+48);} S4= R% 10;LCDDATA(S4+Y);}无符号int HARICIAHADC(无符号int CH){无符号Chan-KaAl;IF(CH====CH===CH==CH==CH=C=)E{LCDDATA(S1+ 48);}//y= t;S2=(R/ 100)% 10;IF(S2){SeaMe=Kalal= 0x00;//Kaal-Seou-Erki-FiksiyOnOn(CH=1){Chanal= 0x40;}否则(CH=2){Kaal= 0x80;}否则(CH=3){Chanal= 0xC0;} CSYAdC=0;GonderAlSpi(0x06);ADC= GordalSPI(KANAL);ADCL=GANDALALSPI(0x00);//子字节0)我在Rasgele Yaz Lm ByByg G OnnDelyDuz。CSYADC=1;//ADCH和LeNeCK!ADC= ADCH和0x0f;SunuC= ADCH;SunuC= SunuC<& 8;char GonderAlSpi;(无符号CHAR数据)//SD-I Limleli i在{OpenSPI(SPIOFFSCORY4,MODE00 00,SMPMID);// BurdA.NCE中MeDeNeCek SangrAdDeNeCek SpEnter de i i iik H.Z.DeEnEnLeli de YaMaLyM.SSPBUF=数据;SSPSTATBITS;BF);返回SSPBUF;}
以上来自于百度翻译 以下为原文 Hi, I am using mcp3204 with 18f4550. Before I have used 18f4553 with this ADC chip. It worked fine. But the same code is not working with 18f4550. There is one difference. 18f4553 was working with external osc at 48MHz. Now I am trying to work with internal oscillator with 8MHz. The problem is this: Output is not stable, it oscillate with wide range. Any idea? the code: /** C O N F I G U R A T I O N B I T S *******************************/ //#pragma config PLLDIV = 5 // (20 MHz crystal on PICDEM FS USB board) //#pragma config CPUDIV = OSC1_PLL2 //#pragma config USBDIV = 2 // Clock source from 96MHz PLL/2 //#pragma config FOSC = HSPLL_HS #pragma config FOSC = INTOSCIO_EC //internal oscillator kullanıyoruz ve RA6 pini I/O olarak kullanılabilir. #pragma config WDT = OFF, LVP = OFF, MCLRE = OFF// WD yi kapattık yoksa sürekli reset atıyor, LVP kapalı(şimdilik önemsiz bir ayrıntı), MCLRE yi kapattık. yoksa sistemin mcu nun çalışması için mclryi Vdd ye çekmek gerekiyor. /** I N C L U D E S *************************************************/ #include "p18f4550.h" #include "delays.h" #include "saat.h" #include #include "timers.h" #include "lcd16.h" #include #include "config.h" #include "komut.h" #include #include #include #include #include "math.h" /** V A R I A B L E S ***********************************************/ // değişkenleri buraya yazıyoruz unsigned int sonuc; unsigned char adch;//adcden alınan değerin yüksek byteını alan değişken unsigned char adcl;//adcden alınan değerin düşük byteını alan değişken //********PROTOTYPES void rakam(unsigned int r); unsigned int harici_adc(unsigned int ch); unsigned char GonderAlSpi(unsigned char data); void main( void ) { OSCCON = 0xF2; // internal oscillator, 8MHz CMCON = 0x07; TRISD = 0b00000000; // PORTD bit 3,4,5 çıkış (0); 7:5 ile 2:0 giriş (1) TRISA =0b00000000; // TRISB =0b00000001;// TRISC=0b00000111; TRISE=0x00; ADCON1 = 0b00001111; Delay10KTCYx(160); A1=0; A2=0; A3=0; B1=0; B2=0; B3=0; /*for(i=0;i<10;i++) { str=32; }*/ cs_adc=0; cs_rtc=1; lcdinit(); // LCD ilk ayarları yapılıyor Delay10KTCYx(60); lcdcmd(0x01); gotoXy(0,0); prints("Sistem"); gotoXy(0,1); prints("Baslatiliyor... "); Delay10KTCYx(200); gotoXy(0,0); prints("hazir "); gotoXy(0,1); prints(" "); while(1) { lcdcmd(0x01); gotoXy(0,0); harici_adc(0); rakam(sonuc); Delay10KTCYx(30); } } void rakam(unsigned int r) { //unsigned int t; //unsigned int y; unsigned int s1,s2,s3,s4; s1=(r/1000); if(s1==0) { prints(" "); } else { lcdData(s1+48); } // y=t; s2=(r/100)%10; if(s2==0&s1==0) { prints(" "); } else { lcdData(s2+48); } //y=t; s3=(r/10)%10; if(s1==0&s2==0&s3==0) { prints(" "); } else { lcdData(s3+48); } s4=r%10; lcdData(s4+48); } unsigned int harici_adc(unsigned int ch) { unsigned char kanal; if(ch==0)//mpc3204ün kanallarını seçme { kanal=0x00;//kanal seçerken fonksiyondan high byte değeri gelmiş oluyor } else if(ch==1) { kanal=0x40; } else if(ch==2) { kanal=0x80; } else if(ch==3) { kanal=0xC0; } cs_adc=0; GonderAlSpi(0x06); adch=GonderAlSpi(kanal); adcl=GonderAlSpi(0x00);//son byte ı almak için rastgele yazılmış bir byte gönderiyoruz. cs_adc=1;//adch and lenecek! adch=adch&0x0f; sonuc=adch; sonuc=sonuc<<8|adcl; } unsigned char GonderAlSpi(unsigned char data)//sd işlemleri için { OpenSPI(SPI_FOSC_4 ,MODE_00,SMPMID);//burda önce mid denenecek sonra end denenecek SMPEND değişik hız denemeleri de yapmalıyım. SSPBUF=data; while(!SSPSTATbits.BF); return SSPBUF; } |
|
相关推荐
4个回答
|
|
嗨,这2个图片有几个显著的区别:PIC18F453 *12位ADCPIC18F45 50*10位你注意到了吗?当做
以上来自于百度翻译 以下为原文 Hi, There is one several significant difference between these 2 PICs : PIC18F4553 * 12bits ADC PIC18F4550 * 10bits ADC Did you pay attention to that ? Regards |
|
|
|
我仍然不确定内部ADC是否被使用,或者外部提到的…
以上来自于百度翻译 以下为原文 I am still not sure if internal ADC is being used, or the external one as mentioned... |
|
|
|
谢谢你的回复。但我没有使用内部ADC。我用的是MCP34ADC芯片,你有什么想法吗?它与18F453很好,但不是18F45
以上来自于百度翻译 以下为原文 thanks for your reply. But I am not using the internat ADC. I am using mcp3204 ADC IC. Do you have any idea? It works fine with 18f4553 but not with 18f4550 |
|
|
|
好的,实际上不是:这2张图片非常相似,你的代码应该工作得很好……我对4553的内部ADC有一个问题,这是非线性的,但这不是你的情况。
以上来自于百度翻译 以下为原文 Ok, actually not: those 2 PICs are so similar that your code should work pretty fine... I had an issue with 4553's internal ADC which was kind of non-linear, but this is not your case. |
|
|
|
只有小组成员才能发言,加入小组>>
5192 浏览 9 评论
2012 浏览 8 评论
1936 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3184 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2238 浏览 5 评论
746浏览 1评论
633浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
518浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
644浏览 0评论
544浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-1 20:16 , Processed in 1.421059 second(s), Total 84, Slave 67 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号