Translate

Membuat Electronic Nose untuk Mendeteksi bau (Aroma) Bakteri / Biofilm Menggunakan Sensor Gas TGS dan Interface VB 6.0 Datalogger Database

Membuat Electronic Nose untuk Mendeteksi bau (Aroma) Bakteri / Biofilm Menggunakan Sensor Gas TGS dan Interface VB 6.0 Datalogger Database


          Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang berfungsi untuk mendeteksi aroma dari bakteri menggunakan sensor gas TGS berjumlah 6 buah, kemudian disimpan kedalam database untuk dataloggernya. pengujian ini dilakukan untuk mendeteksi apakah ada perubahan bau pada setiap harinya dari suatu bakteri akibat perkembangbiakan dan pertumbuhan bakteri / biofilm. alat ini dilengkapi dengan Interface VB 6. untuk lebih jelasnya berikut adalah skema dan programnya.



a. Mikrokontroller ATMega8




b. Sensor Gas TGS2600, TGS826, TGS2611, TGS2620, TGS2612, TGS2602





c. Program Bascom AVR

$regfile = "m8def.dat"
$crystal = 12000000
$baud = 9600

Config Adc = Single , Prescaler = Auto , Reference = Avcc

Dim Dataadc1 As Word
Dim Dataadc2 As Word
Dim Dataadc3 As Word
Dim Dataadc4 As Word
Dim Dataadc5 As Word
Dim Dataadc6 As Word

Start Adc

Do
'tgs2611
Dataadc1 = Getadc(0)

'tgs2600
Dataadc2 = Getadc(1)

'tgstgs2612
Dataadc3 = Getadc(2)

'tgs2620
Dataadc4 = Getadc(3)

'tgs2602
Dataadc5 = Getadc(4)

'tgs826
Dataadc6 = Getadc(5)

'Print Dataadc1 ; "a " ; Dataadc2 ; "b " ; Dataadc3 ; "c " ; Dataadc4 ; "d " ; Dataadc5 ; "e " ; Dataadc6 ; "f "

Print Dataadc1
Print Dataadc2
Print Dataadc3
Print Dataadc4
Print Dataadc5
Print Dataadc6

Waitms 1000

Loop





d. Program Interface VB 6.0



1. Module

Public Conn As New ADODB.Connection
Public Rs As New ADODB.Recordset
Public SQl As String
Public i As Byte

Public Sub dbConnect()
Set Conn = New ADODB.Connection
Conn.ConnectionString = strConn
Conn.Open
End Sub

Public Function strConn() As String
Set Conn = New ADODB.Connection
Set Rs = New ADODB.Recordset
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\yanuar\Desktop\database\dbsuhu.mdb;Persist Security Info=False"

End Function




2. Form

Option Explicit
Dim arrdata()
Dim TotalBaca As Integer
Dim BMI As Single
Dim Keterangan As String
Const MAKSBACA = 18

Dim Conn1 As ADODB.Connection
Dim Cmd1 As ADODB.Command
Dim Param1 As ADODB.Parameter
Dim Rs1 As ADODB.Recordset

Private Sub berhenti_Click()
  start.Enabled = True
    berhenti.Enabled = False
    TimerBaca.Enabled = False
End Sub

Private Sub Command2_Click()
Unload Me
End Sub

Private Sub Form_Load()
Dim i As Byte
For i = 1 To 16
    ComboCOM.AddItem (i)
Next i

End Sub

Private Sub MSComm2_OnComm()
Dim buffer As String
Dim temp As String
Dim pisah() As String
Dim i As Integer

If MSComm2.CommEvent = comEvReceive Then
    buffer = MSComm2.Input
    pisah = Split(buffer, Chr$(13))
On Error Resume Next
If buffer <> " " Then
With Text1
    .SelStart = Len(.Text)
    .SelText = buffer
End With
For i = 0 To 6
    If 0 < 7 Then
        Text2(i).Text = CStr(pisah(i))
        End If
        Next i
    Else
    buffer = " "
    End If
End If
End Sub

Private Sub start_Click()
Dim u As Integer

    On Error GoTo ada_eror
   
    MSComm2.CommPort = ComboCOM.Text
    MSComm2.Settings = "9600,N,8,1"
    MSComm2.RThreshold = 28
    MSComm2.InputLen = 28
    MSComm2.InputMode = comInputModeText
    MSComm2.PortOpen = True ' buka port
   
    ReDim arrdata(1 To MAKSBACA + 1)
    For u = 1 To MAKSBACA
        arrdata(u) = 0
    Next
    TotalBaca = 0
    start.Enabled = False
    berhenti.Enabled = True
    TimerBaca.Enabled = True
    Timer1.Enabled = True
    Timer2.Enabled = True
    Timer3.Enabled = True
