This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

RS485 with 89c51

Hi everybody,

I want to receive data from a Loadcell Indicator throughout RS485. The LoadCell Indicator only send data to Micro chip. I also want my Micro chip communicate with the computer in both ways (transfer and receive) by RS232.

Can I do like that?

This is the first time I code for micro chip. I already try to use RS232, but with RS485 I do not have enough material to do. Please help me with any idea, useful links, papers or example codes.

I'm using T89C51AC2 micro chip and C in coding.

Thank you so much,
Huy

Parents
  • Looks like that microcontroller has one UART, so it won't be real straightforward, but it should still be possible.

    You'll probably need to add some glue logic and an I/O pin or two to switch your UART back and forth between the two ports. You'll probably need to add some kind of software logic to handle switching to the RS485 port in the middle of receiving data from the load cell, resulting in garbled data, which you'll have to ignore and then wait for good data to arrive.

    If your PC initiates communication with your board, rather than the other way around, trying to share one UART with both ports is a little more trickier still. You'll probably have to add some kind of auto retry protocol to the RS232 port for the case when your PC tries to talk to your board, but the UART's connected to the RS485 port instead.

    Having an RS485 device that transmits only seems odd, as it somewhat complicates having multiple devices on an RS485 bus, which is normally a common thing to do.

    Good luck !!

Reply
  • Looks like that microcontroller has one UART, so it won't be real straightforward, but it should still be possible.

    You'll probably need to add some glue logic and an I/O pin or two to switch your UART back and forth between the two ports. You'll probably need to add some kind of software logic to handle switching to the RS485 port in the middle of receiving data from the load cell, resulting in garbled data, which you'll have to ignore and then wait for good data to arrive.

    If your PC initiates communication with your board, rather than the other way around, trying to share one UART with both ports is a little more trickier still. You'll probably have to add some kind of auto retry protocol to the RS232 port for the case when your PC tries to talk to your board, but the UART's connected to the RS485 port instead.

    Having an RS485 device that transmits only seems odd, as it somewhat complicates having multiple devices on an RS485 bus, which is normally a common thing to do.

    Good luck !!

Children