Sending Commands from Visual Basic about IR to Pic


Closed Thread
Results 1 to 5 of 5
  1. #1
    tne_de's Avatar
    tne_de Guest

    Default Sending Commands from Visual Basic about IR to Pic

    Hello,
    i want to send commands about a Visual Basic (Express 2008) about IR to a pic.
    The IR Led is connected with my pc on COM 1.

    My VB Code Snippet:
    Code:
    [...]
    ' Connection to COM1
    With serialPort
        .PortName = cbbCOMPorts.Text 'COM1
        .BaudRate = 2400
        .Parity = IO.Ports.Parity.None
        .DataBits = 8
        .StopBits = IO.Ports.StopBits.One
    End With
    [...]
    serialPort.Write(txtDataToSend.Text) 'txtDataToSend = Input txt field

    My PBP Code for recipient
    Code:
    main:
    serin ir,0,["9999"],dat
        
        IF dat=1 THEN
        led2=turnoff
        led1=turnon
        ENDIF
       
        IF dat=5 THEN
        led1=turnoff
        led2=turnon
        ENDIF
    GOTO main
    My PBP Code for sender
    Code:
    main:
       SEROUT led5,12,["9999",1]
       PAUSE 100
       SEROUT led5,12,["9999",5]
       PAUSE 100
    GOTO main
    With this PBP Code it works regarding Pic to Pic communication.
    But if I send "99991" or "99995" by my Visual Basic programm it does not work.

    I read in the manual that the 12 in the SEROUT command send the data "open inverted" - what does it mean? How could I "open inverted" my command in Visual Basic (Express 2008)?

    Best regards

    EDIT: Additional Information I use a PIC 12F629
    Last edited by tne_de; - 1st April 2009 at 10:03. Reason: change options for Thread Subscription, add adiotional informations

  2. #2
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default Alternate LED Connection

    Hi,

    I really don't know if inversion can be achieved using the default serial class. You can connect the LED to the positive rail and the TX output via a limiting resistor. This give you a straight out. Positive rail is not available on the RS232 connector. So use the DTR line and flip it (Set High) in VB before starting the communication. This gives you a steady positive supply on DTR (8-12 volts). Connecting the LED to the ground inverts the signal. Take care of the LED polarity at the TxOut in both the cases.
    Regards

    Sougata

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    I would suggest you try to send data to your PC to a terminal software first (Hyperterm, MicroCode Serial communicator or whatever else).

    Then from your PC to your PIC.

    I you have good results, then move on VB. I had some bad experiments in the past on some computer on low baudrate.

    High likely, you're using the internal OSC of your PIC? Don't forget at least the OSCCAL_1K define. Not a bad idea to use DEBUG/DEBUGIN as well. It perform better on some case.

    Use current limiting resistor & the InvertedMode on the PIC side, and it should work on small distance between your PIC and the PC.

    On VB side, I would suggest you to use ReadLine. To use it, you'll need to modify your PIC code to send a LF character (10) at the end.
    Last edited by mister_e; - 2nd April 2009 at 14:49.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Feb 2009
    Location
    Southern California
    Posts
    86


    Did you find this post helpful? Yes | No

    Default

    I think the problem is with "1" vs 1 (SOH)

    [HTML]My PBP Code for sender
    Code:

    main:
    SEROUT led5,12,["9999",1]
    PAUSE 100
    SEROUT led5,12,["9999",5]
    PAUSE 100
    GOTO main

    With this PBP Code it works regarding Pic to Pic communication.
    But if I send "99991" or "99995" by my Visual Basic programm it does not work. [/HTML]

    Your pic is sending out hex 1 and your vb is sending out hex 31
    To get vb to send out a 1 try
    txtDatatoSend.txt = "9999" & chr(1)
    this will add a 1 to it, though if you ever want to send 0 it will actually be sending nul characters

    On the other hand you could send a "1" and on the pic side once you receive your dat variable, just subtract "0" from it to give you the value you want or change your if statements to check for "1"

  5. #5
    Join Date
    Apr 2009
    Posts
    7


    Did you find this post helpful? Yes | No

    Arrow

    Hi Sougata

    needed a bit of help on inverters using pic16f72
    read ur posts on the following thread
    http://www.letbasic.com/forum/showth...?t=1846&page=4

    this thread is a year or more old so i believe u have advanced ur inverter quite a lot

    can u help on pic 16f72 code as i'm very bad on coding weras i ve pretty gud hardware knowledge.......

    sam
    [email protected]
    Last edited by samrulezzz; - 29th April 2009 at 06:14.

Similar Threads

  1. Basic PIC circuit acting weird
    By FIONEX in forum General
    Replies: 3
    Last Post: - 9th October 2008, 01:04
  2. PIC BASIC Compiler for ARM machines?
    By stone20008 in forum General
    Replies: 2
    Last Post: - 22nd August 2008, 07:14
  3. pic to pic ir link versus wired link : help please anyone
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 30th May 2008, 21:01
  4. How to use 93C46 Type EEPROM using PIC Basic PRo
    By in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 1st April 2003, 04:07
  5. Help with MPASM and PIC Basic
    By johngb in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 21st February 2003, 13:07

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts