Spindle Pulses Lost in System
- 10K
-
Topic Author
- Offline
- Premium Member
-
Less
More
- Posts: 142
- Thank you received: 32
28 Jan 2025 18:08 #320003
by 10K
Spindle Pulses Lost in System was created by 10K
My lathe spindle originally had an Index pulse and 10 encoder pulses per revolution. From the problems discussed in
forum.linuxcnc.org/38-general-linuxcnc-q...peed?start=40#319800
I thought it would be better if I generated more than 10 pulses per spindle revolution.
I built a ring to fit on my lathe pulley with 180 teeth. I picked this size because it had the most teeth that I though I could machine. They were about 1/16" width and depth. I found that the proximity probe I was using could not detect these small teeth. I replaced it with a Hall Effect Sensor =11.0ptS38J-22ADSO-5KJA5 from Standex Electronics. Here's the installation:
Here's what the output looks like at 400 RPM on my oscilloscope:
This is about 24V. The frequency of the signal is about 6 cycles in 5 mS, or 1,200 Hz. Expected signal is 180 pulses * 400 RPM / 60 = 1,200 Hz. So far, so good.
The signal goes into a breakout board with optoisolators. I can see the signal on the input and output side of the optos, so I know it's going into the circuit OK. I don't see any missed pulses on the oscilloscope. The breakout board feeds a Mesa 7i92.
When I pull up the encoder inputs in HalScope, I see:
Not good. I should see 180 pulses between the index pulses. I'm seeing about 10. Plus, one of the index pulses is missing.
I have a separate DRO that also displays the spindle RPM. If I compare it to the RPM shown on LinuxCNC, they match from 0-150 RPM, then for higher speeds LinuxCNC shows speeds lower than 150. So if the lathe is at 500 RPM on the DRO, LinuxCNC shows about 60 RPM. Again, I can see on the oscilloscope that I'm getting all the pulses.
Here is my .INI and .HAL files. Any ideas?
forum.linuxcnc.org/38-general-linuxcnc-q...peed?start=40#319800
I thought it would be better if I generated more than 10 pulses per spindle revolution.
I built a ring to fit on my lathe pulley with 180 teeth. I picked this size because it had the most teeth that I though I could machine. They were about 1/16" width and depth. I found that the proximity probe I was using could not detect these small teeth. I replaced it with a Hall Effect Sensor =11.0ptS38J-22ADSO-5KJA5 from Standex Electronics. Here's the installation:
Here's what the output looks like at 400 RPM on my oscilloscope:
This is about 24V. The frequency of the signal is about 6 cycles in 5 mS, or 1,200 Hz. Expected signal is 180 pulses * 400 RPM / 60 = 1,200 Hz. So far, so good.
The signal goes into a breakout board with optoisolators. I can see the signal on the input and output side of the optos, so I know it's going into the circuit OK. I don't see any missed pulses on the oscilloscope. The breakout board feeds a Mesa 7i92.
When I pull up the encoder inputs in HalScope, I see:
Not good. I should see 180 pulses between the index pulses. I'm seeing about 10. Plus, one of the index pulses is missing.
I have a separate DRO that also displays the spindle RPM. If I compare it to the RPM shown on LinuxCNC, they match from 0-150 RPM, then for higher speeds LinuxCNC shows speeds lower than 150. So if the lathe is at 500 RPM on the DRO, LinuxCNC shows about 60 RPM. Again, I can see on the oscilloscope that I'm getting all the pulses.
Here is my .INI and .HAL files. Any ideas?
Attachments:
Please Log in or Create an account to join the conversation.
- tommylight
-
- Online
- Moderator
-
Less
More
- Posts: 19995
- Thank you received: 6789
28 Jan 2025 18:26 #320004
by tommylight
Replied by tommylight on topic Spindle Pulses Lost in System
Slow optocouplers.
Better quality BOB should help, or just get 2 fast optos.
Better quality BOB should help, or just get 2 fast optos.
Please Log in or Create an account to join the conversation.
- PCW
-
- Offline
- Moderator
-
Less
More
- Posts: 18388
- Thank you received: 5020
28 Jan 2025 18:30 #320005
by PCW
Replied by PCW on topic Spindle Pulses Lost in System
Halscope (and a software encoder) cannot reliably "see" pulses shorter
than the sample period (4 ms in this case).
That would be fixed by using firmware with a hardware encoder and using
the hardware encoder rather than LinuxCNCs software encoder component.
than the sample period (4 ms in this case).
That would be fixed by using firmware with a hardware encoder and using
the hardware encoder rather than LinuxCNCs software encoder component.
Please Log in or Create an account to join the conversation.
- 10K
-
Topic Author
- Offline
- Premium Member
-
Less
More
- Posts: 142
- Thank you received: 32
29 Jan 2025 14:01 #320085
by 10K
Replied by 10K on topic Spindle Pulses Lost in System
Thanks for the feedback.
Tommylight-
I don't think it's the optoisolators. They're supposedly good to 80 kHz. Also, I confirmed with an oscilloscope the opto input AND output signals are present up to 3,000 RPM (9kHz), and it all looks to be working. The optos are certainly inexpensive 817C. Do you have specific experience with this being a problem?
PCW-
As I mentioned, I have a Mesa 7i92. Is there a hardware encoder that's compatible with this that you'd recommend? I don't have quardrature, just an index and A signal.
Tommylight-
I don't think it's the optoisolators. They're supposedly good to 80 kHz. Also, I confirmed with an oscilloscope the opto input AND output signals are present up to 3,000 RPM (9kHz), and it all looks to be working. The optos are certainly inexpensive 817C. Do you have specific experience with this being a problem?
PCW-
As I mentioned, I have a Mesa 7i92. Is there a hardware encoder that's compatible with this that you'd recommend? I don't have quardrature, just an index and A signal.
Please Log in or Create an account to join the conversation.
- tommylight
-
- Online
- Moderator
-
Less
More
- Posts: 19995
- Thank you received: 6789
29 Jan 2025 15:21 #320089
by tommylight
Replied by tommylight on topic Spindle Pulses Lost in System
Why is your hal scope running at 250Hz? It usually runs at 1000Hz.
And yes, i had issues with cheap BOB's so i stopped using them, some could not do 5KHz properly, but i do have one that uses no optos and is very fast but consequently lacks isolation, hence it also collects dust in the shop.
Some things to notice, BOB's are almost always 5V devices, putting 24V encoders on the inputs might not be healthy for the optos, but again, depending on how they are wired, might also be perfectly OK.
How do the pulses look on the output of optos AND Mesa inputs?
And yes, i had issues with cheap BOB's so i stopped using them, some could not do 5KHz properly, but i do have one that uses no optos and is very fast but consequently lacks isolation, hence it also collects dust in the shop.
Some things to notice, BOB's are almost always 5V devices, putting 24V encoders on the inputs might not be healthy for the optos, but again, depending on how they are wired, might also be perfectly OK.
How do the pulses look on the output of optos AND Mesa inputs?
Please Log in or Create an account to join the conversation.
- PCW
-
- Offline
- Moderator
-
Less
More
- Posts: 18388
- Thank you received: 5020
29 Jan 2025 16:03 #320092
by PCW
Replied by PCW on topic Spindle Pulses Lost in System
PCW-
As I mentioned, I have a Mesa 7i92. Is there a hardware encoder that's compatible with this that you'd recommend? I don't have quardrature, just an index and A signal.
Your current encoder should be fine but you need to use firmware that has a hardware encoder
and wire the (5V!) encoder signals to the 7I92 encoder inputs.
As I mentioned, I have a Mesa 7i92. Is there a hardware encoder that's compatible with this that you'd recommend? I don't have quardrature, just an index and A signal.
Your current encoder should be fine but you need to use firmware that has a hardware encoder
and wire the (5V!) encoder signals to the 7I92 encoder inputs.
Please Log in or Create an account to join the conversation.
- 10K
-
Topic Author
- Offline
- Premium Member
-
Less
More
- Posts: 142
- Thank you received: 32
29 Jan 2025 22:19 #320120
by 10K
Replied by 10K on topic Spindle Pulses Lost in System
tommylight-
The spec sheet on the opto says it's rated for 5-24V input, with a 30V max, so it should be OK. The output is 0-5V, so that should also be OK. I'll take a look at all the signals again when I get back to the lathe.
PCW-
It's been a while since I wired up all of this, so forgive me if I don't remember it all.
The 7i92 was flashed with G540x2D.bit
.
It appears that I mis-connected the "A" signal to the DB25 P13 / HAL 16 and the Index to DB25 P11 / HAL 14.
I'm going to move the wires around and connect them to DB25 P10 and P12 to see if that has an effect. Is that what you were referring to when you talked about Firmware?
The spec sheet on the opto says it's rated for 5-24V input, with a 30V max, so it should be OK. The output is 0-5V, so that should also be OK. I'll take a look at all the signals again when I get back to the lathe.
PCW-
It's been a while since I wired up all of this, so forgive me if I don't remember it all.
The 7i92 was flashed with G540x2D.bit
2 2 IOPort StepGen 0 Step/Table1 (Out)
15 3 IOPort None
3 4 IOPort StepGen 0 Dir/Table2 (Out)
16 5 IOPort StepGen 4 Step/Table1 (Out)
4 6 IOPort StepGen 1 Step/Table1 (Out)
17 7 IOPort None
5 8 IOPort StepGen 1 Dir/Table2 (Out)
6 9 IOPort StepGen 2 Step/Table1 (Out)
7 10 IOPort StepGen 2 Dir/Table2 (Out)
8 11 IOPort StepGen 3 Step/Table1 (Out)
9 12 IOPort StepGen 3 Dir/Table2 (Out)
10 13 IOPort QCount 0 Quad-A (In)
11 14 IOPort QCount 0 Quad-B (In)
12 15 IOPort QCount 0 Quad-IDX (In)
13 16 IOPort None
IO Connections for P1
Pin# I/O Pri. func Sec. func Chan Pin func Pin Dir
1 17 IOPort None
14 18 IOPort PWM 1 PWM (Out)
2 19 IOPort StepGen 5 Step/Table1 (Out)
15 20 IOPort None
3 21 IOPort StepGen 5 Dir/Table2 (Out)
16 22 IOPort StepGen 9 Step/Table1 (Out)
4 23 IOPort StepGen 6 Step/Table1 (Out)
17 24 IOPort None
5 25 IOPort StepGen 6 Dir/Table2 (Out)
6 26 IOPort StepGen 7 Step/Table1 (Out)
7 27 IOPort StepGen 7 Dir/Table2 (Out)
8 28 IOPort StepGen 8 Step/Table1 (Out)
9 29 IOPort StepGen 8 Dir/Table2 (Out)
10 30 IOPort QCount 1 Quad-A (In)
11 31 IOPort QCount 1 Quad-B (In)
12 32 IOPort QCount 1 Quad-IDX (In)
13 33 IOPort None
It appears that I mis-connected the "A" signal to the DB25 P13 / HAL 16 and the Index to DB25 P11 / HAL 14.
I'm going to move the wires around and connect them to DB25 P10 and P12 to see if that has an effect. Is that what you were referring to when you talked about Firmware?
Please Log in or Create an account to join the conversation.
- PCW
-
- Offline
- Moderator
-
Less
More
- Posts: 18388
- Thank you received: 5020
29 Jan 2025 22:51 #320121
by PCW
Replied by PCW on topic Spindle Pulses Lost in System
Yes, you need to both connect to the proper pins that connect
to the internal hardware encoder _AND_ modify your hal file so
it uses the hardware encoder rather than the encoder component.
That is, you will no longer have anything in the hal file that
refers to GPIO 13 or 15 nor loadrt's the encoder component
to the internal hardware encoder _AND_ modify your hal file so
it uses the hardware encoder rather than the encoder component.
That is, you will no longer have anything in the hal file that
refers to GPIO 13 or 15 nor loadrt's the encoder component
Please Log in or Create an account to join the conversation.
- 10K
-
Topic Author
- Offline
- Premium Member
-
Less
More
- Posts: 142
- Thank you received: 32
31 Jan 2025 20:54 #320255
by 10K
Replied by 10K on topic Spindle Pulses Lost in System
I moved wires around on my BOB so that the encoders are connected to the proper inputs on the Mesa 7i92.. I made some changes to the .HAL file. I got several things working:
1) The spindle speed shows up on my display, and matches what I see on my separate DRO, even at 2,000 RPM.
2) Based on Tommylight's earlier question, I figured out why my HalScope was running at 250Hz (double click on samples button, and changed divisor from 4 to 1. That change made the missed pulses go away completely, and validated my cheap Chinese BOB was not glitching.This is the first time I've ever seen 180 pulses per revolution on the HalScope.
3) I used a stopwatch to time 10 seconds, and watched hm2_7i92.0.encoder.00.count. I had calculated I should get 1440 pulses in 10 seconds at 48 rpm, and that's almost exactly what the difference was in the pulse counts before and after. That means that all the pulses are all being seen! I figured out later that I also could just rotate the chuck by hand, and see 180 counts per revolution.
The only remaining problem I have is that something is mis-configured in my .HAL. When I try to thread, the cutter moves in to position, and is either not receiving the index pulse to start or the 180 pulses per revolution or both, and is not starting to thread.
1) The spindle speed shows up on my display, and matches what I see on my separate DRO, even at 2,000 RPM.
2) Based on Tommylight's earlier question, I figured out why my HalScope was running at 250Hz (double click on samples button, and changed divisor from 4 to 1. That change made the missed pulses go away completely, and validated my cheap Chinese BOB was not glitching.This is the first time I've ever seen 180 pulses per revolution on the HalScope.
3) I used a stopwatch to time 10 seconds, and watched hm2_7i92.0.encoder.00.count. I had calculated I should get 1440 pulses in 10 seconds at 48 rpm, and that's almost exactly what the difference was in the pulse counts before and after. That means that all the pulses are all being seen! I figured out later that I also could just rotate the chuck by hand, and see 180 counts per revolution.
The only remaining problem I have is that something is mis-configured in my .HAL. When I try to thread, the cutter moves in to position, and is either not receiving the index pulse to start or the 180 pulses per revolution or both, and is not starting to thread.
loadrt [KINS]KINEMATICS
#autoconverted trivkins
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS
loadrt pid names=pid.x,pid.z,pid.s
loadrt hostmot2
loadrt [HOSTMOT2]DRIVER config=[HOSTMOT2]CONFIG
#setp hm2_7i92.0.watchdog.timeout_ns 25000000
setp hm2_7i92.0.watchdog.timeout_ns 10000000
#loadrt encoder num_chan=1
loadrt abs count=1
#0-invert is used in pendant hal file
loadrt scale names=scale.0,0-invert
loadrt lowpass count=1
addf hm2_7i92.0.read servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
#addf encoder.update-counters servo-thread
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
#addf encoder.capture-position servo-thread
addf abs.0 servo-thread
addf scale.0 servo-thread
addf lowpass.0 servo-thread
# latch all stepgen position counts 50 usec before nominal read time (add per PCW):
setp hm2_7i92.0.dpll.01.timer-us -50
setp hm2_7i92.0.stepgen.timer-number 1
# increase tolerance to read errors
# setp hm2_7i92.0.packet-read-timeout 30 --removed per pcw 12/25/24
setp hm2_7i92.0.packet-error-limit 100
# ---setup spindle---
# set the HAL encoder to 180 pulses per revolution.
setp hm2_7i92.0.encoder.00.scale 180
# set the encoder to non-quadrature simple counting using A only.
setp hm2_7i92.0.encoder.00.counter-mode true
# connect the HAL encoder outputs to LinuxCNC
net spindle-position hm2_7i92.0.encoder.00.position => spindle.0.revs
net spindle-at-speed => spindle.0.at-speed
net spindle-velocity-feedback-rps hm2_7i92.0.encoder.00.velocity => spindle.0.speed-in
net spindle-index-enable hm2_7i92.0.encoder.00.index-enable <=> spindle.0.index-enable
net spindle-phase-a hm2_7i92.0.encoder.00.input-a
#net spindle-phase-b hm2_7i92.0.encoder.00.input-b
net spindle-index hm2_7i92.0.encoder.00.input-index
# ---probe signal---
net probe motion.probe-input <= hm2_7i92.0.gpio.020.in
# --- ESTOP-EXT ---
net estop-ext <= hm2_7i92.0.gpio.014.in_not
# --- BOTH-HOME ---
net both-home-x <= hm2_7i92.0.gpio.016.in
net both-home-z <= hm2_7i92.0.gpio.003.in_not
Attachments:
Please Log in or Create an account to join the conversation.
- PCW
-
- Offline
- Moderator
-
Less
More
- Posts: 18388
- Thank you received: 5020
31 Jan 2025 21:09 #320258
by PCW
Replied by PCW on topic Spindle Pulses Lost in System
Check that the counts are going up (the count direction depends on the state of the 'B' encoder input)
Please Log in or Create an account to join the conversation.
Time to create page: 0.203 seconds