Shop OBEX P1 Docs P2 Docs Learn Events
Shifting the reference ("ground") level using Prop 2 pins — Parallax Forums

Shifting the reference ("ground") level using Prop 2 pins

I've been working on a device that has P2 talk to an SPI peripheral that has its 3V logic levels shifted up by 2V (i.e. LO=2V, HI=5V).

P2's IO is powered from GND@0V, VCCIO@3.3V, the SPI peripheral is at GND@2V, VCC@5V. The logic levels are shifted by 2V between the devices. It turns out that a very simple circuit can leverage P2's current sink mode and make it work in either direction.

P2 IO pin is connected to the anode of a 2V Zener diode paralleled with a 0.1uF capacitor. The cathode goes to the SPI peripheral pin. A 1k pullup is needed on the SPI perhipheral's input/bidirectional pins only. The principle of operation is that the Zener maintains ~2V DC translation shift voltage across the capacitor, the latter otherwise appearing as a short to rising/falling signal edges.

P2 outputs are driven hard (HHHLLL=%000_000), while P2 inputs are driven low (DRVL) with a 100uA current sink (LLL=%101), providing bias current. This ensures proper biasing of the Zener, and thus the level translation shift action is maintained. The pull-up drops 0.1V at 0.1mA bias current.

The cost is <= $0.10 per signal in high quantity SMT. The impedance of the Zener doesn't matter much, since the capacitor bypasses the fast logic edges around it.

YKu07Bs.png

For slower inputs, using the programmable comparator and a series current limiting resistor all by itself is sufficient. That's the P=%110x_CDDDDDDDD pin mode. The SPI peripheral's CMOS 50% logic threshold voltage is at (2V+5V)/2=3.5V - above P2's VCCIO, but we can use 33% threshold level instead, and that would be 2V + 0.33*3V = 3.0V. That means the DAC level 255*3.0/3.3=232 = %1110_1001, so P=%110x_11101001. This will work OK as long as the RC time constant is acceptable (R being the series resistor value, and C being the P2 input pin's capacitance).

Comments

  • jmgjmg Posts: 15,173
    kuba wrote: »
    P2's IO is powered from GND@0V, VCCIO@3.3V, the SPI peripheral is at GND@2V, VCC@5V. The logic levels are shifted by 2V between the devices.
    That's certainly a strange interface :)

    kuba wrote: »
    P2 IO pin is connected to the anode of a 2V Zener diode paralleled with a 0.1uF capacitor.
    Nice use of P2 pin current mode, but keep in mind the very low voltage zeners are very soft, and can vary over a volt over a bit more than a decade of current.
    A LED may be better at ~2V drop ?

  • jmg wrote: »
    kuba wrote: »
    P2 IO pin is connected to the anode of a 2V Zener diode paralleled with a 0.1uF capacitor.
    Nice use of P2 pin current mode, but keep in mind the very low voltage zeners are very soft, and can vary over a volt over a bit more than a decade of current.
    A LED may be better at ~2V drop ?
    Precisely what I was thinking earlier and a green LED at that 1ma current should be close to 2V. But why a 0.1uF cap for "fast edges". That's way too much capacitance, I would have though that a few hundred, even 1,000 pFs would do the trick.

  • The cap is what I had available on the rest of the BOM without adding a yet another line item. It doesn't matter that it's "too much", as long as the "heft" of the part doesn't make it too far from ideal at the slew rates in use. 0.1uF 0402 parts seem just fine, and the Zener's softness seems not to mess up the signals in my application, and it was IIRC cheaper than alternatives - but market conditions vary well enough that if someone needs a kludge like this that's more dependable, and has a few reels of free LEDs hanging about, then it sure will be a stiffer arrangement.

    The important bit is that at the RC time constants involved, the Zener's voltage is "almost constant", and that's why the larger capacitor helps: it's not only about overcoming the Zener's impedance, but also about stabilizing the voltage on it in light of varying bias current.

    In the end, I redesigned the power supply scheme for the entire thing so that the peripheral could be brought down to the common 0V reference level. It required generating a floating 5V supply that could be shifted to be zero centered, i.e. -2.5V ... +2.5V range. With that done, the peripheral's needs were accommodated, and the kludge could disappear. But given that the "kludge" is some resistors, capacitors, and Zeners, and the "unkludging" took a low noise push-pull driver, a transformer, rectifier bridge, and a passive filter in front of the LDO (taken away from the former 0-5V duty) - it's a bit in the eye of the beholder as to what's more "kludgy". I'm fine with generating a plethora of voltages - it seems that any serious mixed-signal system nowadays takes half a dozen voltages just to come up to a DC steady state anyway :)
Sign In or Register to comment.