TTL to RS232 Signal Conversion
- Use a TTL HI output for the RS232 GND: Steve Walz of armory.com says “Use a TTL HI output for the RS232 *GROUND*!! Then you get +/-5VDC levels to fake out the RS232. When TTL-GND goes HI, then a TTL-XMT LO looks like -5VDC and a “mark”. Even sign problems go away in hardware! When TTL-GND goes LO, and TTL-XMT goes HI, it looks like +5VDC and a “space”! You can derive the two TTL signals from one off an inverter or inverter pair! Then magically, you have direct TTL to RS232 conversion!!
M. Adam Davis points out that we should “Just *make sure* the power supply of the pic and/or the power supply of the other rs-232 device are not grounded. ie, my bench power supply has +5v and ground, but the ground is grounded to the house ground, SO is the computer’s rs-232 port. I can’t use this trick without isolation. This also means that any interaction with other external devices requires some thoughtful planning.” [Ed: this is only true if the devices confuse signal ground and chassis ground. Remember that ground is at DB25 pin 7, and not pin 1 Pin 1 is chassis ground, not signal ground.]
Bob Ammerman [RAMMERMAN at PRODIGY.NET] of RAm Systems says:
Here is a neat trick to get a ‘push-pull’ output from two PORT A pins:1: define them as analog (ADCON1)
2: TRIS them as outputs.
Now, when you BSF either of them the other will automatically be cleared.
Andrew Warren says:
Of course, if you can’t configure the pins as analog inputs (because, for instance, the PIC you’re using doesn’t HAVE an A/D converter), you can do this:MOVLW 00000001B ;RA0 = 1, RA1 = 0. MOVWF PORTA ; MOVLW 00000011B XORWF PORTA ;Toggle RA0 and RA1. XORWF PORTA ;Toggle the two pins again. XORWF PORTA ;And again...
Or, if those two pins are the only ones defined as outputs on that port:MOVLW 00000001B ;RA0 = 1, RA1 = 0. MOVWF PORTA ; COMF PORTA ;Toggle RA0 and RA1. COMF PORTA ;Again. COMF PORTA ;And again...
For more detail: TTL to RS232 Signal Conversion
For All Your PCB Need, One-stop PCB Solution Services Appear:
EasyEDA: free PCB design tool, 200,000+ engineers are using
PCBs: 10pcs 2-layer 10x10cm only $8.21, on-time global shipping
Components: save 50% on cost, save on freight if shipped with ordered PCBs