i want to interface my microcontroller(8051) with PC using RS-485 bus and in that i want to connect my 4-5 other microcontroller as my slaves so how can i interface?
i want information about how to send data to slaves and how to get data from them?
is there any fixed format to send and receive data?
ya i know there are so many threads for RS-485 but those can't fulfill my wishes...
i want just work instructions that how can RS-485 n/w works...
i want when will i send data from slaves?????
how can slave know that master ask about data with them and which slave called by the master??
what is the command sequence for programming???????
i want that in wording not in program sequence....
You should read first some basic material for this, this is described in RS-485 Protocol, search threads.
The master station selects a slave station by sending the slaves’ one-byte address, 0 to 255, as a 9-bit transmission. All slaves are interrupted by a 9-bit transmission and compare the received address to their own address. If the addresses do not match, any following communication is ignored. When the addresses do match, then that slave stays on the line and replies to the master by sending back its address as an 8-bit transmission. The master and the selected slave then continue communicating using 8-bit bytes. The non-selected slaves ignore the communication until the master station issues the next 9-bit address byte. The master stations can initiate a transmission but the slave stations can not, they can only respond.
Modbus is a protocol that covers all of your requirements. The specs are at https://modbus.org/tech.php but you will find quite a bit is you just google it.
Try to read this article for interfacing use RS485, maybe useful.
For send data from Computer (as SERVER) to Microcontrollers (as SLAVE), you can use the your own protocol. Each microcontrollers must have a DIFFERENT SLAVE ID. The principle works like this: When a Computer sending data to the Microcontrollers, all the slave will received data, but only one slave who has the SAME ID with intended by the server, which will give an answered, another slave silent. In your protocol could be like this:
STX DATA ETX CRC.
STX = start of text (control char 2)
DATA can contain: SLAVE ID + REQUEST THE COMMAND OF SERVER.
ETX = end of text (control char 3)
CRC = you have to make the same crc function on the pc and all microcontrollers, in order to check whether the packet you received is valid or not on both (server or slaves). If you believe the CRC of data is correct and whether SLAVE ID(from server) in DATA same with your id(store in each microcontroller), if yes then read "requests from the server" and give reply to server.
CRC = you have to make the same crc function on the pc and all microcontrollers, in order to check whether the packet you received is valid or not on both (server or slaves). If you believe the CRC of data is correct and whether SLAVE ID(from server) in DATA same with your id(store in each microcontroller), if yes then read "requests from the server" and give reply to server.