Mystery BS1 Programs
Humanoido
Posts: 5,770
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?
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
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
Post Edited (humanoido) : 7/7/2009 8:45:14 AM GMT
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.
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.
missing every other number.