hostmot2 encoder documentation

More
23 Jan 2024 18:07 #291442 by PCW
Replied by PCW on topic hostmot2 encoder documentation
Should be fixed now in master and 2.9.

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

More
28 Jan 2024 00:57 #291777 by jtrantow
What's the magical incantation to get this version? I installed from 2.9.2 iso. I updated the repo to search 
deb www.linuxcnc.org/ bookworm base 2.9-uspace

deb [arch=amd64,arm64 signed-by=/etc/apt/trusted.gpg.d/linuxcnc.gpg.key.binary.gpg] www.linuxcnc.org/ bookworm 2.9-uspace base
deb-src [arch=amd64,arm64 signed-by=/etc/apt/trusted.gpg.d/linuxcnc.gpg.key.binary.gpg] www.linuxcnc.org/ bookworm 2.9-uspace base

I also tried deb buildbot2.highlab.com/debian/ bookworm 2.9-uspace

This got me updated from 6.1.0-16-rt-amd64 to 6.1.0-17-rt-amd64 and linuxcnc 2.9.2.106.g26e5d but it's still displaying the quad errors. I thought the linuxcnc or buildbot 2.9-uspace would give me all the 2.9 updates including this fix? Not sure what I'm missing?

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

More
28 Jan 2024 01:20 #291780 by PCW
Replied by PCW on topic hostmot2 encoder documentation
I don't know how old the buildbot image is but you may have to build
from 2.9 or 2.10 source to get the latest.

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

More
29 Jan 2024 17:57 #291911 by jtrantow
I cloned master and built the RIP with your fix which works for the hal_encoder_test.hal script!

When I run the attached config, I still see the problem? (Simplified version of my mill.)  I modified the hostmot version # and quad error string to make sure I was running the new hostmot and I am. So I think it's a step in the correct direction but not a complete fix.
Attachments:

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

More
29 Jan 2024 20:19 #291929 by jtrantow
I couldn't figure out how to reopen issue #2680. So I opened a new issue in the tracker. I changed hm2_encoder_read_control_register() to clear encoder errors whenever they are disabled. It still needed the hm2_encoder_force_write(), but with this fix my config works fine. I'm not sure how much overhead the force_write() adds but for my config it doesn't matter since I'm off when this occurs. 

I will push this change, but I wanted to make sure you saw it.

static void hm2_encoder_read_control_register(hostmot2_t *hm2) {
    int i;
    for (i = 0; i < hm2->encoder.num_instances; i ++) {
        hm2_encoder_instance_t *e = &hm2->encoder.instance;
        if (*e->hal.pin.quadrature_error_enable) {
            e->reset_quadrature_error=0;
            if(!e->prev_quadrature_error_enable){ // detect rising edge of pin quadrature_error_enable
                e->reset_quadrature_error = true;
                hm2_encoder_force_write(hm2);
            }
            bool state = (hm2->encoder.read_control_reg & (HM2_ENCODER_CONTROL_MASK | HM2_ENCODER_QUADRATURE_ERROR)) && e->prev_quadrature_error_enable;
            if ((*e->hal.pin.quadrature_error == false) && state) {
                HM2_ERR("Encoder %d: quadrature count error\n", i);
            }
            *e->hal.pin.quadrature_error = (hal_bit_t) state;
        } else{ // quadrature error disabled, set reported error to 0
            *e->hal.pin.quadrature_error = false;
            e->reset_quadrature_error = true;
            hm2_encoder_force_write(hm2);

        }
        e->prev_quadrature_error_enable = *e->hal.pin.quadrature_error_enable;
        *e->hal.pin.input_a = hm2->encoder.read_control_reg & HM2_ENCODER_INPUT_A;
        *e->hal.pin.input_b = hm2->encoder.read_control_reg & HM2_ENCODER_INPUT_B;
        *e->hal.pin.input_idx = hm2->encoder.read_control_reg & HM2_ENCODER_INPUT_INDEX;
    }
}
 

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

More
29 Jan 2024 21:03 #291935 by PCW
Replied by PCW on topic hostmot2 encoder documentation
Forcing a control register update every cycle on every encoder 
almost any machine using Mesa encoders is really not something
that should  be pushed.

Let me do some more investigation into why a existing error is not
cleared before the error mask is removed.

 

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

More
30 Jan 2024 04:54 - 30 Jan 2024 04:56 #291957 by jtrantow
I agree. It will work as a temp solution for me as I always run with quad errors enabled and machine is off when it's doing the extra updates. I also had a bit & mistake that I cleaned up. I'll change the pull request to a draft. 
Last edit: 30 Jan 2024 04:56 by jtrantow.

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

More
30 Jan 2024 15:45 #291989 by PCW
Replied by PCW on topic hostmot2 encoder documentation
Well...I cannot duplicate the error in either current 2.9 or master.
The only way I could generate the "error on error enable"
was to miss-configure the encoder DPLL timer so the read data
gets pipelined by 2 instead of the normal 1 relative to the error
clear.

I tested this cycle  at least 20 times on both versions:

disable check

generate quadrature error

enable check

and was never able to generate an error on enabling the check.
 

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

More
30 Jan 2024 17:04 #291995 by jtrantow
I will retest on my lathe config and try a fresh pncconf config on the mill.

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

More
30 Jan 2024 19:43 #292007 by jtrantow
Thanks for you patience!

I went back and tested my lathe, mill, and a new config named quad. I build the code with your changes and the extra hm2_encoder_force_write() from the pull request. I test the lathe config on one computer, the mill and quad on another identical computer. These are old (2008ish) computers with dual core 3Ghz. The only changes I made to quad.hal were to comment out the extra x-pos-fb lines and add 

net machine-is-on <= halui.machine.is-on           => hm2_7i92.0.encoder.00.quad-error-enable

All three configurations fail with the master (and work with the extra force write) version of hm2_encoder_read_control_register(). I have a bad scale that's easy to create the quad error with. Every time I create an error while quad-error-enable is false, it will erroneously trigger when machine-is-on. (No reason to try multiple times to catch the problem on my setup.)

I have attached the quad files I am using.
 
Attachments:

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

Moderators: PCWjmelson
Time to create page: 0.163 seconds
Powered by Kunena Forum