Sparkfun bidirectional logic level converter is simple, cheap and effective in conversing between two voltage level.
It is amazing how two pull up resistors and N channel transistor can achieve bidirection communication between two voltage levels.
First, have a look at the circuit:
The gate of the BSS138 is connected to LV and both HV and LV are connected with 10kohm pull up resistor.
Simple.
There is only 4 scenarios, LV1 is high, LV1 is low, HV1 is high, HV1 is low. Let look at it one by one.
1. LV1 is low:
Assuming:
LV = 3.3V
HV = 5V
LV1 = 0 (ground)
I like to put figure in analysis.
From the picture above, current will flow from 3.3V to 0V, so we know that the R3 has voltage different of 3.3V.
Why?? 3.3V - 0V, we get 3.3V.
Now the BSS138 gate (G) and source (S) has voltage different of 3.3V. It will turn on the BSS138 and current from 5V will flow according to arrow 2.
In the same time, HV1 is connected to LV1, effectively HV1 is 0V.
2. LV1 is high:
Assuming:
LV = 3.3V
HV = 5V
LV1 = 3.3V
HV1 = ??
Now that LV and LV1 is 3.3V, there is not voltage different across R3, which in turn, indicate that Vgs is zero, BSS138 is not turned on.
Current from HV only able to flow to HV1. Assuming that the input resistance of HV1 is very high, HV1 will get approximately of 5V.
3. HV1 is low:
Assuming:
LV = 3.3V
HV = 5V
LV1 = ??
HV1 = 0V
from HV side, current is flowing according to arrow 1,
at LV side, current will flow from 3.3V to HV1 because
at this point, LV1 is approximately 3.3V
HV1 is equal to 0.
There is potential different for the diode in BSS138, so current will flow through the diode in BSS138.
After the circuit is completed, LV1 = HV1, which is equal to 0.
4. HV1 is high:
Assuming:
LV = 3.3V
HV = 5V
LV1 = ??
HV1 = 5V
HV and HV1 has same voltage, no current will conduct.
3.3V from LV will not flow to HV1 cause HV1 has higher voltage than LV,
so the 3.3V will flow to LV1.
if assuming that the input resistance of LV1 is very high, LV1 will get approximately of 3.3V.
Draft version:
Will edit again
Excellent tutorial. Thank you.
ReplyDelete