How to connect PIC16f877a to VB.net

Discussion about projects that used PIC Microcontroller, Hardware Interface, Programming Algorithm and etc......

How to connect PIC16f877a to VB.net

Postby johnson h'ng » Mon Dec 12, 2011 7:33 pm

Hi,

Can anyone advise me?
I would like to ask any idea to do connection for PIC16f877a to vb.net?
I am currently doing my final year project regarding Home Evaluation System.
The project works when pressing the VB button, the PIC will activated the sensors and it send signal LED light up.
I currently stuck at the phase VB connect to PIC. I not sure what the coding needed.

Thank You,
Johnson
johnson h'ng
Freshie
 
Posts: 5
Joined: Tue Jul 05, 2011 8:55 pm

Re: How to connect PIC16f877a to VB.net

Postby ober » Mon Dec 12, 2011 10:26 pm

Basically it involve communication. The straight forward and simplest method is via UART, on computer it become COM port. Uses USB to Serial/UART converter, it enable computer to create link to microcontroller.

You can refer to some of our tutorials:

1. Getting Started On Graphical User Interface GUI. There are a few examples in that tutorial, from sending commands and receiving data from PIC microcontroller.

2. GUI Controlled Flexibot by Using SKXBee. Another example of tutorial. Using XBee, to control mobile robot from computer, again, it uses VB and COM port.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm

Re: How to connect PIC16f877a to VB.net

Postby johnson h'ng » Mon Dec 12, 2011 11:15 pm

actually i quite don't understand this line
Dim WithEvents ComPort As New IO.Ports.SerialPort
why they use WithEvents?
johnson h'ng
Freshie
 
Posts: 5
Joined: Tue Jul 05, 2011 8:55 pm

Re: How to connect PIC16f877a to VB.net

Postby yonghui » Wed Dec 14, 2011 12:27 am

hmm..
think u need more reading on VB.
:D

regards,
yh
thanks&regards,
yh
yonghui
Professional
 
Posts: 732
Joined: Mon Sep 28, 2009 3:27 pm

Re: How to connect PIC16f877a to VB.net

Postby johnson h'ng » Thu Dec 15, 2011 1:20 am

Hi Sir,

Currently, i get to set the connection for the VB and my PIC. But i had a problem in using the DATARECEIVED() in my VB command.
In my PIC , I have send the " uart_str("The Door Is Close")" to Vb but the message doesn't pop up the messagebox command in vb to show that the door is close.

Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
Dim sp As SerialPort = CType(sender, SerialPort)
Dim indata As String = SerialPort1.ReadExisting()
Messagebox.show("Data received:" , indata)

End Sub

Can anyone suggest/ advise me in this part of the program?
johnson h'ng
Freshie
 
Posts: 5
Joined: Tue Jul 05, 2011 8:55 pm

Re: How to connect PIC16f877a to VB.net

Postby johnson h'ng » Thu Dec 22, 2011 2:26 am

Hi,
Current working on serial connection and I managed to get the serial port reading. Whether my door is close or open through the messagebox.show command. But the problem here I want my message to pop up on label2.text. But I does not work.

Can anyone advice me?

CODE: SELECT_ALL_CODE
    Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived

        Dim input As String
        input = SerialPort1.ReadExisting()
        MessageBox.Show(input)
        '
Label2.Text = input


    End Sub
johnson h'ng
Freshie
 
Posts: 5
Joined: Tue Jul 05, 2011 8:55 pm

Re: How to connect PIC16f877a to VB.net

Postby lockman_akim » Fri Jan 20, 2012 2:50 pm

just use this code:

if serialport1.isopen = false then
label2.text = "Port IS Close"
Else
label2.text = "Port Is Open"
End If
lockman_akim
Novice
 
Posts: 22
Joined: Sun Aug 29, 2010 11:50 pm


Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 1 guest

cron