loading

Newer, simple and better protection circuitry

Type C Set the clamping voltage with one resistor and improved performance. (step 1)

Type D No resistor, the ULN2004 alone protects up to 7 inputs. (step 2)

Protection circuitry is meant to protect against the " whoops..I didn't meant to.........."

It also can be used to permanently connect to external circuitry which has different logic and supply voltage.

Protection circuitry only protects Raspberry Pi pins;

It doesn't safely connect for all logic families and supply voltages

If the external circuitry will blow its self up when shorted to ground, it is likely to blow itself up when connected to protction circuitry.

How to blow up and not blow up external circuits connected to protection circuitry (step 3)

You will be glad to know that no ULN2803/2003/2004 were blown up.

Step 1: Type C

( I was measuring the input current of the ULN2803 buffer wired as a protection circuit, by using a 1.0kohm resistor between the Base and the Collector. It was 90uA. The clamping voltage (V1) was 90mV higher.)

Type C has a 10kohm (Rf) between Base and Collector (see figure 5) and the clamping voltage is 2.5v (see step 4 figure 4). The internal diode is not used, which improves performance (Rs is now halved to 1.03 ohm). Each buffer may be individually set to a clamping voltage by one resistor. Each buffer is independent, with no interaction through the diodes. The Raspberry Pi's input is connected to the output (collector) pin as before.

Other advantages are ;-

1. Each protection circuit is independent. The other buffers can be normal output, or another protection circuit or constant current.

2 The logic levels for the Pi's input are better defined. Up to "knee" (see figure4) the input into the Pi is a 23kohm resistor. Above the "knee" voltage, active circuit works and the input is clamped (see also Step 3) .

3. Whilst protecting an input, and with no change, a "LO" from the Pi set as an output is a "LO", a "HI" is clamped but may be "read" as a "HI"( i.e. Clamping voltage level may be higher than the minimum voltage for a 1 at the external circuit. (see also Step 3))

4. If Rf is 16k then the "HI" is clamped to approx 3.0v, but the maximum input protection current must be reduced.

5. A further useful improvement is to connect two buffers outputs (on the same package) together each with their own resistor(Rf). This gives a Rs = 0.66ohm. So setting the clamping voltage to 2.1v and with a 200mA current from external circuitry the V1 will be 2.233v. (Type A = 2.5v).

Two Type C can have Rf cross connected ( see step 5, figure 7) to form a flip-flop. Each 1.0kohm load resistors may have forward biassed LEDs in series with it to indicate the state. The flip-flop's state may be changed by:-

1 a "HI" or "LO" at either input base

2. two switches to 0v, one on each base.

3. A resistor/capacitor and switch as shown in step 5, figure 7. In this case the flip-flop changes state on each closure of the switch i.e. it divides by two.

Step 2: Type D

To further simplify the protection circuit (see figure 6) use the ULN2004 and no resistor. This only works with the ULN2004 which has a 10kohm resistor at its input instead of a 3kohm in the ULN2803/2003.

The ULN2004 has some other differences. It is designed for higher (>6v) logic and it thus will not drive large (>200mA) currents from 3.3v logic. Its Data sheet ( or some of them) show that it has lower gain at its maximum current but higher gain at lower currents.

However, it makes an excellent input protection circuit. It performance is identical with a Type C (ULN2803) with Rf = 6.8kohm (see figure 4). Connecting two adjacent buffers together is does not give the same improvement in Rs as it does for Type C. If a resistor (Rf) of 10kohm is put between Base and Collector (it becomes a Type C ?), then the clamping voltage is approx 3.0v.

In a practical circuit the Base and Collector are connected. A typical layout of the ULN2004 would have each inputs of the Pi connected to each of the Bases, ( which are connected to the Collector.) If the base and the collector are disconnected (leaving the base connected to the Pi's pins) the buffer may be used as a normal (inverting) buffer.

Like Type C, two buffers can be cross-coupled to make a flip-flop. Changing the state of the can only be by pulling one base/collector to 0v (with a switch or transistor).(see step 5)

Step 3: Blowing Up and Not Blowing Up External Circuitry

"Blowing up" external logic when connected to Protection Circuitry (Types A,B,C,D)

In part 1, the imaginary example of a 50v power supply was short circuited ( and probably blowing up) and using a (very hot) 100ohm resistor saved it. In this part a more realistic example ...

I chose a CMOS logic circuit that gave a larger than standard current output. In the example below the external logic is directly connected to the protection circuit and a buffer set to 1 ("HI")

The external logic circuit was a hex buffer CD4050B (not CD4050A). At 5v supply, source current 6.4mA per buffer. Max dissipation 96mW for six buffers. OK... At 10v source current 12.5mA. Max dissipation per CMOS buffer 93mW. OK..... At 15v, source current 35mA. Max dissipation per CMOS buffer 437mW. It blew. I was surprised, but I shouldn't have been, when it stopped working. If I had shorted the CMOS buffer to 0v with 15v supply, and set the buffer to 1 , it would have blown.

1. The protection circuit protects the Raspberry Pi. It does not provide a safe logic level conversion for all logic types and voltages by direct connection.

2. If an external circuit will be damaged by a short-circuit, then it is likely to be damaged by direct connection to a protection circuit. (In the above example, with 10v and shorted, it would have overheated. Because the protection circuit absorbed 25% of the power, (2.5v x I max) and the max current was reduced (from 14mA to 12.5mA) the CD4050B just survived. Connect the all six CMOS buffers to protection circuits and it would overheat!)

Putting a resistor (1.0kohm) in the 15v example reduces the I max to 13mA, ( 26mW per buffer) Survival!

Not blowing up the external circuitry

First find out if it will survive if shorted to ground. First way is to short it and check the temperature. Second way is to go to the data and, work out the short-circuit current, work out the power, and work out if the power will cause the manufacturer's maximum recommended temperature to be exceeded. Put like this, it is either wasteful or difficult.

So far I haven't found ( or been told of) any 5 volt logic that cannot be directly connected. The JEDEC specifications state that " CMOS may be damaged by short circuits to Vdd or Vss with supplies greater than 5v".

For other logic families and supply voltages put a resistor between the external circuitry and the protection. 1.0kohm usually. Lower resistance values pass enough current to heat the protection circuitry. (JEDEC) "CMOS actual dissipation should be checked when driving low impedance loads." Alex Eames (RasPIO) uses 330 ohm in his protection method.

Why not use it all the time? Because with some of the logic connected it won't work. (The protection circuitry will always protect , but it may not pass 1's and 0's!) Check if it works with 1.0kohm first.

.

.SAMPLE WORKING OUT FOR CMOS LOGIC

.

Short circuit current, dissipation, current with 1.0k to 0v, dissipation (in CMOS), dissipation with protection circuitry connected

For 4069 Hex Buffer (per buffer) and B series CMOS (The data specifies 100mW max per buffer)

Voltage 5v 10v 15v

Typical 4 20 30 mA Typical Current into Short Circuit (from graphs in data)

Power 20 200 450 mW Dissipation with Short Circuit (P=V x I)

1.0k R 2.8 6.6 10 mA Current through 1.0kohm to 0v (protect with 1kohm)

Power 6.7 21.7 50 mW in CMOS with 1.0kohm to 0v.

Power 3.3 14.4 41.6mW in CMOS with 1.0kohm to (2.5v) protection circuitry

For CD2011A (per section) and (some) A series (The data specifies 200mW over Temperature Range)

Typical 1.2 9.0 20 mA Typical Current into Short Circuit

Power 6.0 90 300 mW Dissipation into Short Circuit

Power 3.0 63 240 mW Dissipation using Direct connection to Protection Circuit

1kohm 1.0 4.3 11 mA Current through 1kohm to 0v

Power 2.5 25 40 mW In CMOS with 1kohm to 0v

Power 1.5 11 30 mW in CMOS with 1kohm Connected to Protection Circuit

The logic must be able to source more than 0.25mA ( the CD4017A can't manage that; the CD4017B can).

1 kohm resistor not needed for 5v supply, not needed for 10v A series CMOS but is needed for 10v B series CMOS


Step 4: Voltages and Currents for the General Input/Output Pins of a Raspberry Pi

This section is to introduce the limited bidirectional capability of the protection circuit

The Raspberry Pi can have its output programmed to Output and, with no alteration to the protection circuitr,y will give a LO of 0v, and a HI equal to the clamping voltage. (Section 2 and 3 have notes on adjusting the clamping voltage). The GPIO will still source or sink current, it remains protected, but it won't go above the clamping voltage

1. For a "HI" output the highest voltage is 3.3v ("5v will damage it" RPI org)
2. For a "HI" the lowest voltage is 1.3v. See Note 3. At 1.3v a max of 2mA will be sourced by the pin. (i.e initial setting of ports). If a "HI" is shorted to ground approx 3.3mA will be sourced

. 4. There are additional currents of (another) 2mA, 4mA, 8mA. This gives a maximum of 16mA These additional currents are switched on with software. The maximum average current of the Raspberry Pi must not be greater than 3mA for all the GPIO pins.

5.For a "LO" the minimum voltage is 0.0v and highest "LO" voltage is 0.8v. At 0.8v the "LO" will sink 1.6mA ? (i.e. initial setting of ports). The additional currents are the similar to above. See Note

6. When the pin is an input, "HI" is read when the voltage is between 1.3v and 3.3v. A pull-up resistor of 50kohm may be set.

7. When the pin is an input, "LO" is read when the voltage is between 0.0v and 0.8v. A pull-down resistor of 40kohm may be set.

8.The input may be set in software to be Schmidt trigger, so that noisy digital signals will not caused spurious inputs.

9. There is a diode between an input and the 3.3v supply and between the input and the 0v. (These diodes are present when the GPIO is switched to output, (I forgot to put them in!)) These are for static (i.e electrical charge) protection. I am told that the max total current that can be injected into the 3.3v through these diodes should be less than 1mA.

Note. Thus at a "HI" of 1.3v, the output can be considered as a perfect switch to 3.3v with a 1.0kohm in series with it (at switch on.). A 1.8 kohm "pull up" resistor as used on the SDA and SCL will require the "LO" output to sink current.

About This Instructable

141views

7favorites

License:

More by aeb1:Protecting Pi Inputs (Part 2)........even Simpler Stepper Motor Driving With Less Pins Protect Raspberry Pi Inputs......simple  (Part 1) 
Add instructable to: