RS232 communication with PC/PPC
Crosswinds
Posts: 182
Hello Everyone!
Just wanted to see if there is any information about using the FullDuplexSerialPlus object for simple communication to a PC´s serial port, and a terminal as reciever program?
It should be pretty simple, but it would be nice to know what pins to use, and if there is some tips out there about protocol.
This will just be simple serial strings though.
Just wanted to see if there is any information about using the FullDuplexSerialPlus object for simple communication to a PC´s serial port, and a terminal as reciever program?
It should be pretty simple, but it would be nice to know what pins to use, and if there is some tips out there about protocol.
This will just be simple serial strings though.
Comments
Parallax also has a transistorized level converter circuit on their Propeller Download page. This is not strictly RS232 compatible, but does work in most cases. It also inverts the signal.
If you want to use the existing programming port, you'd use pins 30 and 31 when you initialize FullDuplexSerial
I will be using just a standard serial cable.
And by pins i meant, sorry i should have specified this, the diagram of a standard PC serial cable. Please see this link for an image:
http://www.aggsoft.com/rs232-pinout-cable/images/9-pinout.gif
Im a bit unsure if i really have to use a MAX circut to get this to work. RS232 standard says that anything between 3-5v is okey. And since the prop puts out 3.3 i think this should work?
I have communicated with an old RS232 reciept-printer, that worked great with 3.3 from the prop.
Ok, ignore most of the schematic but take a look at the max232 part. This combines the download circuit with a second RS232 circuit using another two pins. There is a multi serial port object in the Obex by Tim Moore that can handle both serial connections in one cog (actually it can handle up to four).
RS232 to USB adaptors are on ebay for only a couple of dollars each.
I've found this is very handy for debugging as you can have one serial port as the download port and have a terminal program permanently connected to the other port and send debugging messages to that second port. You can also debug to the programming port as well.
Re pins, you can add all 9, but there is a much simpler circuit using 3 pins. You can see it on the second port on that schematic above. Join pins 7 and 8, and join pins 1,4,6. Ground is pin 5 and pins 2 and 3 are the data.
There are good reasons to use a max232 or other interface circuit as the lines can be shorted, you can feed 20 volts down a line (even 20V AC) and nothing bad will happen, you can accidentally cross the Tx and Rx lines and you can even mix up a data line and ground, and nothing bad will happen. It makes everything so much more robust and protects the propeller from damage. A max232 chip costs $1 or less.
The same goes for the transmit signal from the Prop, it may inadvertently be connected to the transmit signal from the RS232 device and even though it won't supply much current it may still damage the Prop. Or you could short the signal inadvertently. For outputs (general-purpose and otherwise) always use a series resistor for protection. I find a value of 220R always handy as it still provides enough current to drive an LED etc and has no trouble with driving RS232 receivers. All RS232 spec drivers have the equivalent of 300R series resistance built-in.
Summing it up you are going to do whatever you want anyway so use the MAX232, or use transistors, or use resistors, but unless you like magic smoke and replacing Props don't ever connected the Prop pins directly to the outside world, which includes RS232.
Firstly, ofcourse i will use a resistor for safetyreasons!
That is was i did with the printer.
I have test it out today, but i cant get it to work.
The only live i get from it is that it puts about 5characters of bull if i pull the input pin from it socket on the demo board. Thats all.
Can this be that the ipaq expects alot higher voltage than props 3.3v? or am i looking at another problem here?
(What is the output voltage of a PC´s serial port?)
These limits are important. They provide some protection against noise and poor connections. It's best to use some kind of interface circuitry designed for this. You can sometimes get by with just a protective resistor, but not always ... and, if it doesn't work reliably, it's your fault for cheating on the standard.
I will have to look in to what voltages it needs. I read somewhere that a PC serial port puts out 12 volts? The iPaq PDA (wich im planning to feed with data, im only feeding just now, output to prop not used, becouse of the danger) must in that case be compatible with that. My guess had not been higher than 5v though.
I will get my hands on a MAX232 circut this evening, and really hope it will work.
Do you think its a voltage problem, considering the symptoms i wrote before?
Both RX and TX pins, measure -5v
Glad i used a beefy resistor on this!
But anyway, i think its confirmed now that the 3.3v with a resistor wont cut it!
I didnt get my hands on a max, but i did get my hands on this:
http://www.parallax.com/Portals/0/Downloads/docs/prod/prop/SerialtoPropeller.pdf
I have those components.
The question is though, do i need to exchange the TX/RX pins with eachother? Have seen discussions about this, like a null-modem.
After a fast look in the schematics, (not good with late night reading) it looks like TX and RX are wired differently. How should i adopt this if i need to exchange them?
If you were going to use a Prop to replace the PC (act as a data terminal instead of a data modem), you would change some of the DB-9 pins around, but that's not what you're doing.
The reason for exchangeing them is if it should work as a null-modem (PC-PC) or not.
But since this would act as a PROP-PC, it should not be necessery then.
The only thing i want is to send data from the prop to the pc (pocketpc), then this diagram should work right?
And if im not way out, i should ignore the RESn part of it right? Thats just for programming the prop?
1) Use only three wires - ground, Tx and Rx.
2) Use D9 plugs and sockets
3) Ground is always pin 5.
4) On a male D9, data comes out of pin 3 (it will usually be minus 12V if you measure it).
5) On a male D9, data goes into pin 2.
6) Conversely, on a female D9, data comes out of pin 2 and goes into pin 3. A female D9 will have minus 12V on pin 2.
A null modem adaptor becomes quite simple. Take two female D9s and join pin 5 to 5 and cross over pins 2 and 3.
Or
Take two male D9s and do the same thing.
I have made up both male/male and female/female null modem adapters and use both depending on the situation.
But you may not need to do any of the above. If you can program a propeller (with whatever circuit works) then you can use the same cable for data communications. Use the propeller terminal, or use any terminal program. The only minor problem I've found doing this is that there is some disagreement on the propeller terminal as to whether you need carriage return or carriage return and line feed. Depending on the code you use, sometimes you find double spacing or no new lines. It is easy to tweak this in software though.
re voltages, minus 5V is the same as minus 12V as far as RS232 is concerned. The 'undefined' voltage is -3 to +3V, so 0V is not a standard RS232 voltage. RS232 signals are resting when the volts are negative, and are positive when data is going through.
I'm suppling the circuit with 5v from a USB port, on my PC.
I'm trying to build a ALDL interface ,( Assembly Line Data Link ) using the
MAX232 . The ALDL uses TTL protocol to communicate. I'm trying to build this ALDL interface to Scan my automobile through my Laptop.
I have tried the LOOPBACK TEST, using Hyper Terminal, but no success.
I can't figure it out, I've built the circuit from scratch twice but no change.
Here is the data sheet link.
http://datasheets.maxim-ic.com/en/ds/MAX220-MAX249.pdf
Any help would be great
Sincerely Aliman
Can you repost this request on a new thread without "hijacking" Crosswinds thread. With a little more actual information I am sure someone can help you.
Aliman
Man thanks for that explanation!
I hope that with this circuit i will be able to communicate with the PPC. and get by with just these componets, since i want to try this out this weekend, and couldnt get a hold on a MAX.
This would rule out any issues with voltage then, right?
Thanks Mike for clarify how i should modify the circut!
I have now hooked up the curcuit and having somewhat more luck with it now.
The ipaqs recieves, but it puts out puke on the screen. just jibberish.
Could that be that i have missed something on my circuit? (Have checked it 4 times) or something else?
The reciever settings in the iPaq lookes like this:
COM1
Baud: 115200
Parity: None
Flow Control: None
Data Bits: 8
Stop Bits: 1
I set the props code for 115200 and mode 0 (Actually i have tested both 0,1,2,3 modes.
Any ideas?
Edit:
It seems like it gets the amount of characters right.
If i send Hello World
That exact same amount of characters (including the space) shows up on the ipaq, but they are totaly off..
Actually the charcters that it spews is not often the same from time to time. they are almost always changing. For some reason? And the strange thing is that its not often it even shows a letter, its mostly like {[( and like that.. But it always shows the right amount of characters.
The lowest baudrate i can use is 9600 i think, i get the same fault, below that nothing shows up. (But this is like when i try to the regular PC with Parallax serial terminal, same thing)
The PNP transistor provides the inversion necessary when programming but you can also achieve the same effect by using the simple resistor circuit mentioned earlier and setting the mode to 3. Just try it.
DB9.2 <----220R(ish)
P30
DB9.3 >----100K(ish)
P31
Yes im using the circuit from Parallax with the modifications Mike Green specified.
Let me get this straight.
Should i just throw that circuit away, replace it with the two resistors that you specify above, and just ground pin 4?
Because it is so easy to do I would just use the 2 resistor circuit and ground pin "5" of the DB9. This is the simplest circuit there is and if it didn't work then your problem lies elsewhere.
The putty is actualy a special port from standard Putty to pocketpc.
2.3 to my pins, and grounded 5. Changed mode in the prop to 3,
Now nothing comes up. Stone dead.
With just the PC and forget the Prop circuit try a loopback between 2&3 of the PC's db9 and make sure anything you type is being echoed.