Ceriwis  

Go Back   Ceriwis > HOBI > Komputer & Teknologi > Programming

Programming Share, tanya jawab, saling bantu antar programmer dengan berbagai macam bahasa pemrograman.

Reply
 
Thread Tools
  #1  
Old 20th November 2011
Linuxmania Linuxmania is offline
Ceriwiser
 
Join Date: Nov 2011
Posts: 392
Rep Power: 14
Linuxmania mempunyai hidup yang Normal
Default Tanya tentang delphi 7 dengan komponen serial (vacomm)

Gan ane ada program yang berfungsi menangkap data yang dikeluarkan oleh Mikrokontroller secara SERIAL(RS232) dan di terima pada PC. Data tersebut berhasil ditangkap oleh PC dengan delphi dan bantuan komponen Vacomm. Code Delphinya:

++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++

procedure TForm1.VaComm1RxChar(Sender: TObject; Count: Integer);

begin



nilai := strtoint (vacomm1.Readtext);

nilai2:= strtoint (edit6.Text);

if (tanda = 1) then

begin

a3naloggauge1.Position := ((nilai*49)/10000)*4 + 0.26;

numlab1.Value := ((nilai*49)/10000)*4 + 0.26;

tanda := 2;

end

else if (tanda = 2) then

begin

a3naloggauge2.Position := ((nilai-nilai2)*49)/1000;

numlab2.Value := ((nilai-nilai2)*49)/1000;

tanda := 3;

end

else if (tanda = 3) then

begin

//(nilai*49)/10000;

numlab3.Value := (nilai*49)/100;

tanda := 4;

end

else if (tanda = 4) then

begin

progressbar1.Position := nilai;

gauge1.Progress := nilai;

gauge2.Progress := nilai;

//temp4 := (nilai*49)/10000;

//numlab4.value := (nilai*49)/10000;

tanda := 5;

end

else if (tanda = 5) then

begin

//temp5 := (nilai*49)/10000;

//numlab5.Value := (nilai*49)/10000;

tanda := 6;

end

else if (tanda = 6) then

begin

//temp6 := (nilai*49)/10000;

//numlab6.Value := (nilai*49)/10000;

tanda := 7;

end

else if (tanda = 7) then

begin

//temp7 := (nilai*49)/10000;

//numlab7.Value := (nilai*49)/10000;

tanda := 8;

end

else if (tanda = 8) then

begin

//temp8 := (nilai*49)/10000;

//numlab8.Value := (nilai*49)/10000;

tanda := 0;

timer2.Enabled := True;

end;

if (nilai = 192) then

begin

tanda := 1;

timer2.Enabled := False;

naik := 0;

end;

end;

++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++



Program diatas sukses tetapi ada kendala apabila mikrokontroller mengeluarkan data yang tidak dapat dikonversi dari string ke integer (strtoint) lalu program error dan berkata convertion fail can't convert to integer.

Pertanyaan:

Tolong beri contoh program filter string to integer agar apabila hanya karakter angka saja yang dapat di proses?



Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


 


All times are GMT +7. The time now is 09:40 AM.


no new posts