ENCODER_RATIO function implementation.

  • Boogie
  • Away
  • Premium Member
  • Premium Member
More
03 Apr 2025 06:04 #325588 by Boogie
Gents,

Continuing my learning process of LinuxCNC and Mesa cards i've managed (thank you PCW and tommylight!), to start my permanent magnet DC servomotor driven by BTS7960 H-bridges, all hooked up to Mesa 7i95T on the test bench.
forum.linuxcnc.org/configuration-tools/5...-bridges-pmdc-servos

Did some basic PID tuning and motors are not reaching following errors. Ferror is loose however - fine tuning not required at this stage.
On my learning short list now there is two topics:
1) encoder-ratio module
2) Mesa THCAD card. As I'm powering my motors and limit/home switches from old laptop power supply - its voltage sags easily when loading servos so found it good opportunity to practice THCAD and PyVCP by reading power supply voltage and present it on AXIS. 

Ad 1) While reading LinuxCNC documentation i found an interesting function ENCODER_RATIO. First thought was "hey! let's do some experiment and slave Z axis servo to X.". Let's say the final idea is to link spindle encoder with rotary/dividing head servo - i can imaging hobbing gears like that:)
Experiment conditions:
- there is three servos available X, Y, Z so three encoders, all the same ppr = 400
- X will be the master, Z will be slave
- i want Z to turn 4 times slower than X

If i understand the documentation right i did the following:
- detached joint.2.motor-pos-cmd from pid.z.command
- detached hm2_7i95.0.encoder.02.position from pid.z.feedback and joint.2.motor-pos-fb
- connected pid.z.feedback and joint.2.motor-pos-fb with encoder-ratio.0.error
- decided to use one of the switches for slave axis on/off so detached remote e-stop (will not using it now) input hm2_7i95.0.inmux.00.input-06-not and hooked it up to encoder-ratio.0.enable
- connected master axis (X) encoder signals A and B to encoder-ratio.0.master-A and encoder-ratio.0.master-B
- connected slave axis (Z) encoder signals A and B to encoder-ratio.0.slave-A and encoder-ratio.0.slave-B
- set ratio by stating ppr: encoder-ratio.0.master-ppr 400 and encoder-ratio.0.slave-ppr 100

AXIS started with no issues. Checked HAL configuration and what i can see is:
- encoder-ratio.0.master-A and B signals are successfully connected to X encoder
- encoder-ratio.0.enable is ok - turning TRUE when switch is activated by me

And i failed successfully:)
- i can see no change on pid.z.feedback as well as on pid.z.output when i move X axis - no change on encoder-ratio.0.error 

I thing i'm not getting fully what manula says about encoder_ratio. i couldn't find any HAL examples showing correct configuration.
What i found is that unfortunatelly encoder-ratio.0.master-ppr and encoder-ratio.0.slave-ppr are PARAMETERS, not PINS so no chance to make nice 'change ratio' option in PyVCP (imagine you can input different spindle/slave axis ratio and hob whatever spur gear you want!). The only option i see it close LinuxCNC, edit ppr numbers and re-start LinuxCNC to get ratio i want.

My idea was to have motorized dividing head connected and with just one switch make it move in sync with spindle @ required ratio...So it is basically ELS. Ehmmm those dreams.

Anyway, please! Could you guys look at it and poke me in good direction? I did research and tried by myself before i bother you but, as i said before, failed successfully:)
Thank you.
Attachments:
The following user(s) said Thank You: tommylight

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

More
03 Apr 2025 12:07 #325611 by andypugh
Replied by andypugh on topic ENCODER_RATIO function implementation.
I have never found a use for encoder_ratio, at least partly because it relies on software-counting of the A and B phases.

If you are using a Mesa card then encoder_ratio won't help you.

But gear hobbing is nevetheless very possible. I do it regularly. I invented the idea of electronically geared hobbing, but I probably didn't invent it first :-)

wiki.linuxcnc.org/cgi-bin/wiki.pl?Hobbing

Note that due to a problem with a certificate on the server that hosts the Wiki, https won't work. This means that to download the linked zip file you will need to copy the URL, edit out the "s" in "https" and then paste the URL back into the address bar. Sorry about this.

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

  • scotth
  • Away
  • Elite Member
  • Elite Member
More
03 Apr 2025 14:29 #325618 by scotth
Replied by scotth on topic ENCODER_RATIO function implementation.
The first CNC hob I worked with was a Pfauter PE 150 with an Allen Bradley 7300 and the Pfauter EGB (electronic gear box). 1983

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

  • scotth
  • Away
  • Elite Member
  • Elite Member
More
03 Apr 2025 14:43 #325620 by scotth
Replied by scotth on topic ENCODER_RATIO function implementation.
The EGB would add or subtract pulses to the table for helical gears based on hob height, as well as handling hob and table speed.

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

Time to create page: 0.069 seconds
Powered by Kunena Forum