Author Topic: TI84+ soundchip - arduino SID emulator  (Read 35464 times)

0 Members and 1 Guest are viewing this topic.

Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: TI84+ soundchip - arduino SID emulator
« Reply #60 on: March 04, 2013, 06:41:43 pm »
Yeah I know, but these are sorta like the technical devvlog videos. When the project is done I put up  a quality video and a tutorial maybe.
If you like my work: why not give me an internet?








Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: TI84+ soundchip - arduino SID emulator
« Reply #61 on: March 04, 2013, 07:41:42 pm »
Keoni that is fantastic! You're gonna give Kerm M a run for his money! :D

Offline utz

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 161
  • Rating: +28/-0
    • View Profile
    • official hp - music, demos, and more
Re: TI84+ soundchip - arduino SID emulator
« Reply #62 on: March 05, 2013, 03:30:17 pm »
just remembered something else that may be of interest to you: http://sourceforge.net/projects/sid-wizard/ (.zip includes sources)

Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: TI84+ soundchip - arduino SID emulator
« Reply #63 on: March 05, 2013, 06:57:18 pm »
Does that run on a c64? Might give it a go and put it on a floppy using my xm cable.
If you like my work: why not give me an internet?








Offline utz

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 161
  • Rating: +28/-0
    • View Profile
    • official hp - music, demos, and more
Re: TI84+ soundchip - arduino SID emulator
« Reply #64 on: March 05, 2013, 07:27:31 pm »
Yup, runs on c64. I see that you are well prepared :p

Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: TI84+ soundchip - arduino SID emulator
« Reply #65 on: March 08, 2013, 07:42:05 am »
Lol why was this topic locked all of the sudden?

Ontopic: I have optimized the code on the arduino and I get some pretty fast transfers now. I don't need to include delay loops on the calculator side anymore. I even tried it with full mode, but quite a few bad bytes got trough. I can probably solve that by making a better connection with the arduino. I removed the SID emulation from the code just so I could work on the data transfer and optimizing this. I hope the external interrupts do not interfere with the library though. I just wanted to have the best possible transfer speeds, so others could use this code in their projects not having to worry about delays.

This code uses external interrupts on pin 3 (clock pin of the linkport is hooked up to this pin)
Code: [Select]
// 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.
  }
}
My goal was to make the code compacter, faster, more readable and understandable. I don't think there is a lot of room for improvement here!

Edit: This is only for receiving bytes from the calculator. I will write the sending code soon.
« Last Edit: March 08, 2013, 07:45:58 am by Keoni29 »
If you like my work: why not give me an internet?








Offline SpiroH

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 729
  • Rating: +153/-23
    • View Profile
Re: TI84+ soundchip - arduino SID emulator
« Reply #66 on: March 08, 2013, 09:03:23 am »
How does it sound? I could use a sound sample :-\
Very funny GIF. Good sense of humour!

Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: TI84+ soundchip - arduino SID emulator
« Reply #67 on: March 08, 2013, 12:06:19 pm »
It sounds like a SID. I only have the one song I played in the videos, so that's not too spectacular. When I get into modulation effects and pitchbends you can really hear its full potential.

Edit: I timed the data transfer. I sent 25600 bytes in 12 seconds which means the transfer rate is 2kB/s or 16kbit/s at the moment. Remember that this arduino is doing nothing other than receiving bytes and relaying them to the pc via serial. This is on normal speed. When I set it to full speed it just gives me a lot of errors (wrong numbers received.) It might be because of the way this code is written, but I am not sure. It might just be because of the high speed and capacitance in the wires. I never had to worry about the capacitance of the wires because the speed was relatively low.

16kbit/s translates to 32000 baud :3

Edit: I can now both read and write respectively from and to the atmega. It's not very smooth at the moment, so I'm gonna run some more tests before I release that.
« Last Edit: March 09, 2013, 08:57:05 am by Keoni29 »
If you like my work: why not give me an internet?








Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: TI84+ soundchip - arduino SID emulator
« Reply #68 on: March 12, 2013, 11:26:11 am »
I made the linkprotocol bi-directional (r/w)
Code: [Select]
#define _N 255

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

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

byte data;
byte bitCount = 8;

