How to determine 485 network is not busy in half-duplex


Closed Thread
Results 1 to 9 of 9

Hybrid View

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

    Default Re: How to determine 485 network is not busy in half-duplex

    I have done multi-master RS485 many years back. I found the AN01230 interesting in how they achieve the multimaster operation.

    What I did involved a little an extra 485 chip, but, essentially utilised the same principles.

    I had a main RS485 transmitter and a separate RS485 listener chip on the same board. Whatever goes out the transmit line is visible back again on the input line via the listener chip. So, any data corruption due to a collision can be detected and the transmit process can be re-started. The rest of the arbitration process is essentially the same except I use discrete IDs for each RS485 station like in any such multi-device setup and the system worked very well.

    You can stop transmitting the moment you see a single byte error in your packet - when sent character is not same as received character.

  2. #2
    Join Date
    Sep 2007
    Location
    Waco, Texas
    Posts
    151

    Default Re: How to determine 485 network is not busy in half-duplex

    Thanks Jerson. I made the mistake of already having the board made so I would like to try to see if I can do it with just one 485 transceiver. The J1708 looks like it is still being used and if I cannot get a modified J1708 protocol to work with a 485 connected the normal way, then my next try would be to try an actual J1708 transceiver. Maxxim makes one and it look as if it would be a drop-in replacement so I would have the expense of re-doing the board design.
    I think I have base code working but for some reason the 485 enable line sits high - even after the packet should have been delivered..... which tells me the program thinks there is still stuff to transmit...... looking into it now....
    Regards,
    Steve

    Code below:
    Code:
    Node_ErrChk:'-------------------------------------------------------------------
    'Checks the received node packet for data integrity and sends an ACK if good or a NAK if bad
                      NodeWord=Node_Addr+Node_Cmd_Resp+Node_Bd+Node_Port_Dev
                      Node_Sum_temp=NodeWord.byte0 ^ $FF                            'Creates a local temp sumcheck used for comparison
                      if Node_Sum_Temp <> Node_Sum then                             'If the received checksum and the local checksum don't match, then.... 
                         error=1                                                    'Turns ON error LED
                         Node_Cmd_Resp=$03                                          'Form our NAK response
                         Node_Addr=Address                                          'What our local address is
                         Node_Bd=0                                                  'Doesn't matter, we are asking for a retransmit
                         Node_Port_Dev=0                                            'Same as above
                         NodeWord=Node_Addr+Node_Cmd_Resp+Node_Bd+Node_Port_Dev     'Create our checksum
                         Node_Sum=NodeWord.BYTE0 ^ $FF                              'ditto
                         ncts=1                                                     'Enable transmission of 485 interface
    NodeLineBusy2:       if BAUDCON1.6=1 then pauseus (Address*10)                  'Checks to see if the receive operation is idle(1), if it is, pause for address*10 uS for random
                         if BAUDCON1.6=0 then NodeLineBusy2                         'Receive operation is still busy, if not, send packet
                         hserout [sync,Node_Addr,Node_Cmd_Resp,Node_Bd,Node_Port_Dev,Node_Sum]   'Send command
                         while not TXSTA1.1 : wend                                  'Wait for USART to finish xmitting
                         ncts=0                                                     'Places 485 interface back into receive mode
                      else                                                          'OR....... 
                         Status1=1                                                  'Turns ON LED
                         NodePktResp=Node_Cmd_Resp & $0F                            'Strips off high order nibble to check for a NAK, put in local temp var - keeps packet integrity
                         if NodePktResp=$03 then goto Node_ReXmit                   'Got a NAK from the Control Computer so send it again
                         if NodePktResp=$02 then Node_ErrChk_Exit                   'We were ACKd, so just leave it alone
    'Now we have received a node packet, believed to be good, so we will ADD $02 to 
    'the Node_Cmd_Resp byte we received and transmit back to Control PC so the PC 
    'knows everything is OK in our world....... and figure a new Checksum......
                         Node_Cmd_Resp=Node_Cmd_Resp + $02                          'Adds the ACK to the byte for our response
                         NodeWord=Node_Addr+Node_Cmd_Resp+Node_Bd+Node_Port_Dev     'Build our new checksum
                         Node_Sum=NodeWord.BYTE0 ^ $FF                              'ditto
                         ncts=1                                                     'Enable transmission of 485 interface
    NodeLineBusy3:       if BAUDCON1.6=1 then pauseus (Address*10)                  'Checks to see if the receive operation is idle(1), if it is, pause for address*10 uS for random
                         if BAUDCON1.6=0 then NodeLineBusy3                         'Receive operation is still busy, if not, send packet
                         hserout [sync,Node_Addr,Node_Cmd_Resp,Node_Bd,Node_Port_Dev,Node_Sum]   'Send command
                         while not TXSTA1.1 : wend                                  'Wait for USART to finish xmitting
                         ncts=0                                                     'Places 485 interface back into receive mode
                      endif
    Node_ErrChk_Exit:
                      Status1=0                                                     'Turns OFF LED
                      Error=0                                                       'Turns OFF LED if it was ON
                      node_PacketRcvd=0                                             'Zero the switch so we don't send other bytes
                      return
    "If we knew what we were doing, it wouldn't be called research"
    - Albert Einstein

Similar Threads

  1. give an address to pic on rs-485 network
    By russellperry in forum Ethernet
    Replies: 2
    Last Post: - 8th February 2014, 23:50
  2. USB CDC serial duplex string example wanted
    By russellperry in forum USB
    Replies: 0
    Last Post: - 31st January 2014, 19:33
  3. PICs in a RS-485 network?
    By atomski in forum mel PIC BASIC Pro
    Replies: 21
    Last Post: - 12th November 2011, 10:52
  4. RS 485 network
    By mychangl in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 25th November 2008, 10:35
  5. Slave Databuffer - RS-485 network
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 1st June 2005, 19:36

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