ada_eror:
 If ComboCOM.ListIndex < 1 Then
    MsgBox "COM berada di Nomor : " & Err.Number & vbCrLf & Err.Description, vbCritical + vbOKOnly, "ERROR"
    start.Enabled = True
    berhenti.Enabled = True
    ComboCOM.Text = "Pilih COM"
End If

End Sub

Private Sub Timer1_Timer()
Dim SQl As String
   
   Call dbConnect
   
    SQl = "INSERT INTO tbsuhu VALUES('" & Text2(0).Text & "','" & Text2(1).Text & "','" & Text2(2).Text & "','" & Text2(3).Text & "','" & Text2(4).Text & "','" & Text2(5).Text & "')"
   
    Dim Rs As Recordset
    Set Rs = New ADODB.Recordset
    Rs.Open SQl, Conn, adOpenDynamic

End Sub

Private Sub Timer2_Timer()
Adodc1.Refresh
Dim ok As Integer
Dim mode As Integer


End Sub

Private Sub Timer3_Timer()
MSComm2_OnComm
End Sub

Private Sub Timer4_Timer()
 Label4.Caption = Format(Time, "hh:mm:ss")
End Sub

Private Sub TimerBaca_Timer()
Dim strInput As String
Dim strPotong As String
Dim singleInput As Single
Dim u As Integer
    strInput = MSComm2.Input
        strPotong = strInput
        If TotalBaca >= MAKSBACA Then
            TimerBaca.Enabled = False
            If MSComm2.PortOpen = True Then MSComm2.PortOpen = False
            Call berhenti_Click
        End If
 
 
 
End Sub




e. Program Delphi 7



unit TA;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls,strutils, TeeProcs, TeEngine, Chart, CPort, mmsystem,
  Series, Buttons;

type
  TForm1 = class(TForm)
    ComPort1: TComPort;
    GroupBox1: TGroupBox;
    Edit1: TEdit;
    Edit2: TEdit;
    Chart1: TChart;
    GroupBox2: TGroupBox;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Memo1: TMemo;
    Label1: TLabel;
    Label2: TLabel;
    Timer1: TTimer;
    Label7: TLabel;
    Label8: TLabel;
    BitBtn1: TBitBtn;
    Series2: TFastLineSeries;
    Chart2: TChart;
    Series3: TFastLineSeries;
    Chart3: TChart;
    Series4: TFastLineSeries;
    Timer2: TTimer;
    Timer3: TTimer;
    Chart4: TChart;
    Series5: TFastLineSeries;
    Chart5: TChart;
    Series6: TFastLineSeries;
    Chart6: TChart;
    Series7: TFastLineSeries;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Edit6: TEdit;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Timer4: TTimer;
    Timer5: TTimer;
    Timer6: TTimer;
    Timer7: TTimer;
    Timer8: TTimer;
    Timer9: TTimer;
    procedure ComPort1RxChar(Sender: TObject; Count: Integer);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure Timer2Timer(Sender: TObject);
    procedure Timer3Timer(Sender: TObject);
    procedure Timer4Timer(Sender: TObject);
    procedure Timer5Timer(Sender: TObject);
    procedure Timer6Timer(Sender: TObject);
    procedure Timer7Timer(Sender: TObject);
    procedure Timer8Timer(Sender: TObject);
    procedure Timer9Timer(Sender: TObject);

  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.ComPort1RxChar(Sender: TObject; Count: Integer);
var buff:string;
begin
comport1.ReadStr(buff,count);
memo1.Text:=memo1.Text+buff;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
comport1.ShowSetupDialog;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
Timer2.Enabled := True;
Timer3.Enabled := True;
Timer4.Enabled := True;
Timer5.Enabled := True;
Timer6.Enabled := True;
Timer7.Enabled := True;
Timer8.Enabled := True;
Timer9.Enabled := True;
if button2.Caption='Connect' then
   begin
   button2.Caption:='Disconnect';
   comport1.Open;
   end
else if button2.Caption='Disconnect' then
   begin
   button2.Caption:='Connect';
   comport1.Close;
   end;

end;

