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
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 !!
"Looks like that microcontroller has one UART, so it won't be real straightforward"
Which begs the question: why choose a processor with only one UART, when plenty are available with two (or even more!)
Why make life difficult for yourself - especially as this is your first microcontroller project?!
It is possible to make a software UART - or, in this case, just a software receiver. Search for "Soft UART" or "software UART" and "bit-bang"
I can not count the posts I have seen over the years where the derivative has been selected <b.before the application was defined. Talk about "cart before the horse"
Erik
you post '89C51' which can be AT89C51, P89C51, something else or a generic name.
Ever so many posts have gone astray because the derivative name was not totally clear.
Yeah, This is exactly my first project with Micro. For all comments, I need time to understand them but I want to say thank you to all for your helps.
This is exactly my first project with Micro then i strongly recommend that you buy a SILabs devboard (F0xx, f1xx, f2xx - stay away from f3xx, f4xx and f5xx) it will give you ICE functionality which gives yo the ability to see everything that goes on inside the chip in real life, not 'simulated'
one more hint
there is, here, the Keil device database
http://www.keil.com/dd/parm_search.asp
it allow you to select 2 UARTs and get a list of all '51 derivatives with that.
"you post '89C51' which can be AT89C51, P89C51, something else or a generic name."
The title just said '89C51', but the body of the post did specify T89C51AC2.
:-)
View all questions in Keil forum