+ Reply to Thread
Page 2 of 3
First 1 2 3 Last
Results 16 to 30 of 32

Thread: Visual Basic 6 to PIC MCU (HOW TO)

  1. #16
    Super Moderator kinjalgp Newbie
    Join Date
    Oct 2002
    Location
    INDIA/USA
    Posts
    1,855

    Default

    There could be many reasons for this. First thing may be baud rate. Or may be improper schematic.
    Show your Micro's code and your schematic.
    "There is no way to peace, peace is the way!"


  2. #17
    3v0
    3v0 is offline
    3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent
    Join Date
    Jul 2006
    Location
    USA
    Posts
    6,464
    Blog Entries
    11

    Default You can check the MAX232 independantly of the PIC.

    If you are using Nigels tutorial schematic.

    Remove the PIC.
    On the MAX232 junper pins 9 and 10 together.
    Use a terminal emulator on the PC.

    Now anything you type on the PC will come in on MAX232 pin 8
    at RS232 levels. It will exit the MAX232 on pin 9 at TTL levels.
    Then go back into the MAX232 on pin 10 as TTL and exit on 7
    as RS232 and go back to the PC.

    With this setup anything you type on the PC should show up on
    the PC screen. If it does your MAX232 and cable are OK.

    Remove the jumper and replace the PIC.

    EDIT: For this test baud rate and parity settings on the PC do not matter,
    but I suggest you use whatever you intend to use with the PIC.
    Last edited by 3v0; 1st August 2007 at 01:56 AM.
    Please post questions to the forums. PM's are for personal communication.

    BCHS/3v0's Tutorials
    Junebug USB PIC programmer kit., USB Bit Whacker,
    The 15 Minute Printed Circuit Board! (+drill time)

  3. #18
    stolzie Newbie
    Join Date
    Dec 2005
    Location
    Gold Coast Australia
    Posts
    16

    Default

    Instead of using a MAX232, as serial ports are becoming rare on laptop's you might want to consider implementing a USB to serial chip. e.g FT232R or FT232BM

    The drivers for these FTDI chips allows you to communicate to the device like any standard serial COM port. So the code you have already implemented will still work.

    Cheers

    Stolzie

  4. #19
    Peter_wadley Good Peter_wadley Good
    Join Date
    Mar 2007
    Location
    Toronto, Canada
    Posts
    374

    Default

    Quote Originally Posted by 3v0
    If you are using Nigels tutorial schematic.

    Remove the PIC.
    On the MAX232 junper pins 9 and 10 together.
    Use a terminal emulator on the PC.

    Now anything you type on the PC will come in on MAX232 pin 8
    at RS232 levels. It will exit the MAX232 on pin 9 at TTL levels.
    Then go back into the MAX232 on pin 10 as TTL and exit on 7
    as RS232 and go back to the PC.

    With this setup anything you type on the PC should show up on
    the PC screen. If it does your MAX232 and cable are OK.

    Remove the jumper and replace the PIC.

    EDIT: For this test baud rate and parity settings on the PC do not matter,
    but I suggest you use whatever you intend to use with the PIC.
    mmm, now thats how to troubleshoot!!

    Its still not working like this 3v0!

    Ok here is what I have going:

    Power is 5V

    On the DE-9..

    Pins 1 & 4 & 6 are connected together.
    Pins 7 and 8 are as well.

    Pin 5 is going to ground on the MAX circuit.

    Pin 2 is going to Pin 7 of the MAX
    Pin 3 is going to Pin 8 of the MAX

    There is a 47uf by cap on Pin 16 of the MAX.

    Between pin 16 and pin 2 is a 22uf cap, + leg is on pin 2

    On Pin 6 there is a 22uf cap going to ground, + leg is on ground side.

    Between pin 1 and 3 I have (2) 4.7uf caps in parallel, since I dont have (2) 10uf caps. + leg is on pin 1

    Between pin 4 and 5 is one 10uf cap, + leg is on pin 4.

    and Pin 9 and 10 are jumpered together.

    Ground is on Pin 15. Vdd is on 16.

    That is exactly how mine is wired.

    The VB6 program:

    On the Form there is 2 txt boxes.

    txtRX and txtTX

    I then Copy and pasted this code:

    PHP Code:
    Private Sub Form_Load()
        
    With MSComm1
            
    .Settings "9600,n,8,1"    ' Baud=9600, Parity=None, Data-Bits=8, Stop-Bits=1
            .CommPort = 1            ' 
    COM1
            
    .PortOpen True         Open the port
        End With
    End Sub

    Private Sub Form_Unload()
        If 
    MSComm1.PortOpen True then MSComm1.PortOpen False
    End Sub

    Private Sub MSComm1_OnComm()
        If 
    MSComm1.CommEvent comEvReceive Then
            txtRX
    .Text txtRX.Text MSComm1.Input
        End 
    If
    End Sub

    Private Sub txtTX_KeyPress(KeyAscii As Integer)
        
    Mscomm1.Output Chr(KeyAscii)
    End Sub 
    Into the code window.

    When I press 'RUN'

    I try to type in the TX text box.. nothing shows up on the RX box.

    argh.
    "Stick around" - Arnold Schwarzenegger in The Predator after impaling a soldier to a wood post

    9vDC Guitar Pedal PSU

    PIC16F84a Game Module

  5. #20
    3v0
    3v0 is offline
    3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent
    Join Date
    Jul 2006
    Location
    USA
    Posts
    6,464
    Blog Entries
    11

    Default

    I did not sort through the wiring. A schematic would go a long way here. The text version makes my head hurt.

    Prior to getting into that lets make sure the PC is doing its job.

    Unplug the RS232 cable from the PIC.

    Type and you should see nothing.

    Short pins 2 and 3 on the RS232 cable (it is still plugged into the PC but not the PIC target). To do this you can makup an DB9 with a wire soldered between 2 and 3.

    With the jumper in place you should see what you are typing on the PC.

    If this does not work either you did not follow these instructions or the BASIC program has problems. Maybe flow control problems. Others may have talked about that.
    Please post questions to the forums. PM's are for personal communication.

    BCHS/3v0's Tutorials
    Junebug USB PIC programmer kit., USB Bit Whacker,
    The 15 Minute Printed Circuit Board! (+drill time)

  6. #21
    Super Moderator kinjalgp Newbie
    Join Date
    Oct 2002
    Location
    INDIA/USA
    Posts
    1,855

    Default

    Are you sure you have connected RS232 cable on COM1?

    A silly question...but sometimes people make this mistake.
    "There is no way to peace, peace is the way!"

  7. #22
    TekNoir Newbie
    Join Date
    Mar 2005
    Location
    Tennessee - USA
    Posts
    138

    Default

    This tutorial from SparkFun Electronics might be useful to you.

    http://www.sparkfun.com/commerce/pre...p?p=BEE-4-UART

    At the bottom of their main tutorial page, under the heading General PIC Tutorials, they have some other serial and UART related information.

    I apologize if it's too little too late, but perhaps it can be of some help for others.
    Last edited by TekNoir; 1st August 2007 at 05:08 AM.

  8. #23
    Peter_wadley Good Peter_wadley Good
    Join Date
    Mar 2007
    Location
    Toronto, Canada
    Posts
    374

    Default

    Quote Originally Posted by 3v0
    I did not sort through the wiring. A schematic would go a long way here. The text version makes my head hurt.

    Prior to getting into that lets make sure the PC is doing its job.

    Unplug the RS232 cable from the PIC.

    Type and you should see nothing.

    Short pins 2 and 3 on the RS232 cable (it is still plugged into the PC but not the PIC target). To do this you can makup an DB9 with a wire soldered between 2 and 3.

    With the jumper in place you should see what you are typing on the PC.

    If this does not work either you did not follow these instructions or the BASIC program has problems. Maybe flow control problems. Others may have talked about that.
    It appears my problem is bigger then the PIC and the MAX.

    When I short pins 2 and 3 of the serial cable It still does not work.

    Could it be my fire wall?

    It is on COM1 for sure.

    Why do we jumper 7 and 8?

    Why do we jumper 1 and 4 and 6?

    I know these are probably the lamest questions but it really will help me solve this.

    Does anyone have the VB6 program made?

    No need to go and make it , but if have it already..

    Well I dont really understand! I am a very consious programmer.. everything in the VB appears to be right..

    Fairly new computer.. COM port has never given problems.. worked with my edrum and programmer..

    HMMMM
    "Stick around" - Arnold Schwarzenegger in The Predator after impaling a soldier to a wood post

    9vDC Guitar Pedal PSU

    PIC16F84a Game Module

  9. #24
    Super Moderator kinjalgp Newbie
    Join Date
    Oct 2002
    Location
    INDIA/USA
    Posts
    1,855

    Default

    Firewall generally doesn't block COM ports so I guess thats not the problem.

    Try this project. Its a terminal program written in VB.
    http://www.programmersheaven.com/dow.../download.aspx
    "There is no way to peace, peace is the way!"

  10. #25
    Peter_wadley Good Peter_wadley Good
    Join Date
    Mar 2007
    Location
    Toronto, Canada
    Posts
    374

    Default

    what should the flow control be set at ?

    it is on HARDWARE right now.
    "Stick around" - Arnold Schwarzenegger in The Predator after impaling a soldier to a wood post

    9vDC Guitar Pedal PSU

    PIC16F84a Game Module

  11. #26
    Super Moderator kinjalgp Newbie
    Join Date
    Oct 2002
    Location
    INDIA/USA
    Posts
    1,855

    Default

    It should be NONE. You don't require any hand-shaking in most cases.
    "There is no way to peace, peace is the way!"

  12. #27
    Peter_wadley Good Peter_wadley Good
    Join Date
    Mar 2007
    Location
    Toronto, Canada
    Posts
    374

    Default

    sweeeeeeeeeeet

    I was just messing with the Properties window for MSCOMM and now it working!

    Input mode was set to Binary.. changed it to Text.

    Dont ask, heh.

    Ill try it with the MAX now..

    Works.

    Ill try it with the PIC now..

    Works!


    Thank you guys SOOOO much! This has given me so many more circuit ideas!!

    Next is USB i guess.. any recommend chips?

    See you.
    "Stick around" - Arnold Schwarzenegger in The Predator after impaling a soldier to a wood post

    9vDC Guitar Pedal PSU

    PIC16F84a Game Module

  13. #28
    Super Moderator kinjalgp Newbie
    Join Date
    Oct 2002
    Location
    INDIA/USA
    Posts
    1,855

    Default

    USB is pretty difficult to start with. Its not like Serial or parallel port. It requires lot of coding.

    But if you use USB to Serial converter chips like FT232...things become much easier as USB coding is abstracted by using the DLLs supplied by FTDI. www.ftdichip.com
    "There is no way to peace, peace is the way!"

  14. #29
    3v0
    3v0 is offline
    3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent
    Join Date
    Jul 2006
    Location
    USA
    Posts
    6,464
    Blog Entries
    11

    Default

    Build a few projects with the RS232 serial first.

    Then you may want to take a look at
    UBW (USB Bit Whacker)

    It uses a PIC18F with USB. It may not be the exact application you are looking for but it is fun to play with and quite inexpensive to build.
    Please post questions to the forums. PM's are for personal communication.

    BCHS/3v0's Tutorials
    Junebug USB PIC programmer kit., USB Bit Whacker,
    The 15 Minute Printed Circuit Board! (+drill time)

  15. #30
    Peter_wadley Good Peter_wadley Good
    Join Date
    Mar 2007
    Location
    Toronto, Canada
    Posts
    374

    Default

    Quote Originally Posted by 3v0
    Build a few projects with the RS232 serial first.

    Then you may want to take a look at
    UBW (USB Bit Whacker)

    It uses a PIC18F with USB. It may not be the exact application you are looking for but it is fun to play with and quite inexpensive to build.
    Will do.

    Probably going to use RS232 with VB then JAVA then C++ before I go for USB.
    "Stick around" - Arnold Schwarzenegger in The Predator after impaling a soldier to a wood post

    9vDC Guitar Pedal PSU

    PIC16F84a Game Module

+ Reply to Thread
Page 2 of 3
First 1 2 3 Last

Similar Threads

  1. K8055 USB Interface Visual Basic Help
    By Sudonon in forum General Electronics Chat
    Replies: 9
    Latest: 18th December 2008, 01:40 PM
  2. Visual Basic for Electronics Engineering Applications
    By ThermalRunaway in forum Electronic Books
    Replies: 25
    Latest: 26th November 2008, 08:56 AM
  3. Serial Communication Interrupt in PIC Basic Pro
    By TheMaccabee in forum Robotics Chat
    Replies: 5
    Latest: 12th April 2007, 07:53 AM
  4. visual basic program for parallel port interface
    By group_x3m in forum Micro Controllers
    Replies: 5
    Latest: 26th May 2006, 01:49 AM
  5. Newcomers, please read! (PIC regarded) Upd. 0xD
    By Jay.slovak in forum Micro Controllers
    Replies: 0
    Latest: 17th April 2005, 01:05 PM

Tags for this Thread