Shop OBEX P1 Docs P2 Docs Learn Events
Serial implementation on different pins — Parallax Forums

Serial implementation on different pins

fiero79fiero79 Posts: 8
edited 2013-10-07 04:36 in Propeller 1
I am trying to use a serial object(simple_serial, or full duplex serial), to communicate using pins 10 and 11 with first an arduino, then a after proven to work, a sparkfun obd2 uart module. I know that I have to convert the levels to interface with the propeller, and I have an idea of using 2 hex schmitt trigger chips one for the 3 volt side, and the other to the 5 volt side. I have not figured out how to implement serial of any type on pins other than the standard pins that the parallax serial terminal communicates with. I am using a quickstart board, and bare bones arduino, and breadboar. I have no experience with the propeller but have been using Aruinos for years.


Help please.


Charlie

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2013-10-06 21:14
    All I/O pins of the Propeller can be used for serial I/O, for that matter, any kind of I/O other than video which works with groups of I/O pins (TV on groups of 4 and VGA on groups of 8). All of the serial objects require that you pass their initialization routine the pin numbers you plan to use. Other than that, everything else is the same as for the PC serial port. There's a "sticky" thread discussing all sorts of interfaces between a 3.3V device like the Propeller and a 5V device like an Arduino.

    If you want more specific help, you'll need to make a schematic drawing of your setup, scan it in, and post it as an attachment to a reply here. Use the Attachment Manager that you get by clicking on the Go Advanced button under the Quick Reply window. Also include your source program as an attachment.
  • fiero79fiero79 Posts: 8
    edited 2013-10-06 21:43
    I understand that all i/o's can be used... My issue is finding anywhere that states how to set up which pins use the obj. If I call fullDuplxSerial(i believe that is the name) or simple serial, it communicates by default on the standard rx/tx that are hooked up to the usb port on the quickstart, how do i change it to use pin 10 and 11 for rx/tx respectively, when calling it. or do I have to dig through the object code and find where the pins are called out save it and change the name of that object to call set up for those pins.

    Charlie
  • average joeaverage joe Posts: 795
    edited 2013-10-06 22:28
    Here's a quick example, taken from some code I have been using for a while: *this uses fullDuplexSerial4port*
    CON
    ' serial ports
      _lcdPort      = 0 
      _lcdBaud      = serial#BAUD115200
      _lcdTX        = 13
      _lcdRX        = 12
      
      _pcPort       = 1
      _pcBaud       = serial#BAUD9600
      _pcTX         = 31  
      _pcRX         = 30
    
      _debugPort    = 3
      _debugBaud    = serial#BAUD9600
      _debugTX      = 4
      _debugRX      = 5
     
    OBJ
     serial : "fullDuplexSerial4port"
    
    Pub StartSerial
      serial.init
      serial.AddPort(_lcdPort,_lcdRX,_lcdTX,-1,-1,serial#DEFAULTTHRESHOLD,serial#NOMODE,_lcdBaud)
      serial.AddPort(_reiPort,_reiRX,_reiTX,-1,-1,serial#DEFAULTTHRESHOLD,serial#NOMODE,_reiBaud)   
      '' add more serial ports here    
      serial.start
    
    

    Or here's the more traditional usage of FullDuplexSerial
    CON
      Debug_RX          = 25
      Debug_TX          = 26
      Debug_Baud        = 115200
    OBJ
     debug  :   "FullDuplexSerial"
     
    PUB StartSerial
    debug.Start(Debug_RX, Debug_TX , 0, Debug_Baud)
    
    

    In both of these examples, to change the pin usage just edit the con section. Example (second usage) : To make pins 18,19 = RX,TX : Change CON section as so
    CON
      Debug_RX          = 18
      Debug_TX          = 19
    

    If you could post some test code, we could help you further!
  • fiero79fiero79 Posts: 8
    edited 2013-10-06 23:32
    thank you, I will try that. That is the straight forward answer that is not really shown anywhere when looking for it.

    Charlie
  • average joeaverage joe Posts: 795
    edited 2013-10-06 23:41
    Just as a hint, you can open the sub-objects in a program *press F8 to view info* click on the object. You can select the "Documentation" radio button to view just the documentation. This can be quite helpful when using objects that you are unfamiliar with. Most of the OBEX objects have excellent documentation. Hopefully this helps!
  • JonnyMacJonnyMac Posts: 9,107
    edited 2013-10-07 04:36
    Most objects that use IO pins allow you to set those IO pins using the .start() method -- this is certainly the case with FullDuplexSerial. Likewise, most objects that launch a driver cog will stop that cog (if running) when the .start() method is called. This allows you to call .start() as needed to re-assign IO pins. The only caveat for you is to ensure your TX buffer is flushed before switching from one set of pins to another.

    Suggestion: If you're going to be switching around like this you should probably have a pull-up on the RX lines of your devices (will be your TX line in FDS). When you stop FDS for one set those pins will be floated; by having a pull-up on your TX pins (again, to the device RX), you won't have to worry about glitches when switching from one to another.
Sign In or Register to comment.