Shop OBEX P1 Docs P2 Docs Learn Events
Propeller to Propeller Chip Communication Via RS-232 Using FullDuplexSerial. — Parallax Forums

Propeller to Propeller Chip Communication Via RS-232 Using FullDuplexSerial.

Balzer365Balzer365 Posts: 7
edited 2009-04-25 20:06 in Propeller 1
Hello,
·
I am AT1 Balzer, I am working on designing a test set for some equipment we repair.· I have a system board running a Propeller Chip and a Relay board running a Propeller Chip.· Both are still in the design stages.· I have them prototyped out on a bread board.· I want to use FullDuplexSerial to communicate from the System board to the Relay board.· Right now only the System board sends commands and the Relay board listens and carries out the commands it receives.
·
The problem I am having is an intermittent communication problem, on the 7th or 8th send of commands the relay board misses one of the commands, and then picks the next command up.· I have included the code for the system board and Relay board.· They are connected together with wires, not sure if I need a resistor between them or not.· Any help would be greatly appreciated.

Thanks

System Code:

Con
_Clkmode········· = xtal1 + pll16x
_Xinfreq········· = 5_000_000

Obj
MonitorCC : "Monitor Cable Connection"
LCD······ : "GLK19264"
DataBus·· : "FullDuplexSerial"

pub main
MonitorCC.Start(18,1)
LCD.Start(15,14,0,19200)
DataBus.Start(13,12,0,19200)
dira[noparse][[/noparse]16]~~
outa[noparse][[/noparse]16]~~
LCD.Brightness(255)
LCD.CLR
LCD.Cursor_Position(2,1)
LCD.Str( string(" SENDING K1 ON COMMAND···· "))
LCD.Cursor_Position(2,2)
LCD.Str( string("····· VIA DATA BUS····· "))
DataBus.TX(66)
waitcnt (clkfreq*4 + cnt)
LCD.CLR
LCD.Cursor_Position(2,1)
LCD.Str( string(" SENDING K2 ON COMMAND···· "))
LCD.Cursor_Position(2,2)
LCD.Str( string("····· VIA DATA BUS····· "))
DataBus.TX(67)
waitcnt (clkfreq*4 + cnt)
DataBus.TX(68)
LCD.CLR
LCD.Cursor_Position(2,1)
LCD.Str( string(" UWATS SELF TEST COMPLETE "))
LCD.Cursor_Position(2,2)
LCD.Str( string("····· RESETTING RELAYS····· "))
LCD.Cursor_Position(2,3)
LCD.Str( string(" CONNECT UUT CABLE ASSEMBLY "))


Relay Board Code:

Con
· _clkmode = xtal1 + pll16x
· _xinfreq = 5_000_000
·
·
Var Byte Value
OBJ

· DataBus:· "FullDuplexSerial"

PUB Main
· DataBus.Start(0,1,0,19200)
·
· repeat
···
··· Value := DataBus.rxcheck
······· Case Value
········· 66 : Dira[noparse][[/noparse]2]~~
·············· Outa[noparse][[/noparse]2]~~

········· 67 : Dira[noparse][[/noparse]3]~~
·············· Outa[noparse][[/noparse]3]~~

········· 68 : Dira[noparse][[/noparse]2..3]~
·············· Outa[noparse][[/noparse]2..3]~

···················································
·······
·········
·········
·········
·······
·····
·····
·
·
·
·
··
·
·

·

··
·
·
·····
·
·


··
·
·
·····


·

