May 18, 2024, 02:06:28 AM

News:

You can now use Vixen to program your Prop-1 and Prop-2 controllers!  Get started quickly and easily, without having to learn PBASIC.  Details in the Library forum.


Recent posts

Pages 1 ... 6 7 8 9 10
71
Prop-2 / MDFLY AU5018 MP3 player
Last post by Jeff Haas - November 16, 2019, 09:57:30 PM
Hi Tim,

Here's the code to control the MDFLY AU5018 MP3 player from the Prop-2.  I ported your code from the Prop-1.  Because the Prop-2 is capable of many more speeds of serial connection, it can communicate via serial with this type of board.  So it makes the whole thing much simpler.  One connection from the Prop-2 to the MP3 board and you can give it all kinds of commands, and leave the rest of the Prop-2's pins free to control relays.

Note that MDFly's website doesn't have the entire manual for the Tenda player.  I found a copy on this link:
http://www.echelleinconnue.net/outils/mobio/composants/TDB380_datasheet_V2_(Tenda_Electronics).pdf

I used the info in the section on Serial Mode.

Instructions on how to set this up are in the top of the code.  I tested this on my Prop-2 with the same MP3 player and a relay.

Jeff

' =========================================================================
'
'   File...... music player.bs2
'   Purpose... control MDFLY AU5018
'   Author.... Timothy Ewing
'   E-mail.... time2dive@hawaii.rr.com
'   Started... 14 NOV 2019
'   Updated... 16 NOV 2019
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================
' Discussion from EFX-Tek board:
' http://www.efx-tek.com/php/smf/index.php?topic=2400.0
'
' Ported from Prop-1 (Basic Stamp 1) to Prop-2 (Basic Stamp 2).
' This version uses serial control for the MDFly/Tenda board.
' Connect a servo cable from R/B/W header on Pin 7 to VCC, GND, and Pin 16 on MP3 board.
' Then use pins 17, 18, and GND on the MP3 board for the headphone jack.

' Name the MP3s like this:
' 001 Firstsound.mp3
' 002 Secondsound.mp3
'
' Name the files like this, make a folder on the SD card named 001,
' then copy the MP3s into the folder the SD card.
'
' Then sort the FAT on the SD card using a utility like DriveSort:
' http://www.anerty.net/software/file/DriveSort/?lang=en
' This makes sure the MP3 player sees "001 Firstsound.mp3" as the actual first sound!

' -----[ Program Description ]---------------------------------------------
'   audio board controller
'   input PIR
'   output to MP3 player via serial
'   output lights

' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

Sio          PIN      15  ' SETUP = out; no ULN
PIR          PIN      14  ' SETUP = DN
MP3          PIN      7   ' Connect to Tenda MP3 board on Pin7 header.
LIGHT1       PIN      1   ' light 1

' -----[ Constants ]-------------------------------------------------------

IsOn         CON     1                       ' for active-high in/out
IsOff        CON     0

#SELECT $STAMP
  #CASE BS2, BS2E, BS2PE
    T2400       CON     396
    T38K4       CON     6
  #CASE BS2SX, BS2P
    T2400       CON     1021
    T38K4       CON     45
  #CASE BS2PX
    T2400       CON     1646
    T38K4       CON     84
#ENDSELECT

Open            CON     $8000
Baud            CON     Open + T38K4            ' B/R jumper installed

' -----[ Variables ]-------------------------------------------------------

timer           VAR     Word
PIRWarmup       VAR     Byte
WarmupTime      VAR     Byte

WarmupTime = 30  ' This may need to be as long as 60 for a reliable PIR response.  30 = 30 seconds.

' -----[ Initialization ]--------------------------------------------------

Reset:

  OUTH = %00000000 : OUTL = %00000000           ' preset IOs
  DIRH = %00000000 : DIRL = %10000010           ' set outputs (1s)

  SEROUT MP3, 188, [239]                        'STOP MP3 module before doing anything

  FOR PIRWarmup = 1 TO WarmupTime               ' Define loop for PIR calibration time
    PAUSE 500                                   ' Wait 0.5 seconds
    DEBUG "."                                   ' Visual feedback in DEBUG window
    PAUSE 500                                   ' Wait 0.5 seconds
  NEXT

' -----[ Program Code ]----------------------------------------------------

Startup:

'  light1 = IsOff                               ' light 1 off

  PAUSE 1000
  SEROUT MP3, 188, [01]                        ' Play SFX 1
  PAUSE 1000                                   ' wait
  SEROUT MP3, 188, [239]                       ' Stop playing

  SEROUT MP3, 188, [06]                        ' Play repeat (assumes repeat is named 006 repeat.mp3)
  PAUSE 1000                                   ' pause
  SEROUT MP3, 188, [239]                       ' Stop playing

  PAUSE 4500                                   ' wait 4.5 seconds

Main:
  timer = 0                                     ' reset PIR debounce timer

  DEBUG CR, "Ready", CR

Check_Trigger:

  DO WHILE (timer < 100)                        ' wait for 0.1 sec input
    PAUSE 5                                     ' loop pad
    timer = (timer + 5) * PIR                   ' update timer
  LOOP

  DEBUG CR, "Triggered", CR

  LIGHT1 = IsOn                                ' turn on light

  SEROUT MP3, 188, [02]                        ' Play SFX 2
  PAUSE 4500                                   ' wait
  SEROUT MP3, 188, [239]                       ' Stop playing

  SEROUT MP3, 188, [03]                        ' Play SFX 3
  PAUSE 4500                                   ' wait
  SEROUT MP3, 188, [239]                       ' Stop playing

  LIGHT1 = IsOff                               ' light 1 off

  SEROUT MP3, 188, [01]                        ' Play SFX 1
  PAUSE 1000                                   ' wait
  SEROUT MP3, 188, [239]                       ' Stop playing

  SEROUT MP3, 188, [06]                        ' Play SFX 6 (repeat sound)
  PAUSE 1000                                   ' wait
  SEROUT MP3, 188, [239]                       ' Stop playing

  GOTO Main
72
Prop-1 / Re: Programming or hardware he...
Last post by Jeff Haas - November 16, 2019, 07:04:30 PM
Tim,

One thing I forgot - the MDFly board you're using can be controlled by a serial connection with a Prop-2.  The Prop-1 doesn't have the right serial speed to work with that board, but the Prop-2 can work fine with it.  So it will make things easier to control the sound effects - you have one connection from the Prop-2 to the MDFly board.  I've got a few of these modules and have used them very successfully with the Prop-2.  I will put up a thread in the Prop-2 section and post code there for you.

Jeff
73
Prop-1 / Re: Programming or hardware he...
Last post by Jeff Haas - November 16, 2019, 09:54:24 AM
A really important change was the two lines in the initialization section, which configure the pins.

This will need to be adapted for the Prop-2, some of the Basic commands are different.
74
Prop-1 / Re: Programming or hardware he...
Last post by time2dive - November 16, 2019, 01:50:10 AM
Everything works! Thanks for the help. So the main changes were to replace  "High Play" with "play IsOn" and all of the other similar commands and add the trigger function....so I was sort of close.  I will tweak the pause and play times to fit the actual track time and see if the Prop1 will control the MDFLY board without the relays.
Will this same code work for a Prop2? I will need more outputs for the final prop. This was a test of concept.
Again...thanks for the help.
75
Prop-1 / Re: Programming or hardware he...
Last post by Jeff Haas - November 15, 2019, 08:05:31 PM
If you're  using relays for all the outputs then I thnik the program will work the way it is.  Using the screw terminal for the light is usually a way to have the Prop-1 provide the power, but triggering the output is the same.

Let us know how it works out!
76
Prop-1 / Re: Programming or hardware he...
Last post by time2dive - November 15, 2019, 05:43:51 PM
Pin0-Pin4 are using P0-P4 using servo connectors,  the light is using Out5. Should that be labeled Out5 or just 5. The reason for the 250 msec pauses is to simulate pressing a button on the audio board.
I will make changes and try it.
77
Prop-1 / Re: Programming or hardware he...
Last post by Jeff Haas - November 15, 2019, 01:41:54 PM
Hi Tim,

I made a few updates:

- Added pin definitions in the Initialization section.  You forgot these, they're important on the BS1.
- Added "PIN" to PIN5 - you needed this.
- Changed all HIGH and LOW lines to JM's "IsOn" and "IsOff", which is easier to read.  You already had that set up in the top of the code.
- Your pauses were all very short, I made them longer so you can see them.  Remember that PAUSE = 1000 is only one second long, so 250 is really short and may not be what you wanted.
- Added JM's debounce routine for the button input.  This will also work for a PIR.  Doing it this way makes things more reliable, especially with a PIR.
- Some simple reformatting, including labelling your first section "Startup" because you're doing something different there than when you trigger the prop.

I tested this on a Prop-1 Trainer.  Try it out, and I think you'll want to experiment with the pauses, they're still pretty short.

Jeff


                                   ' =========================================================================
'
'   File...... music player.bs1
'   Purpose... control MDFLY AU5018
'   Author.... Timothy Ewing
'   E-mail.... time2dive@hawaii.rr.com
'   Started... 14 NOV 2019
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'   audio board controller
'   input PIR
'   output relay controls
'   output lights

' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN
SYMBOL  trigger         = PIN6                  ' SETUP = DN
SYMBOL  play            = PIN0                  ' play
SYMBOL  track1          = PIN1                  ' track 1
SYMBOL  track2          = PIN2                  ' track 2
SYMBOL  track3          = PIN3                  ' track 3
SYMBOL  repeat          = PIN4                  ' repeat
SYMBOL  light1          = PIN5                  ' light 1



' -----[ Constants ]-------------------------------------------------------

SYMBOL  IsOn            = 1                     ' for active-high input
SYMBOL  IsOff           = 0


