Komunikasi data AVR dan PC menggunakan RS-485


Project ini hanya sebagai contoh saja, bagaimana menghubungkan beberapa microcontroller (dlm contoh ini Atmega8535) dgn PC melalui port serial dengan menggunakan RS-485.

perbandingan rs232 dan rs485:
-rs232 hanya menghubungkan antara 2  host (pc ke pc atau pc ke microcontroller) dan jarak maximal kira2  15 meter saja
-Rs485 bisa menghubungkan  beberapa host  ( 1  master dan beberapa slave )  master bisa berupa PC atau Microcontroller dan slave bisa beberapa PC atau microcontroller.
Komponen yang dibutuhkan:
1.  Rs232 to rs485 Converter
2.  modul Atmega8535 + IC max485
3.  CodeVision versi trial  (download gratis)
4.  Kabel telpon  (tergantung jarak PC dgn modul Atmega8535)
Rangkaian :
Rs-485 network
Detail rangkaian slave (microcontroller Atmega8535)
Client-RS-485
Client-RS-485
Code program dalam Visaual Basic 6:
Private Declare Function GetTickCount Lib “kernel32″ () As Long
Dim Timeout As Boolean
Dim data_pantulan As String
Dim perintah As String
Dim messagetosend As Variant
Dim transferprogress As Boolean

‘============================
Private Sub Form_Load()
If MSComm1.PortOpen = True Then Exit Sub
MSComm1.Settings = “9600,N,8,1″
MSComm1.CommPort = 1
MSComm1.PortOpen = True

End Sub
Private Sub kirimdata_Click()
txtdata_dari_slave.Text = “”
MSComm1.RTSEnable = False
Sleep (300)
MSComm1.Output = txtdatatosend.Text
Sleep (300)
MSComm1.RTSEnable = True

Call getResponse
End Sub

Private Sub getResponse()
Static responseBuffer As String
Dim inbuff As Variant
Dim length As Integer
Dim pcount As Long
Dim ccount As Long
Dim duration As Long
duration = 1000

pcount = GetTickCount()
Do While True
inbuff = MSComm1.Input
If Len(inbuff) > 0 Then
responseBuffer = responseBuffer + inbuff
length = Len(responseBuffer)
If responseBuffer <> “” Then
txtdata_dari_slave.Text = responseBuffer   ‘ received a complete response string
responseBuffer = “”
Exit Sub
Else
End If
End If
ccount = GetTickCount()
If ccount >= pcount + duration Then Exit Do  ‘
Loop
txtdata_dari_slave.Text = “no response”
End Sub

===================================================
‘jika slave nya banyak ( contoh disini ada 8 slave)
Private Sub PollSlave()
Dim no_slave As Integer
Dim buffer As Variant
Dim alamat As Integer
Dim ack As Boolean
Dim reply As Boolean
Dim data_dari_slave As String
alamat = &H67
transferprogress = True
‘mengirim alamat node tunggu ack ,kirim perintah  dan menunggu reply data
‘kemudian simpan hasil

For no_slave = 1 To 8
‘txtno_slave.Text = no_slave
‘======hapus inbuffer dan outbuffer
MSComm1.OutBufferCount = 0
If MSComm1.InBufferCount > 0 Then
buffer = MSComm1.Input
End If
‘===================================
Call enabletransmitter ‘ –>

alamat = alamat + 1   ‘ alamat = 68h,69h,6Ah,6Bh,6Ch,6Dh,6Eh,6Fh
alamat_slave = Chr(alamat)
txtno_slave.Text = alamat_slave
buffer = Chr(alamat)
‘MsgBox buffer
‘kirim alamat ke i
MSComm1.Output = buffer
‘=======================================================================
Do ‘tunggu pantulan byte alamat yg dikirim
txtstatus.Text = “tunggu pantulan alamat = ” & buffer
tmrTimeout.Enabled = True
Timeout = False
‘===============sampe trima 1 byte alamat pantulan
Call disabletransmitter  ‘<–
Do
DoEvents
Loop Until (MSComm1.InBufferCount >= 1) Or (Timeout = True)
‘=================

If Timeout = False Then
tmrTimeout.Enabled = False
‘baca byte pantulan  dan bandingkan dgn yg dikirim
data_pantulan = MSComm1.Input
txtalamatslave.Text = txtalamatslave.Text & Asc(data_pantulan)
If StrComp(data_pantulan, alamat_slave, vbBinaryCompare) <> 0 Then
ack = True
txtstatus.Text = “alamat sama okehh”
Else
ack = False
txtstatus.Text = ” alamat  beda”
End If

