Go Down

Topic: 100KHz and 400KHz devices on I2C, anyway to run at both speeds? (Read 600 times) previous topic - next topic

liudr

I have DS1307 RTC with a maximal I2C frequency of 100KHz. I am planning to use MCP23017 that can do 400KHz (max ATMEGA328 can do). Having the added speed will help me flip MCP23017 pins faster. I have a few MCP23017 on route but from calculation, the top speed of setting the pins with 400KHz bus frequency is only about 13KHz.

Say I have 400KHz I2C speed, and I issue a write command with slave address byte + register address byte + data byte + some ack, that is about 30 bytes. So 400KHz/30=13KHz (Is this correct?).

If I have to run at 100KHz, then the top speed is down to 3.3KHz, barely enough for photo gate experiments.

So I wonder if there is any way to run at 100KHz for RTC and then 400KHz for IO extender (probably not?).

Maybe I have to use something like DS1388:

http://datasheets.maximintegrated.com/en/ds/DS1388.pdf

This one does 400KHz but is quite expensive. A DS1307 is only 1/10th of its price if you find the right store (say, dipmicro.com).

Peter_n

You hope to get 13kbyte per second ? But the Arduino has a lot overhead in the Wire library.
Sensors have a hardware implementation for I2C, but the Arduino has a combination of hardware and software (interrupts and buffers and functions, the works). I don't know what the maximum transfer rate is. Some have created faster I2C functions, like the http://www.i2cdevlib.com/

Haven't you heard ? The new RTC is the DS3231. Forget the old dinosaur and troublesome DS1307 with (often crappy) external crystal. Go for the DS3231. It has an internal crystal with temperate compensation and works all the time and is super accurate.

When speed is critical, you better look for something with a SPI bus.

liudr

Thanks.

OK so the rate is further down from 13K writes per second. fm was able to do I2C lcd backpack so was adafruit so I guess that is enough for character LCD. I will use atmega328's IO for high speed stuff like sensing photogates. I remapped my pins and found out that if I run the LCD on extender, I will have enough pins to do the rest (faster stuff) on atmega328's pins. Problem solved.

I just looked at the DS3231 (thanks for the model number), it's good but expensive. DS1307 is 0.5 USD.

I've also used Jeff Rowberg's libraries. Nice and clean but takes a huge chunk out of program space. I've never tried running his libraries on IMU and wire library on an RTC, at the same time. That may not work? He does have a DS1307 library though.

Peter_n

But the DS1307 needs a crystal.
And the Ds3231 is about 1.51 dollar for a complete module on Ebay.
Your turn.  ;)

liudr

Maybe look for a supplier other than digikey? Trying to use ebay modules on a board design is hard. But I'll grab a module for prototyping. Thanks.

robtillaart


if you are on an UNO you can change the I2C speed with just one line of code. TWBR =
Check my I2C multi-speed scanner for the details. Note that you can also go for "weird" numbers ... - http://forum.arduino.cc/index.php?topic=197360.0 -

By adding the TWBR = .. for every read/write you can optimize the devices for speed. Best to add that line in the libraries you use.
(if you want it nice you reset them to the old value at the end of e.g. a read().
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Graynomad

What does a 100k device do when it sees a 400k bit stream?

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

liudr


What does a 100k device do when it sees a 400k bit stream?

______
Rob


You read my mind.

Rob (T),

What is your experience?

robtillaart

I expected interference too but so far I did not encounter problems. Main experience is mixing an EEPROM & IO extender in a few  experiments. I assume that the (100KHz) address logic could not decipher the 400KHz signals and ignores them. For any serious project I would stick to one bus speed and seek components that match the speed. pref. 400KHz to minimize time used.

But yes I should have put a disclaimer under it.
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up