HELP Using an Arduino IOREF pin to decide/switch voltage levels used on a shield - Page 1
Forum section: electronics / beginners

author: tifkat
author_rank: Regular Contributor
timestamp: March 13, 2021, 03:11:00 pm
content: Hi guys,Firstly, I hope the topic makes sense. I'm not 100% sure I even phrased that correctly.I wish to make a shield for the Arduino Mega2560/Due for an LCD I bought, which was made for an STM development board, and uses an odd 34-pin connector, as opposed to the more common 32- or 40-pin connectors common with Arduino shields.I understand that the IOREF pin on these two models is an indicator of which logic levels each one uses (3.3v/5v), and it's very purpose is for shield designers to make one design which can be used on both targets.I am aware that level shifters and bus transceivers with dual-supply rails exist for the very purpose of allowing a 5v device talk to a 3.3v (5v intolerant) devices, and I could easily make a fixed 3.3v<->5v shield. Great for the Mega2560, not so great for the Due.How do I put these two facts/features/mechanisms together to allow my shield talk 3.3v to the LCD and 3.3v or 5v to the currently connected Arduino board, based on the IOREF level?This is my consideration:Both boards have a 5v and 3.3v "pin", output from the onboard voltage regulator, so I'd probably connect the 5v to the shield, and run it into a 3.3v regulator, giving my both levels on the shield. This could then power the LCD "logic" (3.3v) and the backlight (5v).I'd then use a comparator to check IOREF against the 3.3v and use the Hi/Low state of the output to switch either 3.3v or 5v to Vccb on a dual-supply bus transceiver, while Vcca is permanently wired to 3.3v.But... how do I make this switch?Does this sound like a reasonable way to work the circuit?Some side points:I figure I'd use just the 5v from the Arduino, and leave the 3.3v untouched, as the lower voltage MCU may suffer more from noise induced by something on the shield.I am also planning on making this in an expanded version with 5v in from an external power supply, and I/O lines to headers which can connect via ribbon cable to another PCB with various sensors, fan headers etc on it, so working with the 5v in, and regulating it on the shield to 3.3v would probably be the cleanest common solution between the 2 variants of the board.tifkat

author: tifkat
author_rank: Regular Contributor
timestamp: March 13, 2021, 03:27:24 pm
content: Below are the bus transceivers I have narrowed down in my search:On Semi MV74LVX4245-D (Highvolts on A,lowvolts on B)https://www.onsemi.com/pdf/datasheet/mc74lvx4245-d.pdfRenesas HD74LVCC4245A (Highvolts on A,lowvolts on B)https://www.renesas.com/us/en/document/dst/hd74lvcc4245a-datasheet?language=en&r=528136IDT IDT74LVCC3245A (Lowvolts on A,highvolts on B)https://media.digikey.com/pdf/Data%20Sheets/IDT/IDT74LVCC3245A.pdfTexas Instruments SN74LVCC3245A (Lowvolts on A,highvolts on B)https://www.ti.com/lit/ds/symlink/sn74lvcc3245a.pdfIt seems that, dependant on the bus transceiver chosen, permanent 3.3v connection may be either Vcca or Vccb, and the 5v would go to the 'other' side.

author: tooki
author_rank: Super Contributor
timestamp: March 13, 2021, 03:31:59 pm
content: As it happens, I just lashed up such a circuit 2 weeks ago, based on the design in one display shield.Basically, the approach is to use a TI 74LV245A or 74LVC245 bus transciever. You supply it with the desired output voltage for your display (in your and my case, 3.3V). The key is that the 74LV-A and 74LVC series are expressly tolerant of 5V input signals even when it’s being supplied with 3.3V. So they’ll happily accept a 5V input signal and then output it at 3.3V.In other words, you always supply the IC with 3.3V, and then it simply doesn’t care whether the Arduino is giving it 3.3V or 5V signals. In such a design, I don’t see why you’d need to “inform” the bus transceiver of the supply voltage.FYI, TI has a really nice overview of the topic, and suggested hardware, in their voltage level translation guide:https://www.ti.com/lit/ml/scyb018h/scyb018h.pdfBtw, the schematic I copied is the one from this display’s Arduino shield:https://www.buydisplay.com/spi-arduino-2-8-inch-tft-touch-shield-example-ili9341-for-mega-due-unoThe schematic ishttps://www.buydisplay.com/arduino/ER-AS-ILI9341-Arduino-Schematic-Diagram.pdf

