I am a beginner concerning electronics and would love to learn something new. I have a Teensy 4.1 and would like to calculate an encoder's speed. The encoder is built in into a system which supplies it with 12V. So the output I can get is a square wave with too high of a voltage level.
Since the µC cannot cope with such high voltages I need to use a voltage divider.
To get the correct ratio I have chosen R_1=7.5kOhm and R_2=3kOhm. I have also added Schottky Diodes to clamp the voltage between -0.2V and +3.5V.
When I connect everything according to the following schematic and measure between µC input pin and GND I get the following measurment on the scope, not exactly what I expected. Note that the different motor speed, so higher pulse frequency is not the point, the shape of the signal is unexpected.
Schematic (note that I used an Arduino Nano in the drawing, the program did not have a Teensy to wire things up:
Do you have an idea of what could have gone wrong here? Of course I have done a compensation of my scope before measuring. With the voltage divider applied I get negative spikes which I can compensate all the way down to -200mV. This is within range of the DIO ports so should be fine. The rising edge can be detected by the µC, so all is fine but I would just like to understand where the capacitance comes from.Is this a common effect? Can I somehow compensate this so that I get more of a rectangle? Do I need to connect it up differently?
I could be happy with the results I have since I still have a nice rising edge to trigger an interrupt on the µC, however I would still like to understand what is happening here. I would have just expected a square wave with a lower HIGH-level.
Would be happy to learn what is happening here!
EDIT: I have attached a nicer looking schematic and both measurements in one graph. I have now changed to a Teensy 4.1 since that will be the more long term solution for this application. Many people mentioned a capacitive coupling, would this likely be from the driving circuit? As stated, it is a black box, so I do not have any information on the driving circuit. I need to use the 12V encoder, I could also probably drive it from a µC pin with some sort of circuitry making it possible to supply 12V, but I thought since I already have a working system I could just tap into it and use the signal.
To rule out measurement errors I have soldered a nice ground lead to the GND pin to hook my scope onto. I must confess the initial measurements were with a crocodile clip attached to the resistor lead, thought that would be good enough. Got the same results, so I would say it was good enough haha!
I have seen threads like this, could this be my problem and I could compensate it with caps in parallel to the resistors in my voltage divider? I always thought I needed an inductor to counter the effects of a capacitor, what am I thinking wrong here?
Thanks for your help already!