Python API Analog input

More
25 Sep 2017 14:31 #99405 by koth442
Hello all. I am having trouble getting the '.ain' command to work using the LinxCNC / python API. HalScope show's an incoming signal, but .ain just returns a list of 64 zero's. I don't have 64 input pins, so I find that fishy as well. Suggestions? I'm using a MESA 7i87 analog input card.

My code:

python
import linuxcnc, hal, time, sys, os, serial

a= linuxcnc.stat()
a.poll()
a.ain
(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, etc).

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

More
25 Sep 2017 14:54 #99408 by PCW
Replied by PCW on topic Python API Analog input
When software and hardware is installed correctly, the hm2 driver provides a
hal pin/parameter interface to the 7i87, The python API is not related to the 7I87 in
any way.

What hardware do you have?

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

More
25 Sep 2017 14:57 - 25 Sep 2017 15:02 #99409 by koth442
Replied by koth442 on topic Python API Analog input
Not sure, I didn't set up the machine. I know there is also 2 7i64's, a 7i77, and a 7i83 cards. Other than that, not sure. How can I figure out the hardware?
Last edit: 25 Sep 2017 15:02 by koth442.

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

More
25 Sep 2017 15:33 #99413 by PCW
Replied by PCW on topic Python API Analog input
If all is connected correctly, and LinuxCNC is running, you can list the 7I87 pins
with:
halcmd show pin | grep 7i87

if you wanted to show all the connected Mesa hardware pins, you could:
halcmd show pin | grep hm2

or the equivalent for parameters:
halcmd show param | grep hm2

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

More
25 Sep 2017 15:39 #99414 by koth442
Replied by koth442 on topic Python API Analog input
Yes, that worked. I can see my inputs on the 7i87. Thank you.

Is there a way to interface the 7i87 with python API?

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

More
25 Sep 2017 16:30 #99415 by PCW
Replied by PCW on topic Python API Analog input
The LinuxCNC Python API works at the NML interface level not HAL and you will lose the real time capabilities of the hardware if you use Python

What are you trying to do with the analog data from the 7I87?

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

More
25 Sep 2017 16:45 #99416 by koth442
Replied by koth442 on topic Python API Analog input
That's good to know. Is it possible to use a userspace and read data at microsecond intervals?

We are going to get sensor data then process the data outside of LinuxCNC then feed LinuxCNC commands based on sensor data. I'm not the architect of this project, so I don't know why we're doing it that way. The halcmd method you provided above will work, so now I'm satisfying my own curiosity.

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

More
03 Oct 2017 16:55 #99824 by andypugh
Replied by andypugh on topic Python API Analog input

That's good to know. Is it possible to use a userspace and read data at microsecond intervals?


No.

Even in the realtime layer the analogue inputs of the Mesa cards only update every 1mS.

The way to do what you want, if you must use Python, is to create a HAL pin in a Python HAL component that is connected to the Mesa analogue output, then process that data.
linuxcnc.org/docs/2.7/html/hal/halmodule.html

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

More
03 Oct 2017 17:09 #99825 by PCW
Replied by PCW on topic Python API Analog input
Note that anything done in standard Python is not going to be even close to real time
( you may have unpredictable multi-millisecond delays due to memory allocation and garbage collection )

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

More
04 Oct 2017 00:40 #99882 by koth442
Replied by koth442 on topic Python API Analog input
Thanks for the help everyone.

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

Time to create page: 0.085 seconds
Powered by Kunena Forum