Shop OBEX P1 Docs P2 Docs Learn Events
TDB380 demo in PropBASIC — Parallax Forums

TDB380 demo in PropBASIC

phatallicaphatallica Posts: 64
edited 2013-07-21 20:05 in Propeller 1
Application = Serial communication control of MP3(s) for Halloween props and general mayhem
Hardware = Tenda TDB380 (aka www.mdfly.com Model: MOL-AU5121) ... and SD card
Software = PropBasic (PH_TEMPLATE_TDB380.pbas) routine to validate control, limitations, and best practices
- added loop for PIR to re-trigger part of the sequence

I included my test audio files. These files are mostly text-to-speech indications of what folder and file location is playing. A few files indicate what is happening in the code. There is one music file (~35 seconds) to allow for the PIR to initiallize reliably.

Drive Sort - http://www.anerty.net/software/file/DriveSort.php - TDB380 is dumb, in that it does not actually read file names. To get predictable results, you need to name files and folders in alpha-numeric order and then use this drive sorting software to ensure that they are properly arranged.

Datasheet - http://www.flajzar.cz/data/files/739-MP3-DATA.pdf - this is the only copy of Version 2.1 datasheet that I could find. It still leaves much to be desired in regards to completeness (and accuracy ... SD card capacity supported up to 8GB; schematic does not show crossing TX/RX lines).

This is my first effort with the Propeller and PropBASIC, so I attempted to keep the code clean and well-commented. I still need practice with nested subroutines to get comfortable with __paramx control.

Result = This is a cost-effective solution that allows for significant manipulation of folder and files. It lacks in precise timing - I left-in the code that lights an LED to show that it takes about 2 seconds between the "play" command and when TDB380 indicates that it is playing with the BSY output.
By contrast, the ISD17xxx chips are very fast to respond to commands, but I find them to be a pain in regards to recording audio and addressing specific points. I had used these for a handful of previous Halloween props.
By contrast, I don't recall a delay in response with VMUSIC modules either, but cost and set-up were not very attractive. I had used these to synchronize a fireworks display to music.

I welcome any feedback or suggestions, as I am new to this microcontroller, programming language, and peripheral.

TDB380_PropBASIC_Demo.zip

~ph

Comments

  • BeanBean Posts: 8,129
    edited 2013-07-21 16:19
    ph,
    Your code looks great. If this is your "first effort" it is a darn good one.
    One tricky thing you must watch for when using the __paramx variables, is if you use a subroutine inside another one that uses parameter. If you do then the __paramx variable will get changed to the parameter of the call inside the subroutine.

    For example:
    TX     SUB 1 ' parameter is character to send
    Stars  SUB 1 ' parameter is how many stars to send
    
    SUB Stars
      DO
        TX "*"
      LOOP __param1 
    ENDSUB
    

    What happens here is the the TX "*" line will change __param1 to 42. To avoid this, you can move the parameter to a higher paramx value like this...
    SUB Stars
      __param2 = __param1 ' __param1 used by TX subroutine
      DO
        TX "*"
      LOOP __param2
    ENDSUB
    
    Bean
  • phatallicaphatallica Posts: 64
    edited 2013-07-21 20:05
    Thanks for your reply, Bean, as well as your kind words.

    From your feedback, I found at least one subroutine that can be simplified. TDB380_PLAY does not seem to require moving the parameter to __param2. I will clean that up when I test TDB380_PLAY_NOW (subroutine to interrupt an already playing file, to start playing another file).

    ~ph
Sign In or Register to comment.