using HAL to correct axis errors

More
16 Feb 2018 19:55 #106040 by pgf
In fact, the difference between those two loadrt commands is completely relevant. Good catch. I found it too, just a little while ago, *after* discovering that a wrapper script that I use to start linuxcnc from the command-line was saving stderr to a log file of my own creation in /tmp. :-/ So the error message I should have seen was hidden from me by my own script. I was just about to 'fess up here when I saw your post.
./custom.hal:3: Can't find module 'nonsquare_table.ko' in /usr/realtime-3.4-9-rtai-686-pae/modules/linuxcnc

Removing the ".ko" from the module name got me going.

I am wondering about your next question, though, because I think it has a bearing on getting my function to actually do something:

Did you also add it to your hal file with addf?I have had some odd errors where I've forgotten to do that.


It's all very well that I've successfully loaded my component, but I have to assume it's not "hooked up" to anything. a) To get it to actually run, I guess I need to addf it to a thread. But what thread? b) And I assume I need to connect my x-in, y-in, and y-out pins up to something, so that I properly intercept and modify my Y position.

I've been going through the docs trying to understand how and where I'd do these things. Any pointers?

paul

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

More
16 Feb 2018 20:30 - 16 Feb 2018 20:32 #106042 by rodw
Glad you found it but now you are getting me out of my depth!
You 'll want to add it to your servo thrread ( I forget as thats all i've got with Mesa!)

I'm not 100% sure but I think it would be inserted here
net ypos-cmd axis.1.motor-pos-cmd => stepgen.1.position-cmd

Something like this instead
loadrt nonsquare-table 
addf nonsquare_table servo-thread
net xpos-cmd => nonsquare-table.0.x-in
net ypos-cmd <= axis.1.motor-pos-cmd
net ypos-cmd => nonsquare-table.0.y-in
net nonsquare-table.0.y-out => stepgen.1.position-cmd

Maybe as a starting point, just hook up the existing xpos-cmd and ypos-cmd signals and observe the pin values in halshow before you hook the output up in anger
net xpos-cmd => nonsquare-table.0.x-in
net ypos-cmd => nonsquare-table.0.y-in
Last edit: 16 Feb 2018 20:32 by rodw.

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

More
16 Feb 2018 20:33 #106043 by pgf
Thanks! That all makes a lot of sense. I'll report back.

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

More
16 Feb 2018 21:54 #106047 by pgf
Your suggestions work(ed) well! Thanks again.

I realized that I also need to do a reverse transformation for the feedback path.

So now my component looks like this:
component nonsquare_table;
license "GPL"; // GPL v2 or later

pin in float x-in;
pin in float y-in;
pin out float y-out;
function cmd;

pin in float x-fb-in;
pin in float y-fb-in;
pin out float y-fb-out;
function fb;

;;

FUNCTION(cmd){
    y_out = y_in + x_in * 0.007;
}

FUNCTION(fb){
    y_fb_out = y_fb_in - x_fb_in * 0.007;
}

and my custom.hal looks like this:
loadrt nonsquare_table
addf nonsquare-table.0.cmd servo-thread
addf nonsquare-table.0.fb servo-thread


delsig ypos-cmd

net xpos-cmd => nonsquare-table.0.x-in
net ypos-cmd axis.1.motor-pos-cmd => nonsquare-table.0.y-in
net ypos-cmd-adjusted nonsquare-table.0.y-out => stepgen.1.position-cmd

delsig ypos-fb

net xpos-fb => nonsquare-table.0.x-fb-in
net ypos-fb-adjusted stepgen.1.position-fb => nonsquare-table.0.y-fb-in
net ypos-fb nonsquare-table.0.y-fb-out => axis.1.motor-pos-fb


and after an X traverse from 0 to 10, the signals look like this, which leads to one more question.



Should I be rounding off the math, perhaps to the nearest .0001, to ensure that I don't accumulate precision errors of some sort? Or is this kind of trace discrepancy eliminated elsewhere in the code? I don't want to someday get a "following error" because of floating point inaccuracy.

