Now to something very simple which i always have problems with: The reset circuit. It's only made from few parts but it's
ANALOGOUS. (shiver!)
Let's start with the requirements:
For unknown reasons the 68008 CPU needs an excessively long reset pulse after power-up: 0.1 seconds! Because there are other circuits which may pull
!RESET low, most namely the CPU itself,
!RESET must be driven with an open collector or open drain output.
To the right is an image of the current circuit:
Let's discuss it.
This is very important because it's analogous and most times my analogous stuff doesn't work. :-/
Start with
R9 +
R4 and ignore the rest: These two resistors form a voltage divider for Vcc and the voltage in the middle is 2.5V. (5V/2)
Now add the capacitor: Initially it is discharged and behaves like a piece of wire. But as time goes by and current flows through it (and through the voltage divider) it charges and voltage across it increases which subtracts from the voltage present at the voltage divider. So the middle voltage of the voltage divider starts at 2.5V and drops over time to zero.
Next add transistor
T1: The first effect is that the middle voltage is shorted by the base-emitter diode of
T1 to ground, so the middle voltage is initially 0.7V, which is the break-through voltage of the diode, stays at that voltage for a while until it drops below 0.7V and resumes dropping as with no transistor present.
While there is current sinked through the base-emitter diode, the transistor switches on, sinking the
!RESET line to ground. As soon as the base-emitter voltage drops below 0.7V the transistor will switch off and
!RESET rises to Vcc. We only have to choose the capacitance and the resistors appropriately, so that this will happen after approximately 0.1 second.
But that's only half of the story: The transistor is not switched on or off depending on the voltage at it's base pin, instead the amount of current it can sink is a function of the current through the base-emitter diode. While this diode keeps the voltage at the base pin at 0.7V, the current through the diode needed to do this decreases as the voltage at the voltage divider decreases. So at some point in time the transistor is no longer fully able to sink all current from the
!RESET line but only a part of it and the voltage on the
!RESET line will not switch instantaneous to Vcc but will rise slowly.
This is totally unreliable.
!RESET must go away very fast, ideally within one CPU clock cycle. This is where
T2 and it's two associated resistors enter the game: While
!RESET is low
T2 is switched off and the circuit behaves as if
T2 wasn't there. But when
!RESET slowly rises above 0.7V
T2 will start to sink current. This will subtract from the base current of
T1 which will in return sink less current from the
!RESET line and the voltage on the
!RESET line rises even more which will open
T2 more which will ... Yes, a positive feedback and
!RESET will rise very fast once it has reached 0.7V.
Now let's examine power-up and power-down behavior.
At power-up
C1 is empty. But the state of the
!RESET line is unknown. If it rises with Vcc then
T2 will be open right from the start and may finish the reset pulse before it has been activated at all. It's very likely that it will do this because of the pull-up resistor on the
!RESET line. To prevent this the voltage at the base of
T1 must be asserted to be clearly above 0.7V when
C1 is empty: This is true with the given values for
R4,
R9 and
R12 (all 50kΩ) because when
C1 is empty the voltage at the voltage divider will be 1/3 Vcc which is approximately 1.65V and which will be sinked through the base-emitter diode of
T1, opening
T1 which will pull
!RESET low.
Check.✓
After a while capacitor
C1 is loaded (nearly) to Vcc and the input of the voltage divider is Vcc minus Vcap which is (nearly) 0V. When power is switched off, Vcc drops to 0V but the capacitor is still loaded, so the voltage at the voltage divider drops to -Vcc. We'll have to check the circuit that this does no harm.
Check.✓
Now the capacitor must be discharged, so that it is discharged when power is switched on again. This happens through the voltage divider
R4+
R9 in approximately the same time as was required to load the capacitor after power-on.
Check.✓
Last step: calculate the values.
!RESET is pulled up by a
5kΩ resistor which sources
1mA at Vcc=5V and there is some more circuitry attached, so let's say
T1 must sink
5mA.
T1 may have a current amplification of
100 (this is a value which widely varies even for transistors of the same type) so the base-emitter current of
T1 must be
~ 0.05mA.
This current must be sinked through the base-emitter diode of
T1 even after
C1 has charged to – let's say –
1/2 and the remaining voltage at the voltage divider is
2.5V. This leaves a voltage drop of
~2V across
R9. Using the formula
U=R*I <=>
U/I=R we calculate the value for
R9 =
2/0.05e-3 =
40kΩ.
Next the capacitor voltage must rise
2.5V (see above) during
0.1s while being loaded with
0.05mA. The formula for the capacitance is:
C = I*t/U. So
C1 =
0.05e-3*0.1/2.5 =
2µF. Because the calculation is very rough (actually we ignore
R4 which sinks some current as well and we should integrate the current over time because it's not const) so we double the capacitance. Fine adjustments will be made when it is built on the bread board. :-)
Note: You didn't remember the formula for the capacitance? Using ISO units (not inch, miles and gallons) you don't need to look up the formula, you can construct it by pure logics:
The capacitance depends on
- Charging current: higher current => higher capacitance => C ~ I
- Charging time: Current supplied for longer time => higher capacitance => C ~ t
- Voltage increase during charging time: Higher voltage increase allowed => less capacitance required => C ~ 1/U
- Using ISO units there will be no constant factor in the formula. Yeah!
- therefore: C = I * t / U.
Alternatives
We could use a timer IC for the reset circuit, most likely a 555. But this would have a larger footprint than the discrete solution. Else we could use a mono-flop from the 74 series. But basically this increases the footprint even more (14 pin DIP instead of 8 pin DIP).
Or use a counter. But even if fed from the E output of the CPU (which is CLK/10) we'd need to count up to 100,000 for 0.1 seconds which is impractical.
I have also seen using a PIC for reset (basically because the project used a PIC for various control purposes) but using a CPU to generate the reset pulse for a CPU is a little bit ... over designed.
Update: Reset Circuit Test on the Bread Board
Today i tested the circuit and as expected it did not work as expected. Let's see why. For your convenience to the right is another image of the circuit.
As discussed above resistor R12 must be high enough so that T1 actually switches on at power-up.
Full flip requirement:
But there's another requirement for R12: It must be able to sink the whole current which flew through the base-emitter diode of T1 when T2 switches on. Else there will be some base current left at T1 and it will not fully close and therefore the voltage at the reset line will not fully rise to +5V.
To estimate this current is a little bit tricky: It depends on the pull-up current on the reset line and the transistor's current amplification. Worst case is high pull-up current and low current amplification:
• ICE = 5 mA
• hFE = 100
=> IBE ≥ 5mA/100 = 50µA
R12 ≤ UR12 / IR12 = (0.65V-0.2V) / 50µA = 9kΩ
where 0.65V = break-through voltage U
BE of the transistor's base-emitter diode
and 0.2V = saturation voltage U
CE between collector and emitter.
So R12 must be
at most 9kΩ to ensure a full flip when T2 opens.
Power-up requirement:
Immediately after power-on we require that T1 opens, even if T2 is also open due to the pull-up resistor on the reset line. For practical reason we assume C1 not completely empty but discharged to 1V, which leaves 4V at R9. So the current across R9 is:
IR9 = (4V-0.65V) / 50kΩ = 67µA
where 0.65V = break-through voltage U
BE of the transistor's base-emitter diode
This current now flows through R4, R12 and T1:
I
R4 = 0.65V / 50kΩ = 13µA
I
BE ≥ 50µA
I
R12 ≤ (67µA-13µA-50µA) = 4µA
R12 ≥ (0.65V-0.2V) / 4µA = 112.5kΩ
where 0.65V = break-through voltage U
BE of the transistor's base-emitter diode
and 0.2V = saturation voltage U
CE between collector and emitter.
So R12 must be
at least 112.5kΩ to ensure that T1 is initially open at power-up even if T2 is open.
Gotcha! We're trapped!
Can we solve this?
First, we were calculating with worst-case values. We could require better worst cases. Second, we can adjust R4.
Power-up requirement with new R4 value:
R4 is used to make the circuit a bit independent of the current amplification of T1 and of the pull-up current on the reset line and it is needed to discharge C1 when power is off. We can't remove it entirely but we could double it's value which will half the current through it and redo the above calculations:
IR4 = 0.65 / 100kΩ = 6.5µA
IBE ≥ 50µA
IR12 ≤ (67µA-6.5µA-50µA) = 10.5µA
R12 ≥ (0.65V-0.2V) / 10.5µA = 43kΩ
Now R12 must be at least 43kΩ to ensure that T1 is initially open at power-up even if T2 is open. Much better. :-)
Full flip requirement with reduced maximum pull-up current on the reset line:
The other two screws are the current amplification of T1 and the pull-up current on the reset line.
The allowed pull-up current was defined as 5mA which means a pull-up resistor as low as 1kΩ. Let's reduce this to 2.5mA which is still much more than we expect, because the actually used value is 5kΩ, but there may be some current added from the attached devices, though this should be negligible. Let's redo the calculations:
IBE ≥ 2.5mA/100 = 25µA
R12 ≤ UR12 / IR12 = (0.65V-0.2V) / 25µA = 18kΩ
So R12 must be
at most 18kΩ to ensure a full flip when T2 opens.
Power-up requirement with reduced maximum pull-up current on the reset line:
IR4 = 0.65 / 100kΩ = 6.5µA
IR12 ≤ (67µA-6.5µA-25µA) = 35.5µA
R12 ≥ (0.65V-0.2V) / 35.5µA = 12.75kΩ
So R12 must be at least 12.75kΩ to ensure that T1 is initially open at power-up even if T2 is open.
Both requirements are met if we
use 15kΩ for R12.
Fine. :-)
|
Reset circuit with validated resistor values |
To the left is the updated reset circuit as tested on the bread board. Actually i had still problems with the power-up reset if C1 was not completely empty, but that was due to a LED which i connected to the reset line to show it's state. It had clearly more than 5mA.
:-)