CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

serial output on non tx/rx hardware pin
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
picer
Guest







serial output on non tx/rx hardware pin
PostPosted: Tue Jan 25, 2005 11:09 am     Reply with quote

I want to do comms between pics, easiest seems to be serial between, master talks to many slaves and slaves talk back to master. Can I use non usuart tx/rx pins to do serial between pics (then use simple printf statements). 877 will be master and probably 628 slaves, clearly the 877 doesn't have 4-5 hardware serial pins. Just need to pass data between them, maybe something else that just uses normal pins?? Thanks.
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

View user's profile Send private message Send e-mail

PostPosted: Tue Jan 25, 2005 11:11 am     Reply with quote

Google for RS-485, also search the forum archives.
_________________
Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
libor



Joined: 14 Dec 2004
Posts: 288
Location: Hungary

View user's profile Send private message

PostPosted: Tue Jan 25, 2005 12:02 pm     Reply with quote

... or you could also consider using the I2C or SPI bus (these have the advantage of a separate clock line, so unlike the USART solution there's no timing problems even at higher speeds, you can send and even receive at any rate without losing data, even when the PIC has other things to do.). CCS has internal I2C functions built into the compiler, you can easily use I2C on normal pins using only software also.
For longer distaces you can also use the industry standard CAN bus with most of the protocol problems (like collision avoidance, packet acknowledgement, error detection, etc.) already solved in the PICs hardware and in the standard. (even in a difficult multi-master multi-slave arrangement)
These busses are specially made to do what you want. (i.e. having multiple units on a single bus) Most of the PIC models have these I2C, SPI ports implemented in hardware, certain PICs have the CAN ports also.
It is also an advantage that you learn to use those solutions that are up-to-date standard in industrial control.


Last edited by libor on Tue Jan 25, 2005 1:25 pm; edited 1 time in total
picer
Guest







PostPosted: Tue Jan 25, 2005 12:55 pm     Reply with quote

Trying to keep the component count as low as possible and cost low too, see the 16F870 can do I2C and should be able to do everything the 628 can and costs about the same so can substitute that one. 877 has I2C as well so I would be set then. The slave pics have to do pwm and have a/d inputs so that should all fit the bill nicely. Thanks.
picer
Guest







PostPosted: Tue Jan 25, 2005 12:58 pm     Reply with quote

Woops, 87 has I2c and no a/d, 870 has a/d but no I2c. Will have to look again.
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Tue Jan 25, 2005 1:53 pm     Reply with quote

I think what you were originally proposing is viable. One master can talk to many slaves with one TX pin if each slave has an address and only listens to messages with it's address. Or with software UARTs you can have a TX pin for each slave, if you have enough ROM space.
On the receive side you could tie all the slave TX pins to the master RX pin as long as the slaves keep their TX tristated (high impedance) when they are not talking. If two slaves talk at once you will get garbage. Or each slave could have its own software UART RX pin on the master, if the master has enough ROM space.
_________________
The search for better is endless. Instead simply find very good and get the job done.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Tue Jan 25, 2005 3:42 pm     Reply with quote

picer wrote:
Woops, 87 has I2c and no a/d, 870 has a/d but no I2c. Will have to look again.


16F819
16F88

are a couple that fit your description. You should look at the product line card:
http://ww1.microchip.com/downloads/en/DeviceDoc/00148K1.pdf
picer
Guest







PostPosted: Tue Jan 25, 2005 5:04 pm     Reply with quote

819 looks even better than what I was looking at and cheaper too.
picer



Joined: 25 Jan 2005
Posts: 28
Location: Taxahoma

View user's profile Send private message

PostPosted: Tue Jan 25, 2005 5:20 pm     Reply with quote

Thread may go in a few directions here but..if I use I2C then I could have all the pic's on the buss talk to a I2C eeprom correct? That could be very usefull to me.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Tue Jan 25, 2005 5:45 pm     Reply with quote

Yes, it will just be another slave on the "network".
libor



Joined: 14 Dec 2004
Posts: 288
Location: Hungary

View user's profile Send private message

PostPosted: Tue Jan 25, 2005 6:34 pm     Reply with quote

There are lots of I2C devices become available to you if you get familar with this bus, you can connect many devices on the same bus (only the line capacitance is the limit = 20-30 ICs or ca. 10 m of trace), with repeaters and hubs you can also go beyond this limit.
Just a few types of ICs and sensors that are all made with I2C interface: lcd controllers, real-time clocks, eeproms, A/D converters, I/O ports, video encoder ICs, RF chips, various sensors (temperature, pressure, etc.)
I am playing nowadays with a magnetic compass IC module, this also has a I2C interface.
Philips is one of the main promoters of this bus. look here
picer



Joined: 25 Jan 2005
Posts: 28
Location: Taxahoma

View user's profile Send private message

PostPosted: Wed Jan 26, 2005 2:00 pm     Reply with quote

Does anyone have any schematic examples of I2C using the built in I2C in hardware, assume it's pretty much the same way as using an external I2C chip but those are the only examples I can find. Are there special considerations with using the pic for this, as in steps to protect the actual i/o pin, etc? Also assume the code will be somewhat different?
libor



Joined: 14 Dec 2004
Posts: 288
Location: Hungary

View user's profile Send private message

PostPosted: Wed Jan 26, 2005 3:48 pm     Reply with quote

No special tricks as long as you connect devices using the same supply voltage and no galvanic isolation needed. You connect the clock and data lines of all the devices to the same bus. (clock to clock, data to data, no crossing!, the data line is bidirectional itself, the clock is supplied from the master device only, though clock pulses can be stretched by a slave when he wants to read the data line slower than it is transmitted) The devices can only pull-down the line, so when two or more devices do it at the same time, this means a hardwired logical OR.
Dont forget the two pull-up resistors to make the bus high when idle (one on each bus line).
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Thu Jan 27, 2005 8:49 am     Reply with quote

I one trick I rememeber is to only address the pic with even addresses.
It is part of the protocol.
see
http://www.ccsinfo.com/forum/viewtopic.php?t=21129&highlight=i2c+address
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Thu Jan 27, 2005 9:46 am     Reply with quote

treitmey wrote:
I one trick I rememeber is to only address the pic with even addresses.
It is part of the protocol.
see
http://www.ccsinfo.com/forum/viewtopic.php?t=21129&highlight=i2c+address


The LSB of the address determines if the slave is in read mode (bit is set) or write mode (bit is clear). From the slaves stand point the address that you set is always even but from the master's point, it can be even or odd.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
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