⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 digimod.c

📁 Digital Modulation Techniques are those echniques through which we convert digital signals into anal
💻 C
📖 第 1 页 / 共 4 页
字号:
i=0;
do{
i+=1;
x2=x1+(18);
setfillstyle(1,9);
bar(x1,y1,x2,y2);
t_afp[i-1] = getche();
if(t_afp[i-1] < '0' || t_afp[i-1] > '9')
{i-=1;x2-=20;}
graphicText(x1+4,y1,t_afp[i-1]);
if(i == 2)break;
x1=x2+2;
}while(1);
c_hz = atoi(t_afp);
//////////////////////////////////////////phase
x1=230,x2=230,y1=248,y2=258;
i=0;
do{
i+=1;
x2=x1+(18);
setfillstyle(1,9);
bar(x1,y1,x2,y2);
t_afp[i-1] = getche();
if(t_afp[i-1] < '0' || t_afp[i-1] > '9')
{i-=1;x2-=20;}
graphicText(x1+4,y1,t_afp[i-1]);
if(i == 3)break;
x1=x2+2;
}while(1);
c_angle = atoi(t_afp);
/////////////////////////////////////////////////
c_hz*=10;
c_phase = c_angle*(2*pi/360);
/////////////////////////////////////////////////button
int choice=0; //0 done 1 reset
//x1=502;y1=246;x2=548;y2=260;
x1=562;y1=246;x2=608;y2=260;
setcolor(9);
setfillstyle(1,15); //inner
bar(x1,y1,x2,y2);
//outtextxy(510,247,"Reset");
outtextxy(570,247,"Apply");
while(1)
{
switch(getch())
{
case 77:
case 75:
{
if(choice==0)
{
x1=562;y1=246;x2=608;y2=260;
setcolor(15);setfillstyle(1,9);bar(x1,y1,x2,y2);outtextxy(570,247,"Apply")
;
choice=1;x1=502;y1=246;x2=548;y2=260;
setcolor(9);setfillstyle(1,15);bar(x1,y1,x2,y2);outtextxy(510,247,"Reset")
;
}
else if (choice==1)
{
x1=562;y1=246;x2=608;y2=260;
setcolor(9);setfillstyle(1,15);bar(x1,y1,x2,y2);outtextxy(570,247,"Apply")
;
choice=0;x1=502;y1=246;x2=548;y2=260;
setcolor(15);setfillstyle(1,9);bar(x1,y1,x2,y2);outtextxy(510,247,"Reset")
;
}
break;
}
case '
':
if(choice == 0)return(1); else return(0);
}
}
}
///////////////////////////////////////////////
void qamDataBox()
{
setfillstyle(1,0);
bar(130,80,639,440);
setfillstyle(1,8);
bar(140-4,100-4,640+4,246+4);
setfillstyle(1,15);
bar(140,100,634,246);
setfillstyle(1,9);
bar(142,102,632,120);
setcolor(15);
settextstyle(2,0,4);
outtextxy(145,104,"Quadrature Amplitude Modulation (QAM)");
bar(142,124,320,142);
outtextxy(145,126,"First Amplitude");
setfillstyle(1,8);
bar(332,124,379,144);
setfillstyle(1,1);
bar(334,126,377,142);
setfillstyle(1,15);
int xabc=336,yabc=128,xxyz,yxyz=140;
for(int i=0;i<=1;i++)
{
xxyz=xabc+18;
bar(xabc,yabc,xxyz,yxyz);
xabc=xxyz+2;
}
setfillstyle(1,9);
bar(142,146,320,164);
outtextxy(145,146,"Second Amplitude");
setfillstyle(1,8);
bar(332,144,379,164);
setfillstyle(1,1);
bar(334,146,377,162);
setfillstyle(1,15);
xabc=336,yabc=148,xxyz,yxyz=160;
for(i=0;i<=1;i++)
{
xxyz=xabc+18;
bar(xabc,yabc,xxyz,yxyz);
xabc=xxyz+2;
}
setfillstyle(1,9);
bar(142,166,320,184);
outtextxy(145,166,"First Phase");
setfillstyle(1,8);
bar(332,164,399,184);
setfillstyle(1,1);
bar(334,166,397,182);
setfillstyle(1,15);
xabc=336,yabc=168,xxyz,yxyz=180;
for(i=0;i<=2;i++)
{
xxyz=xabc+18;
bar(xabc,yabc,xxyz,yxyz);
xabc=xxyz+2;
}
setfillstyle(1,9);
bar(142,186,320,204);
outtextxy(145,188,"Second Phase");
setfillstyle(1,8);
bar(332,184,399,202);
setfillstyle(1,1);
bar(334,186,397,200);
setfillstyle(1,15);
xabc=336,yabc=188,xxyz,yxyz=198;
for(i=0;i<=2;i++)
{
xxyz=xabc+18;
bar(xabc,yabc,xxyz,yxyz);
xabc=xxyz+2;
}
setfillstyle(1,9);
bar(142,206,320,224);
outtextxy(145,208,"Third Phase");
setfillstyle(1,8);
bar(332,203,399,222);
setfillstyle(1,1);
bar(334,206,397,220);
setfillstyle(1,15);
xabc=336,yabc=208,xxyz,yxyz=218;
for(i=0;i<=2;i++)
{
xxyz=xabc+18;
bar(xabc,yabc,xxyz,yxyz);
xabc=xxyz+2;
}
setfillstyle(1,9);
bar(142,226,320,244);
outtextxy(145,228,"Fourth Phase");
setfillstyle(1,8);
bar(332,223,399,242);
setfillstyle(1,1);
bar(334,226,397,240);
setfillstyle(1,15);
xabc=336,yabc=228,xxyz,yxyz=238;
for(i=0;i<=2;i++)
{
xxyz=xabc+18;
bar(xabc,yabc,xxyz,yxyz);
xabc=xxyz+2;
}
setfillstyle(1,1);
bar(500,224,550,244);
setfillstyle(1,9); //inner
bar(500+2,224+2,550-2,244-2);
setfillstyle(1,1);
bar(560,224,610,244);
setfillstyle(1,9);    //inner
bar(560+2,224+2,610-2,244-2);
outtextxy(510,228,"Reset");
outtextxy(570,228,"Apply");
}
///////////////////////////////////////////////
int qamInputFun()
{
qam.frequency = c_frequency;
char t_afp[3];
int i=0;
i=0;
/////////////////////////////////////////////amp1
int x1=336,y1=128,x2=354,y2=140;
do{
i+=1;
x2=x1+(18);
setfillstyle(1,9);
bar(x1,y1,x2,y2);
t_afp[i-1] = getche();
if(t_afp[i-1] < '0' || t_afp[i-1] > '9')
{i-=1;x2-=20;}
graphicText(x1+6,y1,t_afp[i-1]);
if(i == 2)break;
x1=x2+2;
}while(1);
qam.amp1 = atoi(t_afp);
///////////////////////////////////////////////////amp2
x1=336;x2=354;y1=148;y2=160;
i=0;
do{
i+=1;
x2=x1+(18);
setfillstyle(1,9);
bar(x1,y1,x2,y2);
t_afp[i-1] = getche();
if(t_afp[i-1] < '0' || t_afp[i-1] > '9')
{i-=1;x2-=20;}
graphicText(x1+6,y1,t_afp[i-1]);
if(i == 2)break;
x1=x2+2;
}while(1);
qam.amp2=atoi(t_afp);
/////////////////////////////////////////////////phase1
x1=336;x2=354;y1=168;y2=180;
i=0;
do{
i+=1;
x2=x1+(18);
setfillstyle(1,9);
bar(x1,y1,x2,y2);
t_afp[i-1] = getche();
if(t_afp[i-1] < '0' || t_afp[i-1] > '9')
{i-=1;x2-=20;}
graphicText(x1+6,y1,t_afp[i-1]);
if(i == 3)break;
x1=x2+2;
}while(1);
qam.ang1=atoi(t_afp);
qam.phase1 = qam.ang1*(2*pi/360);
/////////////////////////////////////////////////phase2
x1=336;x2=354;y1=188;y2=198;
i=0;
do{
i+=1;
x2=x1+(18);
setfillstyle(1,9);
bar(x1,y1,x2,y2);
t_afp[i-1] = getche();
if(t_afp[i-1] < '0' || t_afp[i-1] > '9')
{i-=1;x2-=20;}
graphicText(x1+6,y1,t_afp[i-1]);
if(i == 3)break;
x1=x2+2;
}while(1);
qam.ang2=atoi(t_afp);
qam.phase2 = qam.ang2*(2*pi/360);
/////////////////////////////////////////////////phase3
x1=336;x2=354;y1=208;y2=218;
i=0;
do{
i+=1;
x2=x1+(18);
setfillstyle(1,9);
bar(x1,y1,x2,y2);
t_afp[i-1] = getche();
if(t_afp[i-1] < '0' || t_afp[i-1] > '9')
{i-=1;x2-=20;}
graphicText(x1+6,y1,t_afp[i-1]);
if(i == 3)break;
x1=x2+2;
}while(1);
qam.ang3=atoi(t_afp);
qam.phase3 = qam.ang3*(2*pi/360);
/////////////////////////////////////////////////phase4
x1=336;x2=354;y1=228;y2=238;
i=0;
do{
i+=1;
x2=x1+(18);
setfillstyle(1,9);
bar(x1,y1,x2,y2);
t_afp[i-1] = getche();
if(t_afp[i-1] < '0' || t_afp[i-1] > '9')
{i-=1;x2-=20;}
graphicText(x1+6,y1,t_afp[i-1]);
if(i == 3)break;
x1=x2+2;
}while(1);
qam.ang4=atoi(t_afp);
qam.phase4 = qam.ang4*(2*pi/360);
/////////////////////////////////////////////////
int choice=0; //0 done 1 reset
//x1=502;y1=186;x2=548;y2=200;
x1=562;y1=226;x2=608;y2=242;
setcolor(9);
setfillstyle(1,15); //inner
bar(x1,y1,x2,y2);
//outtextxy(510,188,"Reset");
outtextxy(570,226,"Apply");
while(1)
{
switch(getch())
{
case 77:
case 75:
{
if(choice==0)
{
x1=562;y1=226;x2=608;y2=242;
setcolor(15);setfillstyle(1,9);bar(x1,y1,x2,y2);outtextxy(570,226,"Apply")
;
choice=1;x1=502;y1=226;x2=548;y2=242;
setcolor(9);setfillstyle(1,15);bar(x1,y1,x2,y2);outtextxy(510,226,"Reset")
;
}
else if (choice==1)
{
x1=562;y1=226;x2=608;y2=242;
setcolor(9);setfillstyle(1,15);bar(x1,y1,x2,y2);outtextxy(570,226,"Apply")
;
choice=0;x1=502;y1=226;x2=548;y2=242;
setcolor(15);setfillstyle(1,9);bar(x1,y1,x2,y2);outtextxy(510,226,"Reset")
;
}
break;
}
case '
':
if(choice == 0)return(1); else return(0);
}
}
}
///////////////////////////////////////////////
void showDtable()
{
setfillstyle(1,8);
bar(140-4,280-4,640,410+4);
setfillstyle(1,15);
bar(140,280,634,410);
setfillstyle(1,9);
bar(142,282,632,302);
setfillstyle(1,9);
bar(142,306,632,408);
setfillstyle(1,1);
bar(142,306,632,326);
setcolor(15);
settextstyle(2,0,4);
outtextxy(330,286,"8-QAM Data Table");
setfillstyle(1,1);
bar(142,306,242,408);
setfillstyle(1,15);
bar(242,306,244,410);
bar(142,326,632,328);
bar(142,346,632,348);
bar(142,366,632,368);
bar(142,386,632,388);
bar(420,306,422,410);
setcolor(15);
setlinestyle(0,0,2);
line(142,306,244,326);
setcolor(15);
settextstyle(2,0,4);
outtextxy(189,305,"Amplitude");
outtextxy(149,314,"Phase");
setcolor(15);
show_int_graph(qam.ang1,3,170,332);
show_int_graph(qam.ang2,3,170,352);
show_int_graph(qam.ang3,3,170,372);
show_int_graph(qam.ang4,3,170,392);
show_int_graph(qam.amp1,2,320,311);
show_int_graph(qam.amp2,3,510,311);
setcolor(1);
outtextxy(320,332,"000");
outtextxy(512,332,"001");
outtextxy(320,352,"010");
outtextxy(512,352,"011");
outtextxy(320,372,"100");
outtextxy(512,372,"101");
outtextxy(320,392,"110");
outtextxy(512,392,"111");
setfillstyle(1,8);
bar(560,415,620,435);
setfillstyle(1,15); //inner
bar(560+1,415+1,620-1,435-1);
setfillstyle(1,9); //inner
bar(560+2,415+2,620-2,435-2);
setcolor(15);
outtextxy(568,420,"Continue");
}
//////////////////////////////////////////////////////////////////////////
//
void creategraph_Dqam()
{
y12=yvalue2-20,x12=20,y22=yvalue2;
int cgx1=20,cgy1=140, cgx2=500,cgy2=yvalue2;
setcolor(4);
setlinestyle(0,1,3);
line(cgx1,cgy1,cgx1,cgy2);
line(cgx1,cgy2,cgx2,cgy2);
setcolor(14);
setlinestyle(1,1,1);
for(int i = cgx1+20; i<cgx2;i+=20)
line(i,cgy1,i,cgy2);
settextstyle(1,0,4);
setcolor(15);
outtextxy(x12,30,"DIGITAL SIGNAL");
setfillstyle(1,9);
bar(x12,70,x12+250,72);
settextstyle(2,0,4);setcolor(15);
outtextxy(260,460,"Press any key to continue");
int a=30,b=100;
for(i=0;i<=23;i++)
{
setcolor(15);
graphicText(a,y22-100,bd_4qam[i]);
setcolor(15);
graphicText(b,400,bd_4qam[i]);
a+=20;b+=7;
}
setcolor(9);
outtextxy(40,400,"Data   = ");
//getch();
}
/////////////////////////////////////////////////////
void createDsignal_Dqam()
{
setcolor(2);
int len=25;
for (int i=0;i<len-1;i++)
{
if(bd_4qam[i] == '0')
{
dsignal4_0_Dqam(i+1);
}
else
{
dsignal4_1_Dqam(i+1);
}
}
}
//////////////////////////////////////////////////////
void dsignal4_0_Dqam(int pos)
{
setcolor(2);
setlinestyle(0,1,lineweight);
int x=x12;x12+=20;
if (pos == 1 || (pos != 1 && bd_4qam[pos-2] == '0'))
line(x,y22,x+20,y22);
else
{
line(x,y12,x,y22);
line(x,y22,x+20,y22);
}
}
///////////////////////////////////////////////////////
void dsignal4_1_Dqam(int pos)
{
setcolor(2);
setlinestyle(0,1,lineweight);
int x=x12;x12+=20;
if (pos == 1 || (pos != 1 && bd_4qam[pos-2] == '1'))
line(x,y12,x+20,y12);
else
{
line(x,y12,x,y22);
line(x,y12,x+20,y12);
}
}
///////////////////////////////////////////////////////
///////////////////////////////////////////////
void calc_qam_sinewave(int phase,int amp)
{
float frequency;
frequency = (2 * pi * c_hz)/qam_sr;
for (int t = 0; t<qam_lcycle;t++)
qam.sine_value[t] = amp * (sin((frequency*t)+ phase));
}
////////////////////////////////////////////////
void qam_main()
{
qam.x=32;
for (int i = 0;i<25;i+=3)
{
if (bd_4qam[i] == '0' && bd_4qam[i+1] == '0' && bd_4qam[i+2] == '0')
{
calc_qam_sinewave(qam.phase1,qam.amp1);
create_qam_waves();
}
else if (bd_4qam[i] == '0' && bd_4qam[i+1] == '0' && bd_4qam[i+2] == 
'1')
{
calc_qam_sinewave(qam.phase1,qam.amp2);
create_qam_waves();
}
else if (bd_4qam[i] == '0' && bd_4qam[i+1] == '1' && bd_4qam[i+2] == 
'0')
{
calc_qam_sinewave(qam.phase2,qam.amp1);
create_qam_waves();
}
else if (bd_4qam[i] == '0' && bd_4qam[i+1] == '1' && bd_4qam[i+2] == 
'1')
{
calc_qam_sinewave(qam.phase2,qam.amp2);
create_qam_waves();
}
else if (bd_4qam[i] == '1' && bd_4qam[i+1] == '0' && bd_4qam[i+2] == 
'0')
{
calc_qam_sinewave(qam.phase3,qam.amp1);
create_qam_waves();
}
else if (bd_4qam[i] == '1' && bd_4qam[i+1] == '0' && bd_4qam[i+2] == 
'1')
{
calc_qam_sinewave(qam.phase3,qam.amp2);
create_qam_waves();
}
else if (bd_4qam[i] == '1' && bd_4qam[i+1] == '1' && bd_4qam[i+2] == 
'0')
{
calc_qam_sinewave(qam.phase4,qam.amp1);
create_qam_waves();
}
else if (bd_4qam[i] == '1' && bd_4qam[i+1] == '1' && bd_4qam[i+2] == 
'1')
{
calc_qam_sinewave(qam.phase4,qam.amp2);
create_qam_waves();
}
}
}
////////////////////////////////////////////////////
void create_qam_waves()
{
int y=200,x1,y1;
setcolor(2);
setlinestyle(0,0,3);
for(int i=0;i<fsk_lcycle;i++)
{
x1=qam.x+i;
if(qam.sine_value[i] >= 0)
y1=y-qam.sine_value[i];
else
y1=y+((-1)*qam.sine_value[i]);
line(x1,y1,x1,y1);
}
qam.x=x1;
}
///////////////////////////////////////////////////////
void create_graph_qam()
{
int csx1=30,csy1=100, csx2=620,csy2=300;
setcolor(15);
show_int_graph(qam.amp1,2,csx1-25,csy2-csy1-qam.amp1-5);
show_int_graph(((-1)*qam.amp1),3,csx1-30,csy2-csy1+qam.amp1-5);
show_int_graph(qam.amp2,2,csx1-25,csy2-csy1-qam.amp2-5);
show_int_graph(((-1)*qam.amp2),3,csx1-30,csy2-csy1+qam.amp2-5);
setlinestyle(0,0,1);
line(csx1-4,csy2-csy1-qam.amp1,csx1+4,csy2-csy1-qam.amp1);
line(csx1-4,csy2-csy1+qam.amp1,csx1+4,csy2-csy1+qam.amp1);
line(csx1-4,csy2-csy1-qam.amp2,csx1+4,csy2-csy1-qam.amp2);
line(csx1-4,csy2-csy1+qam.amp2,csx1+4,csy2-csy1+qam.amp2);
setcolor(4);
setlinestyle(0,0,3);
line(csx1,csy1,csx1,csy2);
line(csx1,csy2-csy1,csx2,csy2-csy1);
setcolor(9);
setlinestyle(1,1,1);
for(int i = csx1+qam_lcycle; i<csx2;i+=qam_lcycle-1)
line(i,csy1,i,csy2);
settextstyle(2,0,4);
outtextxy(csx1+360,csy2+10,"Frequency for 0  = ");
setcolor(15);
show_int_graph(c_hz,2,csx1+480,csy2+10);
settextstyle(1,0,4);
setcolor(15);
outtextxy(csx1,30,"QAM");
setfillstyle(1,9);
bar(csx1,70,csx1+370,72);
settextstyle(2,0,4);setcolor(15);
outtextxy(260,468,"Press any key to continue");
int a=54,b=csx1+166;
for(i=0;i<=25;i+=3)
{
setcolor(15);
graphicText(a,csy2-195,bd_4qam[i]);
graphicText(a+7,csy2-195,bd_4qam[i+1]);
graphicText(a+7+7,csy2-195,bd_4qam[i+2]);
setcolor(15);
graphicText(b,310,bd_4qam[i]);
b+=7;
graphicText(b,310,bd_4qam[i+1]);
b+=7;
graphicText(b,310,bd_4qam[i+2]);
a+=ask_lcycle;b+=7;
}
setcolor(9);
outtextxy(40,310,"Data      = ");
//getch();
}
//////////////////////////////////////////////
void showDtable2()
{
setfillstyle(1,8);
bar(140-4-100,280-4+50,640-100,410+4+50);
setfillstyle(1,15);
bar(140-100,280+50,634-100,410+50);
setfillstyle(1,9);
bar(142-100,282+50,632-100,302+50);
setfillstyle(1,9);
bar(142-100,306+50,632-100,408+50);
setfillstyle(1,1);
bar(142-100,306+50,632-100,326+50);
setcolor(15);
settextstyle(2,0,4);
outtextxy(330-100,286+50,"8-QAM Data Table");
setfillstyle(1,1);
bar(142-100,306+50,242-100,408+50);
setfillstyle(1,15);
bar(242-100,306+50,244-100,410+50);
bar(142-100,326+50,632-100,328+50);
bar(142-100,346+50,632-100,348+50);
bar(142-100,366+50,632-100,368+50);
bar(142-100,386+50,632-100,388+50);
bar(420-100,306+50,422-100,410+50);
setcolor(15);
setlinestyle(0,0,2);
line(142-100,306+50,244-100,326+50);
setcolor(15);
settextstyle(2,0,4);
outtextxy(189-100,305+50,"Amplitude");
outtextxy(149-100,314+50,"Phase");
setcolor(15);
show_int_graph(qam.ang1,3,170-100,332+50);
show_int_graph(qam.ang2,3,170-100,352+50);
show_int_graph(qam.ang3,3,170-100,372+50);
show_int_graph(qam.ang4,3,170-100,392+50);
show_int_graph(qam.amp1,2,320-100,311+50);
show_int_graph(qam.amp2,3,510-100,311+50);
setcolor(1);
outtextxy(320-100,332+50,"000");
outtextxy(512-100,332+50,"001");
outtextxy(320-100,352+50,"010");
outtextxy(512-100,352+50,"011");
outtextxy(320-100,372+50,"100");
outtextxy(512-100,372+50,"101");
outtextxy(320-100,392+50,"110");
outtextxy(512-100,392+50,"111");
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -