Shop OBEX P1 Docs P2 Docs Learn Events
Quick question about serial connection... — Parallax Forums

Quick question about serial connection...

JomsJoms Posts: 279
edited 2009-03-14 04:45 in Propeller 1
I am just starting to·write code that will send serial data to a stamp.· I am taking this little steps at a time.

When I utilize the program from the labs called 'EnterAndDisplayValues', I can make it display on the terminal.

I hooked a serial cable from pins 2/3 on the computer to pins 26/27 on the prop.· Also hooked pin 5 from the computer to ground from the prop.· I tried to modify that program so it uses pins 26/27 (baud 9600) and send data to the Parallax Serial Terminal looking at com1 using baud 9600.

I can not make it output anything, even though I would expect it to work as normal.· I have changed mode settings on the FullDuplexSerialPlus object and·if I choose mode 1, it will output 'junk', other then that, nothing...

It must be something pretty simple I am overlooking, does anyone have any ideas?

Thanks...

Post Edited (Joms) : 3/18/2009 2:14:29 AM GMT

Comments

  • telluriantellurian Posts: 52
    edited 2009-03-14 03:07
    You cannot directly hook up RS232 pins from a computer to the prop you must have a level converter or at bare minimum a 33K resistor between the computer's TX line and the prop! The Computer outputs + & - 12V signals which may (probably will ) fry the propeller's input pin if not the whole device. Also without a level shifter (i.e. a MAX3232 or equivalent type chip) you will need to invert both the TX and RX pin logic (set mode bits 0 and 1 on the Full Duplex Serial object). Also make sure that the TX fro the computer goes to the RX on the prop and the RX on the computer goes to TX on the Prop (I still get that wrong ... often).

    Also ... with the 33k resistor method (but a MAX3232 type chip is recommended) keep the baud rate down, 9600 will work for sure though.

    -tellurian

    Post Edited (tellurian) : 3/14/2009 3:14:53 AM GMT
  • JomsJoms Posts: 279
    edited 2009-03-14 03:24
    OK... That makes sense, I forgot all about that! I was getting in excited about getting ready to try it and forgot all about the level thing!...

    I think I smoked it... Any program appears to load fine, even to the EEPROM, but I can't seem to make it do any more then that. I am going to go back and get a quick program just to make some LED's flash and see if I did it in. After all it is Friday the 13th [noparse]:([/noparse]

    On a good note, they are cheeper then the BS2!
  • JomsJoms Posts: 279
    edited 2009-03-14 03:36
    Second quick question about the same subject...

    Is there any documention that discribes how to use the FullDuplexSerialPlus? I am having problems making it output the text I want it do...

    PUB start(rxpin, txpin, mode, baudrate) : okay
    PUB stop
    PUB tx(txbyte)
    PUB rx : rxbyte
    PUB rxflush
    PUB rxcheck : rxbyte
    PUB rxtime(ms) : rxbyte
    PUB str(stringptr)
    PUB getstr(stringptr)
    PUB dec(value)
    PUB GetDec : value
    PUB StrToDec(stringptr) : value
    PUB bin(value, digits)
    PUB GetBin : value
    PUB StrToBin(stringptr) : value
    PUB hex(value, digits)
    PUB GetHex : value
    PUB StrToHex(stringptr) : value

    I know what most of them do, but I am trying to make the decimal "1" show up in hex as "30, 30, 30, 31".· In this case 1 is actually a charactor, but in is a variable from somewhere else in the program.
  • JomsJoms Posts: 279
    edited 2009-03-14 04:29
    I tried the second option.· Didn't see the first object you listed in the library, but I still need to look on the object exchange.

    Attached are two files to give you a better idea of what I am doing, instead of trying to explain all of it.· One is something I made for the stamp and works great, I will want to do the same thing as that, only on the propeller.· The second is a PDF that explains what I am trying to calculate and send out of the propeller.

    Basically I am taking two variable, source (src), and destination (dest); calculate a checksum and send the data out as serial.· I figured I would post the whole thing now because I know I will have problems when it ends up time to calculate the checksum.

    After I get this part figured out I am pretty sure I can figure out the next steps, which will basically changing the request command and variables.

    Main Questions:
    Do I need another object to do the conversions or is it just a few lines of code in my current object?
    Second, do I actually use the FullDuplexSerialPlus.hex to output the data in the form I need?
    Third, should I look deeper into the strtohex command for this application?



    Thanks in advance for all your help!· It took me a while to program in the stamp, now I am just done with all the information about the propeller and just starting my own coding...
  • telluriantellurian Posts: 52
    edited 2009-03-14 04:45
    ser.hex( val, size)

    will do what you want (I think) for example if you do

    ser.hex( 1, 4)

    it will send 0001 to the serial port

    or do you literally want 30, 30, 30, 31

    in which case you can write a simple function to do that.


    -tellurian
Sign In or Register to comment.