WWW.REFERATCENTRAL.ORG.UA - Я ТУТ НАВЧАЮСЬ

... відкритий, безкоштовний архів рефератів, курсових, дипломних робіт

ГоловнаТехнічні науки → Навчальна модель аналогово-цифрового перетворювача - Курсова робота

Навчальна модель аналогово-цифрового перетворювача - Курсова робота

end;

PortOut(Adr_CR,bOut);

End;

procedure TF_ADC.B_Write_CRClick(Sender: TObject);

Var nCR:integer;

begin

for nCR:=0 to qCR do

begin

mCR[nCR]:=0;

end;

if CheckBox_CR0.Checked then mCR[0]:=1;

if CheckBox_CR1.Checked then mCR[1]:=1;

if CheckBox_CR2.Checked then mCR[2]:=1;

if CheckBox_CR3.Checked then mCR[3]:=1;

p_Write_CR;

end;

// === CR ==== END ===================

// == SR == BEGIN ===============

Procedure p_Read_SR;

Var b,b1:byte;

Begin

b:=PortIn(Adr_SR);

asm

mov al,b

and al,00001000b

mov b1,al

end;

mSR[3]:=0;

if b1>0 then mSR[3]:=1;

End;

procedure TF_ADC.B_Read_SRClick(Sender: TObject);

begin

p_Read_SR;

if mSR[3]=0 then CheckBox_SR3.checked:=false;

if mSR[3]=1 then CheckBox_SR3.checked:=true;

end;

// == SR == END ===============

// Out_U BEGIN =============

Procedure Tran_bOut_mCR(bOut:byte);

{ Процедура перетворює байт bOut в набір з 8 бітів,

які записуються у масив mCR[0..7], де біт mCr[0] - молодший}

Var b1,b2,b3:byte;

i:integer;

Begin

b3:=bOut;

for i:=0 to 7 do

begin

b1:= b3 div 2;

b2:=b3 mod 2;

b3:=b1;

mCR[i]:=b2;

end;

// Примітка. Відображати біти на екрані наступним чином: D7 D6 D5 D4 D3 D2 D1 D0

End;

procedure TF_ADC.B_Out_UClick(Sender: TObject);

Var bOut:byte;

Ur:real;

begin

U_Out:=StrToFloat(E_Out_U.Text);

for bOut:=0 to qB do

begin

Ur:=mUr[bOut];

// ShowMessage(' bOut= '+IntToStr(bOut)+' Ur= '+FloatToStrF(Ur,ffFixed,6,2));

if Ur>U_Out then break;

end;

// bOut:=round(r1);

Tran_BOut_mCR(bOut);

p_Write_CR;

if mCR[0]=1 then CheckBox_CR0.Checked:=true

else CheckBox_CR0.Checked:=false;

if mCR[1]=1 then CheckBox_CR1.Checked:=true

else CheckBox_CR1.Checked:=false;

if mCR[2]=1 then CheckBox_CR2.Checked:=true

else CheckBox_CR2.Checked:=false;

if mCR[3]=1 then CheckBox_CR3.Checked:=true

else CheckBox_CR3.Checked:=false;

end;

// Out_U END =============

// In_U BEGIN ===================

procedure TF_ADC.B_In_UClick(Sender: TObject);

Var bOut:byte;

Ur:real;

begin

U_In:=0;

for bOut:=0 to qB do

begin

Trans_bOut_mDR(bOut);

PortOut(Adr_DR,bOut);

if mDR[0]=1 then CheckBox_DR0.Checked:=true

else CheckBox_DR0.Checked:=false;

if mDR[1]=1 then CheckBox_DR1.Checked:=true

else CheckBox_DR1.Checked:=false;

if mDR[2]=1 then CheckBox_DR2.Checked:=true

else CheckBox_DR2.Checked:=false;

if mDR[3]=1 then CheckBox_DR3.Checked:=true

else CheckBox_DR3.Checked:=false;

p_Read_SR;

Ur:=mUr[bOut]; // oporna for Dr3 - DR0

if mSR[3]=0 then

begin

U_In:=Ur;

break;

end;

if bOut=qB then

begin

if mSR[3]>0 then U_In:=U_A;

end;

if CheckBox_ADC_Proces_Show.checked then

ShowMessage(' bOut= '+IntToStr(bOut)+' Ur= '+FloatToStrF(Ur,ffFixed,6,2));

// Sleep(5);

end;

E_In_U.text:=FloatToStrF(U_In,ffFixed,4,2);

end;

// In_U END ===================

procedure TF_ADC.B_DiagramClick(Sender: TObject);

Var i:integer;

x,y:real;

Time_Discret:integer;

begin

RegStop:=0;

CheckBox_ADC_Proces_Show.Checked:=false;

QI:=StrToInt(E_QI.Text);

if QI>QI_Max then

begin

ShowMessage('QI>QI_Max= '+IntToStr(QI_Max));

QI:=QI_Max;

end;

Time_Discret:=StrToInt(E_Time_Discret.Text);

Chart1.Series[0].Clear;

for i:=1 to QI do

begin

B_In_UClick(Sender);

x:=(i-1)*Time_Discret/1000;

y:=U_In;

mx[i]:=x;

my[i]:=y;

// if i=1 then y:=y+0.0001;

Chart1.Series[0].AddXY(x,y);

Sleep(Time_Discret);

Application.ProcessMessages;

if RegStop=1 then break;

end;

end;

procedure TF_ADC.B_StopClick(Sender: TObject);

begin

RegStop:=1;

end;

procedure TF_ADC.B_SaveClick(Sender: TObject);

Var flName:string;

tx:TextFile;