author: tifkat
author_rank: Regular Contributor
timestamp: March 13, 2021, 03:39:52 pm
content: Quote from: tooki on March 13, 2021, 03:31:59 pmI had considered this as a possibility. Of course you need a transceiver which is explicitly 5v tolerant, which not all of the single supply models out there are. But, I lacked confidence in my knowledge on what is counted as a high signal on a 5v MCU. I guess that 3.3vshouldwork, but having a dual-supply transceiver would ensure that I was using the 'native' logic level, and remove all doubt, so I dismissed this option.Thanks for the links, I'll check them all out thoroughly.I'm still interested to know how to make the switching design I concocted, if it's a sensible (if not the simplest) idea.

author: tifkat
author_rank: Regular Contributor
timestamp: March 13, 2021, 03:42:19 pm
content: The LCD display in question (which I purchased) is:MRB3973

author: ledtester
author_rank: Super Contributor
timestamp: March 13, 2021, 03:53:37 pm
content: There are level shifters which will work when VCC_A <= VCC_B including equality like the TI TXB0108:https://www.ti.com/lit/ds/symlink/txb0108.pdf?ts=1615570152361Connect the A-side of the chip (including VCC_A) to your shield which is operating at 3.3V.Connect the B-side of the chip to the Arduino and VCC_B to IOREF.This works because 3.3V will always be <= IOREF.The discrete MOSFET level shifter like you see here:https://www.sparkfun.com/products/12009Schematic:http://cdn.sparkfun.com/datasheets/BreakoutBoards/Logic_Level_Bidirectional.pdfmight also work with equal voltages -- I'll have to try it. In that case you would connect the LV side to your shield and the HV side to the Arduino / IOREF.

author: DrG
author_rank: Super Contributor
timestamp: March 13, 2021, 03:58:50 pm
content: I will admit that I have not looked at this real carefully, but why do you need to do any level translation at all? Your LCD works on 3.3V or 5V. You have common pins between the two (Mega / Due). You only need to make sure the shield does it correctly....Take a look at this little projecthttps://create.arduino.cc/projecthub/tolgadurudogan/using-arduino-mega-sensor-shield-with-arduino-due-e46caathat, with a few modifications, makes an existing shield work with either Due (3.3V) or Mega (5V). Since you are designing the shield, you can implement that design outright.Again, what am I missing?

author: tifkat
author_rank: Regular Contributor
timestamp: March 13, 2021, 04:09:16 pm
content: Quote from: DrG on March 13, 2021, 03:58:50 pmThat I'm a masochist who finds 'reasonable' long cuts to do things, so I can learnhowto do them.I want to make this shield for the possibility that someone out there may find it useful for a similarly pinned-out LCD which is NOT 5v tolerant. I saw some out there which did not have this feature, but the same resolution, physical dimensions and driver chipset. I may also look at making something of a kit for my project, and wish to source these non-tolerant units as they may be more cost effective. Designing for possibilities. This is my justification of 'reasonable'Also, I think that 3.3v/5v stated.. is just for the power into the PCB of the module. If you plug in 5v, it has a regulator to drop it to 3.3v. If you plug in 3.3v, it will use that 3.3v. I'm not 100% convinced the I/O lines are 5v tolerant. Here's the datasheet for the driver IC:NT35510I also want to make this bi-directional, because I believe you canreadfrom the LCD, and this is my motivation for making the MCU side of the transceiver match the IOREF level provided by the board.Can I assume safely that these transceivers will work with the touch driver SPI? Or would their switched, asynchronous nature be a problem?

author: tifkat
author_rank: Regular Contributor
timestamp: March 13, 2021, 04:18:49 pm
content: Quote from: ledtester on March 13, 2021, 03:53:37 pmI've seen these and thought the design was pretty clever. I never bought one though, because I read that they were kind of slow with switching high/low. Maybe that was another board which I think relied on a resistor voltage divider for the High->Low transition.

author: ledtester
author_rank: Super Contributor
timestamp: March 13, 2021, 04:36:19 pm
content: QuoteTiming-wise each I/O line is independent of the others if that's what you're getting at. The TI datasheet lists a max data transfer rate of 20 Mbps which for UNO's and Nano's is not going to be an issue.

author: tifkat
author_rank: Regular Contributor
timestamp: March 13, 2021, 04:37:22 pm
content: Quote from: DrG on March 13, 2021, 03:58:50 pmOh yeah, one more reason... because it helps me learn how to do it, for use in other possible shield projects, or other non-arduino related projects which would benefit from such an implementation. If I just planned around the one LCD I own, I'm never going to learn anything!

