November 21, 2024, 06:21:18 PM

News:

Got VSA?  Want to use your Prop-SX?  Now you can!  See the VSA section of the Library forum for Prop-SX code that works with VSA.


Prop-2 --> Soundgin?

Started by ilusion, March 07, 2007, 05:27:18 PM

Previous topic - Next topic

ilusion

March 07, 2007, 05:27:18 PM Last Edit: July 08, 2011, 03:17:08 PM by ilusion
Ok, been beating my head against the wall for a few days on this one. I've got a Soundgin chip I'm trying to drive from the Prop-2. I have the Soundgin in it's "demo" carrier board.

In the carrier board, I removed the Max-232 chip so it would not interfere with serial signals, then (using the carrier board schematic as a guide) I connected the following wires beween the Prop-2 and the Soundgin:

Prop2 P0"W" to Soundgin Pin 10
Prop2 P0"B"  to Soundgin Pin 5

I powered the Soundgin demo board using a 9v wall wart transformer, and I powered the Prop-2 from another 9v wall transformer (two separate supplies, but the prop-2 and the Soundgin board have a shared ground via P0"B" to Soundgin Pin 5).

Then, based on a reading of the Soundgin manual, I wrote the following test code:

Running this code on the BSII:


' {$STAMP BS2}
' {$PBASIC 2.5}

' Pin Definitions
 SOUNDGIN    PIN 0  ' serial out to SoundGin RX pin

' Baud Definitions
 T9600       CON     84    '9600 baud
 T9600I      CON     16468 '9600 baud inverted

'SOUNDGIN SETTINGS
 BAUD        CON     T9600  'use 9600 baud
 ESC         CON     27     'set the escape character
 PRESET      CON     75     'preset
 GONG        CON     3      'preset number

'Main Program Begin
around:
 DEBUG  "Play Gong",CR
 SEROUT SOUNDGIN, BAUD, [ESC,PRESET,GONG]
 PAUSE 5000                          ' wait 5 seconds
 GOTO around


Running the above code produces no sound, so I tried  some tests:

-Tried with 9600I (inverted) results: No Sound

-Power Cycle the Soundgin board & Homework board result: no sound

-Removed P0 connection, replaced MAX232 chip and attached serial cable, ran Soundgin Console program preset 4 (gong) result: plays "gong" sound

-shut down soundgin program, opened hyper term, typed ALT-027, ALT-075, ALT-003 result: plays gong sound

So, what this seems to verify is that

1) the soundgin board is working

2) the serial command to make a gong sounds is
  27,75,3 as per the docs (page 10)

I then did this additional testing:

With the MAX232 chip in place, and serial cable attached to the PC, I used a logic probe to probe pin 10. When the probe touches pin 10 it immediately shows "HIGH" status. When any of the items on the soundgin software keyboard are hit, I get a momentary "low" and a "pulse" light on the probe.

After removing the MAX232 chip, and reattaching the pin 10 to P0"W" of the Prop-2, I connected the probe to pin 10. When the basic stamp is in T9600 mode (i.e. "normal") I see a immediate HIGH on the probe and when the test code is run I see the LOW led light and the pulse light illuminate on 5 second intervals.

When I change to T9600I (i.e. "inverted"), and attach the probe, I see an immediate lighting of the LOW led followed by blinking of the "HIGH" led and PULSE" led's on 5 second intervals.

This would tend to indicate that T9600, NON inverted matches the output of the MAX232 chip.

So, I'm stumped. Does anyone have experience with this chip and the Prop-2 yet? :)

Vern
--
"Why are we in this Handbasket? And where are we going?!"

JonnyMac

March 07, 2007, 07:22:06 PM #1 Last Edit: March 08, 2007, 07:22:41 AM by JonnyMac
I haven't connected mine yet, but have these thoughts based on working with the SpeakJet in the past:

