SerIn2 ASCII Conversion


Results 1 to 13 of 13

Threaded View

  1. #1
    Join Date
    Oct 2005
    Posts
    74

    Default SerIn2 ASCII Conversion

    Hello Folks, Been a long time.

    I have a program I'd written awhile back that uses modbus RTU and now we need to add the Modbus Ascii to it so either can be used. Of course the protocol is determined at start up by a jumper. RTU is tried and tested, just have to squeeze in the ASCII portion.

    The hit list:
    On Power Up Check Jumper then Set Protocol Variable
    Set Baud Rate, Parity and other Port Settings to proper values for Protocol
    Modify HSerIn to decode accordingly
    Modify HSerOut to Encode accordingly



    Using HSerin2, which is the easiest way to convert ASCII to Decimal values.
    I will be placing the values into an array of byte called BufRx.

    The incoming Ascii is like this, with out the spaces.
    :01 03 00 00 00 05 13 10

    When Decoded, after skipping the Colon, and the CRLF I should have this:
    BufRX[0] = 1
    BufRX[1] = 3
    BufRX[2] = 0
    BufRX[3] = 0
    BufRX[4] = 0
    BufRX[5] = 5

    Below, I Wait for the Colon, grab 2 char and convert to decimal and store in array until CR LF.

    I know there has to be an easier way but I'm way rusty. Not even sure if this is correct.

    HSerIn Timeout,Receive,[WAIT(":"),DEC2 BufRX[0], DEC2 BufRX[1], DEC2 BufRX[2], DEC2 BufRX[3], DEC2 BufRX[4], DEC2 BufRX[5],13,10 ]

    Thanks,
    Richard
    Last edited by rwskinner; - 11th February 2008 at 23:41. Reason: Typos

Similar Threads

  1. GPS $GPRMC to PIC16F684. Need help with SERIN2
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 27th November 2009, 09:47
  2. ASCII to Long conversion
    By TerdRatchett in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 5th March 2009, 23:43
  3. ascii conversion help needed
    By muddy0409 in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 13th January 2007, 06:33
  4. Hanging on SERIN2 - SOLVED!
    By blainecf in forum Serial
    Replies: 1
    Last Post: - 13th July 2006, 17:55
  5. Conversion of 10-bit word into ASCII
    By Barry Johnson in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 16th January 2005, 14:26

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