Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Simple I2C interface chip?

Status
Not open for further replies.

oeginc

New Member
Ok, I'm in the beginning stages of designing an electronics platform that will interface to many other devices (think phidgets like).

I believe I'd like all of the devices (which I will be making as well) to interface using the I2C (TWI) protocol (unless there is something better/easier/more universal). I want to leave open the ability for 3rd parties to create devices for this platform as well.

The question I have is:

1) Is there a simple chip that will handle all of the i2c interface stuff for me (analog and/or digital interface to various things like temperature sensors, tilt sensors, etc). Currently I have been using PIC chips to do the interfacing, but when you start talking about having to add a PIC chip to every device and then have special programming for that device, it starts to increase the price quite a bit.

2) If *I* must use a PIC chip (or similar), can anyone recommend a good/cheap chip to use? It only needs to have a couple ADC lines (2-4), a couple digital i/o lines (2-4), and the i2c interface. It doesn't have to be from Microchip, any readily available manufacturer will do. I've used the 16F877a chip, but I'm looking for something that's not so overkill. :)
 
You would always require some kind of programmable device to act as the master device on any I2C buss. The simplest, cheapest, quickest to develop device I've come across is the Picaxe series of PIC microcontroller chips.

T hey are PIC based but have a preinstalled bootloader that are programmed by basic language via a passive serial cable to a PC using their free ICD programming editor. Their version of basic includes hi-level I2C set-up and command functions and their newest released chips can act as a I2C slave as well as a I2C master. Most of their chips are under $10 and there is no need for a hardware programmer/burner.



Lefty
 
Leftyretro said:
They are PIC based but have a preinstalled bootloader

This isn't entirely so, the original PICAXE's didn't run a bootloader, and you don't actually program the PIC - the PICAXE is a BASIC interpreter, which runs tokenised programs stored in the internal data EEPROM memory - which means it's fairly slow, and only has very limited program space. It's really a limited 'poor mans' BASIC STAMP, but VERY impressive for what it is, and how cheap it is!.

The newer, larger PICAXE's presumably still run as an interpreter?, but because of the new FLASH memory writing capabilities presumably store the tokenised BASIC as tables in the program memory?. I don't really think this system would be considered a 'bootloader' either?, as it's only transferring data and not PIC code.
 
I can get the 16F877a chips for under $8/piece, and I (correct me if I am wrong) believe the PIXAXE chips -ARE- Microchip PIC chips...

I don't care so much about the ease of programming as I do the ease of implementation (fewest components) and the cost of the chips.

In the end, I expect I will need to make hundreds of these, so the difference between a $2.00 chip and a $10.00 chip (as well as supporting components) will be significant.
 
Nigel Goodwin said:
This isn't entirely so, the original PICAXE's didn't run a bootloader, and you don't actually program the PIC - the PICAXE is a BASIC interpreter, which runs tokenised programs stored in the internal data EEPROM memory - which means it's fairly slow, and only has very limited program space. It's really a limited 'poor mans' BASIC STAMP, but VERY impressive for what it is, and how cheap it is!.

The newer, larger PICAXE's presumably still run as an interpreter?, but because of the new FLASH memory writing capabilities presumably store the tokenised BASIC as tables in the program memory?. I don't really think this system would be considered a 'bootloader' either?, as it's only transferring data and not PIC code.

You may very well be correct. Piaxe's FAQ document referes to their chip's preloaded code as a 'bootstrap program' but of course the user program being downloaded is a tokenised series of commands that is interpreted on chip as you stated. So perhaps Picaxe is not using the best or correct term for the function they preburn into their chips that communicates to their Windows ICD programming editor.

Speed for I2C should not be an issue as with their higher clock speed options their I2C commands can utilize I2c devices communication at well over 1mhz which is well above the standard low and high speed I2C standards. Of course if the application requires a lot of additonal computational functions in addition to just moving the data back and forth then certainly there are more powerful microcontroller systems/languages.

Lefty
 
oeginc said:
In the end, I expect I will need to make hundreds of these, so the difference between a $2.00 chip and a $10.00 chip (as well as supporting components) will be significant.

As I understand it, you're basically trying to make your own I2C 'chips', although in your case the 'chip' will actually be a module. So each 'chip' will be a slave device, will require it's own address, and will probably require a PIC that has I2C hardware? - master is easy in software, but to do slave you really need hardware.

And yes, the PICAXE is a pre-programmed PIC - funnily enough the name PICAXE was used by Don McKenzie of Dontronics years and years before Reved used the name.
 
oeginc said:
I can get the 16F877a chips for under $8/piece, and I (correct me if I am wrong) believe the PIXAXE chips -ARE- Microchip PIC chips...

I don't care so much about the ease of programming as I do the ease of implementation (fewest components) and the cost of the chips.