author: tifkat
author_rank: Regular Contributor
timestamp: March 13, 2021, 04:42:38 pm
content: Quote from: ledtester on March 13, 2021, 04:36:19 pmHmm.. no. I think the transceivers I listed above, have a 'direction' pin, which has to be set high/low. The one you listed however seems to be auto-direction, so that's a bonus.I'm aiming this at the Due and the Mega2560. 16-bit parallel interface requires more pins than an Uno or Nano can spare.I think the speed which needs to be considers is the required speed to talk to the LCD, which is also, probably not anywhere near 20Mbps.

author: tifkat
author_rank: Regular Contributor
timestamp: March 13, 2021, 04:58:54 pm
content: Imma call this one SOLVED.Thanks totookiI'm confident that using a single supply transceiver at 3.3v will work with either 3.3v or 5v MCUsThanks toledtesterI have the transceiver I need, which does use dual-supply to get the native logic level for the connected Arduino board, it's auto-directional, so asynchronicity is irrelevant, and as inputs are always High-Z, there will be no real current draw, so I can use IOREF on Vccb which means it will always use the correct voltage, without any complications like a comparitor and switching supply rails on the shield itself.Thanks lads!

author: tooki
author_rank: Super Contributor
timestamp: March 14, 2021, 12:01:25 pm
content: Quote from: DrG on March 13, 2021, 03:58:50 pmThe module supply voltage is not the same as the driver IC’s maximum logic input voltage. The IC says the maximum logic input voltage is 3.3V.

author: tooki
author_rank: Super Contributor
timestamp: March 14, 2021, 12:42:26 pm
content: Quote from: tifkat on March 13, 2021, 03:39:52 pmThe datasheet of the MCU will tell you. The one for the Atmega2560 says the minimum “high” input voltage is 0.6xVCC, so 5Vx0.6=3.0V. So 3.3V logic inputs should work just fine (and in my experience, do).

author: DrG
author_rank: Super Contributor
timestamp: March 15, 2021, 03:33:55 pm
content: Quote from: tooki on March 14, 2021, 12:01:25 pmNot following you. I am saying that you do not need any drivers (voltage translators) at all because the LCD works with either 3.3 or 5. You just have to make sure that the "shield" does not misroute - that is why I included that link. To make the shield to attach the LCD compatible with both the 5V Mega or the 3.3 Due, you do not need any voltage translation - that is what I think.The OP want to do it as a learning/skill building deal and I buy that completely.

author: tooki
author_rank: Super Contributor
timestamp: March 15, 2021, 05:08:36 pm
content: Quote from: DrG on March 15, 2021, 03:33:55 pmThe display module has a 3.3V regulator on it to run the LCD from 5V. But it does not have a level shifter on it to allow it to accept 5V logic inputs. And the LCD itself (i.e. the panel and the driver IC on it) is 3.3V-only. This is clear from the schematic, module datasheet, and driver IC datasheet. So if OP’s shielddoesn’tdo level conversion, and it’s used on a 5V Arduino, the display may not work, and may even be damaged.Just to spell it out for you again: LCD module supply voltage and logic voltage ARE NOT THE SAME THING. Level conversion is mandatory if it’s to be made safe for use on 5V Arduinos.And since you seem confused: “driver” doesn’t mean the level shifter. It means the IC that actually drives the LCD panel.

author: DrG
author_rank: Super Contributor
timestamp: March 15, 2021, 06:50:09 pm
content: Quote from: tooki on March 15, 2021, 05:08:36 pmAhh yes, the snarkiness that marks the incessant need for validation and causes you to simply make crap up so that you can be "right".Both commercial boards are openly advertised for DUE OR MEGA. The issue with LV245's has already been discussed and they are in use on the schematic and, presumably, what the OP is using since he has openly said he is basing it on their schematic. But, I notice that you missed all the 5V damage on the I2C - you know, the one where the schematic shows the BSS138? and the one that you did not bother to mention even though you are the smartest poster on the planet - but maybe I missed that - perhaps you could type that in all caps just for me?If he uses those commercial products that account for all of those things, he does not need to do any other translations at all. If he uses the same design in his shield, he has done the appropriate logic translations. If he only uses 5V power, using the bare LCD. he can/will have issues with logic levels. I have no problem admitting that and even asked "what am I missing?" - hastily assuming (in error) that he was using the commercial board and not a bare LCD.The problem I have is an"openly hostile" response from you. Nothing clever. Nothing humorous. Just the usual insecure BS. Now I "liked" the OP's post where he declared it solved - he provided an explanation and he started the thread - your response, as usual, is a different matter. Please list me among those that you ignore to spare me from your brilliance and extremely high EQ (so that you understand, that's mockery, but then you understand so much, I don't need to type that).Think about that - a chance to make a contribution...a chance to discuss something in a civil fashion... and you threw it away just to pathetically impress me with your arrogance and hostility. Well done, son, you certainly schooled me. But, wait, I am still confused...could you state everything you said again please...and define 'driver'..and 'logic level' and 'the' and be sure you type in all caps because you are certainly someone who desperately needs to be heard....also, could you try and type s l o w l y.Now go get your effing shinebox!

