Encoder on 7i95t
- Z3rni3
- Offline
- New Member
-
Less
More
- Posts: 18
- Thank you received: 3
28 Mar 2025 09:30 - 28 Mar 2025 09:36 #325148
by Z3rni3
Encoder on 7i95t was created by Z3rni3
Hello everyone,I’m currently working with LinuxCNC on a Pi5 with a Mesa 7i95T. After getting the configuration for the motors and limit switches working, I’m now trying to set up the encoders (currently just for the X-axis). Unfortunately, I’m still relatively new to this, and I find the .hal configuration a bit overwhelming.
I’m getting the following error when starting up:
Debug file information:
Note: Using POSIX realtime
./main.hal:121: Pin 'joint.0.motor-pos-fb' was already linked to signal 'joint-0-pos-fb'
19234
I’ve attached my .ini and .hal files. Could someone please help me understand which inputs need to be connected where?Thanks in advance for your time and assistance
I’m getting the following error when starting up:
Debug file information:
Note: Using POSIX realtime
./main.hal:121: Pin 'joint.0.motor-pos-fb' was already linked to signal 'joint-0-pos-fb'
19234
I’ve attached my .ini and .hal files. Could someone please help me understand which inputs need to be connected where?Thanks in advance for your time and assistance
Last edit: 28 Mar 2025 09:36 by Z3rni3.
Please Log in or Create an account to join the conversation.
- PCW
-
- Offline
- Moderator
-
Less
More
- Posts: 18445
- Thank you received: 5037
28 Mar 2025 14:20 #325162
by PCW
Replied by PCW on topic Encoder on 7i95t
delete the red text
and change lines like
net joint-0-pos-fb <= hm2_[MESA](BOARD).0.stepgen.00.position-fb
to net joint-0-pos-fb <= hm2_[MESA](BOARD).0.encoder.00.position
If you want encoder feedback (closed loop) rather than stepgen feedback (open loop)
# position command and feedback
net joint-0-pos-cmd <= joint.0.motor-pos-cmd
net joint-0-pos-cmd => pid.x.command
net joint-0-pos-fb <= hm2_[MESA](BOARD).0.stepgen.00.position-fb
net joint-0-pos-fb => joint.0.motor-pos-fb
net joint-0-pos-fb => pid.x.feedback
# PID Output
net joint.0.output <= pid.x.output
net joint.0.output => hm2_[MESA](BOARD).0.stepgen.00.velocity-cmd
# ENOCODER
setp hm2_[MESA](BOARD).0.encoder.00.counter-mode 0
setp hm2_[MESA](BOARD).0.encoder.00.filter 1
setp hm2_[MESA](BOARD).0.encoder.00.index-invert 0
setp hm2_[MESA](BOARD).0.encoder.00.index-mask 0
setp hm2_[MESA](BOARD).0.encoder.00.index-mask-invert 0
setp hm2_[MESA](BOARD).0.encoder.00.scale [JOINT_0](ENCODER_SCALE)
net x-pos-fb <= hm2_[MESA](BOARD).0.encoder.00.position
net x-vel-fb <= hm2_[MESA](BOARD).0.encoder.00.velocity
net x-pos-fb => joint.0.motor-pos-fb
net x-index-enable joint.0.index-enable <=> hm2_[MESA](BOARD).0.encoder.00.in
net x-pos-rawcounts <= hm2_[MESA](BOARD).0.encoder.00.rawcounts
# Home
net home-x => joint.0.home-sw-in
net x-neg-limit => joint.0.neg-lim-sw-in
net x-pos-limit => joint.0.pos-lim-sw-in
and change lines like
net joint-0-pos-fb <= hm2_[MESA](BOARD).0.stepgen.00.position-fb
to net joint-0-pos-fb <= hm2_[MESA](BOARD).0.encoder.00.position
If you want encoder feedback (closed loop) rather than stepgen feedback (open loop)
# position command and feedback
net joint-0-pos-cmd <= joint.0.motor-pos-cmd
net joint-0-pos-cmd => pid.x.command
net joint-0-pos-fb <= hm2_[MESA](BOARD).0.stepgen.00.position-fb
net joint-0-pos-fb => joint.0.motor-pos-fb
net joint-0-pos-fb => pid.x.feedback
# PID Output
net joint.0.output <= pid.x.output
net joint.0.output => hm2_[MESA](BOARD).0.stepgen.00.velocity-cmd
# ENOCODER
setp hm2_[MESA](BOARD).0.encoder.00.counter-mode 0
setp hm2_[MESA](BOARD).0.encoder.00.filter 1
setp hm2_[MESA](BOARD).0.encoder.00.index-invert 0
setp hm2_[MESA](BOARD).0.encoder.00.index-mask 0
setp hm2_[MESA](BOARD).0.encoder.00.index-mask-invert 0
setp hm2_[MESA](BOARD).0.encoder.00.scale [JOINT_0](ENCODER_SCALE)
net x-pos-fb <= hm2_[MESA](BOARD).0.encoder.00.position
net x-vel-fb <= hm2_[MESA](BOARD).0.encoder.00.velocity
net x-pos-fb => joint.0.motor-pos-fb
net x-index-enable joint.0.index-enable <=> hm2_[MESA](BOARD).0.encoder.00.in
net x-pos-rawcounts <= hm2_[MESA](BOARD).0.encoder.00.rawcounts
# Home
net home-x => joint.0.home-sw-in
net x-neg-limit => joint.0.neg-lim-sw-in
net x-pos-limit => joint.0.pos-lim-sw-in
Please Log in or Create an account to join the conversation.
- Z3rni3
- Offline
- New Member
-
Less
More
- Posts: 18
- Thank you received: 3
03 Apr 2025 10:52 - 03 Apr 2025 11:05 #325604
by Z3rni3
Replied by Z3rni3 on topic Encoder on 7i95t
I got the machine to open now.
But when i try to home the axis it gives me a "Joint.0 following error"
Attaching my current X set-up here.
I'd be greatful if anybody finds some time to look over it!
CODE:
#**********************************************
# X Axis (Joint: 0 / Output: 0)
#**********************************************
# PID Setup
setp pid.x.Pgain [JOINT_0](P)
setp pid.x.Igain [JOINT_0](I)
setp pid.x.Dgain [JOINT_0](D)
setp pid.x.bias [JOINT_0](BIAS)
setp pid.x.FF0 [JOINT_0](FF0)
setp pid.x.FF1 [JOINT_0](FF1)
setp pid.x.FF2 [JOINT_0](FF2)
setp pid.x.deadband [JOINT_0](DEADBAND)
setp pid.x.maxoutput [JOINT_0](MAX_OUTPUT)
setp pid.x.error-previous-target True
# limit stepgen velocity corrections caused by position feedback jitter
setp pid.x.maxerror [JOINT_0](MAX_ERROR)
# joint-0 enable chain
net joint-0-index-enable <=> pid.x.index-enable
net joint-0-index-enable <=> joint.0.index-enable
net joint-0-enable <= joint.0.amp-enable-out
net joint-0-enable => pid.x.enable
net joint-0-enable => hm2_[MESA](BOARD).0.stepgen.00.enable
# Joint 0 Step Generator Settings
setp hm2_[MESA](BOARD).0.stepgen.00.dirsetup [JOINT_0](DIRSETUP)
setp hm2_[MESA](BOARD).0.stepgen.00.dirhold [JOINT_0](DIRHOLD)
setp hm2_[MESA](BOARD).0.stepgen.00.steplen [JOINT_0](STEPLEN)
setp hm2_[MESA](BOARD).0.stepgen.00.stepspace [JOINT_0](STEPSPACE)
setp hm2_[MESA](BOARD).0.stepgen.00.position-scale [JOINT_0](SCALE)
setp hm2_[MESA](BOARD).0.stepgen.00.maxvel [JOINT_0](STEPGEN_MAX_VEL)
setp hm2_[MESA](BOARD).0.stepgen.00.maxaccel [JOINT_0](STEPGEN_MAX_ACC)
setp hm2_[MESA](BOARD).0.stepgen.00.step_type 0
setp hm2_[MESA](BOARD).0.stepgen.00.control-type 1
# joint 0 pos/vel/fb
net joint.0-pos-cmd <= joint.0.motor-pos-cmd
net joint.0-pos-cmd => pid.x.command
net joint.0-pos-fb <= hm2_[MESA](BOARD).0.encoder.00.position
net joint.0-pos-fb => joint.0.motor-pos-fb
net joint.0-pos-fb => pid.x.feedback
net joint.0-vel-cmd <= joint.0.vel-cmd
net joint.0.output <= pid.x.output
net joint.0.output <= hm2_[MESA](BOARD).0.stepgen.00.velocity-cmd
net Joint.0-vel-fb <= hm2_[MESA](BOARD).0.encoder.00.velocity
net joint.0-pos-rawcounts <= hm2_[MESA](BOARD).0.encoder.00.rawcounts
net joint.0-index-enable <=> hm2_[MESA](BOARD).0.encoder.00.index-enable
# Encoder
setp hm2_7i95.0.encoder.00.counter-mode 0
setp hm2_7i95.0.encoder.00.filter 1
setp hm2_7i95.0.encoder.00.index-invert 0
setp hm2_7i95.0.encoder.00.index-mask 0
setp hm2_7i95.0.encoder.00.index-mask-invert 0
setp hm2_7i95.0.encoder.00.scale [JOINT_0](ENCODER_SCALE)
# Home
net home-x => joint.0.home-sw-in
net x-neg-limit => joint.0.neg-lim-sw-in
net x-pos-limit => joint.0.pos-lim-sw-in
But when i try to home the axis it gives me a "Joint.0 following error"
Attaching my current X set-up here.
I'd be greatful if anybody finds some time to look over it!
CODE:
#**********************************************
# X Axis (Joint: 0 / Output: 0)
#**********************************************
# PID Setup
setp pid.x.Pgain [JOINT_0](P)
setp pid.x.Igain [JOINT_0](I)
setp pid.x.Dgain [JOINT_0](D)
setp pid.x.bias [JOINT_0](BIAS)
setp pid.x.FF0 [JOINT_0](FF0)
setp pid.x.FF1 [JOINT_0](FF1)
setp pid.x.FF2 [JOINT_0](FF2)
setp pid.x.deadband [JOINT_0](DEADBAND)
setp pid.x.maxoutput [JOINT_0](MAX_OUTPUT)
setp pid.x.error-previous-target True
# limit stepgen velocity corrections caused by position feedback jitter
setp pid.x.maxerror [JOINT_0](MAX_ERROR)
# joint-0 enable chain
net joint-0-index-enable <=> pid.x.index-enable
net joint-0-index-enable <=> joint.0.index-enable
net joint-0-enable <= joint.0.amp-enable-out
net joint-0-enable => pid.x.enable
net joint-0-enable => hm2_[MESA](BOARD).0.stepgen.00.enable
# Joint 0 Step Generator Settings
setp hm2_[MESA](BOARD).0.stepgen.00.dirsetup [JOINT_0](DIRSETUP)
setp hm2_[MESA](BOARD).0.stepgen.00.dirhold [JOINT_0](DIRHOLD)
setp hm2_[MESA](BOARD).0.stepgen.00.steplen [JOINT_0](STEPLEN)
setp hm2_[MESA](BOARD).0.stepgen.00.stepspace [JOINT_0](STEPSPACE)
setp hm2_[MESA](BOARD).0.stepgen.00.position-scale [JOINT_0](SCALE)
setp hm2_[MESA](BOARD).0.stepgen.00.maxvel [JOINT_0](STEPGEN_MAX_VEL)
setp hm2_[MESA](BOARD).0.stepgen.00.maxaccel [JOINT_0](STEPGEN_MAX_ACC)
setp hm2_[MESA](BOARD).0.stepgen.00.step_type 0
setp hm2_[MESA](BOARD).0.stepgen.00.control-type 1
# joint 0 pos/vel/fb
net joint.0-pos-cmd <= joint.0.motor-pos-cmd
net joint.0-pos-cmd => pid.x.command
net joint.0-pos-fb <= hm2_[MESA](BOARD).0.encoder.00.position
net joint.0-pos-fb => joint.0.motor-pos-fb
net joint.0-pos-fb => pid.x.feedback
net joint.0-vel-cmd <= joint.0.vel-cmd
net joint.0.output <= pid.x.output
net joint.0.output <= hm2_[MESA](BOARD).0.stepgen.00.velocity-cmd
net Joint.0-vel-fb <= hm2_[MESA](BOARD).0.encoder.00.velocity
net joint.0-pos-rawcounts <= hm2_[MESA](BOARD).0.encoder.00.rawcounts
net joint.0-index-enable <=> hm2_[MESA](BOARD).0.encoder.00.index-enable
# Encoder
setp hm2_7i95.0.encoder.00.counter-mode 0
setp hm2_7i95.0.encoder.00.filter 1
setp hm2_7i95.0.encoder.00.index-invert 0
setp hm2_7i95.0.encoder.00.index-mask 0
setp hm2_7i95.0.encoder.00.index-mask-invert 0
setp hm2_7i95.0.encoder.00.scale [JOINT_0](ENCODER_SCALE)
# Home
net home-x => joint.0.home-sw-in
net x-neg-limit => joint.0.neg-lim-sw-in
net x-pos-limit => joint.0.pos-lim-sw-in
Last edit: 03 Apr 2025 11:05 by Z3rni3.
Please Log in or Create an account to join the conversation.
- PCW
-
- Offline
- Moderator
-
Less
More
- Posts: 18445
- Thank you received: 5037
03 Apr 2025 16:21 #325627
by PCW
Replied by PCW on topic Encoder on 7i95t
Did you first verify that stepgen feedback worked?
(scaled properly and motion in the correct directions)
That is replace:
net joint.0-pos-fb <= hm2_[MESA](BOARD).0.encoder.00.position
with:
net joint.0-pos-fb <= hm2_[MESA](BOARD).0.stepgen.00.position
Once this works, I would verify that the encoder position is also in the correct direction
and scaled properly.
Also note that for initial tuning with encoder feedback, you will need to widen the following
error limits and reduce the P term
(scaled properly and motion in the correct directions)
That is replace:
net joint.0-pos-fb <= hm2_[MESA](BOARD).0.encoder.00.position
with:
net joint.0-pos-fb <= hm2_[MESA](BOARD).0.stepgen.00.position
Once this works, I would verify that the encoder position is also in the correct direction
and scaled properly.
Also note that for initial tuning with encoder feedback, you will need to widen the following
error limits and reduce the P term
Please Log in or Create an account to join the conversation.
- Z3rni3
- Offline
- New Member
-
Less
More
- Posts: 18
- Thank you received: 3
04 Apr 2025 07:38 - 04 Apr 2025 07:39 #325662
by Z3rni3
Replied by Z3rni3 on topic Encoder on 7i95t
Morning,
I replaced "encoder.00.position" with "stepgen.00.position-fb", which worked fine.
Then I checked the encoder and realized that it was counting in the negative direction when moving in positive coordinates. So, I added a minus sign in front of the stepper count in my .ini.
Now, the axis moves during the first part of the homing process. However, as soon as it hits the home switch for the first time which then tells it to change directions a "following Error" occurs.
I replaced "encoder.00.position" with "stepgen.00.position-fb", which worked fine.
Then I checked the encoder and realized that it was counting in the negative direction when moving in positive coordinates. So, I added a minus sign in front of the stepper count in my .ini.
Now, the axis moves during the first part of the homing process. However, as soon as it hits the home switch for the first time which then tells it to change directions a "following Error" occurs.
Last edit: 04 Apr 2025 07:39 by Z3rni3.
Please Log in or Create an account to join the conversation.
- tommylight
-
- Offline
- Moderator
-
Less
More
- Posts: 20062
- Thank you received: 6824
04 Apr 2025 11:29 #325673
by tommylight
Replied by tommylight on topic Encoder on 7i95t
Please Log in or Create an account to join the conversation.
- Z3rni3
- Offline
- New Member
-
Less
More
- Posts: 18
- Thank you received: 3
04 Apr 2025 11:59 - 04 Apr 2025 12:02 #325677
by Z3rni3
Replied by Z3rni3 on topic Encoder on 7i95t
Sorry, I don't really understand what you're trying to tell me with that.
My home search_vel is -0.5 and the latch_vel is -0.25.
And P is set on 10
My home search_vel is -0.5 and the latch_vel is -0.25.
And P is set on 10
Last edit: 04 Apr 2025 12:02 by Z3rni3.
Please Log in or Create an account to join the conversation.
- tommylight
-
- Offline
- Moderator
-
Less
More
- Posts: 20062
- Thank you received: 6824
04 Apr 2025 12:24 #325682
by tommylight
Replied by tommylight on topic Encoder on 7i95t
P=10 ?
-
Start from the beginning :
-Make a working config WITHOUT encoders, only after that is working properly with correct dimensions move to enabling encoders and editing other values. The link has everything in metric, adjust accordingly for imperial.
forum.linuxcnc.org/10-advanced-configura...glass-scale-feedback
-then check the homing as described in the link i posted above by lowering the search and latch and final homing velocities to see what is actually happening during the homing procedure. For metric machine use 1, for imperial use 0.04
-
Start from the beginning :
-Make a working config WITHOUT encoders, only after that is working properly with correct dimensions move to enabling encoders and editing other values. The link has everything in metric, adjust accordingly for imperial.
forum.linuxcnc.org/10-advanced-configura...glass-scale-feedback
-then check the homing as described in the link i posted above by lowering the search and latch and final homing velocities to see what is actually happening during the homing procedure. For metric machine use 1, for imperial use 0.04
Please Log in or Create an account to join the conversation.
- PCW
-
- Offline
- Moderator
-
Less
More
- Posts: 18445
- Thank you received: 5037
04 Apr 2025 13:13 - 04 Apr 2025 13:13 #325685
by PCW
Replied by PCW on topic Encoder on 7i95t
Also if you use encoder feedback you will need to tune the system
and this requires increasing the following error limits:
FERROR = 0.005
MIN_FERROR = 0.0025
I would increase these to say
FERROR = 1
MIN_FERROR = .25
So you don't get nuisance following errors when tuning
Tuning involves using halscope to plot the following error
It's helpful to plot the joint following error and joint velocity
when tuning.
Note that if you use homing to index, you must connect the encoder
index enable signal to both motion and the PID component.
and this requires increasing the following error limits:
FERROR = 0.005
MIN_FERROR = 0.0025
I would increase these to say
FERROR = 1
MIN_FERROR = .25
So you don't get nuisance following errors when tuning
Tuning involves using halscope to plot the following error
It's helpful to plot the joint following error and joint velocity
when tuning.
Note that if you use homing to index, you must connect the encoder
index enable signal to both motion and the PID component.
Last edit: 04 Apr 2025 13:13 by PCW.
Please Log in or Create an account to join the conversation.
- Z3rni3
- Offline
- New Member
-
Less
More
- Posts: 18
- Thank you received: 3
07 Apr 2025 05:10 #325852
by Z3rni3
Replied by Z3rni3 on topic Encoder on 7i95t
I've got a working config without Encoder input!
That link is very helpful. I'll be following it later today!
Thank you very much!
That link is very helpful. I'll be following it later today!
Thank you very much!
Please Log in or Create an account to join the conversation.
Time to create page: 0.119 seconds