最新免费av在线观看,亚洲综合一区成人在线,中文字幕精品无码一区二区三区,中文人妻av高清一区二区,中文字幕乱偷无码av先锋

用打印機(jī)端口做可編程頻率發(fā)生器電路

出處:sunkingyan 發(fā)布于:2008-07-05 00:00:00 | 1782 次閱讀

         
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<bios.h>
#include<dos.h>

#define CLK1 0x04 /* Clock Pulse High*/
#define CLK0 0xfb /* Clock Pulse Low*/
#define CS1  0x01 /* Chip Select high to deacTIvate DAC*/
#define CS0 0xfe /* Chip Select low to activate DAC*/
#define DATA1 0x02 /* Data Pulse High*/
#define DATA0 0xfd /* Data Pulse low*/

int c[16],dport,ACTUALDATA,out,k;   /*Global Declarations*/
float VOUT;/*DAC OUTPUT*/

void d2b(unsigned int x, int*c)/*Routine for Decimal to Binary Conversion*/
{
int i;
for(i=0;i<=15;i++)
*(c++)=(x>>i) & 0x1;
}

float ftov()   /*Hertz to DAC output Conversion Routine*/
{
int HERTZ;
printf("\n \nEnter the frequency  within 0 to 10000Hz:");
scanf("%d",&HERTZ);
VOUT=0.00040955*HERTZ;
printf("\n VOUT=%f\n",VOUT);
return VOUT;
}

void CLOCK_DAC(void)/*Routine for clocking the DAC*/
{
out|=CLK1;
outportb(dport,out);/*Setting the clock high*/
delay(1);
out&=CLK0;
outportb(dport,out);/*Setting the clock low*/
delay(1);
}

void LOAD_DACDATA(int*c)/*Routine for loading actual data into the DAC*/
{
out|=CS1;
outportb(dport,out);/*Chip Select high to disable DAC*/
delay(1);
out&=CS0;
outportb(dport,out);/*Chip Select low to enable DAC*/
delay(1);
printf("\nDATA loaded into the DAC=");
for(k=15;k>=0;k--)
{
out|=c[k];
outportb(dport,out);
printf("%d",c[k]);
delay(1);
CLOCK_DAC();
}
out|=CS1;
outportb(dport,out);
delay(1);
}

main()
{
int v,inc;
float y;
unsigned  int x;
double fraction, integer, number;
clrscr();
printf("\tUse Your Printer Port as a Programmable Frequency Generator");
printf("\n\t\t\t by\n");
printf("\tK.Suresh,MSD,IGCAR,Kalpakkam,TamilNadu-603102,India");
dport= peek(0x40,8);/*Check up for availability of Printer Port*/
if (dport==0)
{
printf("\n\n LPT NOT AVIAILABLE! EXITING........");
exit(1);
}
printf("\n\nAddress of the printer port found =0x%X",dport);
ftov();
y=(VOUT*8192)/(2.5*1.6384);
v=y/1;
number=y;
fraction = modf(number, &integer);
if (fraction<0.44)
inc=0;
else inc=1;
ACTUALDATA=16384+v+inc; /*Actual data including the Control Word for DAC*/
d2b(ACTUALDATA,c);
LOAD_DACDATA(c);
return 0;
}

0次

版權(quán)與免責(zé)聲明

凡本網(wǎng)注明“出處:維庫(kù)電子市場(chǎng)網(wǎng)”的所有作品,版權(quán)均屬于維庫(kù)電子市場(chǎng)網(wǎng),轉(zhuǎn)載請(qǐng)必須注明維庫(kù)電子市場(chǎng)網(wǎng),http://www.udpf.com.cn,違反者本網(wǎng)將追究相關(guān)法律責(zé)任。

本網(wǎng)轉(zhuǎn)載并注明自其它出處的作品,目的在于傳遞更多信息,并不代表本網(wǎng)贊同其觀點(diǎn)或證實(shí)其內(nèi)容的真實(shí)性,不承擔(dān)此類作品侵權(quán)行為的直接責(zé)任及連帶責(zé)任。其他媒體、網(wǎng)站或個(gè)人從本網(wǎng)轉(zhuǎn)載時(shí),必須保留本網(wǎng)注明的作品出處,并自負(fù)版權(quán)等法律責(zé)任。

如涉及作品內(nèi)容、版權(quán)等問(wèn)題,請(qǐng)?jiān)谧髌钒l(fā)表之日起一周內(nèi)與本網(wǎng)聯(lián)系,否則視為放棄相關(guān)權(quán)利。

OEM清單文件: OEM清單文件
*公司名:
*聯(lián)系人:
*手機(jī)號(hào)碼:
QQ:
有效期:

掃碼下載APP,
一鍵連接廣大的電子世界。

在線人工客服

買家服務(wù):
賣家服務(wù):
技術(shù)客服:

0571-85317607

網(wǎng)站技術(shù)支持

13606545031

客服在線時(shí)間周一至周五
9:00-17:30

關(guān)注官方微信號(hào),
第一時(shí)間獲取資訊。

建議反饋

聯(lián)系人:

聯(lián)系方式:

按住滑塊,拖拽到最右邊
>>
感謝您向阿庫(kù)提出的寶貴意見(jiàn),您的參與是維庫(kù)提升服務(wù)的動(dòng)力!意見(jiàn)一經(jīng)采納,將有感恩紅包奉上哦!