CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

I2C between 5v PIC and 3.3v device
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
rovtech



Joined: 24 Sep 2006
Posts: 262

View user's profile Send private message AIM Address

I2C between 5v PIC and 3.3v device
PostPosted: Sat Oct 28, 2017 9:34 am     Reply with quote

I am considering purchasing a 3.3v pressure sensor to connect to a 5v PIC via I2C.
Is the use of resistors and Schottkey diodes enough protection? The SCL/SDA lines can be driven to about 0.3v above the 3.3v.
I assume that 3.3v replies will be enough to get data back to the PIC.
Yes, the PIC lines will be open drain but could be actively driven high by accident and the $87 sensor is a lot to risk.
Voltage dividers sound complicated because they would have to be from PIC pin to ground but then how would it read back and where would the pullup go? Three resistors?
Running the PIC from 3.3v would really complicate all my ADC inputs and possibly some outputs.
The same problem exists for connecting a Raspberry Pi to a PIC by I2C.
Any suggestions?
temtronic



Joined: 01 Jul 2010
Posts: 9244
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Oct 28, 2017 10:15 am     Reply with quote

You MUST spend $2 for an I2C logic level interface board... it will 'translate' the 5V PIC output to 3V I2C input AND convert the 3V I2C output to 5V PIC input.
Or you can make your own...
BUT the point is you MUST do PROPER logic level conversion !
while some have had some sucess with SMB option for I2C there is NO guarentee it will workk 100% of the time at any speed for ever over cold to hot tempertures.

edit. update...
I checked online , I can buy the convertor boards for 50 Canadian cents, in qty of 20 pcs.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Oct 28, 2017 10:30 am     Reply with quote

The level conversion can be done this way:

1. Enable SMBus on the PIC. This option is available on the hardware
i2c pins. The lower Vih level on the SMbus allows it to work with 3.3v i2c
chips. Or, use an i/o port that has TTL levels (instead of CMOS levels).
Usually this is PortB on 16F or 18F PICs. But check the Electrical
Specifications of the PIC's data sheet.

2. Connect the pullup resistors on SDA and SCL to +3.3v.

3. Use smaller resistors than for +5v operation. Use 3.3K pullups for
a standard 1 ma pullup on I2C for slow speed.

This does not include any protection against setting the PIC pins to +5v outputs.
newguy



Joined: 24 Jun 2004
Posts: 1909

View user's profile Send private message

PostPosted: Sat Oct 28, 2017 12:55 pm     Reply with quote

http://www.hobbytronics.co.uk/mosfet-voltage-level-converter

This circuit works well and is bidirectional. Cost will be a few cents if you're doing a volume build, and maybe a dollar for a one-off. 2N7000 or 2N7002 MOSFETs.
rovtech



Joined: 24 Sep 2006
Posts: 262

View user's profile Send private message AIM Address

PostPosted: Sat Oct 28, 2017 2:03 pm     Reply with quote

I saw that circuit but not the description of how it works as in newguy's link.
This is the other circuit that I was referring to:
http://www.roboard.com/Files/G144/RM-G144_SCH.pdf
It would permit 3.6v on the I2C lines and that is the max spec for the device so I am not crazy about it. Thanks to all.
temtronic



Joined: 01 Jul 2010
Posts: 9244
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Oct 28, 2017 2:23 pm     Reply with quote

