# Converting 5v to 3.3v and vice-versa



## ste2425 (Jan 29, 2015)

Hi guys.

You might have seen a few posts recently of me building a NES Box with a Raspberry PI.

Well im nearly finished but i need a little help from your generous selves with regards to wiring the original controllers.

I'm using a driver called SnesDev to map the controller buttons to keyboard keys for use with emulators but that's not really important.

The original controllers run on 5v, whilst the rpi GPIO pins can only handle up-to 3.3v. 

So my question what is the best method to convert these voltages. 

The NES controller requires power, ground, data output, clock and latch pins from the rpi. 

Now the fun bit. There are apparently three types of controllers.


Some NES controllers will be fully functional at 3.3v across the board. 
Some require 5v input but will run on 3.3v for the latch and clock pin meaning the output data pin will have to be converted down to 3.3v
The last sort require 5v across the board. Meaning the data out pin will have to be converted from 5v to 3.3v but also the 3.3v clock and latch pins will have to be converted up to 5v for the controller to work with them.
Now my controller falls into category 2. When running of 3.3v nothing would work. I briefly connected it to the 5v instead and everything fired into life. However i don't want to run it like this without bringing the data pin down to 3.3v for fear of damaging my rpi.

So what options do i have to bring the 5v data out pin down to 3.3v? Also im toying with the idea of just upping the clock and latch to 5v if not too costly so i don't need to worry when getting a second controller for player two. 

So yea hope all of that makes sense. I will also post up a project log, this time once its finished. Ive learnt my lesson posting logs in progress as i very rarely finish my projects before moving onto the next.


----------



## Iceni (Jan 29, 2015)

Can't you just power it via USB? Since the VDD and the GND are not signal carriers.

The you should be able to cut R1 R2's feed and use a 3.3V feed from the same port. Failing that you could divide the potential at R1 R2 with a second set of resistors in parallel to ground.


----------



## eidairaman1 (Jan 29, 2015)

Need a resistor adapter board


----------



## ste2425 (Jan 29, 2015)

Well that was my original idea but then i read on another forum that powering it from 5v means the Data out will be at 5v which the rpi cant handle. Is that not the case?


----------



## ste2425 (Jan 29, 2015)

eidairaman1 said:


> Need a resistor adapter board



Resistor Adaptor Board? Do you just like a voltage divider or zener diode? Not 100% clued up on how they work but its what google has thrown up. However im a little concerned from @Iceni post. Don't these methods rely on a known input voltage? If the Controller does output 3.3v and not 5v then they will cause issues right? Need to buy a multi-meter and have a test i think.


----------



## xvi (Jan 29, 2015)

How important is it to you that you stick with genuine NES controllers?


----------



## ste2425 (Jan 30, 2015)

xvi said:


> How important is it to you that you stick with genuine NES controllers?



That's what ive used in the past and whilst it worked, it doesn't look right, and doesn't feel as good to use as the original. Plus i now own the original 

Well i got my self a multimeter (Thanks to some left over Christmas vouchers  ) And when fed with 5v the data out is at 5v. But stangly the clock and latch from the rpi are also at 5v? Nowhere in the retropie forums or tutorials has this been mentioned. I thought the clock and latch was sent by the pi so it controlled its voltage? However when running the controller of 5v everything (data, clock, latch) is at 5v, when running of 3.3v everything is at 3.3v. Im a little confused.

Does this mean to run the controller on 5v which it needs im going to have to limit the data out to 3.3v? Shouldn't be hard with a voltage divider (According to Google.) But also use some form of level shifter for the clock and latch so the pi isnt being forced to output 5v on these when it should only run 3.3v?


----------



## W1zzard (Jan 30, 2015)

Have you tried with a 7805 voltage regulator and something like a LD1117V33 for 3.3 V ?

You should be fine without the glue components (capacitors/resistors), just the regulator alone should work for that purpose.

Edit: Misread your original post, those regulators won't work to change logic signals, but they might still be useful to you.


----------



## Frick (Jan 30, 2015)

W1zzard said:


> Have you tried with a 7805 voltage regulator and something like a LD1117V33 for 3.3 V ?
> 
> You should be fine without the glue components (capacitors/resistors), just the regulator alone should work for that purpose.



This, at least for small currents which I've no idea of how large they'll be, but I can't imagine them being too large.


----------



## Brusfantomet (Jan 31, 2015)

A resistor network looking like this for each pin needing to be converted down from 5V to 3,3V:



1: here you connect the 5 V input from the NES controller
2: connect the 3,3 V output to the microcontroller you are using 

The values of R1 and R2 are not that important, but the relationship between them are, R2 must at its MAX be R1 x 2, the lower R2 is in relation to R1 the lower the voltage form 2 will be.

the actual values for R1 and R2 will depend on the input resistance your microcontroller, but i guess values:
R1 : 1000 ohm
R2:  1500 ohm
are small enough to not get influenced by the input resistance, it will give you an output at 2 of
5 V/(1 k +1,5 k) * 1,5 k = 3V
with a draw of 5V/2,5k ohm = 2 mA for the resistor network.

Should 3V be to small a voltage for the input you can replace R2 with a 1800 ohm resistor giving
5V /(1,8 k +1 k) * 1,8 k = 3,22 V
this with a draw of 5V/2,8k ohm = 1,8 mA


----------



## ste2425 (Feb 2, 2015)

Hi guys

Thanks for all the help, i tried to look over examples of some of the components and circuits you posted and i realised i was a little over my head.

So i stumbled across this for a couple of quid and picked one up to have a play with.

http://www.adafruit.com/product/757

Should do the job of catering the category 3 NES controller i posted above. Ill report back when it arrives.


----------

