Spindle Encoder For Speed Control

More
30 May 2016 16:49 #75250 by danimal300
My goal is to get speed input displaying on my console, and have the spindle speed controlled by LinuxCNC to include a wait before exicution until spindle speed is achieved.

I have 2.6.5 controlling a G540 to run my retrofit machine.

I have installed a simple hall switch encoder that I have a verified 8V pulse at 1 pulse per revolution, but I could easily add magnets to get more pulses if needed.

I have tried reading every .hal modification file that I can find online, but honestly I have no idea what emc2 is looking for. I have verified the pinout on the G540 and selected pin1 which corresponds to pin10 on the parallel port. Using stepconfig, I can get the speed display to show up, but it does nothing.

Can someone explain to me the big picture (i.e pulse comes into machine, is read by xxx.hal configuration which looks at xxx.hal file and outputs the scaled RPM value to the screen)

Second, for a very simple configuration like this what would I need to add to my .hal files? Also I accidently ran stepconfig and lost my backlash values and various other little tweaks, so I am not opposed to upgrading or changing anything if that makes life easier/ better because I will be doing everything again anyway. So my machine is starting from a stock configuration, and the only real changes to anything are for step and workspace configuration.

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

More
30 May 2016 20:21 - 30 May 2016 20:22 #75263 by Todd Zuercher
There are pretty good instructions (including example code to add to your hal file) in the Linuxcnc documentation here.
linuxcnc.org/docs/html/examples/spindle.html#_spindle_feedback
linuxcnc.org/docs/html/examples/spindle.html#_spindle_at_speed

For your situation only using one pulse/rev, you would connect the signal connected to the parallel port input to both the index and A-phase of the encoder component.

The basic gist of it is the encoder component reads the pulses and outputs a velocity signal that is connected to the spindle feedback and any display you use.
Last edit: 30 May 2016 20:22 by Todd Zuercher.
The following user(s) said Thank You: danimal300

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

More
30 May 2016 21:47 #75266 by danimal300
I have tried those, but I think that I may see the problem now. What is the function of the encoder index pulse? I see that it says:

encoder.N.index-enable bit i/o

When true, counts and position are reset to zero on the next rising edge of Phase-Z. At the same time, index-enable is reset to zero to indicate that the rising edge has occurred.


I only have a single a chanel, should I duplicate it and bring it in on pin 11 as the index? (being that I have one pulse per revolution)

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

More
30 May 2016 22:01 #75267 by danimal300

There are pretty good instructions (including example code to add to your hal file) in the Linuxcnc documentation here.
linuxcnc.org/docs/html/examples/spindle.html#_spindle_feedback
linuxcnc.org/docs/html/examples/spindle.html#_spindle_at_speed

For your situation only using one pulse/rev, you would connect the signal connected to the parallel port input to both the index and A-phase of the encoder component.

The basic gist of it is the encoder component reads the pulses and outputs a velocity signal that is connected to the spindle feedback and any display you use.


Just so I am understanding this, the code supplements in the linked files should go into custom_postgui.hal correct?

I get the file exists error when I place the Spindle Synchronized Motion into that hal file.

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

More
30 May 2016 22:26 #75269 by danimal300
Nevermind, feel like a dufus, I forgot to put a bonding jumpper in from the 12V supply that is driving my encoder to the G540 common. Now it works great.

Man it hurts to spend an entire holiday weekend trying to fix something thats not broken. Well I learned a ton about hal, so thats nice.
The following user(s) said Thank You: joekline9

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

More
26 Nov 2016 06:52 - 26 Nov 2016 06:53 #83327 by Askjerry
So if I understand this correctly, given the situation where I only have ONE pin to allocate to the SPINDLE ENCODER, and considering that I have ONE piece of reflective material on the shaft... ONE pulse per revolution...


Then I would assign BOTH the ENCODER A and INDEX to the same para port pin... (Pin13)...

Copy from manual... edited...
Re: linuxcnc.org/docs/html/examples/spindle.html#_spindle_feedback
# add the encoder to HAL and attach it to threads.
loadrt encoder num_chan=1
addf encoder.update-counters base-thread
addf encoder.capture-position servo-thread

# set the HAL encoder to 1 pulse per revolution.
setp encoder.3.position-scale 1

# set the HAL encoder to non-quadrature simple counting using A only.
setp encoder.3.counter-mode true

# connect the HAL encoder outputs to LinuxCNC.
net spindle-position          encoder.3.position          => motion.spindle-revs
net spindle-velocity          encoder.3.velocity          => motion.spindle-speed-in
net spindle-index-enable   encoder.3.index-enable <=> motion.spindle-index-enable

# connect the HAL encoder inputs to the real encoder.
net spindle-phase-a         encoder.3.phase-A        <= parport.0.pin-13-in
net spindle-phase-b         encoder.3.phase-B
net spindle-index             encoder.3.phase-Z        <= spindle-phase-a

Does that look about right? (I'll wire it up and attempt it likely this weekend time permitting. It would be nice to have an active spindle speed display instead of just a static one. (And a true "at speed" indicator as well.)

Thanks,
Jerry
Attachments:
Last edit: 26 Nov 2016 06:53 by Askjerry.

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

More
26 Nov 2016 21:41 #83350 by danimal300
I think that I see what you are saying, but I remember needing to use both a spindle phase A, and Spindle Index set to specific pins. It has been a while since I messed with this since I got it going, but it seems to me that is should work either way. I will look at it again and refresh my memory.

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

Time to create page: 0.123 seconds
Powered by Kunena Forum