View previous topic :: View next topic |
Author |
Message |
beaker404
Joined: 24 Jul 2012 Posts: 163
|
RS232 on one wire |
Posted: Fri Oct 04, 2019 2:18 pm |
|
|
CCS 5.064
MPLAB 8.91
PIC18F87K22 @ 64MHz
Have a great project going, I am sending data via RS232 via a MAX232 chip off my PIC board to a real RS232 COM1 DB9 connector on my laptop and watching the data on hyperterminal. All is working great, now I want to use only one wire to do both TX and RX.
Should be simple enough, I am trying the first option here:
https://circuitcellar.com/cc-blog/one-wire-rs-232-half-duplex-ee-tip-135/
I guessed the typo for the resistor was 4.7K then tried 47K.
So what happens is, when I turn my board on, I get the greeting sent to hyperterminal. Just cannot get anything from hyperterminal to the PIC and have it acknowledge.
Set my UART/PIC up like this:
Code: | #device ADC=12 //12 BIT ADC on 18F87K22
#fuses HSH, NOWDT, PUT, NOBROWNOUT, NOMCLR
#use delay(crystal=16M, clock=64M) //18F87K22 running at 64KHz
#use rs232(UART1, baud=57600, STREAM=SERIAL, errors) //Serial Port running at 57600 Baud
#USE SPI(MASTER, MODE=0, SPI1, STREAM=SPI,FORCE_HW) //SRAM SPI running at 16MHz
#use spi(master, SPI2, mode=0, baud=1000000, stream=STREAM_SPI_9356, bits=8, FORCE_SW) // does not work on SPI2 with FORCE_HW EEPROM SPI |
Looking for ideas here, it all works if I go back to my basic two wire rs232 so I know hardware and software are compatible that way. Anyone have thoughts on one wire for rs232? UART settings needed on PIC or laptop side? |
|
|
beaker404
Joined: 24 Jul 2012 Posts: 163
|
|
Posted: Fri Oct 04, 2019 2:27 pm |
|
|
One additional note, I have tried the first and third way of connections on the link with the same results for both. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9241 Location: Greensville,Ontario
|
|
Posted: Fri Oct 04, 2019 2:41 pm |
|
|
OK, have to ask.... what's the idle voltage on the laptop ? is it +5 or +3 or +12 ?
If using a real MAX232, I'd expect +12..but I've seen +3 on several PCs....
Jay |
|
|
beaker404
Joined: 24 Jul 2012 Posts: 163
|
|
Posted: Fri Oct 04, 2019 2:47 pm |
|
|
Have not measured it, going with 12 as it is a true RS232 COM1 port on the back of the laptop (special order these days) and it works directly with my MAX232 chips and any RS232 type device with no mods or extra hardware.
I am wondering if my 57600 baud rate is a problem.
Open for ideas and thoughts, just perplexed why it works PIC to laptop but not laptop to PIC. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: RS232 on one wire |
Posted: Fri Oct 04, 2019 2:50 pm |
|
|
beaker404 wrote: |
I guessed the typo for the resistor was 4.7K then tried 47K.
|
That's not a typo. Some engineers write their resistor values that way.
4K7 means 4.7K. |
|
|
beaker404
Joined: 24 Jul 2012 Posts: 163
|
|
Posted: Fri Oct 04, 2019 2:54 pm |
|
|
Good to know, never run across that way of notation.
Either way 4.7K or 47K I get the same result, one other note, did a standard 1N4001 diode. Thinking about trying a schottky diode. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9241 Location: Greensville,Ontario
|
|
Posted: Fri Oct 04, 2019 5:10 pm |
|
|
hmm, might try 2k2, 2.2Kr, 2200 ohms, red-red-red resistor.
1N4148 should be fine, 1N4001 not.
Try reducing baudrate to say 9600.
What's the distance and type of wire ?
Jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19537
|
|
Posted: Fri Oct 04, 2019 11:02 pm |
|
|
I'd honestly suggest that the laptop is not generating 'proper' RS232
voltages. Most don't. Odds are it uses 5v for a logic 0 and 0v for logic
1. 99% of 'RS232' interfaces on modern kit use these reduced voltages.
They will work since a MAX232 accepts 0v. However the issue here is that
the voltage has to genuinely get within 0.6v of 0v to be seen as '1'.
The output itself typically pulls down to perhaps 0.4v, then the diode drop
then means the signal only gets down to about 1v at your RX input.
Result doesn't work with a circuit like this. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9241 Location: Greensville,Ontario
|
|
Posted: Sat Oct 05, 2019 10:09 am |
|
|
My TRS MODEL 100, 1981 laptop has RS232 (has +-5V) as it's voltages....still works today ! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Oct 05, 2019 10:50 am |
|
|
Try something like a BAT85 (a Schottky diode) which has a much
lower forward voltage drop than the 1N4148 at 1 ma current. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19537
|
|
Posted: Sun Oct 06, 2019 6:31 am |
|
|
temtronic wrote: | My TRS MODEL 100, 1981 laptop has RS232 (has +-5V) as it's voltages....still works today ! |
Exactly.
Laptops have been doing this for years. However this approach will give
problems with what is being done here. The extra voltage drop of the diode
makes seeing the low level unlikely. As PCM_Programmer says using a
Schottky diode may well make the levels work. |
|
|
beaker404
Joined: 24 Jul 2012 Posts: 163
|
|
Posted: Sun Oct 06, 2019 7:41 am |
|
|
no luck with a Schottky diode.
I am considering using optoisolators to level shift back to +-12 levels.
But that will get complicated as there is two way traffic and the PIC side works fine now just coming out of the laptop is wrong.
I am going to put a loop back on the laptop and view with a scope to verify voltage levels. |
|
|
beaker404
Joined: 24 Jul 2012 Posts: 163
|
|
Posted: Sun Oct 06, 2019 7:52 am |
|
|
would it be as simple as putting a MAX232 chip for the laptop output/input to go though then to this circuit? Thinking the MAX232 would deal with the voltage needs and kick it up so the one wire circuit was basically seeing what it does when the PIC side makes a voltage. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19537
|
|
Posted: Sun Oct 06, 2019 8:01 am |
|
|
You need to remember a MAX232 gives inversion. To get the right voltage
level, and signalling, you would have to use two MAX232's. One to take the
connection to the laptop, and generate the inverted logic signals from this
and then a second one to generate the 'real' RS232 levels. Lot's of complexity.
I have to ask why the need is felt for only using the single signalling wire?.
Honestly, just have a normal pair of signal wires and avoid the problem.... |
|
|
beaker404
Joined: 24 Jul 2012 Posts: 163
|
|
Posted: Sun Oct 06, 2019 8:15 am |
|
|
to clarify, only use the TX side from the laptop thru the MAX 232. Then the rest of the circuit would see a TX signal at standard 232 levels. The PIC side sends acceptable data levels to the laptop as I do get communication from the PIC to the laptop just not from the laptop back to the PIC.
or perhaps a better way to do the level shift on the TX coming out of the laptop?
Sorry to post so many times, just thinking out loud here online of course. |
|
|
|