Hal help for home to index with stepgen firmware update

  • Lcvette
  • Lcvette's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
12 Feb 2023 19:24 - 12 Feb 2023 19:59 #264372 by Lcvette
Hello all,

I am hoping this can be solved here and used as future reference for those connecting index pulse on a step direction system with motor encoders,  but not using the encoders for feedback to close the loop. 

My system: 7i92+7i76+7i77
- I control the servos drives with the 7i76 in step and direction
- I feed the motor encoders to the 7i77
- I do not run in feedback control mode due to rough operation that could not be resolved. 
- Goal: utilize motor encoder index pulse to more accurately/ repeatability home the machine. 
- I have new firmware for utilizing this feature from @PCW at Mesa Electronics
- I have attached the new firmware below as well.

  

File Attachment:

File Name: 7i92_chris.zip
File Size:130 KB


Notes from PCW:  There are now 2 index-enable hal pins per encoder: the encoder index enable and the stepgen index enable.


Below is the X axis portion from my existing non index pulse home configuration.  There are some commented out lines from when we were testing feedback mode.

#*******************
# AXIS X JOINT 0
#*******************

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
setp pid.x.maxerror 0

net x-index-enable <=> pid.x.index-enable
net x-enable => pid.x.enable
net x-pos-cmd => pid.x.command
##net x-vel-cmd => pid.x.command-deriv
net x-pos-fb => pid.x.feedback
net x-output => pid.x.output

# Step Gen signals/setup

setp hm2_7i92.0.stepgen.00.dirsetup             [JOINT_0]DIRSETUP
setp hm2_7i92.0.stepgen.00.dirhold              [JOINT_0]DIRHOLD
setp hm2_7i92.0.stepgen.00.steplen              [JOINT_0]STEPLEN
setp hm2_7i92.0.stepgen.00.stepspace            [JOINT_0]STEPSPACE
setp hm2_7i92.0.stepgen.00.position-scale       [JOINT_0]STEP_SCALE
setp hm2_7i92.0.stepgen.00.step_type            0
setp hm2_7i92.0.stepgen.00.control-type         1
setp hm2_7i92.0.stepgen.00.maxaccel             [JOINT_0]STEPGEN_MAXACCEL
setp hm2_7i92.0.stepgen.00.maxvel               [JOINT_0]STEPGEN_MAXVEL

# ---closedloop stepper signals---

net x-pos-cmd <= joint.0.motor-pos-cmd
net x-vel-cmd <= joint.0.vel-cmd
net x-output <= hm2_7i92.0.stepgen.00.velocity-cmd
net x-pos-fb <= hm2_7i92.0.stepgen.00.position-fb
##net x-pos-fb <= hm2_7i92.0.encoder.00.position
net x-pos-fb => joint.0.motor-pos-fb
##net x-encpos-fb => joint.0.motor-pos-fb
net x-enable <= joint.0.amp-enable-out
net x-enable => hm2_7i92.0.stepgen.00.enable

# ---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                      [JOINT_0]ENCODER_SCALE

# ****the following line is for drive tuning purposes only****

net x-encpos-fb <= hm2_7i92.0.encoder.00.position
net x-vel-fb <= hm2_7i92.0.encoder.00.velocity
net x-pos-fb => joint.0.motor-pos-fb
net x-index-enable joint.0.index-enable <=> hm2_7i92.0.encoder.00.index-enable
net x-pos-rawcounts <= hm2_7i92.0.encoder.00.rawcounts

# ---setup home / limit switch signals---

net home-x => joint.0.home-sw-in
net limit-x => joint.0.neg-lim-sw-in





My hope is to create a hal example for an axis for future searchable reference regarding this scenario as I could not find anything specifically related to this method with updated firmware and linuxcnc 2.9, and did not see an option to select in the config builder softwares like mesact, pncconfig, etc.

Any help is greatly appreciated! 

Chris
Attachments:
Last edit: 12 Feb 2023 19:59 by Lcvette.
The following user(s) said Thank You: Clive S, besriworld

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

  • Lcvette
  • Lcvette's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
