- Configuring LinuxCNC
- Configuration Tools
- StepConf Wizard
- Configuring Spindle Feedback with Proximity Sensor
Configuring Spindle Feedback with Proximity Sensor
However, when I air run the threading.ngc example code (EMC2 2.3.0) the code hangs at the first G33 line. I tried executing the G33 line by hand and got a "spindle not turning" message.
Seems to me that somehow the wiring from the scale.0 module doesn't connect to EMC proper. (sorry if this is messy nomenclature, I'm a hal newby.)
Could someone help me get EMC to be aware of the current spindle speed so I can execute G33, G33.1, and G76 commands?
And since I'm asking newby questions, can someone tell me what PWM rate and PDM mode means?
Thanks,
Rus
Please Log in or Create an account to join the conversation.
I am surprised to see that you are using a scale module, you really need to use an encoder module for G33 and G76.Seems to me that somehow the wiring from the scale.0 module doesn't connect to EMC proper. (sorry if this is messy nomenclature, I'm a hal newby.)
For a single pulse channel you need to put the encoder in counter mode (ie setp encoder.0.counter-mode 1)
www.linuxcnc.org/docview/html/man/man9/encoder.9.html
You then need to link encoder position (or better, encoder position-interpolated to the motion.spindle-revs pin (this is very critical)
linuxcnc.org/docs/html/examples_spindle.html
However, you still have one very important part of the puzzle missing. You also need a one pulse per rev index, as that is where EMC2 starts the thread. For this you will need to have another sensor working off a feature on the spindle or a deeper/longer slot on your existing feedback wheel (What are you using at the moment?)Could someone help me get EMC to be aware of the current spindle speed so I can execute G33, G33.1, and G76 commands?
It is probably possible to use a single pulse per rev as both index and counter (though I would not expect that to work especially perfectly) and it should also be possible to synthesise an index pulse from the encoder counts (but I can't see a HAL function to do that in the current version, you would have to write a custom component which checks if encoder counts is an integer multiple of the encoder scale, which is not exactly difficult, but needs some effort).
A real once-per-rev index is better.
PWM generates variable mark-space ratio square waves. The PWM rate is the base frequency of those square waves.And since I'm asking newby questions, can someone tell me what PWM rate and PDM mode means?
Consider that the base thread on your machine runs at something around 20,000nS (or 20uS in sensible units). Every 20uS the PWM function runs, and decides whether to turn on or off the output. It does this by incrementing a counter, and seeing if the value of the counter is above a threshold.
This means that the resolution of the PWM generator is a function of PWM frequency.
Consider a 50kHz base thread frequency. This means that a 1kHz PWM can count from 0 to 50, switching at 25 for 50% PWM value, 10 for 20% PWM value, etc. This gives you a PWM with 50 possible mark-space ratios.
At 10kHz PWM frequency you only get 5 possible values.
PDM is a different way to achieve much the same effect, but it will run at a fixed frequency, equal to the base thread. Every time the function runs it decides if the time-averaged value of the output is above or below the target, and sets the output high or low accordingly.
en.wikipedia.org/wiki/Pulse-density_modulation
Please Log in or Create an account to join the conversation.
First, I think I am using the encoder, but didn't mention that. The encoder output is fed to the scale module, but I failed to mention that.
Here is what I'm using for a sensor:
cgi.ebay.com/Pre-wired-Proximity-Switch-...976b1#ht_3202wt_1142
(I used Ron Steele's guide to retrofit CNC a HarborFreight 7x10 lathe and this is similar to what he recommended.)
As far as I can tell it just emits a pulse once every rotation. And it seems that the reading I'm getting in the postprocessing once scaled by 60 to take it to rpm from rps is correct. I checked this by running the lathe slowly for 60 seconds and counting rotations which matched the readout.
I have no problem writing a custom component if needed but was hoping to avoid this.
Thanks for the education on PWM/PDM. I know my sample rate is set to 17000 ns. I'll absorb what you said and decide what to do here, but seems to me first off that PDM might work just fine.
Thanks again, if you see anything about that sensor that you can pass on I would greatly appreciate it.
Please Log in or Create an account to join the conversation.
As far as I can tell it just emits a pulse once every rotation.
Sounds very Mach3-ish
EMC2 works best with an index and multiple (hundreds) of pulses per rev, but you should be able to make it work with one PPR.
You need to connect the incoming pulse to both the encoder index and pulse channels (A and Z), connect encoder.0.position-interpolated to motion.spindle-revs and set the encoder.0.scale to 1.
Let us know how that goes.
Please Log in or Create an account to join the conversation.
I tried to hard code motion.spindle-on to 1 in my .hal file and EMC2 didn't like that.
How do I get the motion object to correctly process the spindle-speed-in and know it's on? And how do I get the RPS input to RPM output (that I assume I need)
Rus
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
I have the lathe running under EMC2.4.3 with Ubuntu 10.04, and the input pin 15 is correctly receiving the spindle index signal (I checked it with the HAL Meter and HAL Scope - cool features)
I understand what is to be done conceptully here, but don't understand the syntax that I need to write in my .HAL file to get this happening.
"You need to connect the incoming pulse to both the encoder index and pulse channels (A and Z), connect encoder.0.position-interpolated to motion.spindle-revs and set the encoder.0.scale to 1. "
How do I do that?
"I've gotten closer I think, and now have the motion.spindle-revs == encoder.0.position-interpolated, and motion.spindle-speed-in reading correct RPS. However motion.spindle-speed-out is zero, and motion.spindle-at-speed is False as is motion.spindle-forward. motion.spindle-on is also False."
What is the syntax to do this please?
I would really appreciate if you could post the spindle portion of your .HAL file please Rus.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Here's the section:
addf stepgen.capture-position servo-thread
addf encoder.capture-position servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf stepgen.update-freq servo-thread
addf abs.0 servo-thread
addf scale.0 servo-thread
net spindle-cmd <= motion.spindle-speed-out
setp encoder.0.position-scale 1.000000
setp encoder.0.counter-mode 1
net spindle-position encoder.0.position-interpolated => motion.spindle-revs
net spindle-velocity encoder.0.velocity => motion.spindle-speed-in
net spindle-index-enable encoder.0.index-enable <=> motion.spindle-index-enable
net spindle-phase-a encoder.0.phase-A
net spindle-phase-a encoder.0.phase-Z
...
net spindle-phase-a <= parport.0.pin-15-in
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
- Configuring LinuxCNC
- Configuration Tools
- StepConf Wizard
- Configuring Spindle Feedback with Proximity Sensor