Serial communication on the Prop
CumQuaT
Posts: 156
Hi all,
I have some software that I've written for my PC that outputs single character packages via serial port (just like telnet) and I need it to make things happen on my propeller based on what that character is. Since I am an absolute beginner at the propeller, I was wondering if I could get some help with wiring and coding for this sort of functionality.
Thanks heaps in advance!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Who are you, and why are you reading my signature?
I have some software that I've written for my PC that outputs single character packages via serial port (just like telnet) and I need it to make things happen on my propeller based on what that character is. Since I am an absolute beginner at the propeller, I was wondering if I could get some help with wiring and coding for this sort of functionality.
Thanks heaps in advance!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Who are you, and why are you reading my signature?
Comments
/John
Just some thoughts to help you along.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Timothy D. Swieter, E.I.
www.brilldea.com - Prop Blade, LED Painter, RGB LEDs, uOLED-IOC, eProto for SunSPOT, BitScope
www.tdswieter.com
On the Prop side (taken from SimpleDebug.spin):
From there, you can occasionally call uart.rxcheck in a loop.· If the return value is -1, you didn't receive anything since you last checked.· If the return value is something other than -1, it's the next character in the receive buffer.
In between that 'if' and the 'else' would be the magic bits of your code.
Jason
·
And I suggest you use PST (Parallax Serial Terminal) at the PC end. Other software may control the DTR and reset your prop (with the propplug interface). PST will share the port with PropTool nicely.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:
· Home of the MultiBladeProps (SixBladeProp)
· Prop Tools under Development or Completed (Index)
· Emulators (Micros eg Altair, and Terminals eg VT100) - index
· Search the Propeller forums (via Google)
My cruising website is: ·www.bluemagic.biz
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Who are you, and why are you reading my signature?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Who are you, and why are you reading my signature?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Timothy D. Swieter, E.I.
www.brilldea.com - Prop Blade, LED Painter, RGB LEDs, uOLED-IOC, eProto for SunSPOT, BitScope
www.tdswieter.com
Jason
Post Edited (JasonDorie) : 2/19/2009 9:49:34 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Who are you, and why are you reading my signature?
The prop doe not have special serial pins, you just tell the FullDuplexSerial software which are the in and out pins (and inversion, if required). The prop uses a 3.3V interface and you will need a converter to RS232 voltages. There are lots of articles how to do this on this forum.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:
· Home of the MultiBladeProps (SixBladeProp)
· Prop Tools under Development or Completed (Index)
· Emulators (Micros eg Altair, and Terminals eg VT100) - index
· Search the Propeller forums (via Google)
My cruising website is: ·www.bluemagic.biz
Just to clarify, I'm not talking about programming the propeller with the serial, just letting a program I write on it talk to a computer via serial.
I have built a device to control a lighting system, it needs to find out what color to make the lights via a serial connection to a computer.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Who are you, and why are you reading my signature?
There are several objects in the Propeller Object Exchange that can handle the serial I/O for you. FullDuplexSerial comes with the Propeller Tool. Simple_Serial has the advantage that it's simple. The BS2 Compatibility Library has similar routines to Simple_Serial and other useful routines. All of them have some documentation in the source code itself and some (like the BS2 Compatibility Library) has some demo code.
http://www.connectworld.net/rs232.html
...Also, you'll most likely want to look into these topics:
http://forums.parallax.com/forums/default.aspx?f=25&m=208245
"Computer guy's hardware guide for the beginner", is very useful, especially items relating to interfacing a 5v signal to your 3.3v Propeller.
...Read the comments in the FullDuplexSerial code, you'll see that you can assign any available pin as Receive (RX), or Transmit (TX) on your Propeller, you then code your program accordingly.
...I've found the RS232 to USB adapter, available from Parallax, to be very useful. You can still use the USB connection from your PC with the Prop Serial Terminal, HyperTerminal, or even VB, and use any pins you want on the Propeller to configure as your RS232 port.
...Also worth noting, if you're using a Prop Demo Board and the FullDuplexSerial object, assign Pin 30 for TX and 31 for RX to use the same connection you use to download programs to the Prop for serial communications without having to muck around with any hardware. Hit the [noparse][[/noparse]F7] key while in the Propeller IDE to find out which serial port is assigned to your Propeller.
That's about all I've got...
...Oh, wait. If you don't have a Prop Demo Board and you really want to rock your project, download the schematic for the Prop Demo Board and duplicate the circuitry for the USB connection. It's all still serial IO as far as the Prop and PC are concerned, and you'll know you have a proper and robust serial port.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"They may have computers, and other weapons of mass destruction." - Janet Reno
Post Edited (WNed) : 2/19/2009 3:44:38 PM GMT
All I'm really trying to do is this. I want to send characters through telnet (or hyperterminal) on a pc through the pc's serial port (i think it's DB9?) and have those characters be retrieved on the propeller. Let's for argument's sake say I will be displaying them in a debug window.
I've received some great coding examples which I'll be diving into asap (thanks guys) but what I'm after is how to wire that up. Which pins on the serial port do I connect to what on the propeller? Does someone know of a schematic I can use? I don't mind getting extra parts like a MAX232 or whatever to make this happen.
If anyone can help me out here, that'd be amazing!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Who are you, and why are you reading my signature?
I highly recommend just using the Prop Plug as your serial connection if you have one since you won't have to add any wires or ICs or any other circuit. Just write your code to use Full Duplex serial or one of the other serial routines mentioned. Point that code to pins 30/31 that the Prop Plug attaches to. When the Prop Plug is plugged into your computer USB port it shows up at a COM port. You can open that COM port in Hyperterminal or other terminal programs (I prefer the terminal program that Parallax provides).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Timothy D. Swieter, E.I.
www.brilldea.com - Prop Blade, LED Painter, RGB LEDs, uOLED-IOC, eProto for SunSPOT, BitScope
www.tdswieter.com
http://www.parallax.com/tabid/442/Default.aspx
Look at page 5, specifically 2.3.2. Alternative Serial Port Connection. That is the schematic you're looking for. The right side of the schematic is the Propeller side, The left side is the connection to the PC. That's it.
In addition to the really short answer; the schematic uses pins 30 and 31 on the Prop. You can use any pins you want. Also, for asynchronous comms, the DTR signal is not necessary. All I ever use is RX, TX, and Ground, but I'm a barbarian...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"They may have computers, and other weapons of mass destruction." - Janet Reno
Post Edited (WNed) : 2/21/2009 4:28:55 AM GMT
Timothy, I've mentioned a couple of times that I don't, for my own reasons for this particular project, wish to use the propplug. I use it for my prototyping, yes, but I can't for this project. It needs to be serial.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Who are you, and why are you reading my signature?
I have used a basic stamp for a long time. always had problems with serial communications with hyper and/or other terminals and had to put together a little circuit from this forum to get the pins to go fully low or high whatever the case may be.
I am about to receive a propellor chip where i must include a circuit in order to communicate with a serial port. that circuit was mentioned earlier in this forum... it's on page 5 of the propellor speck documument.
anybody know if this circuit would also work on the basic stamp serial communication?
The OEM BS2 schematic (www.parallax.com/Store/Microcontrollers/BASICStampOEM/tabid/135/CategoryID/10/List/0/SortField/0/Level/a/ProductID/21/Default.aspx) shows a typical RS232 interface circuit used for the programming port on the Stamp that can be used on other I/O pins. Check the Stamp manual in the chapters on SERIN and SEROUT. They show how to interface a Stamp to an RS232 port. You may be able to get away with just using a series resistor between input Stamp I/O pin and the RS232 line.
Ok, keep the serial simple. Three wires - Tx, Rx and ground. Use D9 plugs. Pin 5 is ground. Data comes out of pin 3 if the plug is male. Data comes out of pin 2 if it is female. Take a male plug, eg the one from your PC. Maybe make an extension lead (use D9IDC plugs and rainbow cable as it takes less than 1 minute and no soldering). Put the earth lead of a multimeter on pin 5. You will get minus 12V on pin 3. You will get nothing on pin 2 because pin 2 is the input. RS232 rests at negative volts and is active with a positive voltage. Anything less than minus 3V or more than plus 3V is a valid signal. 0V is not a valid voltage in RS232. If you use a max232 you will get 5V out and you want 3V out so use a max3232. Put in minus 12V and you want +3.3V, and put in plus 12V and you want 0V. So after the signal goes through a max3232 the -12V turns into a resting value of +3.3V. It is essentially the circuit of the propstick except we are ignoring R1in and R1out and pin 4 of the D9 is not connected and the 2N3904 and associated components are not used. It is just the max3232 with the 4 capacitors and a D9. Now you have two wires with logic levels of 0V and 3.3V. On the prop stick they go to pins 40 and 39, but they can go to any pin on the prop. Just make sure that you set the pins up as inputs or outputs in the right way. And recode the code to suit those two pins. If you are worried about two outputs fighting (does the prop boot up with pins set as inputs or outputs?), then you could put series resistors in eg anything from 220R to 10k would work.
So start with Mike Green's propstick and just leave some components out. Max3232s are cheap on ebay. 0.1uFs are even cheaper. And a D9 female is only 45c. That will be all you need.
Post Edited (Dr_Acula (James Moxham)) : 2/28/2009 6:02:22 AM GMT