The situation (working)
I have a CNC router, which I occasionally use to mill PCB’s.
I made an RPM counter for the spindle using a TCRT5000:
A temporary setup is holding the sensor above the fan, which rotates at the same speed as the spindle. The signal is read by an Attiny412 and the rpm is displayed on a TM1637 display. I tested it using my Dremel (not shown here) and it has no problems working at 600 Hz (36000 rpm). My spindle only goes up to 180 Hz.
The problem (not working)
The spindle is controlled separately from a box outside of the cabinet via a 100 Vdc PWM signal. I want to place the microcontroller and display in that same box. For this I bought a 7x1.5 mm2 (15AWG) automotive cable at a local hardware store and connected it as follows:
Only the sensor and the 2 resistors are inside the cabinet. The microcontroller and display are at the box outside the cabinet. The counter works as expected as long as the spindle is off. As soon as I turn on the spindle, the rpm output becomes erratic.
What I have tried so far
First, I looked at the 5V at the sensor. It showed spikes at a frequency of 16.7 kHz:
After placing a 10 uF capacitor in parallel at the sensor side it looked like this:
The output of the rpm counter was still erratic, so I placed a 33 nF capacitor between the sensor input and ground. The rpm counter is now working, although not very stable. The signal at the input of the microcontroller looks like this for maximum spindle speed:
and like this for minimum spindle speed:
The values of the capacitors were found by trial and error. It is now almost working as intended, but I don’t know how to improve this even further.
My Question
What can I do to improve? Do I need a different cable or better filtering perhaps? Any help is appreciated.
I have a CNC router, which I occasionally use to mill PCB’s.
I made an RPM counter for the spindle using a TCRT5000:
A temporary setup is holding the sensor above the fan, which rotates at the same speed as the spindle. The signal is read by an Attiny412 and the rpm is displayed on a TM1637 display. I tested it using my Dremel (not shown here) and it has no problems working at 600 Hz (36000 rpm). My spindle only goes up to 180 Hz.
The problem (not working)
The spindle is controlled separately from a box outside of the cabinet via a 100 Vdc PWM signal. I want to place the microcontroller and display in that same box. For this I bought a 7x1.5 mm2 (15AWG) automotive cable at a local hardware store and connected it as follows:
- YELLOW – spindle 100 Vdc PWM
- BLUE – spindle ground
- GREEN – chassis ground
- RED – sensor 5V
- BLACK – sensor ground
- WHITE – sensor signal
- BROWN – NC
Only the sensor and the 2 resistors are inside the cabinet. The microcontroller and display are at the box outside the cabinet. The counter works as expected as long as the spindle is off. As soon as I turn on the spindle, the rpm output becomes erratic.
What I have tried so far
First, I looked at the 5V at the sensor. It showed spikes at a frequency of 16.7 kHz:
After placing a 10 uF capacitor in parallel at the sensor side it looked like this:
The output of the rpm counter was still erratic, so I placed a 33 nF capacitor between the sensor input and ground. The rpm counter is now working, although not very stable. The signal at the input of the microcontroller looks like this for maximum spindle speed:
and like this for minimum spindle speed:
The values of the capacitors were found by trial and error. It is now almost working as intended, but I don’t know how to improve this even further.
My Question
What can I do to improve? Do I need a different cable or better filtering perhaps? Any help is appreciated.