i2c 3.3V to 5V
Jonathan
Posts: 1,023
Hi All,
I am working with the ADS7828 i2c ADC. I have got it working nicely at 3.3V. However, I need to run it at 5V to sample some 5V sensors. My goal is to eventually use the props dedicated i2c pins. Right now I am using pins 6-7 on a demo board.
I have looked in the "Safely interfacing 5V" thread, and have tried both Tracey's two resistor setup and Beau's two transistor setup. With Tracey's setup, the ADC reads correctly once, on start up. With Beau's setup, I get nothing or 65535, depending on where I place the pullups.
Any ideas? Thanks!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
I am working with the ADS7828 i2c ADC. I have got it working nicely at 3.3V. However, I need to run it at 5V to sample some 5V sensors. My goal is to eventually use the props dedicated i2c pins. Right now I am using pins 6-7 on a demo board.
I have looked in the "Safely interfacing 5V" thread, and have tried both Tracey's two resistor setup and Beau's two transistor setup. With Tracey's setup, the ADC reads correctly once, on start up. With Beau's setup, I get nothing or 65535, depending on where I place the pullups.
Any ideas? Thanks!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
Comments
It's just a couple of resistors, so...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Don't visit my new website...
I've got links to the two types I've used at the bottom on this page:
http://www.rayslogic.com/propeller/Programming/i2c/i2c.htm
Thanks for the link. I'll go that route if I have to, but seeing that I can get one good reading, there ought to be a way to make it work without. I hope. [noparse]:)[/noparse]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
I find this configuration works pretty well. I use this circuit to boost a 3.3V signal to trigger 5V Vih = 0.7 Vdd devices, it will still trigger the Vil = 0.3 Vdd low as well. The boost is sufficent to use 5% resistors and still trigger under worst case. I personally use 1k and 3k, but any 1:3 ratio will work and for I2C devices larger values should probably be used.
The nice thing about this circuit is that it can be used bi-directionally, where the series resistor·acts as the current limiter for 5V·device·generated output.·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Post Edited (Paul Baker (Parallax)) : 4/9/2008 4:38:10 PM GMT
I tried your setup using 3.2k and 10k. I'm guessing that is close enough to 3:1. No joy, and I don't even get the one reading. Looking at it on the scope, it seems that the signals are very similar, the clock idles high and it all looks pretty much the same. Of course, I don't really know what I would be lookig for. I don't get why it would work once unless it was something like the clock not being left in the correct state, or something like that.
I'm wondering if it might be hardware. I used a breakout board to take the TSSOP package out to DIP. Maybe I have a dodgy connection. I have another, so I'll try that.
Any other ideas? I really want it to work so I can move on. [noparse]:)[/noparse]
Thanks for the help!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
Looking closer at the scope traces, the succssesful reading shows 4 clock cycles, then the ACK on the data line. On the failed attempt, it doesn't start that way. I'm going to try to attach a BMP from the 'scope to illustrate. The i2cOK shows the first read upon restarting the Prop. The i2cNO file shows what all the subsequent reads look like. I have tried a second ADC and it behaves the same. Blue is clock, red is data.
Drat. I keep getting an error when I try to upload the BMP's.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
Alternatively you can zip the file and post it that way.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
A 1K Resistor to the 5v stuff works well.
Have a look at the i2cObject version 2 in the Object exchange - the i2cDemo.spin has pictures.
If that doesn't work - i'd check your setup. Start with a single device and keep adding gradually.
J
I've tried all of that. I have got other i2c devices to work at 5V. For some reason this particular device is cranky. Looks like I need to go with a "real" level shifter.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
http://forums.parallax.com/showthread.php?p=711750
Tried that. What gets me is that it reads OK once, on startup. Why not afterwards? I see another transistor/diode circuit from Phil in that thread, I'll try that one too.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
-Phil
I have tried all the circuits I could find on the forums except for your transistor/diode one, which I plan to try when I get home. This device seems to be a little cranky for some reason. It works once (with several different circuits) upon startup, then fails all subsequent reads. I have great hopes for your circuit, I'll keep my fngers crossed.
Thanks for all the help folks!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
I totally agree. I think you are chasing the wrong problem too. If it worked once, it should work ad infinitum. Check to make sure your code does not terminate itself somehow after the first read. Maybe your cog stops, or enters a recursive loop.
Care to post your code??
-Parsko
Thanks a ton for all the help!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
also, I've read, but someone confirm, that if your pull-ups or downs are too strong or weak, then devices don't have enough time to react, or "overdrive" the "pull". Would that make sense here?
I took a look at the code and decided to try sticking the adc.initialize(adcCLK) line in the read_adc line. It will now read the ADC at continously 5V BUT...
It only works with a 10k pullups to 3.3v on data and clk lines. I can put a series resistor on the CLK line but not on the data line. Yes, I know this is asking to burn out a Prop pin. I just wanted to see if it works. Another thing, the highest reading I can get is about 3700, in spite of the fact that the ADC channel is tied to +5Vdd. At 3.3V I get the full expected range.
Now I need to go through and try all of the possible interface circuits.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
I wonder:
should be:
or even:
(you'll need to check whether its ACK,NAK or NAK,ACK for your device)
But I think this will expain the getting the same value - i.e. the chip isn't finishing the conversation, and/or the chip is holding i2c lines high/low
Let us know how you get on.
James
Post Edited (Javalin) : 4/11/2008 12:25:02 PM GMT
I'm not sure what the code you posted is trying to do. It does not comile as is. Any way you could explain (in small words) what it is supposed to do? I'm getting pretty tired of this adc, never had this kind of trouble with an i2c device.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
If you're reading multiple bytes the i2c slave (the adc) needs an ACK or NAK as the 9th bit returned basically a "shall I continue" type message. if you don't send it you'll likely not end the "download process". In the ADC's datasheet its says (don't remember the page) the ACK/NAK requirement.
The &= bit at the end was cause I wasn't sure about your ".byte" - so was wondering if that was part of the problem?
Yeah - the MCP320X's are easy!
James
Did you figure this out, get distracted, or bail?
-Parsko
Took a day off, I was (am) frustrated, and sometimes it's best to take a break.
Bottom line, this device just seems cranky. I got two other i2c devices running fine. They work with almost any of the· 5v interface options. I don't know why this one is such a PITA. It does sorat work in 5v mode ATM, but it won't read full scale ie with 5v applied to an input I'm only getting a count of 3270 or so.
I can't seem to find any other i2c adc in a tssop or dip package. Any suggestions? Or does anyone want to try to tame the ADS7828? I'd be happy to send one along, already mounted on a breakout board.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
MCP3204 / MCP3208
http://ww1.microchip.com/downloads/en/devicedoc/21298c.pdf
Lots of example code in the Object exchange for them. Can be run on 2.7v to 5v
J
Update: - oh sorry - these are SPI...
http://www.rayslogic.com/propeller/Programming/i2c/i2c.htm
But, their datasheets both quote a minimum high state voltage of 0.7*Vdd, which would be 3.5 volts...· But, that's very close, so they might work that way...· Or, with that resistive circuit I posted...
Post Edited (Rayman) : 4/13/2008 10:00:00 PM GMT
I only find level shifters on the page you linked. I poked around on your site but didn't find the ADC's.
Javalin, the part you linked is an SPI part. I'd really like to use i2c so I can use the already dedicated i2c pins on the prop.
Thanks for all the help! No takers to try to tame the ADS7828? Not that I blame you. :-0
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot