Speeding up a project which has 10 I2C devices

My project uses 10 I2C FM receivers (AR1010s). I am writing to these receivers quite quickly, changing the tuning and volume of all of them about every 50ms. I’m using multiplexing to address them individually due to the fact that they have a hard-coded I2C address.

The problem I am having is that switching and communicating to each of the radios is a pretty slow process. I identified the “wait for response” section of the tuning function as the culprit, so I’ve commented it out (I didn’t write this function).

The function with commented out part in the middle:

void tuneToStation(unsigned int v) {
  unsigned int r;

  writeReg(2, 0xF400);     // clear to change freq
  
  writeReg(2, 0xF600 | (v - BASEFREQ)); // set REG2_TUNE to new freq
  
  /*do {
    delay(10);
    r = readReg(STATUS);
  } while(!(r & 0x0020));    // waiting for completion*/
  
  r = readReg(RSSI);         // reading signal strength
  r = (r & 0x7e00)>>8;
}

My program logic goes like this:

start loop → read sensors → change radios → delay(50) → end loop

My question is : is there a better way to speed this up? I have a feeling that this will eventually lead to disaster if my Arduino finishes the loop and tries to write to one of these radios while it’s still sending a response from the previous loop.

I am writing to these receivers quite quickly, changing the tuning and volume of all of them about every 50ms.

I've heard of "obsessive channel-surfing", but this is ridiculous ;D

It's going to take a little time for the radios to re-tune and have the RSSI value settle at the new frequency. The code you borrowed from waits for that to happen before doing anything else. By eliminating that wait, you've probably invalidated the RSSI data you're reading.

A better approach would be to do two loops: you change the settings on all the radios in the first one, and check the results in the second. That way, the radios are almost certain to be ready when you come back to check on them.

I've heard of "obsessive channel-surfing", but this is ridiculous ;D

It's "art", man ;)

Your solution sounds good, implementing it now...

It should be possible to run an I2C device off the digital pins. Though you'll have to write your own I2C library to do it. That way you have access to all devices simultaneously. Of course it does kinda defeat the purpose of I2C. Then again so sorta does hard coded IDs...

You could try the SPI interface rather than the I2C as SPI has dedicated chip select lines.

Did you manage initialise them? As I can't get them to fire up.

I'm running an arduino @ 3.3v 8 MHz and when reading the device ID using I2C all works well, but writing the initialisation sequence fails, also rereading the device ID afterwards returns corrupt data?