In the end, I expect I will need to make hundreds of these, so the difference between a $2.00 chip and a $10.00 chip (as well as supporting components) will be significant.

Yes, they are certainly based on selected PIC chips. And for volume production the underlining PIC chip is cheaper. It just wasn't clear from your original posting that you have no issues with programming skills or were considering high volume production. For those of us that aren't skilled in ASM or C and just want something simple and cheap that can do I2C, the Picaxe is a neat solution....

Lefty
 
oeginc said:
I can get the 16F877a chips for under $8/piece, and I (correct me if I am wrong) believe the PIXAXE chips -ARE- Microchip PIC chips...

I don't care so much about the ease of programming as I do the ease of implementation (fewest components) and the cost of the chips.

In the end, I expect I will need to make hundreds of these, so the difference between a $2.00 chip and a $10.00 chip (as well as supporting components) will be significant.

Newark has the following price on the MICROCHIP PIC16F877A-I/PQty List Price 1 - 25 $4.94 26 - 99 $4.81 100 + $4.68
IIRC you said you did not need that many pins. They have the PIC16F88 for under $3. If you choose one with an internoscosc such as the 88 you can save another 50 cents by not buying the crystal caps board space etc.

Depending on you exact needs you might find one with all the features you need for under $2.

I suggest you build and debug the system with a overkill chip like the 877A or the 88. Then once you know you memory needs you can select a chip with just enough to do the job.
 
pull up the parametric search on the microchip website, and filter out all the 16f (or 18f) series chips that don't have an "MSSP" - master synchronous serial port. now pick one with a price that's right, and meets your other requirements.

you can do reasonably well emulating i2c timing with a software uart, but why bother when Microchip has a Philips certified I2C Master/slave interface built right into the chip.

the commands to operate the hardware are pretty simple, and using soft-interrupts (polling) can handle 400kbps transfers no problem, and leaves plenty of CPU power left over for other routines.
 
Nigel Goodwin said:
As I understand it, you're basically trying to make your own I2C 'chips', although in your case the 'chip' will actually be a module. So each 'chip' will be a slave device, will require it's own address, and will probably require a PIC that has I2C hardware? - master is easy in software, but to do slave you really need hardware.

And yes, the PICAXE is a pre-programmed PIC - funnily enough the name PICAXE was used by Don McKenzie of Dontronics years and years before Reved used the name.

Yes, exactly. I am planning to make an i2c servo control module, lcd display module, temperature module, sonar module, H-Bridge motor control module, Relay control module, Accelerometer module, etc.

For the temperature module, the *only* thing I need it to do is read the temperature (adc) and send it down the pipe so I thought there would be something "simple" that I could use in place of a PIC chip.

Are PIC's the best/cheapest chip for doing i2c stuff? Where do the AVR's, the Scenix, or the ARM's fall on this subject? I only have experience with PIC's at the moment (although I have a bunch of Scenix chips laying around to experiment with, as well as some propeller chips - but I think 8 CPU cog's is *WAY* overkill).

And to complicate matters more, is I2C or CAN (or SPI for that matter) better/more popular? :)
 
Last edited:
All the commercial buses are designed to meet specific needs, so none really meet your requirements very well - there was a project called PICNET a few years ago, which did a similar scheme over serial, and later USB, essentialy networking PIC's over a simple bus. Unfortunately the site has disappeared :(

But all the buses you suggest are probably more complicated than you need?, if you're going to use one of them I would suggest picking one that has devices available that you're going to use directly on the bus (such as I2C chips).

Processor wise I don't think it makes much difference?, and PIC's are by far the most popular.
 
for reading the temperature, consider the LM75 (or equivalent). i2c connected thermostat, it can both read the temperature and operate stand-alone, responding to set-points.

Texas Inst seems to have the cheapest version, the TMP175
 
justDIY said:
for reading the temperature, consider the LM75 (or equivalent). i2c connected thermostat, it can both read the temperature and operate stand-alone, responding to set-points.

Texas Inst seems to have the cheapest version, the TMP175

