Shop OBEX P1 Docs P2 Docs Learn Events
Mystery BS1 Programs — Parallax Forums

Mystery BS1 Programs

HumanoidoHumanoido Posts: 5,770
edited 2009-07-09 10:56 in BASIC Stamp
The setup is with two BS1s with pin 0 connected,
and a 1K resis. from pin to ground (inverted).
The programs are demos from the book.

The debug screen counts 1,3,5,...
Sometimes it counts 2,4,6,... when reset is pressed on the transmitter stamp

but the loop is value = value + 1
so I expected to see 1,2,3,...
What is happening?

' {$STAMP BS1} ' Transmitter
' {$PBASIC 1.0}
SYMBOL  SOut            = 0
SYMBOL  Baud            = N2400
SYMBOL  value           = W1
Setup:
value = 1
Main:
  SEROUT SOut, Baud, ("ABCD", #value)
  value = value + 1
  PAUSE 250
  GOTO Main
  END


' {$STAMP BS1}          ' Receiver
' {$PBASIC 1.0}
SYMBOL  SIn             = 0
SYMBOL  Baud            = N2400
SYMBOL  result          = W1
Main:
  SERIN SIn, Baud, ("ABCD"), #result
  DEBUG #result, CR
  GOTO Main
  END

Comments

  • TinkersALotTinkersALot Posts: 535
    edited 2009-07-07 07:50
    just a wild guess, but could your receive routine be getting "every other byte" that is sent?
  • HumanoidoHumanoido Posts: 5,770
    edited 2009-07-07 08:16
    TinkersALot: Thanks for jogging my thinking.
    The idea that it could only get every other byte had to be tied
    to the numeric formatter. The formatter was causing the problem
    as shown in several test programs. To make two working programs,
    delete the number formatter in both programs and the code will
    work reliable. Reset does not change the number sequence
    stream, i.e. it transmits as expected, 1,2,3,... It seems very
    easy to trip on the syntax and even some examples must be
    watched carefully. So when consulting the PBASIC Syntax Guide,
    please make the following changes to correct the code:

    humanoido

    ' {$STAMP BS1} ' Transmitter
    ' {$PBASIC 1.0}
    SYMBOL  SOut            = 0
    SYMBOL  Baud            = N2400
    SYMBOL  value           = W1
    Setup:
    value = 1
    Main:
      SEROUT SOut, Baud, ("ABCD", value)
      value = value + 1
      PAUSE 250
      GOTO Main
      END
    
    
    ' {$STAMP BS1}          ' Receiver
    ' {$PBASIC 1.0}
    SYMBOL  SIn             = 0
    SYMBOL  Baud            = N2400
    SYMBOL  result          = W1
    Main:
      SERIN SIn, Baud, ("ABCD"), result
      DEBUG result, CR
      GOTO Main
      END
    

    Post Edited (humanoido) : 7/7/2009 8:45:14 AM GMT
  • skylightskylight Posts: 1,915
    edited 2009-07-07 09:51
    why would the formatter cause this problem?
  • HumanoidoHumanoido Posts: 5,770
    edited 2009-07-08 05:09
    I don't know why the formatter would cause this.
    I tried changing the hardware, and reversing the
    roles of the transmitter and receiver, and the effect
    is always the same with the # formatter. If someone
    can find more technical information on the BS1's #
    modifier, that may help. The formatter may change
    the timing, causing the skip.
  • HumanoidoHumanoido Posts: 5,770
    edited 2009-07-08 05:52
    There is a brief description in the PBASIC Syntax Guide regarding #, in the BS2 category.
    Notice the decimal formatter in the SERIN command. It is the "#" (for the BS1) or "DEC" (for the other BASIC Stamps) that appears just to the left of the sData variable. This tells SERIN to convert incoming text representing decimal numbers into true-decimal form and store the result in sData. If the user running the terminal software pressed the "1", "2" and then "3" keys followed by a space or other non-numeric text, the value 123 will be stored in sData. Afterwards, the program can perform any numeric operation on the number just like with any other number. Without the decimal formatter, however, you would have been forced to receive each character ("1", "2" and "3") separately, and then would still have to do some manual conversion to arrive at the number 123 (one hundred twenty three) before you can do the desired calculations on it.
  • TinkersALotTinkersALot Posts: 535
    edited 2009-07-08 16:18
    just another wild guess, but stretch your delay time in the xmitter side to longer than 250...I'm wagering that the "extra time" to do that format operation is causing the receiver to miss every other byte.....worth a shot, eh?
  • HumanoidoHumanoido Posts: 5,770
    edited 2009-07-09 10:56
    The timing was increased from 250ms to 1000ms and the result is still the same,
    missing every other number.
Sign In or Register to comment.