7i96S mesa_modbus encoder count interference

More
26 May 2024 16:35 #301499 by somuchforfree

# spindle load

loadrt spindle-load ports=hm2_7i96s.0.pktuart.0
setp spindle-load.00.address 1
setp spindle-load.00.baudrate 9600
setp spindle-load.00.rxdelay 255
setp spindle-load.00.txdelay 10
addf spindle-load.00 servo-thread

setp spindle-load.00.update-hz 10
loadrt conv_u32_float count=1
addf conv-u32-float.0 servo-thread
net spindle-load-float conv-u32-float.0.in <= spindle-load.00.state


Now that I commented a conv_u32_float back in, it jumps around in the snippet above, but does not when I move the setp right after the loadrt for the conv_u32_float.

That's all the testing I can do for now, let me know if I should try anything else.


This works as in "encoder does not jump", but it also doesn't update the Modbus values... so we're getting there I think.

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

More
26 May 2024 16:53 - 26 May 2024 21:37 #301501 by PCW
Not sure whats going on but I do know there's a bug with setting the update rate

You can set pins with setp:

halcmd: setp hm2_7i96s.0.encoder.sample-frequency 100000
halcmd:

Also is it the actual encoder count pin that is corrupted or something else
further down the chain. Thia may help to recreate the issue
 
Last edit: 26 May 2024 21:37 by PCW.

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

More
27 May 2024 15:26 #301593 by PCW
Can you post your hal/ini files and spindle_load source so
I can try and duplicate the issue?

Does the error occur if there is no connection? (wondering if this
can be tested without your particular VFD)

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

More
30 May 2024 23:25 - 30 May 2024 23:28 #301897 by somuchforfree

Is it possibly just noise related?
that is, what happens if you set:

setp hm2_7i96s.0.encoder.00.filter true
setp hm2_7i96s.0.encoder.sample-frequency 100000


I don't have a .sample-frequency in my parameters, just counter-mode, filter, index-invert, index-mask, index-mask-invert, scale and vel-timeout.


I missed that the sample-frequency is child of encoder, not encoder.00. This is why I couldn't set it with setp.
Unfortunately setting the filter frequency like you suggested did not fix the issue.
Last edit: 30 May 2024 23:28 by somuchforfree. Reason: fix quote

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

More
30 May 2024 23:46 #301900 by somuchforfree
Sorry if that was unclear from my original post, but we do not have a VFD connected, it's an Arduino that takes an analog input from a voltage divider conected to the VFD's analog out. That does not matter for the functionality, just to clear things up.
// spindle-load.mod
#define MAX_MSG_LEN 16   // may be increased if necessary to max 251

static const hm2_modbus_chan_descriptor_t channels[] = {
/*  {TYPE,    FUNC, ADDR,   COUNT, pin_name} */
    {HAL_U32, 4,  0x0000, 1,     "state"},
};
# custom_jogwheel.hal
# set jumpers W1-W3 to left for single ended encoder
setp hm2_7i96s.0.encoder.00.counter-mode 1
setp hm2_7i96s.0.encoder.00.filter true
setp hm2_7i96s.0.encoder.sample-frequency 100000 # not encoder.00.!
net joint-selected-count <= hm2_7i96s.0.encoder.00.count

The encoder count and count-latched stay at 0, the input-a and input-b are constantly HIGH, rawlatch and rawcounts are stuck at 65535 but the encoder's velocity and velocity-rpm go to negative values like -15 and -850 respectively, as described in earlier posts.

All of this happens even if I do not have the Arduino connected to the Mesa.

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

More
30 May 2024 23:54 - 30 May 2024 23:55 #301903 by somuchforfree
If I move the setp for the update-hz above the loadrt conv_u32_float the Modbus updates at 10 Hz but the encoder count is going crazy.

If I move it below the loadrt, it will read a correct value once at startup but never update. The encoder rawlatch and rawcount are always at 933 or 934 (restarted LinuxCNC 5 times, 5 times 933/934) after the first Modbus read but after this they are stable and only change when I actually turn the jog wheel.
Last edit: 30 May 2024 23:55 by somuchforfree.

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

More
31 May 2024 00:54 - 31 May 2024 00:57 #301909 by PCW
OK I cannot duplicate this (at least with no modbus device) so not sure whats next

Used your spindle-load comp

With this hal support:


loadrt spindle-load ports=hm2_7i96s.0.pktuart.0
setp spindle-load.00.address 1
setp spindle-load.00.baudrate 9600
setp spindle-load.00.rxdelay 255
setp spindle-load.00.txdelay 10
addf spindle-load.00 servo-thread

setp spindle-load.00.update-hz 10
loadrt conv_u32_float count=1
addf conv-u32-float.0 servo-thread
net spindle-load-float conv-u32-float.0.in <= spindle-load.00.state

Here is a halshow view: (encoder velocity 0 when not moving)

 

Here is the encoder behaviour when moved by hand:

 


Note: you cannot use count mode with a quadrature encoder, this is
an up/down counter mode not a 1x quadrature mode and will miss-count
and give wild velocity numbers when fed quadrature.

Better to use the MPG inputs on TB3 if you want 1X quadrature
Attachments:
Last edit: 31 May 2024 00:57 by PCW.

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

Time to create page: 0.354 seconds
Powered by Kunena Forum