' -----[ Variables ]-------------------------------------------------------

SYMBOL  timer           = B2

' -----[ Initialization ]--------------------------------------------------

Reset:

  PINS = %00000000                              ' clear all
  DIRS = %00111111                              ' make P0-P5 outputs

' -----[ Program Code ]----------------------------------------------------

Startup:

  PAUSE 1000
  play = IsOn                                  ' play mp3
  PAUSE 1000                                   ' wait
  play = IsOff                                 ' play off
  repeat = IsOn                                ' repeat on
  PAUSE 1000                                   ' pause
  repeat = IsOff                               ' repeat off
  PAUSE 4500                                   ' play track 1 for 45 seconds

Main:

Check_Trigger:
  PAUSE 5                                      ' loop pad
  timer = timer + 5 * Trigger                  ' update timer
  IF timer < 100 THEN Check_Trigger            ' wait for 0.1 sec input

  light1 = IsOn                                ' turn on light
  track2 = IsOn                                ' track 2 on
  PAUSE 1000                                   ' pause
  track2 = IsOff                               ' track 2 off
  PAUSE 4500                                   ' wait while track 2 plays
  track3 = IsOn                                ' track 3 on
  PAUSE 1000                                   ' wait
  track3 = IsOff                               ' track 3 off
  PAUSE 4500                                   ' play track 3 for 45 seconds
  light1 = IsOff                               ' light 1 off
  track1 = IsOn                                ' track 1 on
  PAUSE 1000                                   ' wait
  track1 = IsOff                               ' track 1 off
  repeat = IsOn                                ' repeat on
  PAUSE 1000                                   ' wait
  repeat = IsOff                               ' repeat off

  GOTO Main
78
Prop-1 / Programming or hardware help
Last post by time2dive - November 15, 2019, 02:48:09 AM
I am trying to control a MDFLY AU5018 it wants a low to control what plays it runs on TTL voltage inputs. As of now I am using the Prop 1 to control 5v relays P0-P5 to control "Play", "Repeat" and "Tracks. I am using a push button trigger which does appear to work
The problem that I am having is that only the relay hooked up to P0 is doing anything. It is triggering when the other I/O (P1-P5)should be triggering. The other relays have power.

here is my code

' =========================================================================
'
'   File...... music player.bs1
'   Purpose... control MDFLY AU5018
'   Author.... Timothy Ewing
'   E-mail.... time2dive@hawaii.rr.com
'   Started... 14 NOV 2019
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'   audio board controller
'   input PIR
'   output relay controls
'   output lights

' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN
SYMBOL  trigger         = PIN6                  ' SETUP = DN
SYMBOL  play            = PIN0                  ' play
SYMBOL  track1          = PIN1                  ' track 1
SYMBOL  track2          = PIN2                  ' track 2
SYMBOL  track3          = PIN3                  ' track 3
SYMBOL  repeat          = PIN4                  ' repeat
SYMBOL  light1          = 5                     ' light 1



' -----[ Constants ]-------------------------------------------------------

SYMBOL  IsOn            = 1                     ' for ative-high input
SYMBOL  IsOff           = 0


' -----[ Variables ]-------------------------------------------------------


' -----[ Initialization ]--------------------------------------------------

Reset:


' -----[ Program Code ]----------------------------------------------------

  PAUSE 1000
  HIGH play                                    ' play mp3
  PAUSE 250                                    ' wait 250 msec
  LOW play                                     ' play off
  HIGH repeat                                  ' repeat on
  PAUSE 250                                    ' pause 250 msec
  LOW repeat                                   ' repeat off
  PAUSE 4500                                   ' play track 1 for 45 seconds
  Main:
  IF Trigger = IsOff THEN Main                 ' wait for trigger
  HIGH light1                                  ' turn on light
  HIGH track2                                  ' track 2 on
  PAUSE 250                                    ' pause 250 msecf
  LOW track2                                   ' low track 2
  PAUSE 4500                                   ' play track 2 for 45 seconds
  HIGH track3                                  ' track 3 on
  PAUSE 250                                    ' wait 250 msec
  LOW track3
  PAUSE 4500                                   ' play track 3 for 45 seconds
  LOW light1                                   ' light 1 off
  HIGH track1                                  ' track 1 on
  PAUSE 250                                    ' wait 250 msec
  LOW track1
  HIGH repeat                                  ' repeat on
  PAUSE 250                                    ' wait 250 msec
  LOW repeat
  GOTO Main
79
Prop-1 / Re: Programming help?
Last post by Jeff Haas - November 02, 2019, 01:50:10 AM
Chris - Did you manage to get this done?  How did it go?
80
Prop-1 / Re: Programming help?
Last post by BigRez - October 22, 2019, 11:34:00 AM
Oh man... that was 10 years ago???

The program has gone through a few updates since then, mostly changing the timing routines. I'm actually about to start testing that prop before setting it up, so I'll familiarize myself with the code again if you have any questions.
Pages 1 ... 6 7 8 9 10