Strange problem with the HSEROUT and HSERIN


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Jan 2006
    Location
    Toronto
    Posts
    109

    Default Strange problem with the HSEROUT and HSERIN

    I have been trying to setup a RS-485 network between multiple PICs using the MAX3077E Full Duplex transceiver and everything works great even at 115200 Baud as long as i send a single byte.

    Once I start sending more thats when things go wrong.

    This is what I am trying to send:

    HSEROUT [ACK,ToAddress,Command,Parameter.LowByte,Parameter. HighByte]

    and this is the Receiving side:

    HSERIN [WAIT(ACK),ToAddress,Command,Parameter.LowByte,Para meter.HighByte]

    ACK, ToAddress and Command are all BYTE

    Using this code i sometime get 3 bytes but most of the time i only get 2 bytes plus it will not receive again until i reset the pic.


    Does anyone know why this would be a problem? I even reduced the speed to 300 Baud with the same results.

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


    Did you find this post helpful? Yes | No

    Lightbulb Inter character timing?

    Are you facing a hardware turnaround issue here?

    Jerson
    Last edited by Jerson; - 9th January 2006 at 04:50.

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,838


    Did you find this post helpful? Yes | No

    Default

    I faced the same problem when connected the two PIC systems with 485. With direct connection no problem occured. Seems to be the switching delays from the drivers, but up to this momment could not find a solution. So I send one character at a time(*). On the scope everything seems to be right. Termination also was tested.

    (*) One could suggest that pacing could help. It did not (very strange though...)

    Ioannis

  4. #4
    Join Date
    Jan 2006
    Location
    Toronto
    Posts
    109


    Did you find this post helpful? Yes | No

    Default

    The only problem with sending one character at a time is that I have 8 devices on the rs485 bus so i need to be able to address them.

    Is there an easy way to do so while sending the characters 1 at a time?

  5. #5
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    948


    Did you find this post helpful? Yes | No

    Exclamation Turnaround time

    This is a typical problem faced in RS485 based systems. You have to make allowance for the receiver to get a character, buffer it, process it and come back to the point where it is ready to read the next character. I have not worked with a hardware serial port PIC till now, but having experience with the 8051 family, I know that these things matter.

    So, what I do is to send a packet to the slave - wait for a few ms for it to reply / handle the packet and then send the next packet if needed.

    So, the turnaround time I mentioned is not character to character but packet to packet.

    Jerson

  6. #6
    Join Date
    Jan 2006
    Location
    Toronto
    Posts
    109


    Did you find this post helpful? Yes | No

    Default

    Jerson, this sounds like a soulution but what do you mean by a packet? Do you have an example you have done that might be of help to me?

    Thanks.

  7. #7
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    948


    Did you find this post helpful? Yes | No

    Default What is a 'packet'

    Hi PJALM

    I don't have any examples in PIC as I am an 8051 major. I have done a couple of projects on PIC but no comm stuff yet.. So, from the 8051 side this is how I did it.

    A typical command packet would be something like

    STX id cmd arg1 arg2.... ETX where


    STX = 02h, ETX = 03h, id is the slave ID, cmd is the function you want the slave to execute.

    This packet would be received in the background by an interrupt routine, buffered in a RX buffer. This would then be retreived by the mainline program. The mainline will identify the id byte to be its own and formulate a response to send. So, if you see, there is a delay between the complete packet being available to the slave/many slaves and the Id'ed one responding. We have to account for this delay to receive the response successfully.

    I hope this will lead you to a positive solution

    Jerson

  8. #8
    Join Date
    Jan 2006
    Location
    Toronto
    Posts
    109


    Did you find this post helpful? Yes | No

    Default

    Thanks again Jerson.

    This is exactly what I am trying to do , I guess now I just have to figure out how to use the buffer in the USART.

Similar Threads

  1. HSEROUT and Commas, What? Help Me Understand
    By altech6983 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 20th July 2009, 19:12
  2. HSERIN and HSEROUT commands
    By ryan in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 6th January 2007, 22:11
  3. HSERIN and HSEROUT problems
    By amindzo in forum Serial
    Replies: 1
    Last Post: - 6th September 2006, 21:11
  4. HSERIN problem
    By s_syafiq81 in forum Serial
    Replies: 2
    Last Post: - 1st January 2006, 11:05
  5. Problems with HSERIN HSEROUT
    By Pesticida in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 20th September 2005, 17:24

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