The big benefits to using a pre assembled module are
1) low cost - 50 cents per PIC<>device
2) ANY PIC I/O pins can be used
3) ANY PIC can be used
4) simple installation..NO soldering itty,bitty parts( that I can't see....)

Jay
rovtech



Joined: 24 Sep 2006
Posts: 262

View user's profile Send private message AIM Address

PostPosted: Sat Oct 28, 2017 8:44 pm     Reply with quote

Thanks Temtronic. What about the custom chips like the FXMA2102?
There is a board with this plus a 3.3v power supply.
The only two with both level translation and a 3.3v power supply I could find are $9 and $17 Canadian $ approximately. There are lots of translators only for $2.
temtronic



Joined: 01 Jul 2010
Posts: 9244
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Oct 29, 2017 5:00 am     Reply with quote

I've never checked for an interface with regulator and I2C LLC, though it makes sense. It's probably not a 'big seller' as most designers would add the regulator and caps to the PIC board close to the connection of the I2C remote device. That way they control types and placement of parts.
Even in singles, a TO-92 case 3v3 is only 50 cents, so a LOT cheaper than the premade 'all-in-one- modules you describe.
At least TO-92 pkgs I can still see to older ...
rovtech



Joined: 24 Sep 2006
Posts: 262

View user's profile Send private message AIM Address

PostPosted: Sun Oct 29, 2017 10:20 am     Reply with quote

Many of the cheap level shifters have a 5 pin chip besides the expected pair of FETs. I see s201 marked on it.
Does anyone know what it is or what it does. Many boards do not have it.
temtronic



Joined: 01 Jul 2010
Posts: 9244
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Oct 29, 2017 11:02 am     Reply with quote

would have to see a picture of one....
if YOU have good eyesight, simple reverse engineer the module...BTDT 3 decades ago...

5 pin... maybe 4 zener diodes for OV protection ??

a schematic might shed light on it...
rovtech



Joined: 24 Sep 2006
Posts: 262

View user's profile Send private message AIM Address

PostPosted: Sun Oct 29, 2017 11:37 am     Reply with quote

http://www.ebay.ca/itm/IIC-I2C-Level-Conversion-translator-shifter-Module-5-3v-For-Arduino-AVR-STM32/141728904474?ssPageName=STRK%3AMEBIDX%3AIT&_trksid=p2055119.m1438.l2649
should show a picture you can zoom on. I am trying to find a schematic of one of these. There are many of this style and many without this chip, just the FETs.
I had thought of adding a PNP from 3.3v to gnd with a voltage divider from 5v to gnd on the base like a power zener set just above the 3.3v. I am concerned about the $87 pressure sensor and would like backup protection, especially if using cheap voltage regulators. I have had good luck with Chinese components but have had some that I think were factory rejects. I had a 7805 that slowly crept from 5v to 7v over ten minutes! and it was bought from a reputable supplier. The AMS1117-3.3 or equivalent seem to be common voltage regulators and some suppliers imply they are switching but they are linear. Why would you use a switcher from 5v to 3.3v?


Last edited by rovtech on Sun Oct 29, 2017 1:56 pm; edited 2 times in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Oct 29, 2017 11:39 am     Reply with quote

One of the reviews says:
Quote:
Not just a level shifter.

A great feature on these level shifters is the built-in
5v to 3.3v voltage regulator (100 - 150 ma).
This means that it is possible to power (small amounts of)
additional 3.3v logic without an extra power supply.

The regulator is in a SOT23-5 package.
temtronic



Joined: 01 Jul 2010
Posts: 9244
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Oct 29, 2017 12:13 pm     Reply with quote

re:
Quote:
Why would you use a switcher from 5v to 3.3v?

Well if you're really,really paranoid about saving electrons, a 'switcher' ' _should_ be more efficent and run cooler.

as for the upcreeping 7805, depending on heatsink, current draw, and filtering , I can see them 'going funny' though I've used 1,000s of them over the past 40 years without problems.

I don't know what the 'free air' spec is of that ittybitty reg but READ and understand the datasheet... draw too much power and poof...$87 device is $87 'history'.
rovtech



Joined: 24 Sep 2006
Posts: 262

View user's profile Send private message AIM Address

PostPosted: Sun Oct 29, 2017 12:42 pm     Reply with quote

Thanks PCM programmer. I found a picture that shows K833 marked on the chip and although I could not find a data sheet I did find this so it is a voltage regulator. Useful to know which one to buy.
https://arduino.stackexchange.com/questions/8511/how-to-identify-arduino-mini-pro-5v-vs-3-3v/8518
Good point Temtronic, without a spec sheet I have no idea what current it will deliver. It is probably similar to an LM1117.
Perhaps a separate regulator would be safer but a 1amp regulator would be harder to protect from. I have used 78L05 so they would burn open cct when crowbar'd rather than try to blow a fuse. The 7805 I was referring to was new and only running a single PIC.

Edit: Seems it is a KB33 which is a MIC5205 but still looking for the data sheet.
Edit: Found a data sheet which shows that the KB33 marking is on a MIC5205
http://www.farnell.com/datasheets/29605.pdf
Edit: KB33 good for 150 mA, sensor 1.25mA peak.
asmallri



Joined: 12 Aug 2004
Posts: 1635
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

Re: I2C between 5v PIC and 3.3v device
PostPosted: Tue Oct 31, 2017 11:22 am     Reply with quote

rovtech wrote:
I am considering purchasing a 3.3v pressure sensor to connect to a 5v PIC via I2C.
Is the use of resistors and Schottkey diodes enough protection? The SCL/SDA lines can be driven to about 0.3v above the 3.3v.
I assume that 3.3v replies will be enough to get data back to the PIC.
Yes, the PIC lines will be open drain but could be actively driven high by accident and the $87 sensor is a lot to risk.
Voltage dividers sound complicated because they would have to be from PIC pin to ground but then how would it read back and where would the pullup go? Three resistors?
Running the PIC from 3.3v would really complicate all my ADC inputs and possibly some outputs.
The same problem exists for connecting a Raspberry Pi to a PIC by I2C.
Any suggestions?


There are a lot of suggestions on this thread already, but, if the only devices connected to the I2C bus are 3.3 volt devices then an alternative solution that I have used for years is to add a 1K series resistor to the I2C clk and data lines between the PIC and the sensor and connect the pullups to 3.3 volts.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group