Pages: [1]   Go Down
Author Topic: 3.3v to 5v inverter by bc547  (Read 2857 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i was wondering is there any method convert the 3.3 v logic of  sdcard to 5 v of arduino bu using NPN or PNP transistors like bc547 and bc557. do we need to use level shifter ic and so then to use which ic
i have an SD breakout board
Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 71
Posts: 1641
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You can indeed.
The diagram attached works for both BJT's and MOSFETs (though for FETs you omit the 4.7k resistor).
It is also bidirectional so can shift up and shift down.
It is non-inverting so won't mess around with the signal.


For SD cards though you can just get away with a 1.8k and 3.3k resistor forming a potential divider to shift the signals from the Arduino down to 3.3ish volts. For the MISO signal, you can just connect it directly to the arduino as it will happily register 3.3V as a logic 1.

(P.S. Sorry for the zigzzaggy resistors, the program I drew that in favours those to the box ones)


* Transistor Level shift.png (4.29 KB, 326x189 - viewed 172 times.)
Logged

~Tom~

Rapa Nui
Offline Offline
Edison Member
*
Karma: 52
Posts: 1990
Pukao hats cleaning services
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Mind that for fast signals (ie sdcard's one) you need to drive the CMOS inputs (ie sdcard's inputs) with low impedance output drivers (ie push-pull as it is with atmega). The transistor level shifter might work with TTL logic, but with high impedance CMOS inputs (ie 10Meg || 10pF) it will not maintain the fast edges (because ie low->high transition will be done by 10k push only)..
Better you use low value resistors dividers or a none-inverting driver..
Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 71
Posts: 1641
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yeah, that circuit works best when you replace the BJT with a MOSFET. But it shows that it is possible to use BC547s for this purpose.

I have use just resistors in the past with no issues at all.
Logged

~Tom~

0
Offline Offline
Edison Member
*
Karma: 44
Posts: 1471
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Resistors fail for some newer SD cards that have edge detectors. The SD specification requires clock rise time and fall time to be less than 10 ns.

Worse is the fact that the errors in write data won't be detected.  There is no CRC by default since Arduino has no hardware support.

The latest version of SdFat supports software CRC but this slows transfers.

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

so i think the best way is to use mosfet's. i am thinking about BSS138.
but the device needs to be truly bi-directional as there will be communiction between arduino and SD card
Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 71
Posts: 1641
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That MOSFET should be fine.

Gate goes to B in the diagram
Source goes to E
Drain goes to C

Remove the 4.7k resistor and connect the gate directly to 3.3v

You may find if there is a lot of stray capacitance that you need to reduce the two other resistors down to about 1k to get a fast enough rise time.

There is an adapted version of the circuit which uses two MOSFETs to drive the signal which means that both rising and falling edges are sharp.
« Last Edit: August 22, 2012, 01:40:50 pm by Tom Carpenter » Logged

~Tom~

Rapa Nui
Offline Offline
Edison Member
*
Karma: 52
Posts: 1990
Pukao hats cleaning services
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

See the resistors dividers below - the more traditional values with 1k8/2k2 and 220/390 as well. You can go even lower with resistors' values, though.
And the mosfet variant smiley


* 1k8 sd.jpg (70.93 KB, 1110x589 - viewed 79 times.)

* 220 sd.jpg (69.88 KB, 1111x597 - viewed 60 times.)

* fet2.jpg (57.93 KB, 935x633 - viewed 70 times.)
« Last Edit: August 22, 2012, 02:12:13 pm by pito » Logged

SF Bay area
Offline Offline
Sr. Member
****
Karma: 2
Posts: 266
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

what oscilloscope did you use?
Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 71
Posts: 1641
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I would assume it is a software simulation. In reality the MOSFET version doesn't result in those peaks.
Logged

~Tom~

Pages: [1]   Go Up
Jump to: