Communicating through RS-232
12 Mar 2016 00:48 #71458
by squan09
Communicating through RS-232 was created by squan09
Is it possible to use communicate through RS-232 with LinuxCNC? I have a force sensor that has output through RS-232 and would like to read it and possibly use it for positioning feedback in a PID loop. Does this sound like something that would be easy to implement Thanks
Please Log in or Create an account to join the conversation.
12 Mar 2016 03:25 #71477
by cmorley
Replied by cmorley on topic Communicating through RS-232
it is possible but rs-232 is not realtime so there are no time guarantees on data update.
I've done it to operate a mitsubishi VFD.
easiest would be a python component.
next would be a userspace c program.
I've done it to operate a mitsubishi VFD.
easiest would be a python component.
next would be a userspace c program.
Please Log in or Create an account to join the conversation.
24 Mar 2016 02:11 #72079
by squan09
Replied by squan09 on topic Communicating through RS-232
Thanks for the help. So far I have added a button with GladeVCP to the Axis GUI and when it is clicked I begin to read the force sensor. The output is just being printed to the terminal for now. Next I want to be able to actually work with that data. I saw that I can set a hal pins input. Would this be the best way to do this or should I be using something else?
Please Log in or Create an account to join the conversation.
24 Mar 2016 05:41 #72082
by sirop
Well, real time is vague term here.
There are devices on the market that can produce a data stream at a constant rate,
for example, 1000 RS232 datagrams per second.
So you have then a time slice of 1 ms for each datagram. Call it soft real time if you like.
You can definitely write a real-time component either based on MESA UART
or MESA PktUART .
Replied by sirop on topic Communicating through RS-232
it is possible but rs-232 is not realtime so there are no time guarantees on data update.
I've done it to operate a mitsubishi VFD.
easiest would be a python component.
next would be a userspace c program.
Well, real time is vague term here.
There are devices on the market that can produce a data stream at a constant rate,
for example, 1000 RS232 datagrams per second.
So you have then a time slice of 1 ms for each datagram. Call it soft real time if you like.
You can definitely write a real-time component either based on MESA UART
or MESA PktUART .
Please Log in or Create an account to join the conversation.
24 Mar 2016 21:00 #72111
by squan09
Replied by squan09 on topic Communicating through RS-232
Hoe do I set the value of a hal pin in python. Does anyone know of a good reference for this?
I tried: self.test_hal_pin.set_value(999), but I get the following error: AttributeError: 'GPin' object has no attribute 'set_value'
I tried: self.test_hal_pin.set_value(999), but I get the following error: AttributeError: 'GPin' object has no attribute 'set_value'
Please Log in or Create an account to join the conversation.
29 Mar 2016 15:33 #72333
by andypugh
Replied by andypugh on topic Communicating through RS-232
The following user(s) said Thank You: squan09
Please Log in or Create an account to join the conversation.
29 Mar 2016 19:53 #72346
by squan09
Replied by squan09 on topic Communicating through RS-232
Thank you, that is exactly what I needed. My plan now is to set an input pin using this. The documentation states that setting a input programmatically defeats the purpose of the hal input pin, but I have not come across another way to read data through RS-232 and pass it on. Can anyone recommend a better way to do this or is setting the hal pin fine and this would be considered a unique case?
Please Log in or Create an account to join the conversation.
29 Mar 2016 22:22 #72352
by andypugh
Replied by andypugh on topic Communicating through RS-232
Why can't you set a HAL _output_ pin?
Please Log in or Create an account to join the conversation.
30 Mar 2016 00:54 #72355
by squan09
Replied by squan09 on topic Communicating through RS-232
I guess I can. It just made sense to me that if I am getting an input through RS-232 I would set an input pin. If I am not sending anything out to hardware it seems like using an output pin would be just as odd as using an input pin. Does that make sense or would there be an advantage to using an output vs input pin?
Please Log in or Create an account to join the conversation.
30 Mar 2016 07:43 #72367
by ArcEye
Replied by ArcEye on topic Communicating through RS-232
To try and clarify.
You are writing a component, to interface hardware to HAL.
The input to your component comes via reading a serial connection.
The data from this serial connection, after any processing necessary, is sent via output pins connected in HAL.
Any input pins are connected in HAL and are for things like telling the component to start or stop sending data.
If you wrote it in C, using comp, you would be unable to set inputs internally, because the macros are arranged so that
an input pin address is not a valid lvalue and cannot be assigned to.
On the rare occasions you might need to be able to modify an input value at the pin, you should declare the pin IO
regards
You are writing a component, to interface hardware to HAL.
The input to your component comes via reading a serial connection.
The data from this serial connection, after any processing necessary, is sent via output pins connected in HAL.
Any input pins are connected in HAL and are for things like telling the component to start or stop sending data.
If you wrote it in C, using comp, you would be unable to set inputs internally, because the macros are arranged so that
an input pin address is not a valid lvalue and cannot be assigned to.
On the rare occasions you might need to be able to modify an input value at the pin, you should declare the pin IO
regards
Please Log in or Create an account to join the conversation.
Time to create page: 0.082 seconds