Author Topic: TI84 Speaker Dongle  (Read 3920 times)

0 Members and 1 Guest are viewing this topic.

Offline AssemblyBandit

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 374
  • Rating: +60/-1
  • ~AssemblyBandit~
    • View Profile
    • briandm82.com
TI84 Speaker Dongle
« on: July 18, 2013, 08:39:59 pm »
A project I've been working on:  :w00t:



Currently its just a breadboard, MSP430, a speaker, USB cable/connections and wires but it can play music when attached to the USB port. It has 2 channels for playing background music and sound effects using square waves but I hope to modify it to include triangle, noise, and more channels. It communicates through a 1200bps asynchronous serial connection that currently can only receive. If I can’t figure out a reasonable way to free up the other USB line, I will add an FTDI chip or something similar. I haven’t chose a specific speaker yet, but I have 8 coming in to test. I have been poking around at the int and USB ports, decompiled some specific ROM pages, and got some other docs but its not where I want it to be at yet. Been trying to balance software and hardware but if theres enough interest, I'll bump this up.

Offline tr1p1ea

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 647
  • Rating: +110/-0
    • View Profile
Re: TI84 Speaker Dongle
« Reply #1 on: July 18, 2013, 08:53:31 pm »
That would be awesome!

Will this require you to send audio info constantly or will it have the facility to 'upload' music data etc for it to play by itself (which can also be interrupted if need be).
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."


Offline AssemblyBandit

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 374
  • Rating: +60/-1
  • ~AssemblyBandit~
    • View Profile
    • briandm82.com
Re: TI84 Speaker Dongle
« Reply #2 on: July 18, 2013, 09:17:32 pm »
I'm hoping to have default music loops and sound effects that can be called for quick and easy sound, loading a custom track and effects, and then the ability to stream music at 9600bps. The MSP430 has the ability to autodetect baud rates but I don't know if thats how I'm going to do it yet. I want it as simple as possible but I want it to be upgradable as well. For example a program that didn't need lots of effects or nothing fancy could send out a couple of bytes and have it autoloop a music track for it (kinda like it is right now).

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: TI84 Speaker Dongle
« Reply #3 on: July 19, 2013, 01:55:26 am »
That sounds cool. ;) It seems similar to Keoni29's TIMID project, just that it's external. I wonder why you went with USB instead of jack ?

Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: TI84 Speaker Dongle
« Reply #4 on: July 19, 2013, 04:40:31 am »
TIMID is external too. It can be built internally but you still wire it up to the linkport. You need a way to power it though.
If you like my work: why not give me an internet?








Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: TI84 Speaker Dongle
« Reply #5 on: July 19, 2013, 05:11:19 am »
Wow, that would be so cool! O.O
Are you planning to sell some too? :D

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline AssemblyBandit

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 374
  • Rating: +60/-1
  • ~AssemblyBandit~
    • View Profile
    • briandm82.com
Re: TI84 Speaker Dongle
« Reply #6 on: July 19, 2013, 05:26:12 pm »
I chose USB because it can power the MCU without using batteries or extra wires. A while ago, before I visited WikiTI, I was testing the USB ports. I didn't know which ports were which, I was just testing different ports. I figured out how to read the USB ports but I didn't find the port to write. Then I was reading WikiTI and I learned more about their functions. I noticed they had a port that could write to D-. However, I happen to call D-, D+ and I knew that writing to what I called D- was worthless so it kinda ended there. But one day I decided to try it anyway and realized that we just labeled the wires differently! Then yesterday me and Keoni29 were talking about MCUs and he had some sound code for an ATMEL. Now his code is definitely more advanced mine (watch his sound videos!) but I can't use it on the MSP430. I downloaded the Mario theme song someone had ported to freq and duration but because I use different code then others, it sounds horrible! It's recognizable, but horrible :(. I use the available timers in a different way then other people do. Actually, the way I read and inc the counters isn't really the official way to do it, but because I have the processor running at 10 times the speed of my timers, I manage to get away with it. I'll come up with some slick code to manage the sounds better though. By tonight I should have a demo video up with Buttonz playing some music and sound effects. I'm also going to get my Arduino running to check out Keoni29's code. I'll sell it if I can make it cheap enough. I'm thinking $25 max including shipping. I definitely want it to be cheaper than an Arduino, but it has to be able to communicate bilaterally. I'll show you why after it's built ;) This was suppose to be my 'Secret' project but after talking with Keoni29, I made a 3d model and set up this project page. Now its time to get that little speaker bumpin.

Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: TI84 Speaker Dongle
« Reply #7 on: July 20, 2013, 06:45:19 am »
Of course it should be cheaper than an arduino. You need less components to begin with since you have a nice regulated 5v coming out of the usb port, you don't need a usb to serial ttl converter and you don't need a double sided pcb. You save a lot of parts that way.

Edit: This is the basic principle of timing oscillators using just one hardware timer:
Code: [Select]
#include "TimerOne.h"

void setup()
{
  DDRB = 255;
  Timer1.initialize(16);         // initialize timer1, and set a 1/2 second period
  Timer1.attachInterrupt(sound);  // attaches callback() as a timer overflow interrupt
  Serial.begin(9600);
}

unsigned int counter[3] = {256,256,256};
unsigned int wavelength[3] = {256,128,64};
boolean gate[3] = {1,1,1};

void sound()
{
  for (int i = 0; i<=2; i++){ // Cycle trough all the oscillators
    if (counter[i] -- == 0){ // If the oscillator ends half a period
      counter[i] = wavelength[i]; // Reset the counter to the wavelength
      if (gate[i]) // If the gate is on
        PORTB ^=1<<i; // Change the state of the oscillator pin
    }
  }
}

void loop()
{
  if (Serial.available())
  wavelength[0] = Serial.read();
  if (Serial.available())
  wavelength[1] = Serial.read();
  if (Serial.available())
  wavelength[2] = Serial.read();
}
     

You can set the wavelength by sending bytes via serial for this example. I don't mix the channels in software, but I use resistors for that. You can mix in software and output on one pin with pwm.
« Last Edit: July 20, 2013, 07:30:22 am by Keoni29 »
If you like my work: why not give me an internet?








Offline AssemblyBandit

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 374
  • Rating: +60/-1
  • ~AssemblyBandit~
    • View Profile
    • briandm82.com
Re: TI84 Speaker Dongle
« Reply #8 on: July 24, 2013, 01:35:00 am »
It was originally planned to be a little more advanced than just a speaker ;) Now, I don't know how its going to turn out. I have to get rid of asynchronous serial because it's too hard/impossible to implement in BASIC programs. I might need that USB to serial converter to implement the clock pin. I have to do some more testing this weekend, believe me, that 'nice regulated 5v' supply is easier said than done :( I have to convince the calc that it's a peripheral and without having the clock speed for USB it might be a little tough. I may just have to change my initialization code or something but then I still have to figure out a way to control the D+ line or write a new communication protocol. I've added some code to Buttonz to create a demo video. Right now I'm fighting with the interrupts because they want to act all crazy when they see a halt instruction.