paul
Attachments:
The following user(s) said Thank You: LAUSCH

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

More
16 Feb 2018 22:12 #106048 by rodw
Great you got it going.

I don't believe that there is a need to round the numbers as you are not accumulating them in anything.
Just a thought. What do your DRO's say?

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

More
16 Feb 2018 22:28 #106050 by pgf
The DROs look like I was never here, except that the Y position shows a -0 due to the floating point errors:


It was the DROs that reminded me I needed to modify the feeback path -- because when I jogged X, Y was changing too. Not good. :-)

paul
Attachments:

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

More
16 Feb 2018 23:25 - 16 Feb 2018 23:26 #106053 by rodw
The is a pin that tells you if you re jogging
axis.Y.kb-jog-active

maybe you could add a new pin for that to your component and then you could use code like this in your comp
if(!is_jogging){
   // Adjust for crooked table
}
Last edit: 16 Feb 2018 23:26 by rodw. Reason: Oops typo in code
The following user(s) said Thank You: LAUSCH

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

More
16 Feb 2018 23:35 #106054 by pgf
But the mill is crooked all the time -- not just when I'm jogging. I think I need full time correction, unless I'm missing something big.
The following user(s) said Thank You: rodw

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

More
17 Feb 2018 08:59 #106067 by rodw

But the mill is crooked all the time -- not just when I'm jogging. I think I need full time correction, unless I'm missing something big.


Sounds like you are done then. I think what you've done is very cool.

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

More
17 Feb 2018 13:47 #106073 by pgf
Thanks, and thanks for your help and encouragement. I'm pretty thrilled that I don't have to disassemble and try and realign my MDF-and-drawer-slide bed in order to try to adjust things. It wouldn't go well, I'm sure. (Though it will take some time to get used to seeing the Y stepper ticking over slowly while jogging in X alone.)

I'd actually forgotten how superb the linuxcnc architecture is. It simply fantastic that I was able to make this kind of customization at all. My thanks to all designers and hard workers, whether you ever read this or not!

Here's one more version of my component, for the record. It's now documented, and takes the deviation value as a parameter for ease of tuning. After tuning my value ended up at .011 -- the axes were off by about 7/64" at 10" out.
component nonsquare_table """Adjusts for non-square X-Y tables.
    The value of Y is modified linearly based on the value of X,
    i.e.  newY = Y + X * deviation.  Pins are provided for doing
    both the forward and reverse (feedback) transform.  Should
    be inserted between axis and stepgen (or equivalent) components.
    The 'deviation' multiplier is supplied as a parameter, and
    defaults to 0.0.""";
license "GPL"; // GPL v2 or later

option singleton yes;


pin in float x-in;
pin in float y-in;
pin out float y-out "y-out = y-in + x-in * deviation";
function cmd;

pin in float x-fb-in;
pin in float y-fb-in;
pin out float y-fb-out "y-fb-out = y-fb-in - x-fb-in * deviation";
function fb;

param rw float deviation = 0.0;


;;

FUNCTION(cmd){
    y_out = y_in + x_in * deviation;
}

FUNCTION(fb){
    y_fb_out = y_fb_in - x_fb_in * deviation;
}

This isn't actually my first foray into the depths of HAL. When I first built my mill, the controller was practically a direct pass-through of parallel port pins to stepper coils. When I switched from the original DOS software that came with mill's plans to EMC (2004?), there wasn't yet a HAL driver for that, so I had to write my own, and get the sequencing right. Correcting my axis errors was way easier than that! :-)

Here are some pictures of my mill, which don't include a recent upgrade with threaded inserts in the bed and a masonite wasteboard on the top, which together finally give me proper hold-downs. I think the pictures also don't include the ACME screw upgrades for X and Y, which sent my top jog speed from 18 IPS to a whopping 54 IPS! pgf's mill

paul

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

Time to create page: 0.197 seconds
Powered by Kunena Forum