Serial Port RS-232 with LinuxCNC and RTAI

More
31 May 2014 23:30 #47579 by t1m0n
Hi,
I want to use the serial port of my computer to comunicate with a special part via RS-232.
I found something but not what I need because I need real time.

At first, I start the communication via Bash with stty.
This is ok but not real time.
So, I need a piece of software which is compatible with rtai.

I found the module SERPORT, see linuxcnc.org/docs/html/man/man9/serport.9.html.
But this is only useful if I want to use the pins as i/o - without the serial function.

I searched for serial port with rtai and found serial.c, see www.rts.uni-hannover.de/rtai/lxr/source/...vers/serial/serial.c
But this is only available with version 3.3. I use the standard system from iso with kernel 2.6.32-122-rtai.

Have someone an idea?

Please Log in or Create an account to join the conversation.

More
01 Jun 2014 00:10 #47580 by PCW
Not sure what real time means with RS-232
How much data are you transferring and what baud rate are you using?

If you can do the communication synchronously with the servo thread (or maybe a slower thread if need be)
its probably not a big deal to just make a comp that byte bangs the hardware UART interface (with inb and outb)

Please Log in or Create an account to join the conversation.

More
01 Jun 2014 00:28 - 01 Jun 2014 00:34 #47583 by t1m0n
I want to read 2 float values and I want to write 2 floats. Not more..

I found also rt_com but I can't compile it, see rt-com.sourceforge.net/
I get the error, that the following modules can't find:
rt_com.c:32:26: error: linux/config.h:
rt_com.c:34:26: error: linux/ioport.h:
rt_com.c:36:26: error: linux/module.h:
rt_com.c:39:24: error: asm/system.h:
rt_com.c:40:20: error: asm/io.h:
rt_com.c:43:20: error: rtai.h:
This is because I have not the kernel-sources or header-files because I use the ISO-Image of LinuxCNC?

I need this in combination with a new M-Code.
If I call M104 for example, this programm should start.
Actually, with bash it works fine but i want to use real time..
Last edit: 01 Jun 2014 00:34 by t1m0n.

Please Log in or Create an account to join the conversation.

More
01 Jun 2014 01:04 #47585 by PCW
Well thats at least 8 characters total (assuming single precision) and probably more if there is any
protocol involved for synchronization, error checking etc, so wire time will be a big chunk of a
1 KHz servo thread even at 115200 baud. ~1/2 the wire time could be saved by using full duplex
(xmit and recv at teh same time)

That's sort of why I asked the original question: what does real time mean?

Or maybe better, what real time update rate do you need?

Please Log in or Create an account to join the conversation.

More
01 Jun 2014 13:42 #47587 by ArcEye

I need this in combination with a new M-Code.
If I call M104 for example, this programm should start.


As gcode is not realtime programming, anything launched from it is not likely to be.

As PCW is saying, you can do a lot with a userspace component, which will free you from all the restrictions of realtime programming. (ie kernel modules)

When I wrote my arduino pendant interface component, even 9600 baud was fast enough to update three float co-ordinates values and several bit values on a LCD display several times per second.

You will still need to install linuxcnc-dev and linux-headers-2.6.32-132-rtai to interface with the running system and create pins etc.

Have a look at the serialcon code. It is not exactly a force majuere of serial programming, just a simple encapsulation of values in a way the arduino could read easily and even that worked. It does show the basics of creating a component that does serial comms.

www.linuxcnc.org/index.php/english/forum...pendant-for-linuxcnc

regards

Please Log in or Create an account to join the conversation.

More
06 Jun 2014 11:48 #47741 by t1m0n
Thanks for help. Now I start compiling with comp generator.
It generates a .c from a .comp file and compiles this to a hal component.
Is here someone who use this with serial port rs232 or usb?

Please Log in or Create an account to join the conversation.

More
06 Jun 2014 13:29 #47744 by ArcEye

Thanks for help. Now I start compiling with comp generator.
It generates a .c from a .comp file and compiles this to a hal component.
Is here someone who use this with serial port rs232 or usb?


What comp are you referring to?

If it is mine, then it can be used as it was intended as per the thread.

If it is your own, hopefully you can??

You will have to be clearer as to what exactly you mean

regards

Please Log in or Create an account to join the conversation.

More
06 Jun 2014 16:43 #47748 by t1m0n


What comp are you referring to?
If it is mine, then it can be used as it was intended as per the thread.
If it is your own, hopefully you can??
You will have to be clearer as to what exactly you mean
regards

If your component works i want to use it.
So I need only less data then you. The connection is the same.
what kind of programm is it for the jog wheel?
i see it is written in c but it is a .comp file?

if i want to use your source code

1. I Generate a c file from the comp file with comp

2. I compile it as hal component with comp

3. I can use it with loadrt in halcmd?

is that correct or is it now a .c file and I have to start with 2. ?

Please Log in or Create an account to join the conversation.

More
06 Jun 2014 17:59 - 06 Jun 2014 23:02 #47749 by ArcEye
Hi

The code was written to communicate with an arduino, over a USB serial protocol.

Because of the processing limitations of the arduino, the data is coverted to strings before sending, so that the arduino can display it immediately without conversion.
This is not the usual method of data transmission over serial, but it worked best in this scenario.

All the info is here on the thread I pointed you to
www.linuxcnc.org/index.php/english/forum...and-rtai/reply/47748
or here even!
www.linuxcnc.org/index.php/english/forum...pendant-for-linuxcnc

There is no jog wheel, jogging is done with the keyboard

As with any comp file you compile and install it in one go with comp --install nameofcomp.comp

If you want to convert the source you need to be familiar with writing comp files
www.linuxcnc.org/docs/devel/html/hal/comp.html

They are written in C, but contain a lot of macros which the comp program expands to C code in processing, saving you the complexities of pin creation, registering the component etc

regards
Last edit: 06 Jun 2014 23:02 by ArcEye.

Please Log in or Create an account to join the conversation.

Time to create page: 0.106 seconds
Powered by Kunena Forum