// State _N (255) : Do nothing and wait for incoming interrupt. Carry out other tasks in the mean time.
// State  0      : Slave receives  (Receive bytes from master)
// State  1      : Slave sends     (Send bytes to master)

void bitReceive()
{
  if(bitCount){
    data >>= 1;
    if (PIN2L)
    {
      data |= 128;
    }
    bitCount--;
  }
}

void bitSend()
{
  if(bitCount)
  {
    //Set portD
    DDRD |= 4;
    if(data & 1)
      PORTD &= 251;
    else
      PORTD |= 4;
      
    data >>= 1;
    bitCount--;
  }
}

void setup()
{
  CLR(DDRD,2); //pinMode 2 is input
  CLR(DDRD,3); //pinMode 3 is input
  attachInterrupt(1,bitReceive,FALLING);
}

void loop()
{
  byte state = _N, address, cell[128];
  
  while(1)
  {
    if (!bitCount){
      // Pull down clock line to make sure the calculator does not send while the atmega
      // is processing the incoming data.
      DDRD |= 8;
      switch (state)
      {
        case 255:
        {
          bitCount = 8;
          address = data >> 1;
          state = data & 1;
          // When the mode is Slave Transmit the function bitSend() is attached to the interrupt.
          if (state){
            data = cell[address];
            attachInterrupt(1,bitSend,FALLING);
          }
          break;
        }
        case 0:
        {        
          cell[address] = data;
          bitCount = 8;
          // Return to mode _N.
          state = _N;
          break;
        }
        case 1:
        {
          bitCount = 8;
          // Re-attach the bitReceive function to the external interrupt on pin 3 and
          // return to mode _N.
          attachInterrupt(1,bitReceive,FALLING);
          state = _N;
          break;
        }
      }
      // Release the clockline and data line.
      DDRD &= 243;
      PORTD &= 251;
    }
  }
}
This code compiles to less than 1k and it uses only 16 bytes of RAM + 128 for the data cells (used in this example so you can read and write from these cells from the calculator. These will get replaced by the SID registers).

Edit: When I put the content of the main loop in a function it compiles to over 2k O.O I have to do this in order to be able to make this into a library and make the code more readable, but it's not optimized at all.
« Last Edit: March 12, 2013, 12:12:18 pm by Keoni29 »
If you like my work: why not give me an internet?








Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: TI84+ soundchip - arduino SID emulator
« Reply #69 on: March 21, 2013, 12:40:15 pm »
I got it all working again after some tinkering with delays. Now I present to you: THE SOURCE AND SCHEMATICS!
http://8times8.host56.com/?p=98

Edit: You can fit a register write in the fastest interrupts. Stuff can get glitchy when you do though. Not sure why, though. At the lowest interrupt frequency you're always safe and there is no noticable framerate drop when you use an optimized music player.
« Last Edit: March 21, 2013, 05:02:09 pm by Keoni29 »
If you like my work: why not give me an internet?








Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: TI84+ soundchip - arduino SID emulator
« Reply #70 on: March 25, 2013, 11:24:45 am »
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.
« Last Edit: March 25, 2013, 11:28:32 am by Keoni29 »
If you like my work: why not give me an internet?








Offline Dapianokid

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 539
  • Rating: +46/-27
  • That one dude
    • View Profile
Re: TI84+ soundchip - arduino SID emulator
« Reply #71 on: March 28, 2013, 06:12:14 pm »
Is there a way to emulate this soundchip and somehow link together the emulated soundchip and a Wabbit? :)
Keep trying.

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: TI84+ soundchip - arduino SID emulator
« Reply #72 on: March 29, 2013, 04:46:08 am »
I don't think so.

Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: TI84+ soundchip - arduino SID emulator
« Reply #73 on: March 29, 2013, 05:03:45 am »
I was thinking of this too. It is definitely possible if you have the source of wabbit.
If you like my work: why not give me an internet?








Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: TI84+ soundchip - arduino SID emulator
« Reply #74 on: March 29, 2013, 08:27:11 am »
IDK if there's an arduino emu around. Though with TiLEM + libticables, you can probably do something. What I was saying is that wabbit can't do it w/o source mod and TiLEM would need an external program.