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.

PIC16F877A with VB6. Help me guys.

Status
Not open for further replies.

redh_on3

New Member
Hi guys. I have a project named Smart Fluorescent Lamp Control Using Computer Based.
I want to use PIC16F877A as the microcontroller (using assembly language) and use VB6 as the GUI interface.
1st, I want to use LED before do the wiring for fluorescent lamp.

Below is the written assembly code:

Code:
#INCLUDE <P16F877A.INC>
__CONFIG    0X3F32

TRISA        EQU 85H
TRISB        EQU 86H
PORTA         EQU 05H
PORTB        EQU 06H

BSF        03h,5        ;go to bank1
MOVLW        b'00000001'    ;set bit number 0 as input (switch)
MOVWF        TRISA
MOVLW        b'00000000'    ;all bits as output (LED)
MOVWF        TRISB
BCF         03h,5        ;back to bank0

CLEAR:
CLRF        PORTB        ;clear signal for portB output

SWITCH:
BTFSS        PORTA,0        ;test portA bit 0
GOTO        CLEAR        ;this instruction skipped if PORTA switch is pressed
                        
MOVLW         b'00000001'    ;send signal to PORTB (LED)
MOVWF        PORTB
GOTO        SWITCH
END
What code or instruction I have to add/change if I want to trigger the switch(PORTA) to turn on the LED(PORTB) through VB6?

I'm very new to assembly language, VB and also actual wiring. >.<
 
Last edited by a moderator:
hi,
How do you plan to physically connect the PIC to the PC.??? Which Port type on the PC.?
 
hi,
How do you plan to physically connect the PIC to the PC.??? Which Port type on the PC.?

I've planned to use a self-made circuit for PIC16F77A (actually, I have to) and connected to PC using serial port.
Sorry to not provide these details earlier. >.<
 
If you are new to the world of micro controllers I would watch this youtube series:

https://www.youtube.com/watch?v=g0pSfyXOXj8&feature=relmfu

In this episode he shows how to get a audrino micro to talk to a pc..... using a program called "processing"

It is easy to port the aurdrino code to PIC code.

download processing from

https://processing.org/

Thanks for your suggestions but I can't use arduino. I have to use my own circuit using assembly language & interface using VB6.
 
I've planned to use a self-made circuit for PIC16F77A (actually, I have to) and connected to PC using serial port.
Sorry to not provide these details earlier. >.<

hi red,
I noticed that your original post said 16F877a, 16F887, 16F77..???
I assumed that the Code said 16F877A thats the one you meant, is that correct.???

If you post your VB6 program I will work thru it with you.

If you are new to PIC programming in assembler, look a Nigels tutorials, link near my signature.
 
hi red,
I noticed that your original post said 16F877a, 16F887, 16F77..???
I assumed that the Code said 16F877A thats the one you meant, is that correct.???

If you post your VB6 program I will work thru it with you.

If you are new to PIC programming in assembler, look a Nigels tutorials, link near my signature.

Hi, eric.
Yeah, it's. PIC16F877A. I'm sorry for that typo.

I didn't start any of VB6 yet. Later I'll post.

Thanks for the link, I'll go through it first.
 
hi red,
I noticed that your original post said 16F877a, 16F887, 16F77..???
I assumed that the Code said 16F877A thats the one you meant, is that correct.???

If you post your VB6 program I will work thru it with you.

If you are new to PIC programming in assembler, look a Nigels tutorials, link near my signature.

Hi Eric.
I read & learned some from the Nigel's tutorial. Nice. Thanks for sharing that.
Now I need help in writing VB6 program specifically for PIC16F877A.
Do you have any tutorial for that? I'm not good in finding tutorial for that. >.<
 
Hi redh_on3/eric
I have a vb6 GUI for the PIC16F..that uses the pc serial port. With the GUI you can continiously monitor variables in the pic (bit, byte, word, FP24) in numeric form or as a trace. You can also write to any variable. The .exe file is about 260k and the vb source about 650k. In the pic i use an interrupt service routine to handle the requests from the pc so it would be fairly easy to include the code (assembler!) into your pic application. The attachement show what the GUI look like. Let me know if you require more info or a copy of the source code.
 

Attachments

  • PIC_WIN16.jpg
    PIC_WIN16.jpg
    85.5 KB · Views: 178
Hi redh_on3/eric
I have a vb6 GUI for the PIC16F..that uses the pc serial port. With the GUI you can continiously monitor variables in the pic (bit, byte, word, FP24) in numeric form or as a trace. You can also write to any variable. The .exe file is about 260k and the vb source about 650k. In the pic i use an interrupt service routine to handle the requests from the pc so it would be fairly easy to include the code (assembler!) into your pic application. The attachement show what the GUI look like. Let me know if you require more info or a copy of the source code.

hi Lourens,

Thats a neat looking interface, 'Red' should try it on his project.

Thanks for the offer of the source, but I already have my own parallel and serial port logger interface.