16 Feb 2023 06:15 - 16 Feb 2023 07:02 #264600 by Lcvette
I am updating this thread as I have gotten my machine running with home to index using step direction in open loop mode but with the use of encoders being connected to one of my mesa boards.  below is the current working hardware configuration.

7i92+7i76+7i77

This configuration requires the use of an updated firmware from Mesa to utilize a second stepgen encoder enable signal.  once the new firmware is obtained, the following x axis Hal excerpt can be used as a guide template for what will be needed in Hal.

I started with a config built using PNCCONFIG to create the Hal files. the following are the selections required to make the config correct for editing:

-  FEEDBACK = ACTUAL (this creates the encoder halpins which we need, but we will edit some Hal lines to disable feedback control.)

-  Set the joint STEPGENS and ENCODERs on the same designation, For  Example: X Axis, joint, would be configured on STEPGEN.00 and ENCODER.00   They need to match for setting the stepgen index enable signal.

-  The rest must be configured such that you are using the correct cards and in the correct order as the firmware you have.  these instructions may come with your firmware notes.

For the Hal edits, there are really only two needed once you have a feedback type config built from PNCCONFIG.  This is to remove the feedback loop to the PID, This is shown below in Bold BLUE, we are simply renaming the net so that it isn't the source of feedback the PID uses for motion.

net x-pos-fb <= hm2_7i92.0.encoder.00.position

will be changed to:

net x-encpos-fb <= hm2_7i92.0.encoder.00.position


The next change is where we define the index enable pin.

net x-index-enable joint.0.index-enable <=> hm2_7i92.0.encoder.00.index-enable

will be changed to:

net x-index-enable joint.0.index-enable <=> hm2_7i92.0.stepgen.00.index-enable


This should b the extent of what will be required to change in Hal.  You will need to update the INI file joint homing sections and change the following highlighted items to enable home to index. The other settings will be per your own machine requirements.  HOME_USE_INDEX = YES.

From the INI file of the configuration output change the line as show below:

MIN_LIMIT = 0
MAX_LIMIT = 26.5
HOME_OFFSET = .170
HOME_SEARCH_VEL = -2.00
HOME_LATCH_VEL = .100
HOME_FINAL_VEL = .400
HOME_USE_INDEX = YES
HOME_SEQUENCE = 1


Note these edits will of course need to be done for ALL of your used JOINTS (X, Y, Z, A, B etc...)


Hopefully this helps someone out, It was new and as of yet undocumented and the information was rather spread out and hidden in various threads.  thanks to the help of PCW and Tom_L I was able to get my machine homing to index! and it is Glorious!


Edit the above Hal Lines from the Hal File, their location is shown below for clarity:

#*******************
# AXIS X JOINT 0
#*******************

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
setp pid.x.maxerror 0

net x-index-enable <=> pid.x.index-enable
net x-enable        => pid.x.enable
net x-pos-cmd       => pid.x.command
net x-pos-fb        => pid.x.feedback
net x-output        => pid.x.output

# Step Gen signals/setup

setp hm2_7i92.0.stepgen.00.dirsetup        [JOINT_0]DIRSETUP
setp hm2_7i92.0.stepgen.00.dirhold         [JOINT_0]DIRHOLD
setp hm2_7i92.0.stepgen.00.steplen         [JOINT_0]STEPLEN
setp hm2_7i92.0.stepgen.00.stepspace       [JOINT_0]STEPSPACE
setp hm2_7i92.0.stepgen.00.position-scale  [JOINT_0]STEP_SCALE
setp hm2_7i92.0.stepgen.00.step_type        0
setp hm2_7i92.0.stepgen.00.control-type     1
setp hm2_7i92.0.stepgen.00.maxaccel        [JOINT_0]STEPGEN_MAXACCEL
setp hm2_7i92.0.stepgen.00.maxvel          [JOINT_0]STEPGEN_MAXVEL

# ---closedloop stepper signals---

