Real-time close loop control needs serial port communication
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Real-time close loop control needs serial port communication
I am porting a closed loop control system to Redhat kernel version 2.4. This software is heavily real-time and equally relies on RS485 communication through the serial port of the PC which has to be available when needed. What is the best way to ensure that the Serial line driver will have the processor when it needs it? Would it be better to have a separate process for TX and one for RX, or a single process with two threads? Would a lightweight process do?
There are some different types of RS485 transceivers available for the PC. If you are using the type that requires the PC software to switch between RX and TX modes then timing is more critical, its usually done with raising or lowering the RTS line.
Is this the type you're using?
I've found for moderate baud rates that linux is fast enough to send a message on the RS232->RS485 converter, quickly switch to RX mode and receive the response without missing the first few bytes. If that's the only issue then you should be fine. Writing a custom serial driver would be the next step if timing can't be met.
No I am not currently using real-time kernel, or I don't believe I am. It is Red Hat 9.0 with 2.4 Kernel. Before starting the porting I did some research into the subject and quickly learned I would eventually have to use real-time kernel instead of the normal one. But thought I could do a great deal of preliminary work before switching kernel. I believe I would need static priority for my processes. The control processes themselves are quite time critical and the same questions apply to them as well. Would I need real-time kernel to have static priority? Is it better to go real-time now? Is it easy to switch to real-time kernel later?
The response time currently required is in the order of 30ms. We would soon need to monitor digital inputs every 10ms.
The RS484 adaptor I use automatically switches between input and output mode through hardware so fortunately no software intervention required. This means that as soon as the RS485 Master writes to the port, the slave RS485 adapter(s) will switch to input mode automatically and the RX thread/process will receive the message.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.