author: tooki
author_rank: Super Contributor
timestamp: March 16, 2021, 10:48:11 am
content: Quote from: DrG on March 15, 2021, 06:50:09 pmBlah blah blah... this has nothing to do with “validation”, but with the simple fact that you keep stating things that arewrong. I spelled things out for you because you continue to demonstrate that you do NOT understand the issues at hand. Nothing I said is “made up crap”, it’s exactly how it is.The OP clearly linked to the product he’s using, with datasheets. This has nothing to do with any commercial shields. The board you linked to isn’t relevant here. The commercial product (which I linked to originally!) works on Mega and Duebecause it has a level shifter.That’s why I gave it as an example circuit.Quote from: DrG on March 15, 2021, 06:50:09 pmThis is the entire point. Why have you been arguing the opposite, then?!!The commercial board (not shield!) provides 3.3V power but does not perform logic level translation.Quote from: DrG on March 15, 2021, 06:50:09 pmNot hostile — exasperated. In every post, you’ve couched it in “I am not sure”, “I didn’t look at it real carefully”, etc then proceeded to write something indicating you indeed don’t fully understand. Meanwhile this is the exact design issue I was working on just the other day in detail.I wasn’t trying to impress you. Just to provide the correct information.

author: DrG
author_rank: Super Contributor
timestamp: March 16, 2021, 03:16:13 pm
content: Quote from: tooki on March 16, 2021, 10:48:11 amI know you want point-by-point rebuttals and lengthy litigation, but you are not going to get that because you are more of a waste of my time than anything else. Here are the bottom lines for me and I know you will read them carefully and I also know that they will piss you off, but that is just too bad for you, life is tough - wear a helmet.You lost, you just don't know it yet and since you remain confused...what you lost is my respect. What you have gained is the distinction of being the only ignored user in my account - this, since you continued to respond even after I asked you to ignore me - again, evidencing your open hostility.There is so much disingenuous BS and made up crap in your response that it is nothing less than pathetic. I don't take your crap and no user on any forum should have to take that crap. What you will likely never understand are some fundamental issues and that is not my fault.What you characterize as though it were excessive arguing is, in fact, two short messages which any civil person would have understood, or at least would have been open to the possibility, that it was as much of a query as anything else. Your inability or unwillingness to understand that point is strong evidence for your excessive need to be validated among those that you think are your peers (in this case, largely anonymous users on an internet forum).If you were as all-knowing as your arrogance suggests, you would not have copied the commercial schematic (your words), you would have designed your own and you would have seen and mentioned the I2C line.The thread was over. The OP said as much and I acknowledged it (but only by the 'thanks'). It was you who then decided, after the thread was over, to start up with your unnecessary crap. I know you don't like getting called on that, but you know it is true and anyone can see as much - you would not have engaged in this response, or the others which were directed to me, if you didn't know it was true.You are recalcitrant.

author: tooki
author_rank: Super Contributor
timestamp: March 16, 2021, 05:14:51 pm
content: Quote from: DrG on March 16, 2021, 03:16:13 pmOh man, what a piece of work...

