9 Bit Transmission


Closed Thread
Results 1 to 11 of 11
  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
    947


    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
    947


    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
    947


    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.

  7. #7


    Did you find this post helpful? Yes | No

    Default

    Ok I understand,but where is the 9th bit ?

    When I send 1 Byte I have: 1 Start Bit,8 Data Bit,1 Stop Bit.
    Where Is here the 9Th Bit? :-)

    For example when I use Hyperterminal I can not adjust to 9th Bit I just have 7 or 8 Bit data.

    Regard Pesti

  8. #8
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695


    Did you find this post helpful? Yes | No

    Default

    Hi,

    The USART module of a PIC has multi-processor communication
    capability using 9-bit address detection.

    See this document:
    http://www.datadog.com/rs485.pdf

    Use The PC's UART With 9-Bit Protocols
    http://www.elecdesign.com/Articles/I...ArticleID=6245
    (You will have to wait 20 seconds before you see the doc).

    See the datasheet of the used chip.

    Best regards,

    Luciano

  9. #9


    Did you find this post helpful? Yes | No

    Default

    Mille Grazie Luciano !

    :-)

    Regard Pesti

  10. #10
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695


    Did you find this post helpful? Yes | No

    Default

    Hi Pesti,

    With the VB MScomm control you can set the parity as following:

    Code:
    Setting   Description 
    E         Even 
    M         Mark 
    N         (Default) None 
    O         Odd 
    S         Space

    If you use MARK parity, then the bit after the data word is a logical 1.
    If you use SPACE parity, then the bit after the data word is a logical 0.

    With MARK parity the slave device will see the data as a 9-bit transmission. (Last bit = 1)
    Use the MARK parity to send the address to the slaves.

    With SPACE parity the slave device will see the data as a 9-bit transmission. (Last bit = 0)
    Use SPACE parity to send the data to the selected slave.


    (Click on the picture to enlarge)

    (VB pseudocode)
    Code:
    VB pseudocode
    .....
    Insert a delay here to ensure that UART FIFO buffer of the PC is 
    empty before you change the parity. The UART 16550 has up to 16 bytes 
    for the FIFO transmit buffer. 
    
    MSComm.Settings = "9600,M,8,1"
    MSComm.Output = (The slave Address) 
    
    Insert a delay here to ensure that UART FIFO buffer of the PC is 
    empty before you change the parity. The UART 16550 has up to 16 bytes 
    for the FIFO transmit buffer. 
    
    MSComm.Settings = "9600,S,8,1"
    MSComm.Output = (The data for the selected slave)
    .....
    From the Windows control panel you can adjust the size of the FIFO buffers of the used serial port.

    (Click on the picture to enlarge)

    Best regards,

    Luciano
    Last edited by Luciano; - 5th August 2007 at 12:22.

  11. #11


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Thank You!

    Thats it !
    This is the Answer what I waiting for.

    Now I know how to Programming the Software routines.

    I use Pic 18f452 and I see on the PDF Datasheet that I can set the 9th Bit Transmission for RX and TX.

    Thanks a lot Luciano!

    Buona Giornata!


    Regard Pesti.

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 : 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