My regards to sunny RSA.
 
Hi redh_on3/eric
I have a vb6 GUI for the PIC16F..that uses the pc serial port. With the GUI you can continiously monitor variables in the pic (bit, byte, word, FP24) in numeric form or as a trace. You can also write to any variable. The .exe file is about 260k and the vb source about 650k. In the pic i use an interrupt service routine to handle the requests from the pc so it would be fairly easy to include the code (assembler!) into your pic application. The attachement show what the GUI look like. Let me know if you require more info or a copy of the source code.

Wow! looks amazing, Lourens.
It seems too complicated for my project but I'm happy to know more info about yours.
Do you have any simple example code for PIC16F877A connecting to PC (serial port)? whether assembly or C language.
I try to learn from tutorials/project examples but it's too complicated. I'm newbie.

I just need to build a VB interface contains buttons to switch on lamps.
 
hi Lourens,

Thats a neat looking interface, 'Red' should try it on his project.

Thanks for the offer of the source, but I already have my own parallel and serial port logger interface.

My regards to sunny RSA.

Hi Eric.
Sorry I can't online often. Moreover, I have to study for other subjects.
I didn't start any yet but I do sketching how my project will be done.
I have to wait hardware ordered from Cytron first.
That way, I can fully concentrate to test any code or interface.
I'll inform when the hardware arrived.
 
Hi Red
Although the GUI might look complicated at first it is striaght forward to use. The main purpose of the interface is to see what is going on in the pic while it is executing, and then also to be able to modify any variable. This last feature is very handy, it means you can have only an endless loop as the main program and then use the interface to modify any of the registers, including the special function registers; thats how i got my 1st lcd interface figured out and also how i test a new hardware interface. I will prepare you a basic pic application (which will include the serial ISR) for using the interface but you will have to give me time until the weekend. (I also have a version of the GUI for the pic18f)
Wilksey's suggestion of using .net is a good idea which you should consider. If you use 2008.NET on windows 7 there is no need for registering serial port components. I have used .net for a graphical compiler for pic18f's and find it much easier to use.
Regards from sunny RSA.
 
Hi Red
Here are some source code for those who wants to testdrive the GUI. RedsDemo.zip is the complete pic source. (RedsDemo.asm is the main file if you want to re-assemble - use MPLAB Project/Quickbuild ....) I have used the PIC18F876A (only one i got) for the project. PicWin16.zip contains the VB6 source, including the executable PicWin16.exe. The file Using PicWin16.docx will show you how to drive the GUI and MONITOR01.pwn is the file you can import (use the ReadFile button at the top) to configure the parameters for the RedsDemo PIC application.
For your application i would sugest you write code for the PIC to receive one byte and react accordingly. An 'A' will turn on led, a 'B' will turn it off. Then you can easily test it using an pc application like Terminal. Then make a VB program with buttons to send A and B
 

Attachments

  • PicWin16.zip
    97.7 KB · Views: 128
  • RedsDemo.zip
    32.2 KB · Views: 122
Hi Red
Seems to me the two files (MONITOR.pwn and Using PicWin16.docx) were not included in my post because of invalid extensions. The first is a pure text file so i have changed the extention to .txt (so you must change it back to .pwn. The Using PicWin16.docx i have changed to a pdf.
Good luck with your project.
 

Attachments

  • MONITOR01.txt
    367 bytes · Views: 123
  • Using PicWin16.pdf
    695 KB · Views: 190
Hi Lourens
Thanks for sharing the program, Lourens. It's awesome.
I've understand how to control the PIC through VB interface by sending A, B and else (Thanks to you!).

But now I changed my mind to use Arduino (Duemilanove). I think it's the same method to control Arduino using VB interface ( I tested it using and it works!).
My work's done if I only have to control it locally but now I required to do it remotely through LAN which means I have to use VB.NET.

I created the VB interface for the local control using Visual Studio 2008 Express Edition.
(attachment: WindowsApplication1.zip)

  • Do you know to make this VB interface available to use for other PC in LAN?

Image LAN topography for my project (attachment: LANtopo.jpg)

sorry for my late reply.
**in case of I'm using Arduino now. Am I have to move to Arduino section?**
 

Attachments

  • WindowsApplication1.zip
    69.4 KB · Views: 115
  • LANtopo.jpg
    LANtopo.jpg
    31 KB · Views: 151
Last edited:
PICs and VB

Hi Red
Good to hear you got your PIC - VB interface up and running. About using LAN - i am an absolute novice, the same goes for Arduino. I have used the same methods as that of the VB6 monitor but now with VB 2008 in a project to make an ide for pic18's, but still using rs232 (with usb converter) for PIC - PC comms. This project works very well for me. For those interested in applying a pic18 without writing a line of code i include a description of the idea.
 

Attachments

  • PIC01_CB_Programming_with_Pictures.pdf
    270.2 KB · Views: 214
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top