Sign in to follow this  
Followers 0
moosty

Clear RS 232 Receive Buffer

5 posts in this topic

Hi! I am writing a program in to a C200 HE CPU42 to work with an non - OMRON RS232 device. (Texas Instruments MFR S4100 ISO 15693 RFID Reader) During 5 seconds, by a "5 seconds one-shot timer"; * I send (TXD) a read request on the leading edge of P_1s (One second clock) * Receive (RXD) the answer from RS232 device on the trailing edge of P_1s and evaluate. I break the 5 seconds timer if received package has satisfactory information, and stop sending & receiving packages. This works fine. But sometimes, by the activation of 5 seconds timer, I get my previous read requests answer. I think, there is receive buffer receiving all data even I dont activate the RXD command, and by the first activation of RXD command, I get old data from port. Now, my question is: Is there any way to clear this old data, or clear receive buffer if exists ? Clearing old received data by the leading edge of the 5 seconds timer will cure my problem. I can also try to trigger RXD once, and clear the received data before sending the first request but this makes a lot of code, and I have limited program & memory area. Many thanks for all genius guys!

Share this post


Link to post
Share on other sites
To clear the buffer you execute a RXD command with 0 bytes of data to receive. The root of your problem is that you are time based. You need to switch to an event based strategy. In thias case, the event is when something comes into the port. This strategy can only work if there is what is known as a terminating character - that is a common charcater that is sent every time at the end of a reception. Common terminating characters are CR,CR+LF+ETX, etc. Let me know if this is the case and I will post some examples of how to handle the serial port. If you will do a search on this site for TXD or RXD, I have posted some examples in the past.

Share this post


Link to post
Share on other sites
Thank you Jay, Executing RXD with 0 Bytes works! The device I connected sends a start characer, #01, unfortunately it sends binary characters, remaining data can be in any value between #00 and #FF, for this reason, the device does not support end character. Many thanks again!

Share this post


Link to post
Share on other sites
This wouldn't be Modbus protocol, would it?

Share this post


Link to post
Share on other sites
Well, actually this RFID device is a small electronic circuit board designed for general applications, such as hand held terminals and Personal Computer. It is not an industrial type, so it does not support widely used protocols, such as Modbus, Interbus etc. We used Phillips I-Code SLI chips, this chip has been released recently, and there are not much alternative RFID readers around, so we decided to use Texas Instruments. I think OMRON is still working on R&D for a reader for this new I-Code SLI chips. You can find the datasheet of MFR Reader in attached file. If anyone needs more information of the project we are working on, I can send detailed descriptions of this project. Thanks Jay MFR_DataSheet.zip

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0