Excellent, I should have thought of that (PC's, duh!). And to expand on this a little further, I did some more digging and happened across these:

PCF8591; 8-bit A/D and D/A converter
=============================
The PCF8591 is a single-chip, single-supply low power 8-bit CMOS data acquisition device with four analog inputs, one analog output and a serial I2C-bus interface. Three address pins A0, A1 and A2 are used for programming the hardware address, allowing the use of up to eight devices connected to the I2C-bus without additional hardware. Address, control and data to and from the device are transferred serially via the two-line bidirectional I2C-bus.

The functions of the device include analog input multiplexing, on-chip track and hold function, 8-bit analog-to-digital conversion and an 8-bit digital-to-analog conversion. The maximum conversion rate is given by the maximum speed of the I2C-bus.

ADT7516/ADT7517/ADT7519
=====================
The ADT7516/ADT7517/ADT7519* combine a 10-bit temperature-to-digital converter, a 10-bit 4-channel ADC, and a quad 12-/10-/8-bit DAC, respectively, in a 16-lead QSOP package. The parts also include a band gap temperature sensor and a 10-bit ADC to monitor and digitize the temperature reading to a resolution of 0.25°C.

I've read that Analog Devices also makes a very simple 4 ADC/DAC chip as well.

Both of these chips are very similar to what I am looking for. Something that allows my devices to interface with the i2c bus without causing me too much headache (like having to program every single module that goes out). In the end, I'm not sure which way I'll go because choosing a PIC chip appears to cost about the same, but it gives me alot more functionality...

If anyone has any other suggestions, please let me know.
 
After looking around, I think I might go with the Scenix (now Parallax) SX28AC chip for this project.

Parallax sells them for $2.79/each (or down to $1.89 in quantity), they have 20 I/O pins, 2K program space, 136 bytes of RAM, require very little extra hardware to run, and can run at 75MIPS.

Compare that to a 16F84a that sells for ~$6.00/each, has 13 I/O pins, 1.75K program space, 68 bytes of RAM, and can only run 20MIPS...

am I crazy here? What am I missing...
 
oeginc said:
After looking around, I think I might go with the Scenix (now Parallax) SX28AC chip for this project.

Parallax sells them for $2.79/each (or down to $1.89 in quantity), they have 20 I/O pins, 2K program space, 136 bytes of RAM, require very little extra hardware to run, and can run at 75MIPS.

Compare that to a 16F84a that sells for ~$6.00/each, has 13 I/O pins, 1.75K program space, 68 bytes of RAM, and can only run 20MIPS...

am I crazy here? What am I missing...

Well for a start you've chosen a PIC antique to compare it with, that was obselete last century! - it was replaced by the cheaper, higher spec, 16F628 in the 1990's. However, people (rather stupidly) keep using it, so MicroChip appear to have reintroduced it at an inflated price - which can only be good for their profits.

The Scenix chips are pretty obscure, and have never managed any sort of market penetration, but may well be perfectly fine for your purposes?. However, do the Parallax chips include hardware I2C interfaces, which are really essential for I2C slave operation (the 16F84A doesn't either, but there are plenty of more modern PIC's that do).

I would suggest you don't get 'hung up' on MIPS, from the looks of your requirements high MIPS are of no use to you - and I would suggest all you need is small modern PIC's with internal 4 or 8MHz oscillators, and I2C hardware.
 
the 84 is an ancient chip, hence the high price

check out the 16F884 ... 4k, 35 IO pins, hardware I2C (or spi) port, flexible onboard clock generator (32khz-8mhz), roughly $2.50

mips aren't everything. 20 mips is hardly "slow" - speed comes from efficient programming, relying on instructions per second is just a crutch for sloppy code.
 
The chip runs at 75MIPS. Not the basic that's run on it.... Even 1MIPS is incredibly powerful if you have hardware level access.
 
Last edited:
Sceadwian said:
The chip runs at 75MIPS. Not the basic that's run on it.... Even 1MIPS is incredibly powerful if you have hardware level access.

Who codes in Basic? Assembly language all the way baby!

justDIY said:
the 84 is an ancient chip, hence the high price

check out the 16F884 ... 4k, 35 IO pins, hardware I2C (or spi) port, flexible onboard clock generator (32khz-8mhz), roughly $2.50

mips aren't everything. 20 mips is hardly "slow" - speed comes from efficient programming, relying on instructions per second is just a crutch for sloppy code.

This is very good to know, the 16F884 sounds like it's right up my alley, I'll take another look at the Microchips and see what I can find. There are just SOOOOoo many choices it's mind boggling sometimes. I want to Keep It Super Simple. ;)

Also, forgive me for being ignorant, but why does the i2c interface need to be hardware driven for slave applications? Scenix provides software i2c source code for "authentic i2c master/slave interface" HERE
 
Last edited:
PIC16F88 I2C hardware master code

"you can do reasonably well emulating i2c timing with a software uart, but why bother when Microchip has a Philips certified I2C Master/slave interface built right into the chip."

I have a PIC16F88 and some folks are telling me that the only way to use it as an I2C master (controlling a 24LC512) is to write code that controls the pins individually (called bit banging I believe). I have such code already but it ties up the microprocessor. I need to know if it is possible to use the internal hardware to impliment an I2C master, in particular how the pic88 hardware sees the ack signal from the slave.

I am writing my code in assembly language because that is all that I know (for working with the pics).
I already wrote code (with much assistance) that uses the usart hardware to talk to the serial port. That part of the project is finished.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top