Else
lbtimeout.Caption = “waiting adress timeout slave no ” & no_slave
ack = False
End If
Loop Until ack = True Or Timeout = True
tmrTimeout.Enabled = False
Timeout = False
‘=========================================================================
txtinbuffer.Text = ” count= ” & MSComm1.InBufferCount & “  size = ” & MSComm1.InBufferSize & “  isi = ” & MSComm1.Input

If ack = True Then
‘================================================================
Call enabletransmitter  ‘–>  Out
perintah = “b”  ‘kirim perintah baca data output
messagetosend = perintah
tmrTimeout.Interval = 1000
tmrTimeout.Enabled = True
ack = False
MSComm1.Output = messagetosend

Call disabletransmitter  ‘<– IN
Do

Timeout = False
Do
DoEvents
Loop Until (MSComm1.InBufferCount > 4) Or (Timeout = True)

lbtimeoutdata.Caption = “waiting reply data timeout slave no ” & no_slave
If Timeout = False Then
tmrTimeout.Enabled = False
data_dari_slave = MSComm1.Input

reply = True
If StrComp(Asc(Left(data_dari_slave, 1)), alamat, vbBinaryCompare) <> 0 Then
txtoutput_ok.Text = data_dari_slave
‘ txtoutput_ng.Text = Asc(Val(“&h” & Mid(data_dari_slave, 4, 2)))
‘simpanhasil(no_slave,output_ok,output_ng)
txtdata_dari_slave.Text = txtdata_dari_slave.Text & Asc(data_dari_slave)
txtstatus.Text = “alamat cocok”

Else
‘alamat data tdk cocok
txtstatus.Text = “alamat tdk cocok”
End If

Else
lbtimeoutdata.Caption = “waiting reply data timeout slave no ” & no_slave

End If
Loop Until reply = True Or Timeout = True
tmrTimeout.Enabled = False
‘====================================================
End If
txtoutbuffer.Text = ” count= ” & MSComm1.OutBufferCount & “  size = ” & MSComm1.OutBufferSize

Next no_slave
transferprogress = False
tmrTimeout.Enabled = False
txtstatus.Text = “selesai 1 loop”
End Sub

===================================================
Sofware untuk microcontroller Atmega8535 sebagai slave
=====================================================
contoh  Program Avr Atmega8535
#include <mega8535.h>
#asm
.equ __lcd_port=0×15
#endasm
#include <lcd.h>
#include <stdio.h>
#include <delay.h>
#include <ctype.h>
//char lcd_buffer[33];         //-128 to 127

unsigned char  r_index, r_buffer[40], r_char; //0 to 255
void main(void)
{
lcd_init(16);
UCSRA=0×00;
UCSRB=0×98;
UCSRC=0×86;
UBRRH=0×00;
UBRRL=0×47;

delay_ms(500);
PORTD.7=0;
/*r_buffer[0]=’c’;
r_buffer[1]=’o’;
r_buffer[2]=’b’;
r_buffer[3]=’a’;
r_buffer[4]=”;
*/
delay_ms(500);
lcd_putsf(“test comm”);
#asm(“sei”)
while(1) {
r_index=0;
//  UCSRB.7=1;

lcd_puts(r_buffer);  //display data di ram, klo di flash pake lcd_putsf
}
}
interrupt [USART_RXC] void usart_rx_complete(void)
{

lcd_clear();
r_char= toascii(UDR);

if(r_char==’u’)
{
delay_ms(100);
PORTD.7=1;
delay_ms(300);
lcd_putsf(“85->replied”); //85     79=”, 80=p 81=q 82=r  83=s 84=t
delay_ms(200);
putchar(‘u’) ;

}
else if(r_char==’y’)
{
delay_ms(100);
PORTD.7=1;
delay_ms(300);
lcd_putsf(“89->replied”); //89     79=”, 80=p 81=q 82=r  83=s 84=t
delay_ms(200);
putchar(‘y’) ;
}
else
{

if (r_char != ‘x’)   //88
{
r_buffer[r_index++]=r_char;
}
else
{
putchar(‘\n’);              //use putchar to avoid overwrite
r_buffer[r_index]=0×00;        //zero terminate
//UCSRB.7=0;
}

delay_ms(100);
PORTD.7=0;
delay_ms(100);

}
}
=============
KLIK tuk melanjutkan »