i:integer;

begin

if SaveDialog1.Execute then

begin

flName:=SaveDialog1.FileName+'.txt';

AssignFile(tx,FlName);

ReWrite(tx);

for i:=1 to QI do

begin

write(tx,mx[i]:7:3);

writeln(tx,my[i]:7:3);

end; // i

CloseFile(tx);

end;

end;

procedure TF_ADC.RadioGroup_LanguageClick(Sender: TObject);

begin

if RadioGroup_Language.ItemIndex=1 then

Begin

B_Write_DR.Caption:='Записати_DR';

B_Write_CR.Caption:='Записати_CR';

B_In_U.Caption:='Вхід_U';

B_Out_U.Caption:='Вихід_U';

B_Diagram.Caption:='Діаграма';

B_Stop.Caption:='Стоп';

B_Save.Caption:='Зберегти';

B_Exit.Caption:='Вихід';

B_Read_SR.Caption:='Читати_SR';

CheckBox_ADC_Proces_Show.Caption:='ADC_Показати_Процес';

L_Time_Discret.Caption:='Проміжки_Часу (мс)';

MainMenu1.Items[0].Caption:='Файл';

MainMenu1.Items[0].Items[0].Caption:='Зберегти';

MainMenu1.Items[1].Caption:='ADC';

MainMenu1.Items[1].Items[0].Caption:='Вхід_U';

MainMenu1.Items[1].Items[1].Caption:='Вихід_U';

MainMenu1.Items[2].Caption:='Порт';

MainMenu1.Items[2].Items[0].Caption:='Записати_DR';

MainMenu1.Items[2].Items[1].Caption:='Записати_CR';

end;

if RadioGroup_Language.ItemIndex=0 then

Begin

B_Write_DR.Caption:='Write_DR';

B_Write_CR.Caption:='Write_CR';

B_In_U.Caption:='In_U';

B_Out_U.Caption:='Out_U';

B_Diagram.Caption:='Diagram';

B_Stop.Caption:='Stop';

B_Save.Caption:='Save';

B_Exit.Caption:='Exit';

B_Read_SR.Caption:='Read_SR';

CheckBox_ADC_Proces_Show.Caption:='ADC_Proces_Show';

L_Time_Discret.Caption:='Time_Discret (ms)';

MainMenu1.Items[0].Caption:='File';

MainMenu1.Items[0].Items[0].Caption:='Зберегти';

MainMenu1.Items[1].Caption:='ADC';

MainMenu1.Items[1].Items[0].Caption:='In_U';

MainMenu1.Items[1].Items[1].Caption:='Out_U';

MainMenu1.Items[2].Caption:='Port';

MainMenu1.Items[2].Items[0].Caption:='Write_DR';

MainMenu1.Items[2].Items[1].Caption:='Write_CR';

end;

end;

procedure TF_ADC.Save1Click(Sender: TObject);

begin

B_Save.Click;

end;

procedure TF_ADC.InU1Click(Sender: TObject);

begin

B_In_U.Click;

end;

procedure TF_ADC.OutU1Click(Sender: TObject);

begin

B_Out_U.Click;

end;

procedure TF_ADC.WriteDR1Click(Sender: TObject);

begin

B_Write_DR.Click;

end;

procedure TF_ADC.Write_CR1Click(Sender: TObject);

begin

B_Write_CR.Click;

end;

end.

Додаток Б

Тестування перетворювача

Додаток В

Принцип роботи АЦП

0100090000032a0200000200a20100000000a201000026060f003a03574d46430100000000000100dd640000000001000000180300000000000018030000010000006c0000000000000000000000350000006f0000000000000000000000413f00007326000020454d46000001001803000012000000020000000000000000000000000000007f120000771a0000c80000001f010000000000000000000000000000000f030058600400160000000c000000180000000a0000001000000000000000000000000900000010000000f10e000015090000250000000c0000000e000080250000000c0000000e000080120000000c00000001000000520000007001000001000000a4ffffff00000000000000000000000090010000000000cc04400022430061006c00690062007200690000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000110040ae110010000000a4b1110024af110052516032a4b111009cae1100100000000cb0110088b1110024516032a4b111009cae11002000000049642f319cae1100a4b1110020000000ffffffff0c26f600d0642f31ffffffffffff0180ffff01800fff0180ffffffff000000000008000000080000d4fb240501000000000000005802000025000000372e9001cc00020f0502020204030204ef0200a07b20004000000000000000009f00000000000000430061006c00690062007200000000000000000064af1100dee32e31e88d0832c4b21100d0ae11009c38273108000000010000000caf11000caf1100e87825310800000034af11000c26f6006476000800000000250000000c00000001000000250000000c00000001000000250000000c00000001000000180000000c0000000000000254000000540000000000000000000000350000006f00000001000000e7298740a48e87400000000057000000010000004c000000040000000000000000000000f10e00001509000050000000200035003600000046000000280000001c0000004744494302000000fffffffffffffffff20e000016090000000000004600000014000000080000004744494303000000250000000c0000000e000080250000000c0000000e0000800e000000140000000000000010000000140000000400000003010800050000000b0200000000050000000c0250012902040000002e0118001c000000fb020200010000000000bc02000000cc0102022253797374656d0000000000000000000000000000000000000000000000000000040000002d010000040000002d01000004000000020101001c000000fb02f3ff0000000000009001000000cc0440002243616c6962726900000000000000000000000000000000000000000000000000040000002d010100040000002d010100040000002d010100050000000902000000020d000000320a0d000000010004000000000027025001202f0800040000002d010000040000002d010000030000000000

Loading...

 
 

Цікаве