net x-pos-cmd <= joint.0.motor-pos-cmd
net x-vel-cmd <= joint.0.vel-cmd
net x-output  <= hm2_7i92.0.stepgen.00.velocity-cmd
net x-pos-fb  <= hm2_7i92.0.stepgen.00.position-fb
net x-pos-fb  => joint.0.motor-pos-fb
net x-enable  <= joint.0.amp-enable-out
net x-enable  => hm2_7i92.0.stepgen.00.enable

# ---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      [JOINT_0]ENCODER_SCALE

net x-encpos-fb <= hm2_7i92.0.encoder.00.position
net x-vel-fb    <= hm2_7i92.0.encoder.00.velocity
net x-pos-fb    => joint.0.motor-pos-fb
net x-index-enable joint.0.index-enable <=> hm2_7i92.0.stepgen.00.index-enable
net x-pos-rawcounts  <= hm2_7i92.0.encoder.00.rawcounts
Last edit: 16 Feb 2023 07:02 by Lcvette.
The following user(s) said Thank You: besriworld, spumco

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

More
29 May 2023 00:54 #272381 by jhandel
I should read the whole thread (especially the first part)... you are running 2.9... thanks and sorry for the noise.. I would delete the previous post if it was allowed.

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

More
29 May 2023 11:09 #272420 by tommylight
Deleted.
Pretty sure you should be able to delete your own posts, but can not recall for sure.

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

More
29 May 2023 23:07 #272462 by rodw

Deleted.
Pretty sure you should be able to delete your own posts, but can not recall for sure.

No, its not possible. Best solution is to delete the content and put a note in 
The following user(s) said Thank You: tommylight

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

More
31 May 2024 19:29 - 31 May 2024 19:54 #301985 by besriworld
Hello, I'm trying to set up a home with an index. When HOME_IGNORE_INDEX = NO I have repeatability 13-20uM. For more accurate I want to use the index pulse from the servo driver. I have the special firmware. Each time it is zeroed in a different place. I can't find a logical reason. I use low speed but no change. I am attaching the files. I work on the X axis.
In Halshow I test the index signal comes.

 

File Attachment:

File Name: my_LinuxCN...5-31.hal
File Size:7 KB


 

File Attachment:

File Name: my_LinuxCN...5-31.ini
File Size:4 KB
Attachments:
Last edit: 31 May 2024 19:54 by besriworld.

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

More
31 May 2024 19:58 #301994 by PCW
Unless LinuxCNC is using encoder feedback
(and your hal file is not), you cannot use homing
to encoder index.

It is possible to home open loop step/dir systems
to index with firmware that has support for step/dir index

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

More
31 May 2024 20:39 #302002 by besriworld
Yes, that is the case. On the other topic, I have firmware supports the stepgen index.

In another thread you explained how to modify my firmware.
"To support stepgen index, you need
1. Recent LinuxCNC 2.9 or master

2 To change the stepgen revision from 0x02 to 0xC2

3. If you want shared encoder/stepgen index pins, replace
QCountIDXPin with SharedSDQCIdxPin
(the module number must match on shared pins
so stepgen index 00 == encoderindex 00)
like:
IOPortTag & x"NN" & QCountTag &SharedSDQCIdxPin,

4.If you want just a stepgen index, use :
IOPortTag & x"NN" & StepGenTag & StepGenIndexPin, "





I made a mistake in the previous comment. The signal is:HOME_USE_INDEX

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

More
31 May 2024 22:02 #302011 by PCW
If you successfully built software that incorporates stepgen index
you should have a stepgen index enable pin for each stepgen.
This is the pin you must use (rather than the encoder index enable pin)
if you are homing to index on a step/dir system  without encoder
feedback to LinuxCNC.

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

More
01 Jun 2024 02:37 - 01 Jun 2024 02:56 #302030 by besriworld
All day I tried different options. I'm pretty sure I made this change before I left the shop...it was connected to the correct pin.
 
Last edit: 01 Jun 2024 02:56 by besriworld.

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

Time to create page: 0.189 seconds
Powered by Kunena Forum