Shop OBEX P1 Docs P2 Docs Learn Events
NEWB serial — Parallax Forums

NEWB serial

lboucherlboucher Posts: 139
edited 2009-03-25 16:40 in General Discussion
HI All

I have a parrallax usb to serial adapter and i would like to send data to an SX28.
I need to have a max232 circuit right?

Thanks
Lucas

Comments

  • BeanBean Posts: 8,129
    edited 2009-03-04 14:53
    Lucas,
    No you don't need a MAX232. Just connect to the serial adapter.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    There is a fine line between arrogance and confidence. Make sure you don't cross it...

    ·
  • lboucherlboucher Posts: 139
    edited 2009-03-04 15:33
    Really ok.

    I thought serial was +/- 15 volts and the ttl voltage was 5 volts.
    I am right in quessing that since this is a usb to serial adapter the serial is 5 volts because usb is 5 volts.

    Thanks
  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-03-04 16:29
    You're right, it's USB to TTL-level serial -- I use that device all the time to communicate with my projects. Just remember that the TX pin on the USB2SER needs to connect to your RX pin on the SX and vice-versa. And you must connect the Vss pin to your SX ground. Also, your serial mode needs to be True (if using SX/B use "Txxxx" as your baud constant where xxxx is the baud rate, e.g., T9600)

    [noparse][[/noparse]Edit] Fixed typo.

    Post Edited (JonnyMac) : 3/5/2009 7:46:38 AM GMT
  • lboucherlboucher Posts: 139
    edited 2009-03-05 00:17
    Ok now i am just confused.

    I hook up my usb to serial.

    Pin 3 to the serin pin on the sx, connect the ground. (Not using a pull up resistor, should i be?)

    Then use the attached program.

    When i hit "A" on hyperterminal it shows up on the SX as 191 instead of 65.

    Hyperterminal setting 9600 8 bits N parity 1 Stop bit No flow control

    What in the world is going on, this should be simple.
  • lboucherlboucher Posts: 139
    edited 2009-03-05 00:19
    Thought i would take my first crack at using the debug capability, but when i tried to connect both the USB SX-KEY and USB serial adapater the power light on the board went out, looks like i am shorting something. Anyone know whats up?
  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-03-05 00:26
    You can't use the internal clock source for serial comms -- it's not accurate enough.

    And I know it sounds funny to say, but you're using old fashioned SX/B syntax. RX_BYTE should be a function declared like this:

    RX_BYTE        FUNC    1, 0
    


    ... and coded like this:

    FUNC RX_BYTE
      SERIN Sio, Baud, __PARAM1
      ENDFUNC
    


    Since __PARAM1 is used to return a byte from a function we can use it to receive the serial byte (I've looked inside the SERIN code so I know this is okay).


    [noparse][[/noparse]Edit] See attached -- it will get you going (I tested with a Propeller Plug with is the follow up to the USB2SER).

    Post Edited (JonnyMac) : 3/5/2009 12:48:15 AM GMT
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2009-03-05 01:58
    lboucher,
    Jonnymac said...And you must connect the Vdd pin to your SX ground
    I think Jon meant to say
    And you must connect the USB Vss ground pin to your SX ground

    regards peter
  • lboucherlboucher Posts: 139
    edited 2009-03-05 02:18
    Been messing around with it for the past half hour, did catch that problem.
    (Interesting if you do connect the serial ground to VDD then unplug the SX tech board the power led glows half dim.)

    Also I finally got it to work at 50 MHX specifying N9600 not T9600, can someone explain why?

    Anyways thanks for the help everyone.
    I am an ME, and I am just starting up the learning curve with microcontrollers at this level, only ever messed with the BS2 before.
  • lboucherlboucher Posts: 139
    edited 2009-03-05 02:46
    Moving on to the next thing, I want to move the serial communications to an interrupt.
    Does anyone know a good line by line tutorial on how to do this.
    I have plenty of examples, but for a NEWB i find it hard to follow.

    Thanks again
  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-03-05 07:41
    Peter Verkaik said...
    lboucher,
    Jonnymac said...
    And you must connect the Vdd pin to your SX ground

    I think Jon meant to say
    And you must connect the USB Vss ground pin to your SX ground

    regards peter

    Yes, that's what I meant -- thankfully, the USB2SER doesn't have a Vdd pin! wink.gif
  • PropabilityPropability Posts: 142
    edited 2009-03-06 03:18
    I've followed this thread and I'm just wondering why when the FT232R on the board already does the USB to rs232 TTL levels why would there be a HIN232 chip which takes the TTL levels and converts it to the +15 -15 ·levels of true rs232 ? Can the SX chip safely see these types of signals. The basic stamps have that capacity but I thought the SX chips did not.·Maybe ·Parallax·can give some thought here. I've just started to mess around with the SX's and would like to know if this is alright to do (hooking up the pins of the DB9 on the USBto232 directly to an SX pin).
  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-03-06 04:19
    Keep in mind that the BASIC Stamp is a programmed PIC or SX -- if a Stamp can do it, the SX can do it (and usually much faster). If you want to take RS-232 levels directly into the SX you do the same thing you did with the Stamp: insert a 22K resistor between TX of the serial signal and the RX pin on the SX. Easy-peezy. If you're programming with SX/B and using SERIN and SEROUT you'll need to specify inverted (N) mode.
  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-03-06 04:24
    lboucher said...
    Moving on to the next thing, I want to move the serial communications to an interrupt.
    Does anyone know a good line by line tutorial on how to do this.
    I have plenty of examples, but for a NEWB i find it hard to follow.

    Thanks again

    -- www.parallax.com/Portals/0/Downloads/docs/books/BegAssemforSX.pdf

    See chapters 10 & 12

    Post Edited (JonnyMac) : 3/6/2009 5:25:27 AM GMT
  • PropabilityPropability Posts: 142
    edited 2009-03-06 19:29
    I guess I was confused by your response to the OP's question.


    I thought serial was +/- 15 volts and the ttl voltage was 5 volts.
    I am right in quessing that since this is a usb to serial adapter the serial is 5 volts because usb is 5 volts.

    JonnyMac said...
    You're right, it's USB to TTL-level serial -- I use that device all the time to communicate with my projects. Just remember that the TX pin on the USB2SER needs to connect to your RX pin on the SX and vice-versa. And you must connect the Vss pin to your SX ground. Also, your serial mode needs to be True (if using SX/B use "Txxxx" as your baud constant where xxxx is the baud rate, e.g., T9600)

    [noparse][[/noparse]Edit] Fixed typo.
    ·Note: I tried to do two quotes but could not get it to work so I just did a copy and paste.
  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-03-06 20:21
    There are two products mentioned in this thread:
    1) USB2SER -- this is USB to TTL serial
    2) USBto232 -- this is USB to RS-232 serial

    I may have incorrectly assumed that the original poster was using #1 -- perhaps it was #2. If #1, use True mode and connect the TX pin to the RX input of the SX. If #2 put a 22K resistor (to limit current to a safe level) between TX pin and the RX input and use Inverted input.
  • PropabilityPropability Posts: 142
    edited 2009-03-06 21:24
    I went looking for converters in the Accessories section and only found the RS232 version (USBtoSER(rs232)) . Only when I looked for the USB2SER did I find it in the 'Tools' area (why is it not also in the 'converter' area?) . I got mine from Fry's (rs232) and it works great. If I saw the USB2SER there I would have gotten that also.

    Sorry for the misunderstanding on this - you are a great help here.

    Pete
  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-03-06 21:43
    The USB2SER module is a Parallax product, and a specialty one at that -- you may not find it at Fry's.

    www.parallax.com/Store/Accessories/Tools/tabid/162/CategoryID/37/List/0/Level/a/ProductID/32/Default.aspx?SortField=ProductName%2CProductName
  • lboucherlboucher Posts: 139
    edited 2009-03-07 02:55
    Woops, so i quess i should make sure i put a 22K resistor on that.
    At least it worked for 10 minutes last night and hasn't damaged anything yet.
  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-03-07 02:59
    The SX is pretty tough and while it has protection diodes on the pins you shouldn't stress them.
  • Old_LadyOld_Lady Posts: 20
    edited 2009-03-25 14:02
    Hi team -

    Question on Parallax USB2SER design:

    Parallax offers the schematic for this design as a reference for people who want to have a USB interface to their microcontroller. I have the USB2SER device here on my desk (tiny little thing, very sleek design), as well as two documents from Parallax that I downloaded from here:

    http://www.parallax.com/Store/Accessories/Tools/tabid/162/CategoryID/37/List/0/Level/a/ProductID/32/Default.aspx?SortField=ProductName,ProductName

    Johnny Mac - you said (above) that in order to use this part, we would need to connect the TX from the FT232 to the RX of the SX48 (through the 150 ohm resistor), and the RX from the FT232 to the TX of the SX48 (through another 150 ohm resistor). Can you verify this? The 4 pin connector coming off the USB2SER design consists of an active low RESET, then TX, RX, and VSS. I'm only using the TX and RX pins, and I've connected the VSS to my GND on the SX48. And in software, this FT232 chip wants the serial mode to be TRUE... correct?

    I'm allowing my customers to select between serial (RS232) and USB communication, and I want to be sure that I get this guy (FT232) hooked up correctly. Not a huge deal, as they can always be swapped in SW, but I would like to have the design as clean as possible.

    And I'm a little hesitant, since I got an updated schematic (Rev B) for the USB2SER from Parallax that was wrong, and they are aware of it and are cleaning it up... (thanks Joshua!) .... I'm putting this USB capability into my production board, and I want to feel better about the design, since my boss won't be happy about needing to pay for another board spin if it doesnt' work!

    Thanks,
    Laura (Old_Lady).... Actually I'm 42, so I'm not all THAT old..... just a little bit old.... if there is such a thing.....
  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-03-25 15:58
    I don't remember saying you needed resistors with the USB2SER -- I never use them; I make a direct connection between the two devices. The only time you would need a resistor is if you're taking RS-232 level data directly into the SX without a MAX232 type inverter; a 22K will limit the current and protect the SX.

    When using ANY kind of inverter (MAX232, USB2SER) the software mode will be True. The only time you'll use Inverted is with the 22K resistor trick I just mentioned.l
  • Old_LadyOld_Lady Posts: 20
    edited 2009-03-25 16:40
    Sorry, resistors were on Parallax "reference design" schematic.
    Thanks for the clarification.
    ~ Laura
Sign In or Register to comment.