Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Interfacing AT89c51 with VB2010 using USB or RS232

Status
Not open for further replies.

prongs1911

Newbie level 6
Joined
Jun 15, 2012
Messages
11
Helped
4
Reputation
8
Reaction score
4
Trophy points
1,283
Activity points
1,352
Hi!
I am trying to send data from 89c51 and display it on PC using VB2010. I also want to send some numeric data(control parameters) to microcontroller from PC. I have some knowledge of 89c51 programming but little about VB2010.
I need help on VB2010 program on how to communicate using USB or RS232 port.
Can anyone help me?
 

Here's a sample code to reading serial port in vb.net using delegate!

PHP:
Private Delegate Sub SerialWork(ByVal Serial As System.IO.Ports.SerialPort)
    Private Delegate Sub SetReadSerialData(ByVal data As String)
    Dim DataReceived As String = String.Empty

    Private Sub SerialWorkProcedure(ByVal Serial As System.IO.Ports.SerialPort)
        If SerialPort1.IsOpen Then
            Dim _DataReceived As String = SerialPort1.ReadExisting()
            ReadSerialData(_DataReceived)
        End If
    End Sub

    Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs)
        Dim SW As New SerialWork(AddressOf SerialWorkProcedure)
        SW.BeginInvoke(SerialPort1, Nothing, Nothing)
    End Sub

    Private Sub ReadSerialData(ByVal data As String)
        If Me.InvokeRequired Then
            Try
                Dim RSD As New SetReadSerialData(AddressOf ReadSerialData)
                Me.Invoke(RSD, data)
            Catch generatedExceptionName As Exception
            End Try
        Else
            ''''' Here's your data...
            DataReceived += data
        End If
    End Sub

sending data to the rs232 is so easy! Serialport1.Writeline("Hello world")
 

use this code in ur serial port data recived event....
Code:
Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs)
        Dim temp as string
        temp = Serialport1.Readexisting()
    End Sub
after this u can display the value of temp in label or textbox whichever u want....
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top