- Posts: 12
- Thank you received: 0
PID and Homing with index.
8 years 10 months ago #102799
by UAVpilot
PID and Homing with index. was created by UAVpilot
Hello,
I have this configuration:
5i25 or 7i92 -> 7i77 -> servo (fast)
At the end of the process homing, the servo drive jerks sharply and sometimes shuts down due to overload. I found out why this happens:
At the signal index-enable (falling to low), the encoder counter pid.x.feedback do reset. However, pid.x.command will only be reset in the next servocycle. As a result, in the current servocycle, pid.x.error becomes
equal pid.x.command and a very large value appears briefly at the output of PID (pid.x.output). A fast servo manages to do it.
The PID component has a pin pid.x.error-previous-target, which is TRUE by default. If change it to FALSE, the result is slightly improved, but the problem does not resolve.
I have this configuration:
5i25 or 7i92 -> 7i77 -> servo (fast)
At the end of the process homing, the servo drive jerks sharply and sometimes shuts down due to overload. I found out why this happens:
At the signal index-enable (falling to low), the encoder counter pid.x.feedback do reset. However, pid.x.command will only be reset in the next servocycle. As a result, in the current servocycle, pid.x.error becomes
equal pid.x.command and a very large value appears briefly at the output of PID (pid.x.output). A fast servo manages to do it.
Attachment not found
The PID component has a pin pid.x.error-previous-target, which is TRUE by default. If change it to FALSE, the result is slightly improved, but the problem does not resolve.
Attachment not found
Please Log in to join the conversation.
8 years 10 months ago #102800
by UAVpilot
Replied by UAVpilot on topic PID and Homing with index.
I made a small patch for pid.c, which seems to completely solve this problem:
Results:
Code:
--- pid.c.orig 2017-11-25 04:26:15.000000000 +0300
+++ pid.c 2017-12-09 01:36:06.645777032 +0300
@@ -325,6 +325,8 @@
} else {
tmp1 = command - feedback;
}
+ if(pid->prev_ie && !*(pid->index_enable))
+ tmp1 = 0;
/* store error to error pin */
*(pid->error) = tmp1;
/* apply error limits */
Results:
Attachment not found
Attachment not found
Please Log in to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
-
Less
More
- Posts: 4739
- Thank you received: 2
8 years 10 months ago #102801
by Todd Zuercher
Replied by Todd Zuercher on topic PID and Homing with index.
Do you only have a servo thread?
I have this same problem on a machine that is running a servo thread and a floatingpoint base thread, For me the problem goes away If I run only a single thread. Also if I try to home the machine again after the error, it does not do it because the encoder offset was zeroed with the first failed attempt. (I only get the error after closing and restarting Linuxcnc.)
I have this same problem on a machine that is running a servo thread and a floatingpoint base thread, For me the problem goes away If I run only a single thread. Also if I try to home the machine again after the error, it does not do it because the encoder offset was zeroed with the first failed attempt. (I only get the error after closing and restarting Linuxcnc.)
Please Log in to join the conversation.
8 years 10 months ago #102804
by UAVpilot
Replied by UAVpilot on topic PID and Homing with index.
Yes, only servo thread.
Stable way to reproduce the problem:
1. Move the axis (mechanically) to a distance of 30mm or more from the home switch.
2. Start LinuxCNC.
3. Start the homing procedure.
Stable way to reproduce the problem:
1. Move the axis (mechanically) to a distance of 30mm or more from the home switch.
2. Start LinuxCNC.
3. Start the homing procedure.
Please Log in to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
-
Less
More
- Posts: 4739
- Thank you received: 2
8 years 10 months ago #102807
by Todd Zuercher
Replied by Todd Zuercher on topic PID and Homing with index.
Do you have pid.N.index-enable connected?
Please Log in to join the conversation.
8 years 10 months ago #102808
by PCW
Replied by PCW on topic PID and Homing with index.
If pid.N.index-enable is connected and you still get this issue it may be a thread order problem
Can you post your hal/ini files?
Can you post your hal/ini files?
Please Log in to join the conversation.
8 years 10 months ago #102817
by UAVpilot
Replied by UAVpilot on topic PID and Homing with index.
index-enable connected.
hm2_7i92.0.encoder.00.index-enable <=> pid.x.index-enable <=> axis.0.index-enable
INI & HAL, inessential removed:
I tried to change the order of the components in the thread - the result does not change. As expected.
hm2_7i92.0.encoder.00.index-enable <=> pid.x.index-enable <=> axis.0.index-enable
INI & HAL, inessential removed:
Warning: Spoiler!
Code:
---------8<------------INI----------8<---------
[AXIS_0]
TYPE = LINEAR
HOME = 0.0
FERROR = 2
MIN_FERROR = 1
MAX_VELOCITY = 50
MAX_ACCELERATION = 1000
P = 1.0
I = 0.0
D = 0.0
FF0 = 0.0
FF1 = 0.0
FF2 = 0.0
BIAS = 0.0
DEADBAND = 0.0
MAX_OUTPUT = 10.0
INPUT_SCALE = 1024.0
OUTPUT_SCALE = 10.0
OUTPUT_MIN_LIMIT = -10.0
OUTPUT_MAX_LIMIT = 10.0
MIN_LIMIT = -155.00
MAX_LIMIT = 0
HOME_OFFSET = 0
HOME_SEARCH_VEL = 50
HOME_LATCH_VEL = -3
HOME_FINAL_VEL = 10
HOME_USE_INDEX = YES
HOME_IGNORE_LIMITS = YES
HOME_SEQUENCE = 0
---------8<-------------8<----------8<----------
---------8<------------HAL----------8<---------
loadrt trivkins
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]AXES
addf motion-command-handler servo-thread
addf motion-controller servo-thread
loadrt hostmot2
loadrt [HOSTMOT2]DRIVER0 board_ip=[HOSTMOT2]BOARD0IP config=" num_encoders=6 num_pwmgens=0 num_stepgens=0 sserial_port_0=000xxx"
addf hm2_7i92.0.read servo-thread
addf hm2_7i92.0.write servo-thread
loadrt pid names=pid.x,pid.z,pid.s
addf pid.x.do-pid-calcs servo-thread
addf pid.z.do-pid-calcs servo-thread
addf pid.s.do-pid-calcs servo-thread
....
#*******************
# AXIS X
#*******************
setp pid.x.Pgain [AXIS_0]P
setp pid.x.Igain [AXIS_0]I
setp pid.x.Dgain [AXIS_0]D
setp pid.x.bias [AXIS_0]BIAS
setp pid.x.FF0 [AXIS_0]FF0
setp pid.x.FF1 [AXIS_0]FF1
setp pid.x.FF2 [AXIS_0]FF2
setp pid.x.deadband [AXIS_0]DEADBAND
setp pid.x.maxoutput [AXIS_0]MAX_OUTPUT
net x-index-enable <=> pid.x.index-enable
net x-enable => pid.x.enable
net x-output => pid.x.output
net x-pos-cmd => pid.x.command
net x-vel-fb => pid.x.feedback-deriv
net x-pos-fb => pid.x.feedback
net x-pos-cmd <= axis.0.motor-pos-cmd
net x-enable <= axis.0.amp-enable-out
net x-pos-fb <= axis.0.motor-pos-fb
net x-index-enable axis.0.index-enable
# ---setup home / limit switch signals---
#net x-home-sw => axis.0.home-sw-in
net x-neg-limit => axis.0.neg-lim-sw-in
net x-pos-limit => axis.0.pos-lim-sw-in axis.0.home-sw-in
# ---PWM Generator signals/setup---
setp hm2_7i92.0.7i77.0.1.analogout0-scalemax [AXIS_0]OUTPUT_SCALE
setp hm2_7i92.0.7i77.0.1.analogout0-minlim [AXIS_0]OUTPUT_MIN_LIMIT
setp hm2_7i92.0.7i77.0.1.analogout0-maxlim [AXIS_0]OUTPUT_MAX_LIMIT
net x-output => hm2_7i92.0.7i77.0.1.analogout0
# enable _all_ sserial pwmgens
net x-enable hm2_7i92.0.7i77.0.1.analogena
# ---Encoder feedback signals/setup---
setp hm2_7i92.0.encoder.00.counter-mode 0
setp hm2_7i92.0.encoder.00.filter 1
setp hm2_7i92.0.encoder.00.index-invert 0
setp hm2_7i92.0.encoder.00.index-mask 0
setp hm2_7i92.0.encoder.00.index-mask-invert 0
setp hm2_7i92.0.encoder.00.scale [AXIS_0]INPUT_SCALE
net x-pos-fb <= hm2_7i92.0.encoder.00.position
net x-vel-fb <= hm2_7i92.0.encoder.00.velocity
net x-index-enable <=> hm2_7i92.0.encoder.00.index-enable
net x-pos-rawcounts <= hm2_7i92.0.encoder.00.rawcounts
net x-neg-limit hm2_7i92.0.7i77.0.0.input-04
net x-pos-limit hm2_7i92.0.7i77.0.0.input-03
#setp pid.x.error-previous-target 0
....
I tried to change the order of the components in the thread - the result does not change. As expected.
Code:
...
addf pid.x.do-pid-calcs servo-thread
...
addf motion-command-handler servo-thread
addf motion-controller servo-thread
...
Please Log in to join the conversation.
8 years 10 months ago #102823
by PCW
Replied by PCW on topic PID and Homing with index.
Thread order is wrong, it should be:
hardware read
everything else
hardware write
hardware read
everything else
hardware write
Please Log in to join the conversation.
8 years 10 months ago #102851
by UAVpilot
Replied by UAVpilot on topic PID and Homing with index.
So?
I tried it. As expected, the problem remained.
I noticed that on the given oscillograms I was mistaken in the designation of cycles: The inscription "Cycle N + 1" should be read as "Cycle N + 2". Below is the correct picture. Sorry.
My patch causes the PID to skip the cycle N+1
Code:
loadrt hostmot2
loadrt [HOSTMOT2]DRIVER0 board_ip=[HOSTMOT2]BOARD0IP config=" num_encoders=6 num_pwmgens=0 num_stepgens=0 sserial_port_0=000xxx"
addf hm2_7i92.0.read servo-thread
loadrt trivkins
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]AXES
addf motion-command-handler servo-thread
addf motion-controller servo-thread
loadrt pid names=pid.x,pid.z,pid.s
addf pid.x.do-pid-calcs servo-thread
addf pid.z.do-pid-calcs servo-thread
addf pid.s.do-pid-calcs servo-thread
....
addf hm2_7i92.0.write servo-thread
I tried it. As expected, the problem remained.
I noticed that on the given oscillograms I was mistaken in the designation of cycles: The inscription "Cycle N + 1" should be read as "Cycle N + 2". Below is the correct picture. Sorry.
Attachment not found
My patch causes the PID to skip the cycle N+1
Please Log in to join the conversation.
8 years 10 months ago #102852
by PCW
Replied by PCW on topic PID and Homing with index.
I suspect there's still a hal file issue of some kind as this is not a common problem with home to index
The feedback position should change at the same time as and the commanded position. If not
that still suggests a thread order or HAL connection problem
Can you post your complete hal and ini files?
The feedback position should change at the same time as and the commanded position. If not
that still suggests a thread order or HAL connection problem
Can you post your complete hal and ini files?
Please Log in to join the conversation.
Time to create page: 0.065 seconds
