Shop OBEX P1 Docs P2 Docs Learn Events
BS2 to BS2 SERIN / OUT - Third time is no charm — Parallax Forums

BS2 to BS2 SERIN / OUT - Third time is no charm

John KauffmanJohn Kauffman Posts: 653
edited 2011-11-03 16:39 in BASIC Stamp
I have tried on two occasions to try BS2 to BS2 communication by SERIN and SEROUT, as per
C:\Program Files\Parallax Inc\Stamp Editor v2.5\Help\Content\LanguageTopics\ExampleTopics\SeroutEx.htm

It has never worked, even though I cut and pasted the example code and re-built circuit several times. The last times were for my personal edification. Now I need it to work for a project: HomeWork board to HomeWork board. I tried again and nothing happens.

I added some beeps to diagnose (codes attached).
From the sender I get the start beep but no beeps from inside loop.
From the receiver I get the start beep and text of "start" on the debug screen.
After that nothing - no beeps from either BS2 from in the loop, nothing on debug screen.

It seems the loop is not running on either BS2

Has anyone encountered similar problems?
Any suggestions?
I'm glad to post a close-up image of circuit if that helps.

Thanks.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-03-28 15:50
    I haven't had a chance to look at your code, but the main issue is that the Stamps are single threaded. They can only execute one thing at a time. When they're executing a SERIN, they're looking for serial data on the specified I/O pin. When they're doing something else like IF statements or GOTOs or SEROUTs, they're not listening to that I/O pin at all. The problem that you have then is synchronization so one BS2 will execute a SERIN just before the other BS2 will send its data and vice-versa. One way to synchronize the two BS2s is to use another pair of I/O pins, one an output from one BS2 and the other an output from the 2nd BS2. When the two BS2s are idle, the "master" BS2 uses its output pin as a "hey there! I plan to send you data!" by setting it to high. When the "slave" BS2 notices this, it sets its synchronization I/O pin to high to mean "ok, I'm almost ready". When the "master" notices this, it sets its I/O pin back to low and the "slave", when it sees this, sets its I/O pin back to low also, then immediately drops into a SERIN for the data. The "master" does a brief PAUSE to allow the "slave" to drop into its SERIN, then begins to send data with a SEROUT.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-03-28 15:58
    For one thing, in "2-Receiver", you have:
    SERIN SI/FC, Baud, [letter] ' recieve one byte

    That should be:
    SERIN SI\FC, Baud, [letter]

    PE -- El Backslash-O !
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2011-03-28 16:12
    Hi John , it would be good to see your circuit diagram. The diagram in the help file has had an error from day one , at least the help file I have.

    The help file diagram shows P1..Stamp1 to P1..Stamp2 as the data line and P0..Stamp1 to P0..Stamp2 as flow control. The error is in the code , both So and Si should equal 1 and Fc in both programs should equal 0.

    Jeff T.
  • John KauffmanJohn Kauffman Posts: 653
    edited 2011-03-28 16:39
    PJ: good spotting, fixed. It is wrong in the help
    Jeff: That (plus PJ's) fixed it. I wanted this to work for several years now. I wish I could put back all of the hair I've pulled out.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-03-28 16:46
    Hasn't this been set right in the latest PBASIC IDE?

    Post Edit --

    No, it's still the same in 2.5.2. [Aaackkk!]
    I remember a guy posting about this a couple of years, come to think of it.
    Amazing.

    Well, it could work with whichever pins you want, but not if you stick to the diagram provided. And that backslash typo still compiles (??).

    So, here I have the SO on P0 and the SI on P0, the Fpins on both the xmtr and rcvr are P1, and the diagram is true to the description - everything is consistent. (See Attached!)
  • vaclav_salvaclav_sal Posts: 451
    edited 2011-03-28 17:30
    Taking into account an error in the documentation ( great catch schematic not matching the code!) and sample code typos I believe there is a need to stress the importance of the F parameter in both SERIN and SEROUT and their uniqueness to BASIC Stamp.
    .
    It seem that even our friends in Parallax do not fully understand the function of F parameter between two BS's. Both PAUSEs in SEROUT and SERIN - without comments(!) - are not necessary.
    Or maybe they wanted to emphasize the handshaking effect by slowing things down?

    I do not want to sound like old nag – but that pull down resistor on the flow control pins in this case is mandatory!

    Vaclav
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-03-28 17:45
    I don't know if Kauffman will be back.
    So, I corrected the code and the diagram (as a post edit to #6.)
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2011-03-28 18:02
    PJ I also remember this cropping up in the past, I still have V2.4 so I was unsure if it had been corrected yet. Maybe in V3.0

    Jeff T.
  • John KauffmanJohn Kauffman Posts: 653
    edited 2011-03-29 20:09
    Kauffman is back. I'm using editor 2.5. The fixes to slash, SO/SI and F are working fine.
    PJ: HOpefully others will find this thread by search and also pick up on your corrected materials posted.

    To whom at P'lax do we give the list of changes for the next help file?
    I also found an example elsewhere that won't compile because a pin is not declared.
  • pathikgohil85pathikgohil85 Posts: 21
    edited 2011-11-03 16:39
    Can anybody tell me, how will I add 3 stamps with one master stamp in circuit? Can you please verify my circuit?

    Pathik Gohil
    819 x 460 - 13K
Sign In or Register to comment.