View previous topic :: View next topic |
Author |
Message |
creative_35
Joined: 02 Jan 2007 Posts: 15
|
One Wire Communication Protocol |
Posted: Fri Dec 11, 2009 10:51 pm |
|
|
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
|
|
Posted: Sat Dec 12, 2009 7:11 am |
|
|
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
|
|
Posted: Sat Dec 12, 2009 8:00 am |
|
|
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
|
|
Posted: Sat Dec 12, 2009 8:34 am |
|
|
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
|
|
Posted: Sat Dec 12, 2009 9:48 am |
|
|
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
|
|
Posted: Sat Dec 12, 2009 10:22 am |
|
|
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
|
|
Posted: Sat Dec 12, 2009 10:43 am |
|
|
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
|
|
Posted: Sat Dec 12, 2009 11:08 am |
|
|
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
|
|
Posted: Sat Dec 12, 2009 1:56 pm |
|
|
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
|
|
Posted: Sat Dec 12, 2009 10:10 pm |
|
|
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
|
|
Posted: Sat Dec 12, 2009 11:19 pm |
|
|
FvM wrote: | single wire software UART | Now I know what I'm gonna do for comms in my next project
Jay wrote: | Not bad for something that's been up 24/7 for over 20+ years. | Good stuff! And thanks for pointing out the examples.
Rohit |
|
|
Douglas Kennedy
Joined: 07 Sep 2003 Posts: 755 Location: Florida
|
|
Posted: Sun Dec 13, 2009 2:49 pm |
|
|
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
|
|
Posted: Sun Dec 13, 2009 4:20 pm |
|
|
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
|
|
Posted: Sun Dec 13, 2009 4:32 pm |
|
|
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
|
|
Posted: Sun Dec 13, 2009 5:10 pm |
|
|
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? |
|
|
|