Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
Edit: New video



Old news and old sourcecode!
Old picture, yet gives a good overview of the hardware.

Newer picture with the on off switch, midi connector and jumper settings for midi/sid mode selection.




This is an atmega microprocessor emulating a SID soundchip. (found in old c64 homecomputers) I used a library for the emulation and I wrote my own link protocol. The calculator shifts out the data and the arduino code processes it. This thing works with everything with two free GPIO pins. The link protocol is pretty simple to implement. I designed it with the TI84+ in mind, but you can hook it up to any calc with a bidirectional open-drain linkport. I programmed the link protocol in AXE.


Code:
.send
lbl s
0->port
pause 1
for(b,0,7
if r1^2
3->port
else
2->port
end
pause 1
0->port
pause 1
r1/2->r1


And this is the code running on the arduino:
(note: get the lib as well http://code.google.com/p/sid-arduino-lib/ )
I removed the midi functionality for now, but it will be back soon.

Faster optimized code for the arduino:

Code:
#include <SID.h>

// MACROs
#define PIN2H (PIND & 0B00000100)
#define PIN3L !(PIND & 0B00001000)

#define CLR(x,y) (x&=(~(1<<y)))
#define SET(x,y) (x|=(1<<y))

SID mySid;

void setup()
{
  pinMode(2,INPUT);
  pinMode(3,INPUT);
  mySid.begin();
}

int n=0;
int timer=0;
int count=0;
int dcount=0;
byte get=B00000000;
int addrval[3] = {0,0,0};


    #define CHANNEL1  0
    #define CHANNEL2  7
    #define CHANNEL3  14


void loop()
{
  do{
    do
    {
      if (PIN3L)
      {
        if (PIN2H)
        {
          CLR(get,count);
        }
        else
        {
          SET(get,count);
        }
        count++;
       
        while(PIN3L)
        {
        timer++;
          if (timer==500){
            n=count=0;
            break;
          }
        }
        timer=0;
      }
    }while(count!=8);
    addrval[n]=get;
    n++;
    count=0;
  }while(n!=2);

  mySid.set_register(addrval[0], addrval[1]);
  n=0;
}


Hardware:
The tip of the 2,5mm plug is connected to arduino pin 2 (DIP pin 4) and the ring is connected to arduino pin 3 (DIP pin 5.) Remember that the pinout of the arduino is not the same as the microcontroller. Check the pinouts before you build this.
Pin 9 (DIP pin 15) is the audio output.
Isn't this a duplicate of your old topic? Or am I thinking of the UARTunes project for the Prizm? At any rate, this seems like a cool project. Do you have any better or more extensive sound samples? How many bytes per minute is the music? How many channels does this support? You specified that it requires a bidirectional open-collector linkport; why? Is the protocol like the TI linking protocol, in that to acknowledge a state change on one line, the peer pulls the other line low?
I made a digital to analog converter before Smile
The project in its current state has no need for bi-directional linkport, but I want to add the I/O functionality of the TI-nterface to it.
This looks great, Iím going to have to sharpen my soldering skills and really buckle down and build stuff instead of having my friend build stuff lol
I will post some music samples when I have a half decent music player.
I'd assume, since it is emulating the SID, It would have 3 channels monophonic.

KermMartian wrote:
Isn't this a duplicate of your old topic? Or am I thinking of the UARTunes project for the Prizm? At any rate, this seems like a cool project. Do you have any better or more extensive sound samples? How many bytes per minute is the music? How many channels does this support? You specified that it requires a bidirectional open-collector linkport; why? Is the protocol like the TI linking protocol, in that to acknowledge a state change on one line, the peer pulls the other line low?
These are the registers of the SID. By writing to them you can alter the sound.
I want to add "hardware" pitch bending with different modes such as LFO, portamento and sweep. The sound processor will also have a lookuptable with musical notes' pitch values. If you write to one of the three dedicated "musical note" registers it will relay it to the freq-hi and lo registers and it will turn on the gate of the channel. This saves a lot of memory and time on the calculator side!

Example:
Calculator sends a NOTE ON normally:

Code:
00 ff - write ff (0-255) to register 00 (Freq Lo)
01 ff - write ff (0-255) to register 01 (Freq Hi)
04 17 - write TRIANGLE|GATE_ON to register 04 (Conrol reg)

That's 6 bytes!

Calculator sends a NOTE ON with this new feature:

Code:
1D nn - write nn(0-255) to register 29

That's only two bytes!
Creating "shortcut"-style commands is definitely a good idea to save space. I'm going to play around with the PWM in the TI CC430 processor that Tari, geekboy, and I are thinking of using for our wireless CALCnet adapter to see if I can make a MOD tracker; that sort of compression trick would be very handy.

Code:

switch(addrval[0]){
        case 29: {
                   mySid.set_register(0,note[addrval[1]]%256);
                   mySid.set_register(1,note[addrval[1]]/256);
                   mySid.set_register(4,mySid.get_register(4)|1);
                   break;
                 }
        case 30: {
                   mySid.set_register(7,note[addrval[1]]%256);
                   mySid.set_register(8,note[addrval[1]]/256);
                   mySid.set_register(11,mySid.get_register(11)|1);
                   break;
                 }
        case 31: {
                   mySid.set_register(14,note[addrval[1]]%256);
                   mySid.set_register(15,note[addrval[1]]/256);
                   mySid.set_register(18,mySid.get_register(18)|1);
                   break;
                 }     
        default: {mySid.set_register(addrval[0], addrval[1]); break;}
      }


Replace
mySid.set_register(addrval[0], addrval[1]);
with that code.

Edit: I made some modifications to the library so it suits my needs. With the first stable release of the source I will include this in a zip.

Edit:

After I shot this video and put it all back together it worked for a while and then it just stopped working. Perhaps some dodgy soldering or short circuit. I took the mods out and started optimizing source code and what not.

This is a uni-directional link protocol:

Code:

// MACROs
#define PIN2L !(PIND & 0B00000100)
#define PIN3L !(PIND & 0B00001000)

#define CLR(x,y) (x&=(~(1<<y)))
#define SET(x,y) (x|=(1<<y))

byte get;
byte bitCount = 8;

void bitTransceive()
{
  get >>= 1;
  if (PIN2L)
  {
    get |= 128;
  }
  bitCount--;
}

void setup()
{
  CLR(DDRD,2); //pinMode 2 is input
  CLR(DDRD,3); //pinMode 3 is input
  Serial.begin(115200);
  attachInterrupt(1,bitTransceive,FALLING);
}

void loop()
{
  if (!bitCount){
    // Pull down clock line to make sure the calculator does not send while the atmega
    // is processing the incoming data.
    SET(DDRD,3);
    Serial.println(get);
    get = 0;
    bitCount = 8;
    CLR(DDRD,3);
    // Released the clockline.
  }
}

AXE on calc:

Code:

:.send
:lbl s
:While port=1
:0->port
:For(8)
:if r1^2
:1->port
:3->port
:else
:2->port
:2->port
:end
:0->port
:r1/2->r1
:end


The arduino can only receive the data sent from the calculator and it cannot send anything. It can reach speeds up to 2KB/sec because it uses interrupts. That is 32.000 Baud!
There is a bi-directional version I'm working on. It works, but I want to optimize it further and make it really stable before I release it. There is a sneak peek version on omnimaga: http://ourl.ca/18162/341428
Once the linking is reliable I plan on adding the SID emulator back in as well as some I/O operations the calculator can access such as digital to analog conversion and analog to digital conversion.

I put this project on a hold for a few days because I am working on a game that will eventually make use of the soundchip (but this game will not be dependent on the presence of the soundchip.) This is to give people a reason to build one of these things. I might write a simple chiptune tracker as well because I have to
is the sound still stored on the calc as its playing, though? i wonder how difficult it would be to send the song (up to a certain size) that would be played when a signal is sent to it.
There is not a lot of free ram available on the microcontroller. Just 2K and the emulator and communication software uses some of that. Songs can get large pretty quickly when you have a lot of swirls and effects in them. The calculator has a lot more memory compared to the microcontroller.
nah, i mean if you made the sound card with its own storage and all. even so, i think the practicality may be a bit difficult. but, essentially you could have the card do all the audio parsing, freeing up the z80 for more processes.

[edit]
Hah, i knew i put this down before!
http://www.cemetech.net/forum/viewtopic.php?t=8503&highlight=
but this was more a debate about whether it was feasible.
That would make it more expensive and more difficult to make and thus less attractive for people to build themselves. For those who want something more demanding could also send data via serial to the pc which makes mp3's play for example.
I just featured the soundchip on my website. There is some more background information on there, but no source code yet.
http://8times8.host56.com/
source and schematics released!
http://8times8.host56.com/?p=98
I am working on a minimalistic music editor that I am going to use for composing music for my Hero Core port.
16 step 3 channel loop. All triangle waves.
64 step 2 channel loop. All triangle waves. No use of ADSR volume envelope.

Edit: Some notes might sound a bit off. That's because I am using a frequency table made someone else and it's not very accurate. I will calculate a new one in excel.
That sounds great, keoni29! I must say that so far I don't hear anything terribly different from what a mod music player like MobileTunes could generate directly, so I look forward to what you can generate with different waveforms and dynamics. Percussion would be much easier for you, for example.
Indeed. Once I implement wavetables in my engine that is going to be a lot easier.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 2
» All times are GMT - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement