View previous topic :: View next topic |
Author |
Message |
hmmpic
Joined: 09 Mar 2010 Posts: 314 Location: Denmark
|
TX/RX simple 1 wire custom made protocol...? |
Posted: Fri Aug 15, 2014 2:30 pm |
|
|
I need to transmit and receive some data on a 1 wire simple custom made protocol.
There are two unit, one is sending and one is receiving! Not two way com.
Communication must be slow and real simple. First I think using slow RS232 maybe 1200b. The code must be simple C, use of delay is optimal here.
We are talking simple protocol, no checking and complicated stuff, just some clean and simple ansi C stuff. It is not time critical.
Maybe someone have some working code?:-) |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Fri Aug 15, 2014 2:39 pm |
|
|
CCS supplies an example in the FAQ section(?) using a 'one wire' configuration, though good old 'RS-232' will work fine if half duplex using putc(), getc().
you may need 'drivers' on the wire if going more than say 1M.
hth
jay |
|
|
hmmpic
Joined: 09 Mar 2010 Posts: 314 Location: Denmark
|
|
Posted: Fri Aug 15, 2014 3:02 pm |
|
|
Hi
NO wire it is light from a monitor, sound old and crazy. Only ansi C |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Fri Aug 15, 2014 4:26 pm |
|
|
I "made" this:
http://www.ccsinfo.com/forum/viewtopic.php?t=51489
months later i don't think it solves any issues but it was fun to make.
I think what you are trying to do is blink a couple of pixels on the screen black and white and use it to program/configure somthing...
Check out hackaday.com... ive seen this before.. cant tell you where in the site.
G. _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
hmmpic
Joined: 09 Mar 2010 Posts: 314 Location: Denmark
|
|
Posted: Sat Aug 16, 2014 12:28 am |
|
|
Yes just that, light is a real cheap way to update some user config on a system. OK, i will make something my self... |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19545
|
|
Posted: Sat Aug 16, 2014 2:48 am |
|
|
It's worth just adding, that the existing 'software' RS232, now supports (has done for a few years now), 'FLOAT_HIGH' as an option. When this is used, the driver _only_ pulls the line low, just like I2C drive.
So you can simply have two #use RS232 statements, one just defining a TX pin, and one defining an RX pin, like:
Code: |
#use RS232 (BAUD=1200, TX=PIN_A0, FLOAT_HIGH, STREAM=TXO)
#use RS232 (BAUD=1200, RX=PIN_A0, STREAM=RXI)
|
Then simply have a pull-up resistor on this line, and you can fputc to the stream TXO, and the data will be sent on the line, and fgetc on RXI to receive.
If you use a pin that supports an interrupt on falling edge, then both devices can ignore the line, till it drops to say the other device is signalling.
The only 'ingenuity', is working out how to handle things like simultaneous 'starts' occurring. |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Sat Aug 16, 2014 8:03 am |
|
|
Ttelmah wrote: | The only 'ingenuity', is working out how to handle things like simultaneous 'starts' occurring. |
CAN deals with this by having a fresh start after a random delay.
It does have to monitor for bus contention.
Mike |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19545
|
|
Posted: Sat Aug 16, 2014 8:52 am |
|
|
Yes.
The key thing is though that using 'one wire' open collector drive, with software RS232, you won't know it's happened. Remember that software RS232 doesn't read the line at the same time as writing, so won't even know that something else has pulled the line low.
So long as this approach is 'single master', it is no problem, but trying for anything like multi-master, will be quite difficult.
For single master, with reply only, this approach needs the minimum software. |
|
|
hmmpic
Joined: 09 Mar 2010 Posts: 314 Location: Denmark
|
|
Posted: Tue Aug 19, 2014 4:09 am |
|
|
Hi
My solution after some test.
C# program there read some configurations string and flash them out on a monitor. I made lot of test with ambiance-light sensors. The best result was some gray level on the monitor. I convert the string to bit resulting in gray, white, and black. It wont work with just black and white and some timing. Therefore the 3 gray level, it eliminate the timing issue. So simple to convert to .ASP and mobil phone.
For reading the blink stream I use my PIC and one ad-converter there slice the light level into to bit again. It work, and it is cheap fast and smart! |
|
|
|