Hi people, i'm still having a headache with this system.
My circuit design is slightly different from @jim-p circuit (no diodes and non-inverting comparator setup), and rn having weird behavior as you'll see in the scope screenshots.
First, this is my current design: sorry if it's messy but it's just a 5min-chaos-drawn comparator just for these tests. Everything is soldered in place in a perfboard.
The most significant changes ive made are: adding a potentiometer instead one of the two resistors of the voltage divider to have a trimmable 0-2.5v threshold and a setup a voltage divider instead of double power 5v/3v3 to have a 3v3ish output.
all external connections are done with dupont females to another really simple perfboard like this:
12v + and - > to the car battery and to a small chinese buck converter set to 5v3A.
5v output from the dcdc and gnd (same as car) hooked to a esp32s3supermini and brought out with two 20cm wires to the comparator board.
gpio8 of the uC > to the out_3v3 pin.
Now, this is what i see with the scope:
ch1 (yellow) is hooked up to the sensor + pin.
ch2(blue) is hoohed up to the output central node of the voltage divider.
ch3(purple) is hooked up to the central pin of the pot (threshold)
all probes gnd to the battery -/car chassis.
Problem: the threshold trimmer doesnt behave as expected. if I set the threshold to 2.3v and below, the "0" level of the sensor shifts up alot, as you can see here:
and the output goes always high.
So i cant do fine adjustments to the threshold, and can capture only really high spikes with very much inconsistency(scope snapshots with input hidden):
While writing this post, i realized i probably hooked up the trimmer in the most random way at 2am after a 12h long shift, so maybe i could fix my mistakes just by rewiring the trimmer like this:
cutting two wires and adding the blue ones.
Does it make sense? please don't judge the beginner mistakes as i'm just learning.
any heads up will be helpful.
Before hooking all up to the car, i hooked this same comparator to a 555 astable square wave generator to test thresholds and everything, and it seemed working quite fine, here's the scope snapshots:
as you can see, during breadboard bench tests, adjusting the threshold as little as 0.06v would shift the output from a clean low to a pretty clean square wave.
What am I getting wrong? would that rewiring of the pot solve my headache? any better ideas?
Appreciate everybody's help as it makes my brain bigger