Question on i2c timing talking to expansions

Expansion modules and attachments
Post Reply
AlanM
Posts: 263
Joined: Wed Jan 01, 2014 7:26 am

Question on i2c timing talking to expansions

Post by AlanM »

I have four powerheads. Two are on the relay box dimming ports. Two are on a 16-channel PWM dimming expansion. I am using DCPump classes for all four powerheads and two are on sync and two on anti-sync.

I have a pump profile set for Nutrient Transport with a 60 duration. That should mean 600ms long pulses. The two on the relay box dimming port work great, but the two on the expansion don't seem to react in those sub-second timings. They turn on and off kind of randomly.

Roberto, do you have a sense for what kind of minimum timing is possible for those i2c devices? I'm guessing I'm running in to a latency in sending commands to that expansion that isn't getting the pulses recognized.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Question on i2c timing talking to expansions

Post by rimai »

I don't think so.
We can do very very fast transitions to create even lightning storms on LEDs.
So, it should be pretty fast.
I took a look at the libraries, which BTW, you patched ;) and I see this:

Code: Select all

void RA_PWMClass::SIXTEENChExpansionWrite()
{
	byte thiscrc=0;
	for ( byte a = 0; a < SIXTEENCH_PWM_EXPANSION_CHANNELS; a++ )
		thiscrc+=Get16ChannelValueRaw(a)*(a+1);
	if (millis()%60000<200) lastcrc=-1;
	if (lastcrc!=thiscrc || millis()<5000)
	{
		lastcrc=thiscrc;
		// setup PCA9685 for data receive
		// we need this to make sure it will work if connected ofter controller is booted, so we need to send it all the time.
		Wire.beginTransmission(I2CPWM_16CH_PCA9685);
		Wire.write(0);
		Wire.write(0xa1);
		Wire.endTransmission();
		for ( byte a = 0; a < SIXTEENCH_PWM_EXPANSION_CHANNELS; a++ )
		{
			SIXTEENChExpansion(a,Get16ChannelValueRaw(a));
		}
	}
}
What this does is it keeps track of a CRC to check for any changes in any of the channels.
When there is a change, it sends the data through to the module.
The only thing I can think of is latency on the loop() itself, but that would also affect the relay box ports too.
Try removing that CRC check and send data to the dimming module all the time to see if it makes any difference.
Roberto.
AlanM
Posts: 263
Joined: Wed Jan 01, 2014 7:26 am

Re: Question on i2c timing talking to expansions

Post by AlanM »

Thanks. I will try with that out and see what happens.

Another possibility is that the Jebao RW4s that I am sending the signal to isnt nearly as fast at reacting as the Tunze. I dont know what circuit they have internally listening for 0-5v DC and doing something with the speed...
Post Reply