Shop OBEX P1 Docs P2 Docs Learn Events
Help Reading Serial Port RS 232 — Parallax Forums

Help Reading Serial Port RS 232

rough_woodrough_wood Posts: 61
edited 2009-05-14 07:35 in Propeller 1
I've been trying for a couple days now to figure out how to read anything useful off the RS 232 on the Propeller Professional Development Board. I have messed around with FullDuplex and all that from the Fundamentals book to no avail.

My goal is to get a signal from my Spaceball 5000 (It is a 3D motion controller similar to http://www.3dconnexion.com/·) so I can hook the signal probably first to my oscilloscope to hack it. Once I know what binary stuff I get when I manipulate the Spaceball I can try to get it to be read by the Propeller and use it to move servos or god knows what.

I also have multimeters that can connect to my computer and make real handy spreadsheet data etc. This would also be great to be able to use on Propeller.

The problem is I have no idea how to even get a signal. I realise RX will be sending data to the Prop, and that my devices probably need a clock type signal through CTS. I can get this to communicate fine to my laptop through that debug window. I get the idea of pushing buttons to control the debug or input numbers to have it converted and that sort of stuff. The problem is using the MAX3232E thing to interface at all between the Prop and my devices plugged to the RS 232.

Does anyone have any links or advice? I am very new to Propeller so please explain in detail if you can.

This Spaceball, as well as the Multimeters, do have Drivers that must be installed for Windows to properly interact with the devices. I am going off the assumption that these devices are simple things that send out pulses indicating their status after getting a "Send me Data" signal, which probably goes through CTS. I assume any power, as far as VSS VDD, is provided by the jack I've been talking about in the bottom left corner of the PPDB.

Thanks for any help. Please remember I am very new to this specific Language and Chip. I can program TI calculators a bit in Basic, that is the extent of my programming knowledge, besides monkey see monkey do in BS2. As far as the electronics part the toughest thing I've done is make a spark gap with a 555 and ignition coil without any directions. Just to give you an idea of my programming and electronics knowledge (or lack thereof).

Comments

  • Dr_AculaDr_Acula Posts: 5,484
    edited 2009-05-13 05:41
    I like to use RS232 for all sorts of things. You can plug it in the wrong way, connect two outputs together, short out pins and even send a signal to an unpowered device, and nothing bad will happen. But I also try to keep everything really simple. Use just three pins - Tx, Rx and Gnd. DTR/DSR/CTS/RTS are all useful for flow control but they can also cause a lot of confusion. So what I like to do is build a null modem cable that loops these signals back into the device that sent them, so the device thinks that the receiving device is always ready to receive. With a cog running and listening, that will be true. It is also true for a PC running vb.net etc as the buffer can hold many characters.

    A loopback cable joins pin 7 and 8 (this loops RTS and CTS). Also, join pins 1,4 and 6 together. On the back of a D9, you can do this with solder bridges and just one wire.

    Now you have just three wires, pin 2,3 for Rx and Tx and pin 5 for ground.

    On a PC there is a male plug and males output data on pin 3. I stick with that standard, so pin 3 is an output on a male plug and an input on a female plug.

    If you want to join two male plugs together, cross over pin 2 and 3.

    For your device, check the volts on pin 2 and 3 - one of these should be -12V or similar.

    So, run your signal through a loopback plug to turn it into 3 wires. Run the Tx and Rx into a max232. This converts the +12V/-12V to 0V/5V. Then run that into a propeller.

    Keep asking questions - the above is probably a bit confusing!
  • rough_woodrough_wood Posts: 61
    edited 2009-05-13 16:22
    I am actually plugging this in directly to the PPDB. It fits plug to plug, no rigging necessary (besides needing a gender swap fitting from Radio Shack). My issue is connecting those 4 pins (not necessarily needing all of them) and having the Spin code properly manage the input and output of those 4 connections to let me hook up the usb oscilloscope and start decoding the binary so I can actually later use the devices in projects.

    My issue is almost entirely code, so long as I know which pins to connect to Rx Tx etc.

    I will definately keep that all in mind though once I take a project from the PPDB to its final setup.
  • Steve LindengSteve Lindeng Posts: 6
    edited 2009-05-13 16:58
    Peripherals like trackballs and mice tend to get power from the RS-232 connection - like USB, one (or more) of the pins can be used for power or the device can get the power directly off the TX pin.

    As the good doctor says, you can really get away with just a few pins - 2, 3, 5 and one other for power (I work with a GPS which uses RS-232 and a RJ-11 jack - pins 3 and 4 are RX/TX, pin 2 is Vcc and pin 5 is Gnd). I would suspect the Spaceball is getting its power from the DTR pin (pin 4), as this is commonly 'high' from the DTE (Data Terminal Equipment - PC).

    BTW, RS232 is an asyncronous communication protocol - unlike SPI or I2C, it does not require a clock signal from the processor. RTS/CTS are flow control - somewhat like a clock, but only so far as to tell the processor or peripheral that the next data can be sent. Most RS232 emulators continue to check the RX port for data - true asyncronous communication could occur simultaneously.
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-05-13 17:28
    Hello rough_wood,

    you have to get more specific on what you have already tried.

    I would do the following
    I would build a breakout-circuit where you can connect an oscilloscope to all of the 9 PINs of the D-SUB-connector

    Then connect your device with the break-out-circuit inline with a PC and probing on which pins you have voltage
    and signals

    This will give you an overview which PINs needed to be connected.

    If you need CTS or RTS only a few of the serial-com-objects provide this

    It would be helpful if you could provide a circuit how you connected the device to the PPDB
    and attach code that you used

    best regards

    Stefan

    Post Edited (StefanL38) : 5/13/2009 5:43:27 PM GMT
  • rough_woodrough_wood Posts: 61
    edited 2009-05-14 03:20
    Here is where I am so far:

    I spliced the wires and plugged it in to my computer. In order to get it to run, you have to start the driver on the Windows Computer. The Spaceball then beeps only if pins 3 and 7 are connected. It turns out that a signal, which I will attach below, is sent through pin 3 from the computer to the Spaceball. It sends an initial set of pulses as the Spaceball beeps its first times, then a second set of pulses as it beeps its second times.

    Purple seems to be it's power source, which if I recal was -6V or so. Purple was pin 7 I should add. Pin 2 was the pin that it would send out its information when I would press the buttons or move the spaceball. The 6Axis Spaceball motion was too complicated for now, so at the moment I am figuring out how to utilize the 12 buttons.

    Am I right that Red (pin 3) is Tx, Purple (pin 7) is RTS, and Brown (pin 2) is Rx?

    Now I am working on figuring out what Baud I need, how to make Prop send those 2 initial pulses, then how to read the pulses coming in. I am assuming by sending those initial pulses that it effectively activates the spaceball by acting as its start driver. Once it's up and running I can make sure the buttons can turn on LEDs, but I'm gunna have to figure out what these binary words or longs or whatever they are happen to be, and have Prop keep an eye for those variables, and activate LED's accordingly. After that I'll try to decode the motion controller.

    Thanks for all the help so far.

    Images: Blue lines from Pin 2 Red from Pin 3. I'll put in button 1 and 2, and the 2 pulses for Start Driver in order.

    I should also add, I found once the driver is started Red (Pin 3) can be disconnected and everything runs, just with a 5V amplitude. Red seems to always be -10V (when connected to Windows Serial Port).

    Hopefully the pictures show up. They all uploaded fine but arent in my preview posts.
  • rough_woodrough_wood Posts: 61
    edited 2009-05-14 03:30
    I did the math, there seem to be between 9 and 10 pulses per square which is 1ms. So the Baudrate is between 9000 and 10,000 so it's probably 9,600. Now I'm figuring out if these are words longs etc and what they mean (the pulses pictured above)

    The equation I used was Timeperpulse=1/baud. I tried 1.1111 and 1.0000 to find 9000 and 10,000. Since I think 9,600 is a common Baud number I'm gunna assume it's that.
  • rough_woodrough_wood Posts: 61
    edited 2009-05-14 07:35
    I have read the text files on those Start Driver pings. They are, to my knowledge, 9600 baud, 11001000100101110101001010011110

    I have tried a bunch of things to make this work. First off, when I was testing the serial port when it was plugged to my laptop, it said it had -5V between the metal ground wire and the Pin7. I think that is RTS. I don't know of a way to duplicate this on the PPDB.

    So when I plug from my desktop RS232 to the PPDB RS232, I run something to the effect: (All are the same I just change PUB and the Oscilloscope probes) (these are a hack of EnterAndDisplayValues)

    '' Messages to/from Propeller chip with Parallax Serial Terminal. Prompts you to enter a '' value, and displays the value in decimal, binary, and hexadecimal formats.

    CON

    _clkmode = xtal1 + pll16x
    _xinfreq = 5_000_000


    OBJ

    Debug: "FullDuplexSerialPlus"

    PUB TwoWayCom | value

    Debug.start(5, 4, 2, 9600)
    waitcnt(clkfreq*2 + cnt)
    value := Debug.rx
    waitcnt(clkfreq*2 + cnt)
    Debug.start(31, 30, 0, 9600)
    Debug.Dec(value)
    For this one RX from the RS232 on the PPDB goes to Pin5 Prop. This reads the Ping I send from my windows computer a few seconds after I F10 the Prop, Run Oscilloscope (Osc), then launch Parallax Serial Terminal (PST). It gives me the value 118 in PST. When I plug the Osc directly to Rx coming from that Max3232 it shows the inverse of those REDSTARTDRIVER images above. So my intuition would say the same or inverted signal should come out toward PST if I connect Osc there. The problem is, it doesnt. It sends the right length of communication but it's Binary seems off.

    I have also tried directly sending out the long binary number I got from the Text file of the Osc run from which I got the Start Driver pics above. It always complains about the length of the number mentioning 32 bit.

    I have tried sending out the number 118 using Debug.Dec(118) and Bin(118, 32) but they don't come out right. I tried inverting the numbers which gave me 137 (10001001 instead of 01110110) and it still doesn't come out right.

    I have even tried Debug.tx(Debug.rx) and everything I can think of. I cannot get the Prop to send out the same or the inverted signal it gets from my Windows Desktop when running the Start Driver program to boot up the Spaceball. It receives it fine, Osc confirms that it is just the inverse of what I want. Then trying to have Prop regurgitate that same waveform either the same or inverted just won't work any way I've tried so far.

    So at this point I am stuck trying to simply send the above REDSTARTDRIVER signal from the Prop. Even if I get this, I still anticipate an issue with not being able to throw -5V through RTS like my computer seems to. Hopefully that issue will be as simple as chaning a mode in Debug.start. The problem is, that -5V RTS powered the system after I disengaged Pin3 after the initial Start Driver.

    Any advice? Hopefully I am explaining this right. It's pretty complicated trying to properly say what you have done and what questions you have lol.

    Thanks
Sign In or Register to comment.