Untuk Menghilangkan Trial Windows 7


RemoveWAT (Windows Aktivasi Technologies) adalah sebuah software untuk menghilangkan trial 30 hari pada windows 7, dan dapat digunakan untuk versi Windows 7 Starte, Windows 7 Home Basic, Windows 7 Home Premium, Windows 7 Professional, Windows 7 Enterprise dan Windows 7 Ultimate. jika anda mempunyai windows 7 namun telah di blacklist oleh microsoft silahkan anda gunakan Aktivator ini dan jika layar monitor anda full black atau hitam pekat berarti anda sedang menggunakan salinan/BAJAKAN Win 7 atau tertera This copy of Windows is not genuine.
  • Free Download RemoveWAT 2.2.5 l  3MB
  • KLIK tuk melanjutkan »

    Norton Internet Security 2011 Full Crack 88 Years

    Setelah kemarin disuguhkan dengan Kaspersky PURE, kini sobat akan saya suguhkan dengan Norton Internet Security 2011 Full Crack 88 Years. Oya, Norton ini juga sudah direquest olah seorang XP-ZONE Lovers, bagi yang sudah request, cekidot..

    Norton Internet Security 2011 Full Crack 88 Years adalah seri antivirus dari Norton yang terbaru. Pada Norton Internet Security(NIS) ini, terdapat fitur-fitur canggih untuk sobat yang sering online, anatara lain Smart firewall, Antispam, Antiphishing, Network monitor, Norton save web dan Antispyware. Sayangnya tidak ada virtual keyboard untuk menghindari keylogger seperti milik Kaspersky. Norton ini terkenal dengan ringannya, baik saat protecting maupun scanning. Untuk melihat perbedaan Norton AV dan Norton IS dapat dilihat di compare product..

    Features :
    • Norton Reputation Service: instantly checks where files came from and how long they’ve been around to identify and stop new crimeware faster than other, less sophisticated security software.
    • Norton Protection System uses several overlapping layers of protection that work together to stop viruses, spyware and other online attacks.
    • Norton Download Insight warns you if a downloaded file or application is dangerous before you install or run it on your PC.
    • Norton File Insight gives you detailed information about the files found on your PC including where the file came from (the website URL) and if it can be trusted.
    • Norton Pulse Updates run in the background and provide mini updates every 5 to 15 minutes — more frequently than the nearest competitor — for the latest protection against online threats.
    • SONAR 3 Behavioral Protection monitors your PC for suspicious behavior to quickly detect new online threats.
    • Email and instant message monitoring scans emails and IMs for suspicious links and potentially dangerous attachments.
    • Smart two-way firewall prevents hackers from accessing your PC and stealing your personal information.
    • Network mapping and monitoring shows you all the devices connected to your home network so you can easily spot uninvited guests using your wireless Internet connection and/or eavesdropping on you when you go online.
    • Norton Bootable Recovery Tool creates an emergency CD/DVD/USB that gets you back up and running even if your PC has become so infected that it won’t even start up.
    • Vulnerability protection prevents cybercriminals from using security holes in applications to sneak viruses or spyware on to your PC.
    • Professional-strength spam blocking keeps your mailbox free of unwanted, dangerous and fraudulent emails.
    • Bot detection finds and blocks the automated programs cybercriminals use to take control of your PC to access your private information and send out spam to launch attacks on other PCs.
    • Worm protection safeguards your PC against fast-spreading Internet worms and prevents you from accidentally passing them on to others.
    • Rootkit detection finds and removes deeply buried crimeware that can hide other types of threats and allow cybercriminals to take control of your PC.
    Kiranya cukup sampai disini, bagi sobat yang ingin install, tidak usah bingung karena saya sudah menyematkan tutorial cracknya. Dan bagi sobat yang berhasil, tolong untukdibantu sobat lainnya yang belum berhasil, sekali lagi saya minta tolong, bisa melalui komentar atau Fans Facebook Page...

    NOTE : NIS 2011 ini telah saya uji di PC saya(Windows 7 Professional). Instalasi dan cracking berhasil 100%, hasilnya dapat dilihat dari screenshot diatas. Link download dibawah adalah direct link, cepat dan mudah.

    Password : www.xp-zone.co.cc
    Download NIS 2011
    Download Crack NIS 2011
    KLIK tuk melanjutkan »