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 support@ccsinfo.com

I2C project - need assistance

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
alefarre



Joined: 17 Jun 2005
Posts: 3

View user's profile Send private message

I2C project - need assistance
PostPosted: Fri Jun 17, 2005 9:09 am     Reply with quote

Hello, I am a student of engineering and making my own meteorological station as a project for my home!

I have analog sensors which will be connected to PIC12F675 each. And each of the PIC12 will interface through I2C to the central PIC 16F873.

As I have read another threads about I2C, I have concluded that a multimaster environment is difficult to achieve. And as PIC12 does not provide I2C by hardware but PIC16F873 does I plan to:

Set PIC12 as Masters by software and PIC16 as Slave by hardware.

Would this work? Are there gonna be problems with collisions or something like that?

Another thing is that I need to sleep PIC12's and want PIC16 wake them up wherever I want.

I would appreciate any comments, suggestions and code examples for the use of master PIC12 I2C and slave PIC16 I2C.

Thanks.
jds-pic



Joined: 17 Sep 2003
Posts: 205

View user's profile Send private message

Re: I2C project - need assistance
PostPosted: Fri Jun 17, 2005 9:56 am     Reply with quote

alefarre wrote:
Hello, I am a student of engineering and making my own meteorological station as a project for my home!

excellent first project.

alefarre wrote:

I have analog sensors which will be connected to PIC12F675 each. And each of the PIC12 will interface through I2C to the central PIC 16F873.

ok, so you have a distributed sensor system.

alefarre wrote:

As I have read another threads about I2C, I have concluded that a multimaster environment is difficult to achieve. And as PIC12 does not provide I2C by hardware but PIC16F873 does I plan to:


here is where you have jumped tracks, don't worry it is common before you have done a couple of designs. you are already discussing implementation details before you have quantified what problems the architecture has to solve. so, make a list of all of the things that you want your system to do, e.g.

1) get temperature data from sensor in back yard.
2) get rain guage data from sensor on pedastal
3) get wind direction and windspeed data from Dallas Onewire Weather Station.
4) present human-readable data on an LCD display.
5) provide raw data to a PC running linux so it can be stored, manipulated, and accessed by other programs (e.g. graphing and/or web access).

then, you need to set some system constraints which will start to shape your implementation, e.g.

1) sensors can be up to 50m from central point.
2) sensors must be remote powered from central point.
3) system must support an interface to a PC.
4) system must support a once-per-second update rate.
5) system must be immune to damage or latch-up to nearby lightning activity.

alefarre wrote:

I would appreciate any comments, suggestions and code examples for the use of master PIC12 I2C and slave PIC16 I2C.
Thanks.


first determine the requirements and constraints as i outlined above. then decide on how to implement it. for example, i believe you'll have a much easier time with RS232 (even TTL level) between the PIC12's and PIC16. timing is less critical and you don't need to worry about the distance limitations of i2c. moreover, RS232 is MUCH easier to debug if you don't have a little bit of lab equipment. the right way to do this is to hang all of the sensors off of RS485, and develop a lightweight polling protocol for the master to periodically interrogate all of the slaves. this will be nice and deterministic and easy to code for. by the way, this sort of implementation is commonly used in lots of industrial applications, and therefore will be a great learning experience for you.

as a side note, when you think i2c you should think board level or possibly board to backplane connections. when you think RS232 you should think module to module or system to system connections. serial TTL is sort of in the middle of the two, and saves the expense of the level converters at both end (e.g. MAX232). however modern RS232 drivers are extremely robust against stupid users (shorts) and ESD events (or high V/m fields like lightning produces), so you should take that into account as well. the "cheap" solution is not so cheap if various chips keeping blowing up.

ps:
you'll possibly end up with something like this:
http://losdos.dyndns.org:8080/demo/temperature/
e.g.


ps:
for more info on how i2c works, see
http://www.ccsinfo.com/forum/viewtopic.php?t=23260
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Fri Jun 17, 2005 10:19 pm     Reply with quote

A good post by jdc-pic although I would suggest looking at RS485 as an alternative for interprocessor commuications for a distributed system matching the profile put forward by jdc-pic.

Have you considered using an 18F45xx PIC instead of the 16F873 - The 18F family has a lot more system resouces and capabilities available for a project like this and is available as a hardware pin for pin compatible alternative.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Sat Jun 18, 2005 5:17 pm     Reply with quote

Quote:
I have analog sensors which will be connected to PIC12F675 each. And each of the PIC12 will interface through I2C to the central PIC 16F873.

Distributed processing of the sensor data is cool. Way to go.

Quote:
A good post by jdc-pic although I would suggest looking at RS485 as an alternative for interprocessor commuications.

Oh, add CAN to your list of buses to consider too. You can use PIC18F258, or MicroChip's MCP25050 CAN I/O expander/ADC. The former will give you a more flexible solution, and the latter will give you a smaller&cheaper solution.

Godspeed,
Nick
alefarre



Joined: 17 Jun 2005
Posts: 3

View user's profile Send private message

My problem is just I2C
PostPosted: Mon Jun 20, 2005 9:57 am     Reply with quote

Hello, I appreciatte your interest in my project.

First of all, sensors are not my problem. Its my decision to make use of analog sensors connected to PIC12 because I have already bought them. Distance is not a problem because I have planned to use wireless connection afterwards...

But is part of my project to implement I2C between the PIC12 and PIC16, as a challenge lets say...

Again I need assistance to know about my topology, that is, a lot of PIC12 as Master by software and PIC16 as Slave by hardware(which will be the central controller).

I have CCS C compiler with ICD and if you can help me or provide me some example code I will be grateful.

Thanks again!
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Mon Jun 20, 2005 10:26 pm     Reply with quote

Sorry no code example but a comment. IF you have a single central controller (the PIC 16) then why not implement a sinlge mater (the PIC 16) and multiple slaves. This would be far simpler to implement than a multimaster scenario.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
jds-pic



Joined: 17 Sep 2003
Posts: 205

View user's profile Send private message

PostPosted: Mon Jun 20, 2005 10:34 pm     Reply with quote

asmallri wrote:
Sorry no code example but a comment. IF you have a single central controller (the PIC 16) then why not implement a sinlge mater (the PIC 16) and multiple slaves. This would be far simpler to implement than a multimaster scenario.

unlike the PIC16, the PIC12 does not have HW-based i2c; and slave i2c without the SSP HW is extremely problematic. hence his inverted topology, with the PIC16 as the lone slave to many PIC12 masters.

prediction: "he'll be back".

RS232 or RS485 is the way to go here.

ps
alefarre wrote:

First of all, sensors are not my problem. Its my decision to make use of analog sensors connected to PIC12 because I have already bought them. Distance is not a problem because I have planned to use wireless connection afterwards...

how do you intend to get i2c over a wireless link?


jds-pic
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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