Excuse me for my English.
How can I send data from a PIC 16F876 to four slaves
using the I2C bus protocol, with the same address?
Could you help me, a piece of code would be welcome!
mimie64.![]()
Excuse me for my English.
How can I send data from a PIC 16F876 to four slaves
using the I2C bus protocol, with the same address?
Could you help me, a piece of code would be welcome!
mimie64.![]()
I2C bus protocol requires unique addresses for each slave. Just code the address into each slave if you are building the slaves yourself of course.
Thanks to all of you for your greath wok!
... just to avoid to have trouble in future and have a clear view of a new project, I have in plan to use the slave routine on almost 12 PIC of 18F2550 and one Master with 18F4550.
The idea is that:
I shall have the Master far from the first slaves at about two to three meters and the second slave is far from the first slave around 50 cm, and all other slaves are distanced 50 cm between them.
At the end the total length shall be more than 10 meters. but less that 12 meters.
Also, I would use the RJ45 connectors to make interconnection between the PCBs and use the preassembled CAT5 Ethernet patch cable to carry the supply voltage from the Master to the slaves.
I have thinked to put on pin 1, 2 and 3 the VCC, on pin 4 the Clk, on pin 5 the Dat and on pin 6. 7 and 8 the GND?
The lenght of the cables can be a problem?
The idea to use the RJ45 with the CAT5 patch cable is good?
Leo
Last edited by Wirecut; - 27th March 2016 at 13:19. Reason: typo error
Leo
WIKI I2C
CAT5 CAPACITANCEThe maximum number of nodes is limited by the address space, and also by the total bus capacitance of 400 pF, which restricts practical communication distances to a few meters.
52pF / metre
cat5 balanced cable / i2c unbalanced signal.
cat5 characteristic impedence of 100 ohms is probably a big load for the i2c pins also.
its not a good match , and won't go far
A regular CAT5 RJ45 has 4 twisted pairs, but they're not "in order"
1,2 orange,orange/wht
3,6 green,green/wht
4,5 blue,blue/wht
7,8 brown,brown/wht
I'd pair the SDA and SCL signals each with a GND (ie 1=GND, 2=SDA, and 7=SCL, 8=GND) and use the others for PWR/GND.
10 meters is a long way for a single-ended TTL level signal. They make I2C bus extenders for this sort of thing.
If I have correctly understand, the maximum length from the capacitance point of view is around 8 meters, but what shall be the maximum distance for the single ended TTL?
Leo
Leo
I don't think there's any good single answer to that... it's dependent on so many different things it's hard to make a general statement.
Personally, I start getting nervous as soon as a signal leaves a board!
SDA and SCL are not good combination in one pair. Because of cross talk.
Much better is to combine GND and SDA on ona pair, GND and SCL on second pair. But capacitance play big roll. Probably CLK must be driven, not with pull up. SDA should have strong pull up.
But do not connect multiple GND on both sides, as that will create long loop antenna, probably...
I thing, but maybe i'm wrong, best chanse to get it to work is:
1. Pair GND and signal on 2 pairs for SDA and SCL, connect that ground only on output port of module.
2. Use third pair for power
3. Ground unused pair master, as GND for signals.
Generally not good idea to run TTL signals out of boards.
If you design master and slave's why not to go with RS485, half duplex or duplex?
me tooPersonally, I start getting nervous as soon as a signal leaves a board!
spi can get that sort of distance but you need a cs signal for each slave
I wonder if you used a pair of those 3v-5v level shifters back to back if they could act like a repeater ?
could be a cheap solution
wireless may be an option
rfm69 modules and the like can get 300k bps over that range and a master slave setup is no too difficult
It will work fine - as long as the PICs are the only I2C devices on the bus. The I2C specification was written to deal with low-power devices that have no more than 2 mA drive. As a result, all the pull ups (in parallel) could be no smaller than 2.5K. Since a PIC pin will sink more than 20mA, you can use much smaller pull ups. If there are only two PICs on the bus, I regularly use a 1K pull up at each end, with 10 ohms in series (one at each end) to reduce ringing. Since your CAT-5 will be twisted pairs, use one wire of each pair as GND (and the other as SDA or SCL). You should have no trouble at distance of at least 50'. But if you do get errors, you can slow the I2C bus down to lower data rates.
Be aware, however that any other non-PIC devices on the bus will probably not be able to drive such small pullups properly.
Charles Linquist
Your tips are pushing me towards the RS485.
The only trouble and not've never used before.
I am somewhat concerned about the protocol to use.
You have to give me a hint where to look to select the protocol that I could use?
Leo
Leo
If you have used serial RS232, then the RS485 is just the same. Only drivers (chips) are different. And the signal is TTL level from your controller to the RS485 driver.
The RS485 is not a protocol, rather a low level electric specs of the medium. It does not care about how the data will be sent.
So you really have not many concerns on this. Almost Plug and play.
Ioannis
Bookmarks