If you're connecting through the MAX232 you'll want to use Inverted (N9600) mode; if you go direct use True (T9600) mode.  If you are using True mode, make your serial pin high and wait at least one byte period (1 ms at 9600 baud; I'd use 10) so that any startup switching doesn't cause the chip to think it's receiving.

From my Prop-2/BS2 template:

#SELECT $STAMP
  #CASE BS2, BS2E, BS2PE
    T2400       CON     396
    T4800       CON     188
    T9600       CON     84
    T19K2       CON     32
    T38K4       CON     6
  #CASE BS2SX, BS2P
    T2400       CON     1021
    T4800       CON     500
    T9600       CON     240
    T19K2       CON     110
    T38K4       CON     45
#ENDSELECT

Inverted        CON     $4000
Open            CON     $8000

N9600           CON     Inverted + T9600


You might want to pull the ULN out of the pin you're using for serial comms as it has shown to interfere with True mode communications (e.g., our serial accessories).
Jon McPhalen
EFX-TEK Hollywood Office

ilusion

Answering my own (really old) post here in case someone else runs into this issue. How to make a Prop-2/Basic Stamp II talk to the soundgin and put it through it's paces - including making it speak.  ;D


'{$STAMP BS2}
'{$PBASIC 2.5}
' **************************************************************
' *                  Soundgin demo program                     *
' *       By Vern Graner SSE, Texas Information Services       *
' **************************************************************
' *   Code takes a SOUNDGIN chip though simple excercises      *
' **************************************************************
' * Revision Info: V0.7 (VLG) 4-3-2007  First Draft            *
' * Revision Info: V0.8 (VLG) 1-22-2011 Added speech demo      *
' **************************************************************

' ************************
' * Conditonal Compile   *
' *************************************************************************
#SELECT $STAMP
  #CASE BS2, BS2E, BS2PE
    T2400       CON     396
    T4800       CON     188
    T9600       CON     84
    T19K2       CON     32
    T38K4       CON     6
  #CASE BS2SX, BS2P
    T2400       CON     1021
    T4800       CON     500
    T9600       CON     240
    T19K2       CON     110
    T38K4       CON     45
  #CASE BS2PX
    T2400       CON     1646
    T4800       CON     813
    T9600       CON     396
    T19K2       CON     188
    T38K4       CON     84
#ENDSELECT

' ************************
' * I/O Definitions      *
' *************************************************************************
' Pin Definitions
   SOUNDGIN    PIN 12  ' serial out to SoundGin RX pin
   ' avail     PIN 1  '
   ' avail     PIN 2  '
   ' avail     PIN 3  '
   ' avail     PIN 4  '
   ' avail     PIN 5  '
   ' avail     PIN 6  '
   ' avail     PIN 7  '
   ' avail     PIN 8  '
   ' avail     PIN 9  '
   ' avail     PIN 10 '
   ' avail     PIN 11 '
   ' avail     PIN 12 '
   ' avail     PIN 13 '
   ' avail     PIN 14 '
   ' avail     PIN 15 '

' ************************
' *Speech Data           *
' *************************************************************************
' Speech code generated by text to speech generator:
' http://www.graner.net/projects/speech

' Soundgin. speech. demonstration.
' PAU S AW1 N JH IH1 N PAU S P IY1 CH PAU D EH1 M AX N S T R
' EY1 SH AX N PAU
Text1  DATA   252, 236, 231, 224, 216, 214, 214, 224, 252, 236
       DATA   234, 207, 207, 201, 252, 204, 206, 223, 193, 224
       DATA   236, 239, 235, 194, 238, 193, 224, 252
       DATA   0 'Add a zero to indicate end of phrase

' Playing. preset. sounds
' PAU P L EY1 IH NG PAU P R IY S EH1 T PAU S AW1 N D Z PAU
Text2 DATA   252, 234, 221, 194, 214, 078, 210, 252, 234, 235
      DATA   207, 236, 206, 239, 252, 236, 231, 224, 204, 248
      DATA   252
      DATA   0 'Add a zero to indicate end of phrase

      ' Playing. scales. with. different. wave. shapes
' PAU P L EY1 IH NG PAU S K EY1 L Z PAU W IH1 DH PAU D IH1 F
' ER AX N T PAU W EY1 V PAU SH EY1 P S PAU
Text3 DATA   252, 234, 221, 194, 214, 078, 210, 252, 236, 217
      DATA   194, 221, 248, 252, 246, 214, 214, 241, 252, 204
      DATA   214, 214, 209, 208, 193, 224, 239, 252, 246, 194
      DATA   245, 252, 238, 194, 234, 236, 252
      DATA   0 'Add a zero to indicate end of phrase

      ' Playing. a. three. note. chord
' PAU P L EY1 IH NG PAU EY PAU TH R IY1 PAU N OW1 T PAU K
' AO1 R D PAU
Text4 DATA   252, 234, 221, 194, 214, 078, 210, 252, 194, 252
      DATA   240, 235, 207, 207, 252, 224, 228, 239, 252, 217
      DATA   196, 235, 204, 252
      DATA   0 'Add a zero to indicate end of phrase

' Soundgin. Demo. Complete.
' PAU S AW1 N JH IH1 N PAU D EH1 M OW PAU K AX M P L IY1 T PAU
Text5 DATA   252, 236, 231, 224, 216, 214, 214, 224, 252, 204
      DATA   206, 223, 196, 252, 217, 193, 223, 234, 221, 207
      DATA   207, 239, 252
      DATA   0 'Add a zero to indicate end of phrase

' ************************
' *Constants and vars    *
' *************************************************************************
  ' System Definitions
  ' Baud Rates
  SevenBit        CON     $2000 ' \
  Inverted        CON     $4000 '  Serial TTL com baud modes (used with conditional compile)
  Open            CON     $8000 ' /

' System Variables
  cntI        VAR     Byte   ' \ counters
  cntB        VAR     Byte   ' /
  strAddr     VAR     Word   ' String Address for data values (speech)
  char        VAR     Byte   ' Characters (for speech also)

'Soundgin Settings
  BAUD        CON     T9600  ' set the baud rate
  ESC         CON     27     ' set the escape character
  PRESET      CON     75     ' preset

  MusicalNoteOscA1    CON     88
  MusicalNoteOscA2    CON     89
  MusicalNoteOscA3    CON     90

  OscControlA1        CON     16
  OscControlA2        CON     32
  OscControlA3        CON     48

  OscSine             CON     0
  OscTriangle         CON     1
  OscSaw              CON     2
  OscRamp             CON     3
  OscPulse            CON     4
  OscNoise            CON     5

'Soundgin presets
  preSPACEWARP        CON     0  ' 0 Space Warp
  preWABA             CON     1  ' 1 Waba
  preRANDOMTHOUGHTS   CON     2  ' 2 Random Thoughts
  preGONG             CON     3  ' 3 Gong
  prePWANG            CON     4  ' 4 Pwang
  preWOW              CON     5  ' 5 Wow
  preRANANANA         CON     6  ' 6 Rananana
  preTWARTY           CON     7  ' 7 Twarty
  preTELLY            CON     8  ' 8 Telly
  prePULSATOR         CON     9  ' 9 Pulsator
  preBOUNCE           CON     10 '10 Bounce
  preTIPTOE           CON     11 '11 Tip Toe
  preSPOKES           CON     12 '12 Spokes
  preCHOPPER          CON     13 '13 Chopper
  prePHAZER           CON     14 '14 Phazer
  prePOWERLINES       CON     15 '15 Power Lines
  preHEAVYMETAL1      CON     16 '16 Heavy Metal 1
  preHEAVYMETAL2      CON     17 '17 Heavy Metal 2
  preACMOTOR          CON     18 '18 AC Motor
  preYAYA             CON     19 '19 Ya-Ya
  preMARCH            CON     20 '20 March
  preNOISECHATTER     CON     21 '21 Noise Chatter
  preBLIPCHATTER      CON     22 '22 Blip Chatter
  preCARNEY           CON     23 '23 Carney
  preEARTHQUAKE       CON     24 '24 Earth Quake
  preMINDPROBE        CON     25 '25 Mind Probe
  preSIREN            CON     26 '26 Siren
  preSQUABA           CON     27 '27 Squaba
  preSTEAMLOCOMOTIVE  CON     28 '28 Steam Locomotive
  preSIMPLEFM         CON     29 '29 Simple Frequency Modulation
  preSIMPLEAM         CON     30 '30 Simple Amplitude Modulation


' ************************
' * Main Program Begin   *
' *************************************************************************
  around:
  GOSUB SGReset 'force a complete chip reset

' ************************
' * Play Speech Demo     *
' ************************
  DEBUG CLS
  DEBUG "Speaking text:",CR
  DEBUG "Soundgin speech demonstration.",CR
    strAddr = Text1     ' set pointer in data table
    GOSUB Speak
    PAUSE 1000

' ************************
' * Play each preset     *
' ************************
  DEBUG CLS
  DEBUG  "Playing Preset Sounds...",CR,CR
  strAddr = Text2     ' set pointer in data table
  GOSUB Speak
  GOSUB SGReset       ' Reset soundgin

  FOR cntI = 0 TO 30
    DEBUG HOME,CRSRDN,CRSRDN, "Preset #",DEC cntI
    SEROUT SOUNDGIN, BAUD, [ESC,PRESET,cntI]
    PAUSE 1000
  NEXT
  PAUSE 1000
  GOSUB SGReset

' ************************
' * Play scales/waveform *
' ************************
  DEBUG CLS
  DEBUG  "Playing scales with different wave shapes...",CR,CR
    strAddr = Text3     ' set pointer in data table
    GOSUB Speak         ' Speak
    PAUSE 1000
    GOSUB SGReset       ' Reset soundgin

  DEBUG "Sine Wave",CR
      SEROUT SOUNDGIN, BAUD, [ESC, 4, OscControlA1, 7, OscSine]
      GOSUB sgPlayScale
  PAUSE 1000

  DEBUG CR, "Triangle Wave",CR
      SEROUT SOUNDGIN, BAUD, [ESC, 4, OscControlA1, 7, OscTriangle]
      GOSUB sgPlayScale
  PAUSE 1000

  DEBUG CR, "Sawtooth Wave",CR
      SEROUT SOUNDGIN, BAUD, [ESC, 4, OscControlA1, 7, OscSaw]
      GOSUB sgPlayScale
  PAUSE 1000

  DEBUG CR, "Ramp Wave",CR
      SEROUT SOUNDGIN, BAUD, [ESC, 4, OscControlA1, 7, OscRamp]
      GOSUB sgPlayScale
  PAUSE 1000

  DEBUG CR, "Pulse Wave",CR
      SEROUT SOUNDGIN, BAUD, [ESC, 4, OscControlA1, 7, OscPulse]
      GOSUB sgPlayScale
  PAUSE 1000

  DEBUG CR, "Noise Wave",CR
      SEROUT SOUNDGIN, BAUD, [ESC, 4, OscControlA1, 7, OscNoise]
      GOSUB sgPlayScale
  PAUSE 1000

  PAUSE 2000                          ' wait before continuing
  GOSUB SGReset                       ' Reset soundgin

' ************************
' * Play 3 note chord    *
' ************************
  DEBUG CLS, "Playing a three note chord:",CR,CR
    strAddr = Text4     ' set pointer in data table
    GOSUB Speak

   GOSUB SGReset                       ' Reset soundgin
   DEBUG "Note 64 on A1",CR
   SEROUT Soundgin, BAUD, [ESC,88,64] 'start a note on A1
   PAUSE 500

   DEBUG "Note 68 on A2",CR
   SEROUT Soundgin, BAUD, [ESC,89,68] 'start a note on A2
   PAUSE 500

   DEBUG "Note 71 on A3",CR
   SEROUT Soundgin, BAUD, [ESC,90,71] 'start a note on A3
   PAUSE 500

   PAUSE 3000

DEBUG "Stop all oscillators",CR
  SEROUT Soundgin, BAUD, [ESC,84] 'stop A1
  SEROUT Soundgin, BAUD, [ESC,85] 'stop A2
  SEROUT Soundgin, BAUD, [ESC,86] 'stop A3


' ************************
' * Done                 *
' ************************
    DEBUG CLS, "Soundgin demo complete.",CR,CR
    strAddr = Text5     ' set pointer in data table
    GOSUB Speak
    GOSUB SGReset

    '  GOTO around ' To make it repeat the demo, uncomment this line
    END

' Subroutines
' ------------------------------------------------------------
SGReset:
'    DEBUG CR,"Reseting Soundgin Chip...",CR
    SEROUT SOUNDGIN, BAUD, [ESC,ESC,ESC,ESC,ESC,ESC,ESC,ESC]
'    DEBUG "Rest sent",CR
    PAUSE 1000
'    DEBUG CLS
    RETURN

Speak:
   DO
    READ strAddr, char                  ' read byte from EEPROM
    strAddr = strAddr + 1               ' point to next character
    IF (char = 0) THEN EXIT             ' if 0, exit routine
'    DEBUG DEC char, ","                 ' print data cell value
    SEROUT SOUNDGIN, BAUD, [CHAR] 'Send the sound to the soudngin
    PAUSE 65
  LOOP
  PAUSE 2000 ' allow time for speech to complete (make larger as needed)
  RETURN

SGPlayScale:
    DEBUG "Note="
    FOR cntI = 64 TO 75
      DEBUG CRSRX, 5, DEC cntI
      SEROUT SOUNDGIN, T9600, [ESC, MusicalNoteOscA1, cntI]
      PAUSE 150
      SEROUT SOUNDGIN, T9600, [ESC,84]
      PAUSE 10
    NEXT
    DEBUG CR
    RETURN
--
"Why are we in this Handbasket? And where are we going?!"