|
|
View previous topic :: View next topic |
Author |
Message |
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Thu Feb 27, 2020 6:42 am |
|
|
16 slaves, implies high bus capacitance. If each chip adds just 5pF, that
gives 80pF, without any wire at all. Add a few feet of wire and capacitance
will probably be at least three times this. Add connectors, and it goes up
even further. Cables typically have capacitances between perhaps
100 and 240pF/m, so with 2m plus of wire the bus is not suitable
for high speed operation. The I2C bus is normally specified for 1m maximum
length at 100Kbps, but 10M at 10Kbps.
High speed is _worse_ for noise immunity. You should always
aim to run the bus as slow as you comfortably can. The faster you push
it the more problems it'll have.
Speed is your _enemy_ for reliable communications over a distance.
Also remember that in the real world there will be much more RF than
you have over test links. I run I2C about 3m to some instrument heads, but
run with 10Kbps, and with the bus driven to 12v, with added checksums
on the data. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Thu Feb 27, 2020 6:44 am |
|
|
OK since 'high speed' is not necessary, get the project to work 100% at 'low' speed... 'Standard or 100KB/sec'.
Faster isn't always better. At higher speeds you MUST design PCBs properly, select correct components and pay very,very careful attention to details like wiring, power supply design, bypass caps, etc.
You could spend DAYS trying to debug code that doesn't work at high speed and finally discover it's really the hardware that is at fault. By starting off slow, you can get the software to properly work THEN increase the speed, if required. You can having timing problems as you switch LEDS on/off and be sure the power supply is good for 5X what you think it should be !
It looks like your project has 128 LEDs and 128 detectors. If the detectors are simple 'on/off - light/nolight', the design could have been made simpler. I did a similar project with 2 16F877s when they were new, 2+ decades ago. |
|
|
emaxxenon
Joined: 21 Jan 2020 Posts: 42
|
|
Posted: Thu Feb 27, 2020 6:55 am |
|
|
Thanks for the answers.
I will try to work at low speeds.
Would the resistance values be appropriate as in the diagram I sent?
The length of the cable from the master to the first slave is 50cm.
The cables between the slaves are 10cm. The total cable will be 2 meters.
Does it cause a problem at standard speed?
Do I need to change resistance values? I have not added my resistors yet and I want to add the appropriate one in line with this information.
I am currently waiting for 10us when turning on each IR led.
I am waiting for 160us for the scanning time of 16 IR LEDs.
Do I need to increase this waiting time when I reduce the i2C communication speed?
Code: |
for(int i=0; i<16; i++)
{
//Receiver IR
i2c_start();
i2c_write(R_SLAVE1_W);
i2c_write(i);
i2c_stop();
//Transmitter IR
i2c_start();
i2c_write(T_SLAVE1_W);
i2c_write(i);
i2c_stop();
delay_us(10); <---------------------------------------------
}
i2c_start();
i2c_write(R_SLAVE1_R);
R1_1 = i2c_read();
R1_2 = i2c_read(0);
i2c_stop();
|
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Thu Feb 27, 2020 8:54 am |
|
|
Ok, need to know WHAT are the 'slave' devices ? Not all I2C devices can run at all 4 speeds !! |
|
|
hamid9543
Joined: 31 Jan 2013 Posts: 63
|
|
Posted: Thu Feb 27, 2020 11:11 am |
|
|
temtronic wrote: | OK since 'high speed' is not necessary, get the project to work 100% at 'low' speed... 'Standard or 100KB/sec'.
Faster isn't always better. At higher speeds you MUST design PCBs properly, select correct components and pay very,very careful attention to details like wiring, power supply design, bypass caps, etc. |
Speed defined in master or master and slave ? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Thu Feb 27, 2020 12:56 pm |
|
|
'speed', bus speed is always defined or controlled by the 'master'. However one needs to know the slave capabilities for 'speed'. Obviously you cannot set the bus speed higher than the furtherest, slowest slave on the bus.
But we still don't know what the slave devices are... they may NOT be 'fast' devices.... |
|
|
emaxxenon
Joined: 21 Jan 2020 Posts: 42
|
|
Posted: Thu Feb 27, 2020 11:45 pm |
|
|
temtronic wrote: | 'speed', bus speed is always defined or controlled by the 'master'. However one needs to know the slave capabilities for 'speed'. Obviously you cannot set the bus speed higher than the furtherest, slowest slave on the bus.
But we still don't know what the slave devices are... they may NOT be 'fast' devices.... |
All the pic I use is the same (Master and Slaves = 18F25K22 / 20Mhz)
The same program is installed on all slave pic. I only turn IR leds on and off.
Only 8 receiver IR cards send information to the Master. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Fri Feb 28, 2020 6:24 am |
|
|
OK, now we KNOW that the slaves are actually PICs ,what I call 'active' I2C devices. Active, meaning a programmable computer controls the I2C subsystem unlike a 'passive' device where an internal 'state machine' does the controlling. That PIC is in the same family as the 46k22, so has a max I2C bus speed of 400KHz, however I would configure for 100KHz or 'slow' speed. You may need to enable 'clock stretching'. Start with the master and ONE slave, get a program to work, then add ONE more slave, get it to work, and then another....when all are working 100% THEN and only then, icrease the speed to 400KHz. It may work though a lot depends on proper hardware and correct coding.
Too bad you didn't ask how to get 128 LEDs and 128 rcvrs to work before....
You could have easily done it with just 2 18F46K22 PICs....one as the master AND LED control, 1 as the slave with rcvrs. |
|
|
|
|
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
|