Shop OBEX P1 Docs P2 Docs Learn Events
My failed FullDuplexSerial experiment — Parallax Forums

My failed FullDuplexSerial experiment

MicksterMickster Posts: 2,694
edited 2014-01-22 06:31 in Propeller 1
So I took an RS232 cable and chopped it. Then I stuck my Prop board with two serial ports between the two chopped ends and simply tried to pass the data through in both directions using FullDuplexSerial. Each Rx was fed to the other Tx but it wouldn't work as I'd hoped. I selected the appropriate Baud and used the ".RxCheck" routines to be sure there was no waiting(?).

Have I misunderstood something silly here?

Comments

  • JonnyMacJonnyMac Posts: 9,107
    edited 2014-01-21 11:19
    Did you connect the TX of one port to RX pin of the other?
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-01-21 12:14
    How long was the cable?

    I try to use a MAX3232 chip (or other longer distance serial protocol chip) if the cable is over a few feet.

    My 5V TTL barcode reader will only work out to about six feet of cable.
  • MicksterMickster Posts: 2,694
    edited 2014-01-21 13:08
    @Jon

    Yes, whatever is received on port #1 is sent to transmit on port #2 and vice versa.

    @Duane

    The board is equipped with MAX3232s and is a well proven design. I can receive data from either device and send it to PST.

    Thanks for the attention, guys.
  • Mike GMike G Posts: 2,702
    edited 2014-01-21 13:43
    Post your code?
  • MicksterMickster Posts: 2,694
    edited 2014-01-21 14:00
    CON
      _clkmode = xtal1 + pll16x
      _clkfreq = 80_000_000
    
    
      
      RS232RX_1     = 22
      RS232TX_1     = 23
      
      RS232RX_2     = 24
      RS232TX_2     = 25
      
      Mode          = 00
    
    
    '' mode bit 0 = invert rx
    '' mode bit 1 = invert tx
    '' mode bit 2 = open-drain/source tx
    '' mode bit 3 = ignore tx echo on rx
    
    
      Baud          = 9600
      
    VAR
      long mailbox[4]
      byte rx2
      byte rx3
      
    OBJ
      UART1 : "FULLDUPLEXSERIAL"
      UART2 : "FULLDUPLEXSERIAL" 
      UART3 : "FULLDUPLEXSERIAL"
      
      
    PUB Start | char , rxchar
    
    
    
    
          
      UART1.Start(31,30,Mode,Baud)                          ' Connect to Parallax Serial Terminal
      UART2.Start(RS232RX_2,RS232TX_2,Mode,Baud)            
      UART3.Start(RS232RX_1,RS232TX_1,Mode,Baud)            
    
    
    
    
      UART1.rxflush
      UART2.rxflush
      UART3.rxflush
    
    
      
        
      Repeat
        
    
    
        rx2:=UART2.RxCheck
            
        rx3:=UART3.RxCheck
    
    
             
        UART3.TX(rx2)     
        UART2.TX(rx3)
    
    
    
  • Mike GMike G Posts: 2,702
    edited 2014-01-21 14:18
    Double check mode is set correctly for the devices.

    Doesn't RxCheck return a -1, $FFFF_FFFF, when no data is available? How do the attached devices react to receiving a series of $FFs? Are you missing an IF statement?
  • MicksterMickster Posts: 2,694
    edited 2014-01-21 14:25
    That's kinda my question....do I need logic when I am simply trying to emulate a hardwired connection?


    Edit: Tried other modes with no success.
  • ColeyColey Posts: 1,110
    edited 2014-01-21 14:34
    @Mickster,

    I assume this is for my board?
    If so then try this code, I just tested it and it is ok.

    This code tx's from 0 to z ASCII out on UART1 TX which should be wired to UART2 RX.
    The received character is echoed out on UART2 TX which should be wored to UART1 RX
    Provided the echoed character received on UART1 RX is the same it is then output to PST.

    Regards,

    Coley

    EDIT for some reason the percent sign will not show in a post, stange!
    CON
      _clkmode = xtal1 + pll16x
      _clkfreq = 80_000_000
    
    
      
      RS232RX_1     = 22
      RS232TX_1     = 23
      
      RS232RX_2     = 24
      RS232TX_2     = 25
      
      LED_1         = 27 ' LED 1
      LED_2         = 26 ' LED 2
    
    
      Mode          = percentsign0011
    
    
    '' mode bit 0 = invert rx
    '' mode bit 1 = invert tx
    '' mode bit 2 = open-drain/source tx
    '' mode bit 3 = ignore tx echo on rx
    
    
      Baud          = 115200
      
    VAR
      long mailbox[4]
      
    OBJ
      UART1 : "FULLDUPLEXSERIAL"
      UART2 : "FULLDUPLEXSERIAL" 
      PST   : "Parallax Serial Terminal"
    
    
      
    PUB Start | char , rxchar
    
    
      PST.start(Baud)    
      UART1.Start(RS232RX_1,RS232TX_1,Mode,Baud)
      UART2.Start(RS232RX_2,RS232TX_2,Mode,Baud)
      UART1.rxflush
      UART2.rxflush
    
    
      Repeat  
        Repeat char from "0" to "z"
          UART1.tx(char)      ' tx character on UART1
          UART2.tx(UART2.rx)  ' echo character back on UART2
          rxchar := UART1.rx  ' waits for character to be echoed back
          If rxchar == char        
            PST.char(char)    ' tx received character back to Parallax Serial Terminal
          Else
            PST.char("!")     ' tx '!' as an error
            UART1.rxflush
            UART2.rxflush
            Quit
        waitcnt(cnt+clkfreq/10)
    
  • ColeyColey Posts: 1,110
    edited 2014-01-21 14:43
    @Mickster,

    Looking at your original code, you are using rxcheck, this will return -1 if there is no data, Mike G is correct.
    If you are using my board then you have to invert the tx and rx pins in the Mode settings as you are going through an RS232 level shifter.

    What is it you are trying to do?
  • MicksterMickster Posts: 2,694
    edited 2014-01-22 03:15
    @Coley

    Hey bud!

    Yes it is your board. Kills me to have to use it because I only need the two serial ports but it is self contained and professional looking and going in a piece of CNC equipment.

    Here's my project:
    • PC, DOS-Based controller, circa 1994, source code no-longer available
    • Needs to talk directly to a 3M-Microtouch touch monitor. There isn't a memory resident mouse emulating driver
    • Touch monitor has its own micro-controller that communicates via RS232 (9600, N, 7, 2)
    • PC initiates the communication by sending "R" (reset) to the touch screen's micro-controller
    • The touch screen's micro-controller responds with Chr(1) + "0"......but the PC software expects an immediate response or it exits to DOS
    • The original touch monitor just failed after 20 years so now we are attempting to fit a newer model
    • Incredibly, the firmware of the touch screen's micro-controller, according to 3M-Microtouch, has "become cluttered with features and has slowed down a bit"
    • So this new controller is not responding with said Chr(1) + "0" quick enough and therefore the PC's software assumes that there is no touch screen present and simply exits to DOS.
    ​My plan is to have the Prop intercept the one initial "R" from the PC and immediately return a Chr(1) + "0" to keep the DOS software happy and prevent it from exiting. All other comm's can then simply pass through.

    Unfortunately, I have to visit the customer's facility to test this new code so have to wait for the next opportunity.

    Regards,

    Mickster
  • ColeyColey Posts: 1,110
    edited 2014-01-22 06:31
    OK I think I understand and it seems simple enough, I will knock something up for you tonight and email it over.

    So are there any STX or ETX characters sent just chr(1) and "0", no CR or LF??

    Regards,

    Coley
Sign In or Register to comment.