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

One Wire Communication Protocol
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
creative_35



Joined: 02 Jan 2007
Posts: 15

View user's profile Send private message

One Wire Communication Protocol
PostPosted: Fri Dec 11, 2009 10:51 pm     Reply with quote

Hi there,
I need to transfer data from one pic to another with one wire. (RC1 is the only port available in master PIC) Is there any protocol available in ccsc?
Your valuable suggestions are appreciated, thank you.
Guest








PostPosted: Sat Dec 12, 2009 7:11 am     Reply with quote

When I bought my CCS C version 2.574 there was example code on the disk as well as information in the manual, so I'd try there first.
That being said, if you 'cut your own code' you can make your protocol bullit proof,hacker proof. I did that and to date NOONE has been able to get into any of my systems.
Jay
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sat Dec 12, 2009 8:00 am     Reply with quote

Quote:
to date NOONE has been able to get into any of my systems

Apparently, noone has tried seriously...
Referring to the original topic, what's the name of the said example?
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Sat Dec 12, 2009 8:34 am     Reply with quote

Quote:
I need to transfer data from one pic to another with one wire.
Is this communication in one direction or in two direction?

Single direction is easy, so my guess is you want to send and receive data on the same single I/O pin. There might be other protocols, but a protocol that is well documented and discussed on this forum is the Dallas Semiconductor 'One Wire' protocol (now owned by Maxim).

Touch.c in the Drivers directory is a first simple implementation of this protocol (Master only). A more advanced implementation can be found in ds2432.c, but this might be overkill for you.
The Slave in this protocol is normally a dedicated piece of hardware, that's why it will be more difficult to find Slave example code.

Development effort (==time==money) will be a lot less if you could free a second port and use standard UART or I2C protocols.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sat Dec 12, 2009 9:48 am     Reply with quote

Maxims one-wire protocol is difficult in two regards, I think:
- it has to work without a precise clock at the slave
- it's implementing additional data integrity checks for disturbed communication

Serial UART protocols with exact bit timing are much easier. They can work as software UART with any PIC.
You would be able to implement it bidirectionally on a one wire bus with pull-up resistor. Unfortunately, the
existing software UART from CCS don't support this mode of operation, so you have to design it on your own.

As with any half-duplex connection (e.g. RS485), there must be a clear rule who's allowed to talk at a time.
Guest








PostPosted: Sat Dec 12, 2009 10:22 am     Reply with quote

examples are EX.PBUSR.c, EX_PBUSM.C

Regarding the noone has defeated my protocol.
This equipment is listed as ULC Burglary Class AA, think of banks, jewelry shops, furriers, etc. It is NOT some simple cut-the-phone-line dialer system. Even if one wire(that's one conductor, NOT a cable) is cut, I have a backup and can communicate with all of the systems. Yes, some have tried, but my host knows where and when the tampering has happened. Some of the best crooks in Montreal and Toronto have tried, even the Feds(RCMP) and it's still NOT been compromised.
Not bad for something that's been up 24/7 for over 20+ years.
PICs and CCS C allowed the hardware to get simpler and smaller.

Designing a full duplex, interlaced, bidirectional, one conductor system that runs over 24 miles one way was a bit of a challenge, however it is still in operation today.


Jay
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sat Dec 12, 2009 10:43 am     Reply with quote

Yes, the said examples are still present with recent CCS C versions. If I understand right, they use external hardware
to achieve the wired or function, at least the referenced #use RS232 command specifies two pins. I've been
talking of multiplexing RX and TX to one pin by software.
Guest








PostPosted: Sat Dec 12, 2009 11:08 am     Reply with quote

The examples in my manual(December 10, 1997) show using Port B.0 as both xmt and rcv functions.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sat Dec 12, 2009 1:56 pm     Reply with quote

Yes, indeed, very interesting. It's also the case with CCS V3 examples. I wasn't yet aware of this option.
The old code can be still compiled without errors by V4 compiler. Have to check, if it still works.

Thanks for showing something new.

P.S.: The examples haven't changed with V4! It didn't realize, that there are two RS232 instances in the code.
It seems like the said examples are the requested solution.

I also didn't understand yet, that CCS ICDs can use a single wire software UART.
creative_35



Joined: 02 Jan 2007
Posts: 15

View user's profile Send private message

PostPosted: Sat Dec 12, 2009 10:10 pm     Reply with quote

Thanks for All comments,
Actually I need one way communication up on request (interrupt driven) from Master. I didn't notice the example file in ccsc. EX_PBUSM.C. Let me study it and I hope it can solve the issue. Maxim's one wire protocol is useless because It's source code is not available. Thanks for reminding ccs example.
Rohit de Sa



Joined: 09 Nov 2007
Posts: 282
Location: India

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

PostPosted: Sat Dec 12, 2009 11:19 pm     Reply with quote

FvM wrote:
single wire software UART
Now I know what I'm gonna do for comms in my next project Very Happy

Jay wrote:
Not bad for something that's been up 24/7 for over 20+ years.
Good stuff! Smile And thanks for pointing out the examples.

Rohit
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Sun Dec 13, 2009 2:49 pm     Reply with quote

I don't know where to get the manual that probably explains in more detail PBUSM and PBUSR. Is it using a max232 for example to get greater distance
of say 1500 ft? Now 20 miles must be using additional boosters. Can the devices connected be discovered as with dallas one-wire via the 00 01 10 search algorithm? Did the mounties (RCMP) test it on horseback?
Guest








PostPosted: Sun Dec 13, 2009 4:20 pm     Reply with quote

The examples are in the examples subfolder....commented by CCS,fairly easy to understand,even for an old Z80 Assembler guy like me...

I'm NOT using the MAX232 series of chips for serial buffers.They are NOT bidirectional,please remember I'm using ONE wire. I use descrete MPSA42, MPSA93 transistors as the level translators.To get the 24 miles for my system , you need +-60 volts at a few milliamps. Nowadays you could use a high voltage opamp configuration,but my version has been stable for 20+ years, so why change?

Yes, each node is addressable,but NOT using Dallas techniques. Rolling my own has had a LOT of advantages,especially being hacker proof.
I can even change a nodes address on the fly from the host,basiclally reconfigure it's id and purpose in life.


It was 'fun' to see the RCMP techs try to compromise my system!Got a real nice lunch that day!

Jay
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sun Dec 13, 2009 4:32 pm     Reply with quote

One wire implies that no unidirectional standard driver as MAX232 can be used. By default they are using
a single processor pin for a software UART operated with FLOAT_HIGH option (and an external pull-up resistor).
By changing the interface to use two individual pins, external driver transistors and protection circuits at
the receiver can be added. The present protocol uses an 8-Bit ID to indentify individual stations.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Sun Dec 13, 2009 5:10 pm     Reply with quote

creative_35 wrote:
Actually I need one way communication up on request (interrupt driven) from Master.
Not sure what you mean by 'communication up on request', but one way communication over a single wire is easy and can be implemented with a standard UART (software or hardware).

The only questions remaining are:
- What is the distance to the receiving PIC?
- Will there be only a single PIC listening, or multiple?
- What is the desired baudrate?
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