A code scrutiny question


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    974


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by kevlar129bp View Post
    Hello all,
    Code:
    ' Wait until the character “B” AND board address is received serially on porta.0
    serin2 serialinput,84,[WAIT ("B",board)]
    if board <> boardAddr then goto start 
    ' Wait until the character “R” is received serially on porta.0 and put next character into B1
    SERIN SerialInput,N9600,["R"],relay
    ' Wait until the character “S” is received serially on porta.0 and put next character into B2
    SERIN SerialInput,N9600,["S"],stat
    Chris
    I think you will need to change the statements as shown below
    Code:
    ' Wait until the character “B” AND board address is received serially on porta.0
    SERIN2 serialinput,84,[WAIT ("B",DEC2 board)]
    if board <> boardAddr then goto start 
    ' Wait until the character “R” is received serially on porta.0 and put next character into B1
    SERIN2 SerialInput,84,["R"],DEC2 relay
    ' Wait until the character “S” is received serially on porta.0 and put next character into B2
    SERIN2 SerialInput,84,["S"],DEC2 stat
    Here I am assuming the B??R??S?? each gets a 2 digit decimal value

  2. #2
    Join Date
    Dec 2005
    Location
    Salt Lake City, Ut, USA
    Posts
    108


    Did you find this post helpful? Yes | No

    Default

    Thank you Mike and Jerson. To explain in more detail, I'll try to answer your questions as best I can.

    The mcu I plan on using is the 16F871.

    On port B, I'll have 8 dip switches for the "board" address (set high or low).
    0 to 256 ex: B129

    There will be 24 GPIO's left over, therefore they will be the "relay".
    1 to 24 ex: R22

    The "stat" will either be on or off.
    0 or 1 ex: S0

    In the above example, I would like to:
    On board 129, turn relay 22 off

    On that note, I commented 2 lines in the code to possibly garner advice on the proper way to send those commands from vb.net. If any of you could comment on that as well, that would be great.
    Thank you guys again.

    Chris

  3. #3
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    974


    Did you find this post helpful? Yes | No

    Default

    I think the second line is good.
    MSComm1.Output = "B??R??S??" + Chr$(13)

  4. #4
    Join Date
    Dec 2005
    Location
    Salt Lake City, Ut, USA
    Posts
    108


    Did you find this post helpful? Yes | No

    Default

    Thank you Jerson,
    I suppose I could try both in VB. I'll go with your suggestion first.

    Chris

Similar Threads

  1. 16F to 18F transition pains
    By lurker in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 5th December 2008, 01:35
  2. Code to control 4 LEDs and 2 servos
    By The Master in forum Off Topic
    Replies: 2
    Last Post: - 26th November 2008, 13:33
  3. General Question About Multiple Interrupts
    By grzeh666 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 31st August 2008, 17:09
  4. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  5. Code for I2C Slave
    By Balachandar in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 21st November 2006, 19:14

Members who have read this thread : 0

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