procedure TForm1.Button3Click(Sender: TObject);
begin
Edit1.Color:=clwhite;
Edit2.Color:=clwhite;
Edit3.Color:=clwhite;
Edit4.Color:=clwhite;
Edit5.Color:=clwhite;
Edit6.Color:=clwhite;
edit1.text:='';
edit2.text:='';
edit3.text:='';
edit4.text:='';
edit5.text:='';
edit6.text:='';
memo1.Text:='';
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
close;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
ThousandSeparator:=',';
DecimalSeparator:='.';
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
label7.Caption:='Date  '+ FormatdateTime('d/mm/yyyy',Date);
label8.Caption:='Time  '+ FormatDateTime('hh:nn:ss',Time);
end;

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
close;
end;

procedure TForm1.Timer2Timer(Sender: TObject);
var
  F: TextFile;
begin
  AssignFile(F, 'D:\TGS2611.txt');
  Append(F);
  WriteLn(F, Edit1.Text);
  CloseFile(F);
end;

procedure TForm1.Timer3Timer(Sender: TObject);
var satu,dua,tiga,empat,lima,enam:double;
    rin,kin,vin,din,lin,hin:string;
    jumlahdata:integer;

begin
  jumlahdata:=chart1.GetMaxValuesCount;
  form1.Caption:=inttostr(jumlahdata);
  //if jumlahdata > 60 then
  //   begin
  //   Series2.Clear;
  //   Series3.Clear;
  //   Series4.Clear;
  //   Series5.Clear;
  //   Series6.Clear;
  //   Series7.Clear;
  //   end;

  hin:=memo1.Lines[memo1.Lines.count-6];
  lin:=memo1.Lines[memo1.Lines.count-5];
  din:=memo1.Lines[memo1.Lines.count-4];
  vin:=memo1.Lines[memo1.Lines.count-3];
  rin:=memo1.Lines[memo1.Lines.count-2];
  kin:=memo1.Lines[memo1.Lines.count-1];

  if rightstr(hin,1)= 'a' then
     begin
     edit1.Text:=leftstr(hin,length(hin)-1);
     satu:=strtofloat(edit1.text);
     Series2.Add(satu,'',clred) ;
     end;
  if rightstr(lin,1)='b' then
     begin
     edit2.Text:=leftstr(lin,length(lin)-1);
     dua:=strtofloat(edit2.text);
     Series3.Add(dua,'',clgreen) ;
     end;
  if rightstr(din,1)='c' then
     begin
     edit3.Text:=leftstr(din,length(din)-1);
     tiga:=strtofloat(edit3.text);
     Series4.Add(tiga,'',clgreen) ;
     end;
  if rightstr(vin,1)='d' then
     begin
     edit4.Text:=leftstr(vin,length(vin)-1);
     empat:=strtofloat(edit4.text);
     Series5.Add(empat,'',clgreen) ;
     end;
  if rightstr(rin,1)='e' then
     begin
     edit5.Text:=leftstr(rin,length(rin)-1);
     lima:=strtofloat(edit5.text);
     Series6.Add(lima,'',clgreen) ;
     end;
  if rightstr(kin,1)='f' then
     begin
     edit6.Text:=leftstr(kin,length(kin)-1);
     enam:=strtofloat(edit6.text);
     Series7.Add(enam,'',clgreen) ;
     end;


end;

procedure TForm1.Timer4Timer(Sender: TObject);
var
  F: TextFile;
begin
  AssignFile(F, 'D:\TGS2600.txt');
  Append(F);
  WriteLn(F, Edit2.Text);
  CloseFile(F);
end;

procedure TForm1.Timer5Timer(Sender: TObject);
var
  G: TextFile;
begin
  AssignFile(G, 'D:\TGS2612.txt');
  Append(G);
  WriteLn(G, Edit3.Text);
  CloseFile(G);
end;

procedure TForm1.Timer6Timer(Sender: TObject);
var
  H: TextFile;
begin
  AssignFile(H, 'D:\TGS2620.txt');
  Append(H);
  WriteLn(H, Edit4.Text);
  CloseFile(H);
end;

procedure TForm1.Timer7Timer(Sender: TObject);
var
  I: TextFile;
begin
  AssignFile(I, 'D:\TGS2602.txt');
  Append(I);
  WriteLn(I, Edit5.Text);
  CloseFile(I);
end;


procedure TForm1.Timer8Timer(Sender: TObject);
var
  K: TextFile;
begin
  AssignFile(K, 'D:\TGS826.txt');
  Append(K);
  WriteLn(K, Edit6.Text);
  CloseFile(K);
end;

procedure TForm1.Timer9Timer(Sender: TObject);
var
  J: TextFile;
begin
  AssignFile(J, 'D:\TGS2611.txt');
  Append(J);
  WriteLn(J, Edit1.Text);
  CloseFile(J);
end;

end.





f. VIDEO HASILNYA