author: tifkat
author_rank: Regular Contributor
timestamp: March 20, 2021, 12:40:31 am
content: DrG.The datasheets discuss a bare LCD vs an LCD module, which has the LCD attached to a PCB. I bought the LCD module.The LCD module I have purchased, the MRB3973 is made for dev boards using STM MCUs. I checked each of the listed dev boards and am pretty sure they're all 3.3v logic level.The LCD module (having a PCB on it) I suppose is essentially a shield for these STM boards, but that's not really useful for me using an Arduino - pinout differences.If you're using the module with one of those STM dev boards, you can routepowerto the module as either 3.3v or 5v, and the onboard regulation will safely put out 3.3v topowerthe LCD panel itself. Thesignallines will already be at 3.3v. All comms between your STM board and the LCD panel will be at 3.3v natively.The LCD panel uses an NT35510 LCD driver IC, so you just poke data at it, and it will handle the timing of signal comms to the LCD panel itself, saving you the grind of bit-banging the data to the LCD with correct timing etc. This is a 3.3v logic level part. casually 'chatting' to it (signal) at 5v will most likely damage it.The PCB provided in the LCD Module doesn't do anything to ensure the signal wires are 3.3v logic level, only thepower, ie to turn the backlight on, and topowerthe NT35510 driver IC. It's your own problem to ensure the signal wires are 3.3v logic level. Of course being aimed at 3.3v MCUs this is not a consideration of the manufacturer.I'm using this with an Arduino Due (should it ever arrive!) so I'm also good at 3.3v, but since I have to make a PCB to essentially adapt the module to the Arduino form factor, I felt I should probably make it useful to boards with either 3.3v or 5v logic level. Of course this is also limited to the formfactor of the Mega2560 or the Due, as that's the formfactor I am using. I don't really want to design a shield for something I don't have, also I'm pretty sure that the Arduino Mega/Mega2560 would be the only 5v boards with enough IO pins to run this 16-bit parallel interface, so it's probably unnecessary to make a formfactor for anything else.Tooki got it right. My purpose here was to essentially adapt the LCD module 'built-in shield for 3.3v logic level STM boards' to the Arduino via my own custom 'gender bender' STM formfactor<->Adruino board formfactor with logic level shifting to make it useful to both 3.3v and 5v boards. The 5v/3.3v ability of the LCD module stated in the 'specs' is ONLY for POWER, not SIGNAL. I need to level-shift the SIGNAL because I plan for this to be compatible with 5v logic level Arduino MCU boards.I have read these pages over and over a number of times, because I purchased them from a country where English is not the primary language. I always read them with a level of scepticism, and look for non-obvious information which may be omitted due to the assumption by the manufacturer/publisher that you already know it, or that it is irrelevant to their productas they sell it. If you buy it for some other purpose, you're on your own. That and endless rabbit-hole type research into the supposed purpose it was sold for, and you start to get a clearer picture of how it will or won't work for your own project.This topic was all about how to use the IOREF pin on (most) Arduino boards to ensure that 3.3v native signals go through un molested, and 5v signals go through after being shifted down.That said, it looks like I'll be running the TXS0108E chip, and running the LCD side on 3.0v, as the NT35510 can work down to much lower than even that, AND VCCa MUST be lower than VCCb, so if VCCb is coming in at 3.3v, I MUST have VCCa at a lower level. I figured -0.3v would be enough of a difference.tifkat

author: DrG
author_rank: Super Contributor
timestamp: March 21, 2021, 04:27:30 pm
content: Quote from: tifkat on March 20, 2021, 12:40:31 amGood deal, thanks for the explanation and good luck with the project.

author: tifkat
author_rank: Regular Contributor
timestamp: April 04, 2021, 11:26:18 am
content: For anyone reading this in the future, the 'power' to the LCD is actually power to the LED backlights. The PCB handles a buck conversion to 3.3v which runs through the onboard LED driver IC. This is the only place where 5v is 'tolerated'.

author: tooki
author_rank: Super Contributor
timestamp: April 04, 2021, 02:03:51 pm
content: Quote from: tooki on March 13, 2021, 03:31:59 pmFYI, since writing that, the PCB arrived, the kid it was for used it for his final project, and it worked perfectly. So copying that schematic was a win.I can send you a streamlined version of the schematic (since the original has numerous options not relevant here, making it kinda hard to follow) if you want.

author: tifkat
author_rank: Regular Contributor
timestamp: April 09, 2021, 07:40:46 pm
content: Quote from: tooki on April 04, 2021, 02:03:51 pmWould love that, thanks tooki!

author: tooki
author_rank: Super Contributor
timestamp: April 10, 2021, 01:17:31 pm
content: Quote from: tifkat on April 09, 2021, 07:40:46 pmI have school Monday and Tuesday, so Wednesday is the earliest I can get it.What software do you use? If Altium can export to it I’ll send you that, otherwise just a PDF.