Comments

  • James LongJames Long Posts: 1,181
    edited 2009-04-22 21:49
    Balzar,

    It would help greatly if you would break up your code into two groups.

    Place each group between the "(code) write code here(/code)" tags You must use the square brackets in place of the "(". Like this
    [noparse][[/noparse]code] <---- tag
    



    This will preserve your indentation and help us decipher which object is going to what.

    James L

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    James L
    Partner/Designer

    Lil Brother SMT Assembly Services
  • Balzer365Balzer365 Posts: 7
    edited 2009-04-22 22:44
    James,



    Not following can you gime me a better example.



    Thanks,









    ·



    ··
    ·
    ·
    ·····
    ·

    ·




    ··
    ·
    ·
    ·····
  • James LongJames Long Posts: 1,181
    edited 2009-04-22 22:51
    Balzer365 said...
    James,



    Not following can you gime me a better example.



    Thanks,

    If you do not include
    [noparse][[/noparse]code] tags
    



    The format of your code will be not spaced correctly. Spin requires spacing to be correct.

    The tags use the brackets like shown above with the following format:

    (code) your spin code here(/code) ( must be replaced with [noparse][[/noparse].

    Hope this helps.

    James

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    James L
    Partner/Designer

    Lil Brother SMT Assembly Services
  • Balzer365Balzer365 Posts: 7
    edited 2009-04-23 00:09
    Thanks, I figured it you here you go.


    System Board Code:

    Con
    
    _Clkmode          = xtal1 + pll16x
    _Xinfreq          = 5_000_000
    
    Obj
    
    MonitorCC : "Monitor Cable Connection"
    LCD       : "GLK19264"
    DataBus   : "FullDuplexSerial"
    
    pub main
    MonitorCC.Start(18,1)
    LCD.Start(15,14,0,19200)
    DataBus.Start(13,12,0,19200)
    dira[noparse][[/noparse]16]~~
    outa[noparse][[/noparse]16]~~
    LCD.Brightness(255)
    LCD.CLR 
    LCD.Cursor_Position(2,1)
    LCD.Str( string(" SENDING K1 ON COMMAND     "))
    LCD.Cursor_Position(2,2)
    LCD.Str( string("      VIA DATA BUS      "))
    DataBus.TX(66)
    waitcnt (clkfreq*4 + cnt)
    LCD.CLR 
    LCD.Cursor_Position(2,1)
    LCD.Str( string(" SENDING K2 ON COMMAND     "))
    LCD.Cursor_Position(2,2)
    LCD.Str( string("      VIA DATA BUS      "))
    DataBus.TX(67)
    waitcnt (clkfreq*4 + cnt)
    DataBus.TX(68)
    LCD.CLR
    LCD.Cursor_Position(2,1)
    LCD.Str( string(" UWATS SELF TEST COMPLETE "))
    LCD.Cursor_Position(2,2)
    LCD.Str( string("      RESETTING RELAYS      "))
    LCD.Cursor_Position(2,3)
    LCD.Str( string(" CONNECT UUT CABLE ASSEMBLY "))
    



    Relay Board Code:

    Con
    
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
      
      
    Var Byte Value
    OBJ
    
      DataBus:  "FullDuplexSerial"
    
    
    PUB Main
    
      DataBus.Start(0,1,0,19200)
      
      repeat
        
        Value := DataBus.rxcheck
            Case Value
              66 : Dira~~
                   Outa~~
    
              67 : Dira~~
                   Outa~~
    
              68 : Dira[noparse][[/noparse]2..3]~
                   Outa[noparse][[/noparse]2..3]~
    
  • TreeLabTreeLab Posts: 138
    edited 2009-04-23 00:57
    In the last case you set pins 2,3 to inputs, then try to set their pin states. Is this what you intended?

    Cheers!
    Paul Rowntree
  • James LongJames Long Posts: 1,181
    edited 2009-04-23 01:17
    From your code,

    The system only loops through once. I do not see how you see any LCD activity after the three TX (transmits) from the system board.

    You really need a looping code to see it more than three times.

    If you car calling this from another method (or object) you need to do the following:

    
    Pub start
    MonitorCC.Start(18,1)
    LCD.Start(15,14,0,19200)
    DataBus.Start(13,12,0,19200)
    dira[noparse][[/noparse]16]~~
    outa[noparse][[/noparse]16]~~
    LCD.Brightness(255)
    
    Pub Main
    LCD.CLR 
    LCD.Cursor_Position(2,1)
    LCD.Str( string(" SENDING K1 ON COMMAND     "))
    LCD.Cursor_Position(2,2)
    LCD.Str( string("      VIA DATA BUS      "))
    DataBus.TX(66)
    waitcnt (clkfreq*4 + cnt)
    LCD.CLR 
    LCD.Cursor_Position(2,1)
    LCD.Str( string(" SENDING K2 ON COMMAND     "))
    LCD.Cursor_Position(2,2)
    LCD.Str( string("      VIA DATA BUS      "))
    DataBus.TX(67)
    waitcnt (clkfreq*4 + cnt)
    DataBus.TX(68)
    LCD.CLR
    LCD.Cursor_Position(2,1)
    LCD.Str( string(" UWATS SELF TEST COMPLETE "))
    LCD.Cursor_Position(2,2)
    LCD.Str( string("      RESETTING RELAYS      "))
    LCD.Cursor_Position(2,3)
    LCD.Str( string(" CONNECT UUT CABLE ASSEMBLY "))
    Waitcnt(clkfreq*4 +cnt)      <-----you may need this to time the system correctly, but that depends on your other code.
    
    



    Call the start method once. The after that "main".

    If you are doing this fast the display may be in a reset state when you are getting data.

    We would need your full code if you are not providing it, to help further.

    James L

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    James L
    Partner/Designer

    Lil Brother SMT Assembly Services
  • Balzer365Balzer365 Posts: 7
    edited 2009-04-23 11:20
    James,

    With the system board you are correct it only loops once.· The LCD works 5.0 picks up evey bit of information that is transfered to it.· The way that I loop it is I just use the reset button for testing purposes.· The problem that I am having is with the databus, theres 3 transmit statments Databus.tx(66), Databus.tx(67) and Databus.tx(68).· These codes get trasmitted to the relay board.· The relay board works most of the time, but it seems like the 7th or 8th time I hit the reset button on the system board(to run the code again), the relay board will miss one of the commands and then pick the next code up or wait until I reset the system board again.· I was thinking maybe I needed to flush the rx buffer, but attemps to do so made the relay board more unstable.

    Thanks for the assistance

    Ryan

    Paul,

    With that statement when the system board transmitted 68 to the relay board via Databus.tx(68)· I wanted the relay board to make I/O Pins 2 and 3 Low I guess I could get rid of the Dira statement because I don't need them to be inputs.·

    Thanks for the assistance

    Ryan
  • MagIO2MagIO2 Posts: 2,243
    edited 2009-04-23 14:30
    Code running in one COG should never touch any port pins and port direction that it does not need!

    DataBus.Start(0,1,0,19200) will start a COG running the serial interface driver and you assigned it the pins 0 and 1.
    So, you should not to a
    dira~~/outa~~ which changes all ports. Of course in your case it won't change anything, but it's bad practice which you should not get used to.

    Why do you use rxcheck and not rx? First I would change that to rx. And write the received byte on 8 port pins with LEDs attached to see what the relais board really receives. I would guess that you have a problem with the reset. During reset the ports are set to inputs. If you don't have a pull-down resistor there might be noise on the tx line of your system board, which confuses the relais board.

    You could also change the system board software to a endless loop and see if the relais board misses transmissions then as well.
  • Balzer365Balzer365 Posts: 7
    edited 2009-04-23 15:15
    MagIO2,

    Thanks for the information, I am currently deployed and work a 12hr shift as soon as I can I will give your ideas a try.· I will keep everyone informed.



    Thanks,

    Ryan
  • Balzer365Balzer365 Posts: 7
    edited 2009-04-25 10:24
    Thanks everyone for the inputs.· I have the program working fine now.

    Ryan

    ·
  • marcalmarcal Posts: 5
    edited 2009-04-25 16:03
    please will you say what the problem was - and what the answer was - thank you
  • James LongJames Long Posts: 1,181
    edited 2009-04-25 18:42
    Yes,

    I too would like to know what the problem was.

    James L

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    James L
    Partner/Designer

    Lil Brother SMT Assembly Services
  • Balzer365Balzer365 Posts: 7
    edited 2009-04-25 19:58
    I re-wrote the system·code to loop for testing purposes.· The relay board hasn't missed a beat since·I did that.·I will keep playing with it and if I find more info out I will let you all know.

    Thanks again for all the help.


    Ryan

    ··
  • James LongJames Long Posts: 1,181
    edited 2009-04-25 20:06
    Balzer365 said...
    I re-wrote the system code to loop for testing purposes. The relay board hasn't missed a beat since I did that. I will keep playing with it and if I find more info out I will let you all know.


    Thanks again for all the help.





    Ryan

    Well, I'm glad you have it working without missing data. Resetting one board of the system may have confused the receiver board. With the loop, you will not have the reset issue.

    James L

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    James L
    Partner/Designer

    Lil Brother SMT Assembly Services
Sign In or Register to comment.