Jump to content
Electronics-Lab.com Community

pls help me regrading microcontroller

Recommended Posts

what exactly you need?
About the project, this is a simple and easy to realize. Because you have RS232 I hope you need only two point connection, because multi point with RS232 is a bit difficult.
First think is to get a decision what type be a protocol of communication, master/slave or not. When you have a master slave protocol, one master initiate the communication. Another way is any device to initiate a communication. Depending of the application you can use one or another type of communication.
Next step is to create a protocol. The core of protocol should be something like this :
Byte 1 Start Byte
Byte 2 Package length
Byte 3 Type of package
Byte 4 Command
Byte 5 - Byte n data
Byte n+1 - CRC 16
Byte n+2 CRC 16

If you have a multipoint communication then is usefully to have a sender address and recipient address. Also depending of data length the CRC can be 8 bit or 32 bit, also you can implement another type of data protection.
When you send a data you should use change some of the data. Lets say that you start byte should d be a 0xFF then to prevent false in protocol form data with value 0xFF you should add extra byte. For example your start byte can be 0xFF, 0x00. Each 0xff value n your data you should replace with 0xff,0x01 for example. You will know exactly what is the start byte and what is a data, without chance of mistake.
If the protocol is master slave, the master should send some command or data to slave, and slave will return some result, or will execute some command. If the protocol is not master slave, then you must add some extra logic before start a data sending. First you should check the line, if you have a simple RS 232 point to point this not a problem, but if you have a multipoint network communication this is a very important. First you check for the another device transition. Second you start a communication. If you find a data transition you should wait a random number of time and again tray to send a data. Also you should check for the collisions. No matter that the chance is very low, is possible two device to start communication on to same time, no matter the line choking. In that case your should detect a collision, after that you must wait a random time and try again to sent a data.
The type of protocol is depending from your communication speed, and application. In critical application I am use master slave communication if have not other requirements. In some case each device should be bale to initiate a communication, in this case a high speed communication is a good solution to solve the problem with a collision and decreasing the real data rate.

p.s. excues me if i have a writing errors, i use a spell check in MS word, but i have not time to read careffully the result of speling.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...