3 Axis USB Rotary Encoder Feedback

More
24 Apr 2012 18:22 #19504 by lizard
Apparently Peter was able to use an optical 'encoder' connected to a parallel port pin to control spindle speed.

My system has three off-the-shelf USB rotary 2-channel optical encoders, xyz on a mill, along with three USB hardware interfaces. The mill is currently running open-loop.

So I would like to input the position values into the Axis GUI and do some feedback operations such as limits for motor stall, correct for missing steps, etc.

There is a gcc Linux compatible C/C++ library for the encoders using a linked in library to allow reading the encoder position, set up event handlers, etc. It is simple enough to get the data using the library and display it in real time as the mill runs. The nice thing about this interface is that it has absolute position and knows which direction the encoder is spinning - without having to count each step.

The question is, how to input the data into the Axis interface? Could I just store it in a file and use their event handler to update the file, then read it somehow into EMC, or could it even be integrated directly into EMC as either an event handler or as a readPositon call?

Note: I have an older version of the encoder but it is dual-channel just like the newer one to discern direction.

This is how to get the values from the USB device:
Library to link in -lphidget21
Header file: #include <phidget21.h>
C file Encoder-simple.c in download phidget21-c-examplesNNN.tar.gz

Here is a link to the various downloads:
Documentation: www.phidgets.com/documentation/Tutorials...d_Standard_C-C++.pdf
Example Code: www.phidgets.com/downloads/examples/phid....1.8.20120216.tar.gz
GNU library for Linux: www.phidgets.com/downloads/libraries/lib....1.8.20120216.tar.gz
Encoder info: www.phidgets.com/products.php?product_id=1057

Thanks

Alfa

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

More
24 Apr 2012 19:10 #19506 by andypugh
lizard wrote:

The question is, how to input the data into the Axis interface?


The first thing I would try is to see if hal_input can see them as a USB HID device, if it can then it is all fairly easy and there is no coding required.
wiki.linuxcnc.org/cgi-bin/wiki.pl?Simple_Remote_Pendant

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

More
25 Apr 2012 14:21 #19525 by lizard
Andy,

tried
less /proc/bus/input/devices

per the article, but they didn't show up. Installed libusb-dev as well with no joy.

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

More
16 Nov 2012 18:23 #26668 by lizard
Is this ability now available with the new linuxCNC vs EMC?

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

More
16 Nov 2012 19:05 #26669 by andypugh

Is this ability now available with the new linuxCNC vs EMC?


I am not aware of any changes in hal_input since the last release.

Have you considered writing your own HAL driver? It may not be all that hard.

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

More
18 Nov 2012 12:03 #26737 by jmelson


My system has three off-the-shelf USB rotary 2-channel optical encoders, xyz on a mill, along with three USB hardware interfaces. The mill is currently running open-loop.

So I would like to input the position values into the Axis GUI and do some feedback operations such as limits for motor stall, correct for missing steps, etc.


Alfa

The problem with this is that USB is not a real time mechanism, and in some modes can only
process one message per frame (1 ms). If the device sends position updates automatically,
this may be once per frame, but it won't be synched with the LinuxCNC servo thread rate.
So, some servo cycles will get a reading, and some won't. So, there could be a +/-
1 ms jitter in when these encoder position readings arrive for processing. Also, at
least so far, there is no real time driver for USB, so it will be VERY hard to get
timely position updates to the motion system of LinuxCNC.

Jon

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

More
18 Nov 2012 12:07 #26738 by jmelson

Encoder info: www.phidgets.com/products.php?product_id=1057

Alfa

Ah, there is is in their datasheet, update rate 125 samples/second.
What "1 ms time resolution" means is a mystery, but I guess it means it sends
the USB packet in the first USB frame after the measurement was taken.
I can't see how this can be used to correct for lost steps or any other
motion assurance function.

Jon

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

More
18 Nov 2012 17:37 #26743 by cncbasher
Jon ,

yes i'd agree with you , even with all the timing issues with usb , I don't think you'd get the data through in a reliable and consistant time frame

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

More
18 Nov 2012 23:35 #26757 by andypugh

The question is, how to input the data into the Axis interface?

You need to get the data in to HAL. Axis picks it up from there.

It won't be real-time, (USB limitation) but it might actually suffice for what you want.

Do the Phidgets show up as USB HID devices? ie, can the normal hal_input module be used?
Try the first steps here to see:
wiki.linuxcnc.org/cgi-bin/wiki.pl?Simple_Remote_Pendant
The following user(s) said Thank You: lizard

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

More
20 Nov 2012 00:34 #26803 by lizard
As this is a stepper system it isn't for the feedback loop - doesn't have to be realtime.
I'll try to see it in the HAL as andypugh suggests.
Another option might be to disconnect the phidget USB cable and talk to the encoders directly.

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

Time to create page: 0.696 seconds
Powered by Kunena Forum