Logic level conversion - change GND? - Page 1
Forum section: electronics / beginners

author: chris_staite
author_rank: Newbie
timestamp: June 11, 2015, 06:21:22 am
content: Hi all,Long time lurker, first time posterI've been working on a data logger for my local Scout county. I'm trying to interface a ATMega32U4 with a cheap Chinese RC522 RFID reader/writer (this contains the NXP MFRC522 chip).Although 3.3v versions of the 32U4 circuit exist, they are significantly more expensive (for no particular reason). So, trying to keep costs down, for what is a very short run, I'm hoping to use the 5v version. However, this is giving me logic level conversion issues.Testing things out on my Arduino Uno, I've been able to use SPI at 5v. I'm not sure what long-term damage I'm doing to the MFRC522 with this, so would prefer not to in the production version. The datasheet says that I can go Vdd+0.5v on these pins, and Vdd can be at maximum 4v.Anyway, to the crux of my question. I could, obviously, and probably should, use a logic level convertor and a linear regulator. Bearing in mind the current draw for the MFRC522 is usually 10mA, peaking at 40mA when doing read/write operations. However I wondered if I could cheat a little. I've never seen any talk of this around which is either because I've not been looking or because it's a very bad idea. However, could I simply use a voltage divider to supply GND of the board with 1.7v. Then my power and data at 5v would then be (relative to GND on the board) 3.3v. Of course, signals will be -1.7v when pulled low, but I'm not sure what kind of issue a negative voltage might have.Need to try and keep the overall cost down below £20 per unit, so if I could do this then it would be great. Otherwise, I may have to resort to using a 3.3v ATMega328P board and interface using a USB-Serial adapter. I know this is the more sensible solution, but it's likely someone will plug a pinhead in the wrong way round, whereas a USB connector is pretty fool-proof.Many thanks for your help in advance, Chris.

author: Ian.M
author_rank: Super Contributor
timestamp: June 11, 2015, 08:15:37 am
content: Dont do that - its nothing but trouble and risks latchup and destruction of the 3.3V device.74HC4040hex buffer chips are dirt cheap and most manufacturers versions have inputs that can tolerate considerable overvoltage. Run it at 3.3V, connect 5V signals direct to its inputs and it will output 3.3V levels.Going the other way, a 3.3V logic '1' level may not be reliably be seen as a logic '1' by a 5V MCU unless it has TTL compatible inputs. Check the ATMega32U4 datasheet for the logic '1' threshold for the pins in question and if you don't have at least 1/2V margin use an 74HCT4040(or any other 74HCT gate) buffer @5V as its TTTL compatible input is quite happy with 3.3V logic '1' levels. Both chips mentioned are a fraction of a dollar.I don't know what you are trying to get at with USB and pinheaders and the possibility of reversals. I suspect its to do with getting data off the logger, but you need to clarify that if you want advice. Letting non-techy users plug *ANYTHING* onto a bare board is a *BAD* idea. If its for non-techies, put it in a box with external connectors that only fit one way, and *NEVER* use a consumer standard connector (e.g USB or PC DE9 serial) for nonstandard signal levels/voltages unless there is absolutely no risk of damage if its connected to whatever that connector is normally used for. If it has a 2.1mm or 2.5mm center pin DC jack, it needs to tolerate up to 18V AC or DC without damage!

author: matseng
author_rank: Frequent Contributor
timestamp: June 11, 2015, 08:56:41 am
content: I'm sure it's not a 4040 you want - they are 12 bit binary counters :-) The hc4050 buffer is better for this purpose....

author: MatthewEveritt
author_rank: Unknown
timestamp: June 11, 2015, 09:06:17 am
content: I'm not sure I understand the reason not to run at 3.3v.(might even be as simple as swapping the / adding a regulator)The 32u4 usb should work fine down to 3v (page 240 of the data sheet), no need for a serial adapter.

author: Ian.M
author_rank: Super Contributor
timestamp: June 11, 2015, 09:15:24 am
content: I should also mention single gate level translators - more expensive if you have a lot of signals, but if only a few, one type of device can handle both conversions if it has separate Vdd pins for its input and output, potentially reducing BOM costs and saving board space. Google: single gate logic level shifter@matseng: Thanks for the correction. The principle still stands but I badly mixed up '4040 and '4050 between checking datasheets/pricing and typing the part no.@MatthewEveritt: Does the ATMega32U4 have clock speed limitations at 3.3V?

author: Zero999
author_rank: Super Contributor
timestamp: June 11, 2015, 09:30:48 am
content: You need the 74HC4050 for 5V to 3V conversion and the 74HCT34 or 74HCT241 for 3V to 5V conversion.http://www.nxp.com/documents/data_sheet/74HC4050_CNV.pdfhttps://www.engineering.uiowa.edu/sites/default/files/ees/files/NI/pdfs/00/53/DS005359.pdfhttp://www.ti.com/lit/ds/symlink/cd74hc240.pdfThere's also the old CD4504B which can do both but being old CMOS it's slower.http://www.ti.com/lit/ds/symlink/cd4504b.pdf

author: tyguy2
author_rank: Unknown
timestamp: June 11, 2015, 04:49:43 pm
content: If you wanted to be REALLY cheap, you could use a voltage divider. However, for a longer term solution, you should probably use level shifters.

author: MatthewEveritt
author_rank: Unknown
timestamp: June 11, 2015, 05:35:45 pm
content: Quote from: Ian.M on June 11, 2015, 09:15:24 amProbably but if that's acceptable it solves the problem with no extra parts / work.

author: chris_staite
author_rank: Newbie
timestamp: June 11, 2015, 08:32:32 pm
content: Thanks for the comments guys. The issue with swapping the board out to 3.3v is the XTAL speed, it shouldn't exceed 12MHz according to the datasheet. The boards are populated with a 16MHz XTAL and I don't have the kit to desolder them (they are SMD). Due to the small run it would be too expensive to make my own.I have managed to find the on-board 3.3v pin which is provided by the USB logic on the 32U4 chip which is helpful at providing the supply voltage. I still need to do logic level conversion for the 4 pins, but I think you've convinced me that I should splash out on the conversion logic.Rather than increasing the complexity, I think I might just opt for the more expensive 3.3v version of the board. In fact, I might swap out to a Teensy-LC since it's 3.3v and USB and available for not that much. Just need to find a good way to power it from battery.