Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

interfacing PIC16F877A with Visual Basic 6.0

Status
Not open for further replies.
i'm doing project about parking guidance system.

for this project, i used infrared sensor to detect the presence or absence of cars inside the parking lot.

if there is car the green led will on whereas if there is no car, red led is on

the sensors will give value 1 if it detects car whereas 0 for absence of car.

i need to send the output of the sensors to visual basic 6.0

in the visual basic there will be a form repsenting parking lots.

the form will display the condition of each parking lots whether empty or not.

i'm using 8 parking lots for this project..

i plan to use serial port to interface pic to VB
tq

That seems quite a simple project, what input do you what from us at this stage.?
 
That seems quite a simple project, what input do you what from us at this stage.?

for this project,i'm using serial port.

i want to know how the programming at Visual basic form to get input from the PIC.

i've try with the following codes to obtain only one input from PIC:

-------------------------------------------------------------------
Private Sub Form_Load()


MSComm1.RThreshold = 1
MSComm1.InputLen = 1
MSComm1.Settings = "2400,N,8,1"
MSComm1.DTREnable = False
' Open COM1
MSComm1.CommPort = 1
MSComm1.PortOpen = True



End Sub

Private Sub MSComm1_OnComm()
Dim sData As String ' Holds our incoming data
Dim lHighByte As Long ' Holds HighByte value
Dim lLowByte As Long ' Holds LowByte value
Dim lWord As Long ' Holds the Word result

If MSComm1.CommEvent = comEvReceive Then

sData = MSComm1.Input ' Get data (2 bytes)
If sData = "1" Then
Text1.BackColor = vbGreen
If sData = "0" Then
Text1.BackColor = vbGreen

End If

End If


End Sub

Private Sub Form_Unload(Cancel As Integer)
MSComm1.PortOpen = False
End Sub
---------------------------------------------------------------------

for the few seconds the codes working and get the input from PIC but after that my laptop shutdown.

for your information,i'm using serial to usb cable to interface between the PIC and my laptop.

TQ
 
hi,
Thats not true digital data from PIC to PC as you are using the RS232 input of the PC.

Are you sending the 8 bits of data from the PIC from the UART TX output, using a Line Driver [ like a MAX232].?

Looking at the VB program it looks as though it will not work.:)

As you have only 8 data bits to send, why dont you encode a byte and send that via the PIC's UART to the PC and then use the VB program to test the state of each bit.???
 
hi,
Thats not true digital data from PIC to PC as you are using the RS232 input of the PC.

Are you sending the 8 bits of data from the PIC from the UART TX output, using a Line Driver [ like a MAX232].?

Looking at the VB program it looks as though it will not work.:)

As you have only 8 data bits to send, why dont you encode a byte and send that via the PIC's UART to the PC and then use the VB program to test the state of each bit.???

no,i'm not using any driver
can u give me the sample program??
 
no,i'm not using any driver
can u give me the sample program??

hi,
The PC serial port expects the input signals to be the RS232 format and voltage levels.

Can you post the PIC code that sends this data to the PC.?

Are you using the PIC's TX [Uart].?
 
i try to program a oscilloscope by using vb6 and pic16f84a micro controller can any one help me to do this project . i stacked in interfacing section
 
The 16F84 does not have an ADC module and so it will be extremely difficult to use it as an oscilloscope.

Mike.
 
The USB-RS232 converters are very buggy They often crashes the computer without nothing being wrong with your program. You have a driver for the cable , it might be previously installed from a phone data cable or some device that uses the same driver. You don't have an error handler in your code , this might be a reason.
 
this is my code

below is part of my code for PIC.

i want to send the value,value1,value2,value3,value4,value5,value6,value7 to VBV 6.0.this value will have one text box for each.the value will be either 0 or 1.

if the value is 0,the text box will be in red color.if the value is 1, the text box will be in green color.

i want to know how to do the programming in VB.for the PIC code,is there any program i need to add to send data to vb.

TQ

--------------------------------------------------------------------------
#include <16F877a.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) // Jumpers: 8 to 11, 7 to 12

#include <lcd.c>
#byte portb=6
#byte portc=7

void main()
{
unsigned int value,value1,value2,value3,value4,value5,value6,value7,COUNT;

lcd_init();
lcd_putc("EMPTY:");
delay_ms(1000);

set_tris_a(0b00000000);
set_tris_b(0b00000000);//setting the port job
set_tris_c(0b11111111);
set_tris_d(0b11111111);
set_tris_e(0000000000);

do
{
value=input(PIN_C0);
value1=input(PIN_C1);
value2=input(PIN_C2);
value3=input(PIN_C3);
value4=input(PIN_C4);
value5=input(PIN_C5);
value6=input(PIN_A5);
value7=input(PIN_A4);
}while(TRUE)

}
 
Need Help...

Ei guys... do you have there tutorial, site, books for programming PIC 16F877 Microcontroller using Visual basic...

Thnx
 
could someone help me i'm a 4th yr college engrng student. i'm making a parking lot 20 slot monitoring using a sensor! i'm planning to do the program in VB using a parallel port... i dont have any starting program yet!! the condition is this.. in VB we have 3 forms: display of inn and out customer, the monitoring in 2nd floor, the monitoring in ground floor. the logic is if the car is presented in 1 slot the green light is on else its red!! the stay of the car is for only 5mins in each slot and the LED will off...

plsss help me I'm new in this kind of project... pls!!!
 
This is not better idea to communication through serial. The easy way is you only need to communication to your pic through your program (VB)

Let me show you sample.

If you want to know the status pin of your pic, you only need to talk to pic with the code that pic understand, eg:

YOU (in VB side) : You send the code "What the status of your pin1?"
PIC : Pic will answer with the code "My pin1 is low?"

Thanks

below is part of my code for PIC.

i want to send the value,value1,value2,value3,value4,value5,value6,value7 to VBV 6.0.this value will have one text box for each.the value will be either 0 or 1.

if the value is 0,the text box will be in red color.if the value is 1, the text box will be in green color.

i want to know how to do the programming in VB.for the PIC code,is there any program i need to add to send data to vb.

TQ

--------------------------------------------------------------------------
#include <16F877a.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) // Jumpers: 8 to 11, 7 to 12

#include <lcd.c>
#byte portb=6
#byte portc=7

void main()
{
unsigned int value,value1,value2,value3,value4,value5,value6,value7,COUNT;

lcd_init();
lcd_putc("EMPTY:");
delay_ms(1000);

set_tris_a(0b00000000);
set_tris_b(0b00000000);//setting the port job
set_tris_c(0b11111111);
set_tris_d(0b11111111);
set_tris_e(0000000000);

do
{
value=input(PIN_C0);
value1=input(PIN_C1);
value2=input(PIN_C2);
value3=input(PIN_C3);
value4=input(PIN_C4);
value5=input(PIN_C5);
value6=input(PIN_A5);
value7=input(PIN_A4);
}while(TRUE)

}
 
This is not a microcontroller related question. You will need a driver that allows phisical acces to the parallel port if using XP. Witch VB are you using?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top