9 Bit Transmission


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1

    Red face 9 Bit Transmission

    Hi,

    I Know that I should use for a RS485 Transmission a 9 Bit Transmission,and that for example the 9th Bit for the Adress must be Set to 1.

    But My Question is how can I do this with PicBasicPro.?
    Did I Need a Word Variable or I can just use a Byte variable?

    I Send The Data from MY PC with a Visual Basic Software !
    Did I Need a Binary Transmission for my Visual Basic Software?

    Thank You very much for any Answer !

    Regard Pesti.

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    967


    Did you find this post helpful? Yes | No

    Default

    I Know that I should use for a RS485 Transmission a 9 Bit Transmission,and that for example the 9th Bit for the Adress must be Set to 1.
    Not at all true. Most people use the 9 bit data format to achieve high speed data transfers. You can define your own protocol and use it with normal 8 bit data.

    I generally use a protocol having a header like this
    Code:
      Destination address <1 byte> Source address <1 byte> 
      Command <1 byte> data <n bytes> Checksum <2 bytes>
    Advantage of my method, you do not have to juggle VB to get the 9th bit

    Jerson

  3. #3
    Join Date
    Mar 2005
    Location
    Magnolia, TX
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    Jerson,
    Can you elaborate on your method? It's sounds interesting since you apparently don't require any manipulation of the stop bit on the PC side.

    Darryl

  4. #4
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    967


    Did you find this post helpful? Yes | No

    Default

    Darryl

    As I showed in the previous post, you build your own protocol. If you are doing ASCII commands, then you need a sync character to know the start of packet.

    Code:
    STX DST SRC CMD DATA.......DATA CS ETX
    This can be the format for a typical packet. STX (02H) is the start character you seek to know there is a command / response packet. DST is the slave id which you want to talk to. SRC is the id of the master and can be omitted if there is a single master as in the case of a PC based logger. CMD tells the slave which function is being invoked and DATA passes parameters to the function if they are needed. Finally CS is a checksum to verify that the data packet has arrived without corruption. CS could be as simple as a LRC longitudinal redundancy check or as severe as a CRC16 cyclic redundancy check.

    ETX (03H) generally is not needed but can be used to frame the command / response packet.

    The slave responds with a message within the alloted time window (fixed by your program). If not, the master times out and understands that the slave is disconnected or not working. I have built many systems using this type of
    protocol and it works really well.

    You could look at the MODBUS specification if you want to learn more. MODBUS however offers an ASCII mode and a binary RTU mode. PLCs generally use the RTU mode to garner speed. In ASCII mode, you have to send every byte converted to 2 bytes of ASCII. So, a character like 02H will be sent as 30H, 32H. This is also applicable to the protocol I described above.

    Jerson

  5. #5


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Thank You !

    Yes I think I will use my own Protocoll !

    But I dont understand how Can I send a 9 Bit Packet when a Byte have just 8 Bit?

    9 Bit is more then 255 and is a Word Size !

    Thats mean when I Use 9Th Bit I must send a Word Divided in two Bytes ?

    Thanks

    Regard Pesti.

  6. #6
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    967


    Did you find this post helpful? Yes | No

    Default

    Pesti

    You do not have to use 9 bits. Your standard serial UART will do the job just fine. I mentioned this earlier
    You can define your own protocol and use it with normal 8 bit data.
    When you use the 9 bit packets, you distinguish address and data bytes by the 9th bit alone. So, any byte having the 9th bit set is an 8bit address byte whereas all words with the 9th bit low are data.

    Jerson
    Last edited by Jerson; - 4th August 2007 at 09:25.

Similar Threads

  1. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 07:55
  2. How to receive stream of bytes using PIC USART
    By unifoxz in forum mel PIC BASIC Pro
    Replies: 34
    Last Post: - 20th June 2009, 10:38
  3. Sleep Mode
    By Pesticida in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th March 2008, 10:31
  4. PICBasic newbie problem
    By ELCouz in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 12th February 2008, 00:55
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

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