Shop OBEX P1 Docs P2 Docs Learn Events
Digital noise source and the BASIC Stamps — Parallax Forums

Digital noise source and the BASIC Stamps

Buck RogersBuck Rogers Posts: 2,195
edited 2025-03-19 05:19 in BASIC Stamp

Hello!
Well I've gone and done it again. This code:

' {$STAMP BS1}
' {$PBASIC 1.0}

SYMBOL serData = B2
SYMBOL  LcdCls = $0C
SEROUT 6, T2400, (LcdCls)
Main:

'DEBUG serData
SERIN 7, T2400, serData
'DEBUG serData
serData = serData + 1
'DEBUG serDATA
SEROUT 7, T2400, (serData)
SEROUT 6, T2400, (#serData)
SEROUT 5, T2400, (serData)
'DEBUG serDATA
GOTO Main

Which is for the Stamp1 and grew out of the code translation that @JonnyMac did for me a (long) while earlier. It will cause the number 192 to written to an LCD display such as the two line one from Parallax. And send the same number to a digital noise source, the MM5437 from National Semiconductor. (Originally) Mine was bought from Jameco a very long time ago. However Unicorn Electronics sells it and a largely different device, MM5837 and they might have stock.

The code for the Stamp2 looks like this:

' {$STAMP BS2}
' {$PBASIC 2.0}

serdata  VAR  Byte

again:
'*****this will wait for serial from calculator
SERIN 15,396,[serdata]

'***this will send it to the pc debug screen
'DEBUG DEC serdata, CR


'***this will send the same data plus 1 back to the calculator
serdata=serdata + 1
SEROUT 15,396,[serdata]
SEROUT 12,396,[serdata]
'SEROUT 15,396,[serdata]
SEROUT 14,396, [DEC serdata, CR]
GOTO again

And works the same as for the Stamp1, except that the display shows the numbers stacked. I get 192 on the first line and then 192 underneath on the second. It seems display formatting doesn't work on the Stamp1.
Almost forgot no mascots were involved in any of that or in writing this.

Comments

  • GenetixGenetix Posts: 1,763

    Buck,

    Mystery number coding drives me nuts because it's hard to tell what is what.

    I remember when I took Mechatronics, it took me 10% to write the code and 90% to document it.

    BS1 uses SYMBOL, and BS2 uses PIN and CON.
    The great thing about declaring these constants is that it makes changing them to a different value quick and easily.

    ' Declare I/O Pin Constants (BS1)
      SYMBOL SerialLCD = 6
      SYMBOL TI83Plus = 7
    
    ' Declare I/O Pins (BS2)
      TI83Plus PIN 15
      SerialLCD PIN 14
    ' Serial Baud Rate
      T2400 CON 396 ' 2400, 8-bit, no parity, true (noninverted), Driven output
    

    What is Pin 5 connected to, and which LCD are you using because normally there is some kind of initialization sequence.

  • @Genetix said:
    Buck,

    Mystery number coding drives me nuts because it's hard to tell what is what.

    I remember when I took Mechatronics, it took me 10% to write the code and 90% to document it.

    BS1 uses SYMBOL, and BS2 uses PIN and CON.
    The great thing about declaring these constants is that it makes changing them to a different value quick and easily.

    ' Declare I/O Pin Constants (BS1)
      SYMBOL SerialLCD = 6
      SYMBOL TI83Plus = 7
    
    ' Declare I/O Pins (BS2)
      TI83Plus PIN 15
      SerialLCD PIN 14
    ' Serial Baud Rate
      T2400 CON 396 ' 2400, 8-bit, no parity, true (noninverted), Driven output
    

    What is Pin 5 connected to, and which LCD are you using because normally there is some kind of initialization sequence.

    Hello!
    The Serial LCD in question is one of Parallax's own, in this case one of 27977-RT. I am not using any initialization sequence here, because it early proved to be not needed.

  • GenetixGenetix Posts: 1,763

    Buck,

    I assume that your program gets a number from the calculator.

    I notice in the BS2 program that a CR is also sent to the LCD; this will move to the next line.
    You can also choose the first or second line by sending a 128 or 148, before you send data.

    Since your using a 2-line LCD, why not print the received value on the first line and the transmitted value on the second.
    This will help verify that your program is doing what it should.

    On the BS2 you could using Conditional Compilation to turn this 'debugging mode' on and off.
    Refer to Page 70 of the BASIC Stamp Manual for this.

  • @Genetix said:
    Buck,

    I assume that your program gets a number from the calculator.

    I notice in the BS2 program that a CR is also sent to the LCD; this will move to the next line.
    You can also choose the first or second line by sending a 128 or 148, before you send data.

    Since your using a 2-line LCD, why not print the received value on the first line and the transmitted value on the second.
    This will help verify that your program is doing what it should.

    On the BS2 you could using Conditional Compilation to turn this 'debugging mode' on and off.
    Refer to Page 70 of the BASIC Stamp Manual for this.

    Hello!
    It's a thought. But for now this is only for testing out how the noise source reacts to a specific bit input. As for the value, that's preset by the fellow who wrote the original programs for the calculator.
    But try this one:

    ' {$STAMP BS2}
    ' {$PBASIC 2.0}
    
    serdata  VAR  Byte
    
    again:
    '*****this will wait for serial from calculator
    SERIN 15,396,[serdata]
    
    '***this will send it to the pc debug screen
    'DEBUG DEC serdata, CR
    
    
    '***this will send the same data plus 1 back to the calculator
    serdata=serdata + 1
    SEROUT 15,396,[serdata]
    SEROUT 14,396, [DEC serdata, CR]
    SEROUT 13,84,[serdata]
    'SEROUT 13,396, [DEC serdata, CR]
    'SEROUT 13,84, [DEC serdata, CR]
    GOTO again
    

    That is the one I was actually going to show all of you. That earlier one was just a normal show and send for the calculator and the display.

Sign In or Register to comment.