Showing posts with label ipod. Show all posts
Showing posts with label ipod. Show all posts

Saturday, March 08, 2008

atmega168 bug

I just discovered a bug that may have plagued some of you who've tried the same code and circuit I describe here. I've previously used an older arduino with an atmega8 chip, which works smoothly. I just got a newer arduino with an atmega168, and I was so excited that I didn't have to manually reset every time I wanted to upload new code. Sadly, when I plugged in my newly soldered remote, I found that every time I tried to toggle the play/pause, I also advanced the song and vice versa. When I look at the serial data the two arduinos are sending, it turns out they're different. The atmega168 adds a lot of other unwanted stuff, as below. I'm unsure why this is at the moment or how to fix it, but Tom Igoe has been consulted, so hopefully we'll have an answer soon.

Atmega168 Play/Pause
FA
FF
55
3
2
0
1
FA
3C01
F3
FF
55
3
2
0
8
F3
3E01

Atmega8 Play/Pause
FA
FF
55
3
2
0
1
FA
FFFF9C00

Saturday, February 23, 2008

The iPod Eagle Has Landed

Big news in iPod land -- the eagle has landed (i.e. I've delivered the iPod and assistive remote to Hannah). I got to spend some time with Hannah and her family last week when I went to demonstrate the remote, and from what I saw, it looks like the project is a big success. Both Hannah and her younger sister were mesmerized by the magic of controlling the music with a big green switch. Hannah's parents are going to keep me informed about how it's going and what improvements I should make for the next version. I have some pictures, but I haven't asked for permission to publish them yet, so no pictures of Hannah right now - maybe later. However, I do have some pictures of the spiffy cardboard housing created by the Adaptive Design Association. The housing was designed by intern Lulu Chin and full-time staff member Lillie ____ (I don't know Lillie's last name, but I'll find out!)

On the technical front, I've had a few requests for more specifics regarding my circuit using the arduino, so I finally got around to drawing the schematic. Note that I don't include the detailed iPod remote schematic - just that the three important lines are power, ground, and AUD (as specified on the remotes I hacked). For Hannah, we just used two switches - one for play/pause and one to advance the song. To allow for the possibility of using different switches at a later time, I used two mono-jacks in my circuit instead of the actual switches.



In addition, for this particular protoype, I needed my connections to be semi-permanent - meaning that all the wires need to be stable and secure in the arduino (and everywhere), as this is going to be used by a five-year-old. I don't want to be trekking uptown every couple of weeks to reconnect power or ground. But on the other hand, the functions that Hannah uses may change over time, so at some point I may need to remove and reprogram the arduino. I was about to get out my handy hot glue gun for the task when Tom Igoe gave me one of his Arduino Proto Shields -- once again, Tom saves the day. With this handy board, I can solder my wires to the shield and the pop the shield into the arduino with some header pins - good to go.

Saturday, November 10, 2007

ipod + big green switch

Tonight I was able to connect the big green switch Tracy lent me to a mono-jack and use it to control my ipod. The whole process was amazingly simple. I just replaced one of the switches I was already using with the female end of the mono-jack, plugged in the switch, and watched it work. Unfortunately, neither the ipod that Tracy had nor the one that Alex found will work with the remote and tx/rx protocol I'm currently using. I'm hoping that I can find someone who has a new ipod nano that I can use for testing purposes and then either a new ipod nano or the older version (that I'm currently using) can be purchased for the project. As soon as I know which version (and thus which size) ipod I'll be using, I can start building an enclosure for the whole thing. I'm still unsure what that will look like, but it's going to be pretty minimal - just needs to house an arduino, two mono-jacks, a small piece of perf board, and the remote cord.

Sunday, September 30, 2007

ipod + arduino = love

Last spring, I was able to control my ipod using key presses via Processing (see that post). This fall, I wanted to move away from the laptop and use external switches/sensors and an Arduino microcontroller to facilitate the building of a multi-switch music station. The code required some tweaks to work with Arduino, but it's very similar to the previously posted code. Note that you need to set the serial baud rate to 19200; if you use 9600, nothing will happen.

//code that controls basic (play/pause, next, previous, volume up, and volume down) functions of ipod
//rosie daniel

int hits = 0;

int buttonStates[]={0,0,LOW,LOW,LOW,LOW,LOW};
int buttonPrevious[]={0,0,LOW,LOW,LOW,LOW,LOW};
int buttonRelease[] = {0xFF, 0x55, 0x03, 0x02, 0x00, 0x00,0xFB};

int commands[]={0,0,0x01,0x08,0x10,0x02,0x04};

int checkSum(int len, int mode, int command1, int command2, int parameter) {
int checksum = 0x100 - ((len + mode + command1 + command2+ parameter) & 0xFF);
return checksum;
}

void setup() {
Serial.begin(19200);
pinMode(2, INPUT);
pinMode(3, INPUT);
pinMode(4, INPUT);
pinMode(5, INPUT);
pinMode(6, INPUT);
}

void loop() {

for (int c=2; c<7; c++)
{
buttonStates[c] = digitalRead(c);


buttonStates[c] = digitalRead(c);

if (buttonStates[c] != buttonPrevious[c] ) {
delay(5); //helps avoid a 'double' press - check a second time to see if the button is still pressed after a delay
buttonStates[c] = digitalRead(c);
if (buttonStates[c] == HIGH) {
sendCommand(commands[c]);
//Serial.print(hits);
hits++;
}
buttonPrevious[c] = buttonStates[c];
}

}

}

void sendCommand(int cmd) {
int cs = checkSum(0x03, 0x02, 0x00, cmd, 0);
Serial.println(cs,HEX);



int bytes[] = {0xFF, 0x55, 0x03, 0x02, 0x00, cmd, cs};
for (int i = 0; i < 8; i++) {
Serial.print(bytes[i], BYTE);

}

for (int i = 0; i < 8; i++) {
Serial.print(buttonRelease[i],BYTE);
}

}

Saturday, September 15, 2007

Hannah's ipod project

This semester, I'm going to continue my ipod project with a new twist: I'll be working on the project as an internship with the Adaptive Design Association. I'm going to be making a new version of a muti-switch music station originally designed by Alex Trusedell in the 80's. Her version used three cassette players to give musical feedback to users for successful completion of tasks (usually activating various switches that improve fine motor skills). While cassette players were functional, there were several problems with them: they were heavy and bulky; they could play a limited amount of music, depending on the length of the cassette tapes; and they required that someone eject and flip the tape whenever it came to the end of one side. Although tape players can now automatically flip the tape without a manual ejection, they still add a tremendous amount of weight and bulk to the station. The version I'm going to be working on will replace the old cassette players with an ipod, which will reduce the size and make the station much more portable, as well as increase the size of the music library available and add more music control functions.

Ideally, the new music station will be reproduced and customized for a variety of children and needs, but to begin, I'm going to focus on creating a music station especially for Hannah (see Hannah's story). In the next week, I hope to meet with Hannah's occupational therapist and possibly her parents to discuss her individual needs and get a better idea of what kind of switches/sensors I'll want to include in the station. I'm also hoping to visit Hannah's class and meet Hannah herself.

On the ipod technical front, I've started to translate my Processing code to Arduino so that an Aruduino microcontroller can replace a laptop in the system. Over the next week, I plan to have that code completed as an Arduino library (which I'll release on this site), at which point I'll begin using physical switches to activate the functions as opposed to keypresses.

Thursday, April 19, 2007

I have iPod Mojo

I've been working on this project since October, first for my pcomp final project and then all semester for Project Development Studio. The difficult thing is that, although I've learned a lot along the way, I've really had nothing to show for my efforts. The ipod never responded to any commands I sent it, so I had no way of knowing if I was making progress or not. Until now.

Friday night I figured out one problem -- I was trying to send the serial data over the wrong wire. Then earlier this week, I was reading online somewhere that you can't just send a command to the ipod without also sending it a "button release" command afterward. So today in Tom's office, we sent the right code over the right wire, and it worked!!! I was hopping around Tom's office squealing, "Oh my god!!!" Seven months of work finally came to fruition today. I am so relieved and excited. Now I'll actually have something to show for my final project in Project Development Studio next Thursday and something to continue working with if I want. Tom helped me tremendously and most of the information I needed was online, but I actually solved this problem, even though it took seven months. I feel like this is my first real ITP accomplishment, and it feels damn good. I did something hard and didn't give up on it even though I really wanted to. So overall, today was really good for my sense of self-efficacy and mood.

Over the next week, I will be undertaking the task of documenting everything I did over the last seven months in an effort to provide a comprehensive resource for people interested in hacking an ipod remote.

Here's the code for Processing.

import processing.serial.*;

Serial ipod;
int buttonRelease[] = {
0xFF, 0x55, 0x03, 0x02, 0x00, 0x00,0xFB };

void setup() {
String[] serialPorts = Serial.list();
println(serialPorts);

ipod = new Serial(this, serialPorts[0], 19200);
}

void draw() {
background(0);
}

void keyReleased() {

switch (key) {
case 'f': // forward
sendCommand(0x08);
break;
case 'p': // play/pause
sendCommand(0x01);
break;
case 'b': // backward
sendCommand(0x10);
break;
case 'u': // vol up
sendCommand(0x02);
break;
case 'd': // vol down
sendCommand(0x04);
break;
case 'n': // next album
sendCommand(0x20);
break;
case 'v': // previous album
sendCommand(0x40);
break;
case 's': // next album
sendCommand(0x80);
break;
}
}


int checkSum(int len, int mode, int command1, int command2, int
parameter) {
int checksum = 0x100 - ((len + mode + command1 + command2+parameter) & 0xFF);
return checksum;
}
void serialEvent(Serial ipod) {
char inByte = char(ipod.read());
print(inByte);
}



void sendCommand(int cmd) {
int cs = checkSum(0x03, 0x02, 0x00, cmd, 0);
println(hex(cs));


int bytes[] = {
0xFF, 0x55, 0x03, 0x02, 0x00, cmd, cs };
for (int i = 0; i < bytes.length; i++) {
ipod.write(bytes[i]);
}
for (int i = 0; i < buttonRelease.length; i++) {
ipod.write(buttonRelease[i]);
}
}

Friday, April 13, 2007

ipod AUD

Finally learned something useful about the ipod remote. The three wires I need are power, ground, and AUD. I removed L, R, and CON6, and the remote still worked beautifully. Previously I thought AUD would refer to "audio" and didn't expect it to impact the transmission of serial data. So for the past couple of weeks, I've been trying to send data over the CON6 line -- no wonder it didn't work.

Friday, March 23, 2007

iPod Project - long time, no do

So I haven't done jack shit on the ipod project recently and MUST get into gear - have to present in Project Development Studio next week. So tonight I ordered a breakout board for the ipod dock connector from ridax. I also found an article about safety flaws in the ipod/Nike shoe system that might provide useful information.

Update: While I'm not going to abandon the goal of sending serial data to an ipod, I'm going to add a simultaneous plan of attach - back to the remote. I'm going to try to combine this project with my Assistive Technology project - the mouth piano.

Wednesday, November 29, 2006

iPod Glove

The Idea




Background Information


These images and information are taken from Maushammer's Apple iPod Remote Control Protocol site.

We've also relied on a previous ITP project, iChair.




Sensor Testing




Wiring and Soldering


Initially, we removed the green (data) and yellow (ground) wires from the remote and connected them to Arduino. Soon we realized that we couldn't send information to the remote - it's a one-way deal.

So the next step was to cut the wires and solder connections to them.




Hatti, Seamstress in Residence, Soldering Goddess





Problems in the Land of Solder

In Hatti's words: "This whole week has involved soldering and resoldering. Turns out, hacking into commercial devices are terribly tricky. At first, we tried just hot glue-ing straight into the remote because there is some type of film on the surface connectors that repells the solder. That is to say, once you have completed the (perfect) solder, it pops right off of the surface. Using only the hot glue worked…THE DAY OF. Overnight, however, the glue, I’m assuming, had seeped under the wires, thus disrupting the continuity and disabling the switch."
"It seemed as though I was trapped in a cycle of 1. solder for 8 hours, 2.have the ipod working 3.leave it overnight, 4.next day = not working... Finally, it occured to me to use fabric duct tape to cover the first solder (using an exacto knife to slide it perfectly over the boundaries of the two connectors) and then solder the second, and then immediately secure the positions with hot glue."


Goodbye Arduino, Hello PIC

After days of trying to send serial data to the ipod via Arduino with no success, Tom suggested we try to use the PIC chip instead. At this point, Hatti spent most of her time soldering and resoldering and sewing the FSRs and the remote, and I threw myself into the world of PIC.



The Next Phase


Still no luck using the PIC chip, so we've order a female connector for the iPod from Sparkfun so we can see what serial data the iPod spits out. Should be here around the 15th....just after finals are done. Perfect.