I'm working on updating our products, but there are a number of constraints. TL;DR I can't change the parts that would make this really easy.
We have devices that interface to our control panel using a three wire system. +24 VDC, 0 VDC and a signal line (bi-directional) that roughly varies 0 to 5 VDC. People do all kinds of fun things in the field and we get more then the allotted voltage on the signal line (~ > 5 VDC). I can't protect against everything but I know what the common failures are and I can work to stop that from being an issue. I'm thinking I can use an op-amp diode clamping circuit to get what I want (a peak clipper/clamper). I want the voltage to vary 0 VDC to 7 VDC, and anything over 7 VDC to + 24 VDC just gives me 7 VDC out of the op amp. I can scale that back down to the 0 VDC to 3.3 VDC range for the micro ADC. This allows me a number of things:
- I have sufficient resolution to distinguish the voltage levels I need.
- +24 VDC on the signal line is no longer an issue.
- By extending the range of the diode clamping and down scaling, I have a new state where we can determine that the installer did it wrong (and certain other failure modes can be seen).
So I built this circuit on a bread board today, the voltages are not the exact ones, it just a proof-of-concept and I'm limited in power supplies on hand (I'm not going to get into the failure to equip the shop correctly).
From what I found on-line this should work just dandy, but it doesn't. The op-amp is rail-to-rail in and out. All literature shows that this should vary from 0 VDC to 12 VDC smoothly then clamp at 12 VDC and not change beyond that up until the rails. I get about 7 VDC out of the op-amp with no input.
I'm doing something wrong or this isn't even right and I'm not smart enough to understand why. My knowledge is meh as my education was alright and it's been almost a decade between graduating and having to do any work that requires understanding.