Raspberry Pi Pico - Signal Level Shifting (Ep. 0.3)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] welcome to life with david i'm david and today i'm continuing my research into using a raspberry pi pico as low capacity data storage for my 6502 computer last time i looked at the parallel data throughput of the pico while using micro python and determined that it was sufficient now it's time to try connecting the devices together as you might know the pico uses a 3.3 volt signal level whereas my 6502 and most arduinos use 5 volts 5 volts could damage 3.3 volt devices and 3.3 volts might not be high enough to register as a logic 1 for higher voltage devices the answer lies in external signal level shifters so why don't you join me as we look into the theory and operation of signal level shifters level shifters can either be unidirectional or bi-directional a pair of resistors can be used to drop 5 volts to 3.3 volts and a bipolar transistor can be used to convert from 3.3 to 5 volts however today we're going to examine a bi-directional solution and an channel mosfet you can buy small boards from amazon or ebay for less than a dollar and they can dave four bi-directional level shifters one of the cool things about a mosfet is that as long as the source to gate voltage is above the gate threshold the mosfet acts as a switch and current can flow in either direction between the drain and the source the gate threshold is usually anywhere from 0.1 to 2 volts depending on the device used as we see from the diagram the mosfet is connected with the source connected to the 3.3 volt bus and is pulled up to 3.3 volts with a 10k ohm resistor the drain is connected to the 5 volt bus and is pulled up to the 5 volts with a 10k ohm resistor the gate is connected to the 3.3 volt supply let's first look how this circuit converts from 3.3 volts to 5 volts i'm simulating this circuit using an online simulator called circuit js i'll input a very slow triangle wave so we can see what's happening the high level side is attached to a high impedance input initially both sides are high then the low level side input is driven low which also drives the source of the mosfet low as the difference between the 3.3 volt gate voltage and the source voltage exceeds the gate threshold the mosfet begins to conduct between the drain and the source this drags the high level side to the same signal level as the low level side when the low level side returns to 3.3 volts the mosfet stops conducting and the high level side returns to 5 volts the conversion from 5 volts to 3.3 volts is slightly different mosfets have what's called a body diode which allows current to flow between the source and the drain all moss fits have this it's just the way they're built because it's not shown on this representation of a mosfet i'll add the body diode as a discrete component so you can see how central it is to conversion from high to low signal levels the low level side is connected to a high impedance input when the high level side is driven towards zero volts the body diode begins to pull the low level input down eventually the gate threshold voltage is exceeded and the mosfet begins to conduct between the source and the drain which completely drags the low level side to the same voltage as the high level side at this point the low impedance of the mosfet effectively bypasses the body diode until the high level side voltage increases as the difference between the gate and the source goes below the threshold voltage the mosfet shuts off with only the body diode conducting current until the high level side voltage is approximately the same as the maximum low level side voltage which in this case is 3.3 volts now let's simulate data signals when we input a square wave to the low level side of the level shifter we see a nice crisp square wave on the high side output the same holds true when we input a square wave into the high level side input [Music] let's look at a real world example first i need to solder on a couple headers so this level shifter will fit in a breadboard next i connect 3.3 and 5v power to the level shifter i'll get the power from the pico then i input a 3.3 volt peak to peak triangle wave into the low level side i bias the signal so that the lowest voltage corresponds to ground first i set it to about 14 kilohertz so we can examine the switching points in detail you can see that a low level voltage of about two and a half volts switches the 5 volt side next we increase the frequency to about 80 kilohertz and we can start to see some slower rise times on the 5 volt side however the rise times are less than two microseconds which is more than fast enough for communicating with a 6502 with a one megahertz clock speed finally i ramp up the frequency to kilohertz which exacerbates the slow rise time but then there's a lot of capacitance for my oscilloscope leads to test the low level output i feed a 5 volt triangle wave at 7 000 hertz into the high level input if you look closely you can see the effect of the body diode on the low level output as i increase the frequency to 250 kilohertz the rise times for the low level signal continue to look acceptable now i'll connect the level shifter between the pico and an arduino like my 6502 the arduino has a 5 volt signal level unlike my 6502 i can replace the arduino for a few bucks if i smoke it i'll connect arduino pins 2 and 3 to the high level side of two level shifters correspondingly i'll connect the pico gpio pins 16 and 17 to the low level sides of the respective level shifters i'll set up pico pin 17 and the arduino pin 2 as outputs the other two pins as inputs [Music] next i write a sketch to toggle arduino pin 2 as quickly as i can and look at the level shifter's low level output at about 90 kilohertz we see a pretty clean output waveform to test the conversion from low level to high level i toggle pico pin 17 as fast as i can which is about 60 kilohertz and look at the high level output at first i'm concerned that the rise time from 3.3 volts to 5 volts is pretty slow but again it's really only about one and a half microseconds most instructions on the 6502 take at least two microseconds and i need several instructions to grab the data so i've got plenty of time for the signal to settle thanks for joining me today we examined how bi-directional level shifters work and whether they are suitable for moderate speed data transfer the speed of the level shifter was very respectable and was quick enough that it won't be the limiting factor in data transfer between the pico and the 6502 next i'll try to connect the pico to the high speed paper tape port on the tim chip for my first attempt at parallel data transfer right now i have no idea when or how it will work but i have high hopes so stay tuned if you like this video or you think someone else might please give it a thumbs up if not give it a thumbs down the more likes this video has the more youtube will recommend it to others also please leave a comment or suggestion for things to do i hope to do more of these videos so please subscribe and click on the bell for notifications of new videos let's get together next time for another day in life with david see you soon [Music] you
Info
Channel: Life with David
Views: 1,244
Rating: undefined out of 5
Keywords: Raspberry Pi Pico, Level Shifter, MOSFET, Level Shifter Theory
Id: hnZMxVGoRVo
Channel Id: undefined
Length: 10min 18sec (618 seconds)
Published: Sun Apr 11 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.