yashsingh1/xdaforums huggingface dataset:
[Samsung Galaxy Nexus] pchuk815:
You are correct.

I've been lurking on this thread for a while. I'm a civil engineer by trade but I've always had electronics and programming as a hobby. Arduino is new to me so forgive me if this won't work but can you do:

delayMicroseconds(10000)
delayMicroseconds(10000)
delayMicroseconds(10000)
delayMicroseconds(10000)
delayMicroseconds(10000)
delayMicroseconds(10000)
delayMicroseconds(10000)
delayMicroseconds(10000)
delayMicroseconds(10000)
delayMicroseconds(10000)

It's definitely not the cleanest code but it would (I think) get you the desired effect.
[Samsung Galaxy Nexus] silverchris:
you could use multiple delays in series, or write your own delay using a loop... timing looks like it needs to be within 20milliseconds of what the phone expects.

I would try to help more with the code, but I have never played with an arduino, or a arduino sketch
[Samsung Galaxy Nexus] silverchris:
or

int i;
for (i = 0; i < 10; i++){
delayMicroseconds(10000);
}
[Samsung Galaxy Nexus] pchuk815:
That's definitely a much cleaner version.

It's been a while since I've coded anything...(even then, I didn't care if looked nice, as long as it worked). Like I said, I'm a civil engineer, not an electrical engineer or programmer... ;-)
[Samsung Galaxy Nexus] silverchris:
Ya, that regulator is more then enough for this job.
[Samsung Galaxy Nexus] aggie6600:
I'm a civil engineer as well. I'm the geek that writes scripts for work as a hobby. Drives my wife crazy when I stay up til 3 am writing a Python script that will save me 5 minutes in ArcGIS. My code is definetly a mess, but it works (most of the time).

I used to dabble in electronics in college, but that has been 10 years and I don't remember much. I 'might' be able to get a 555 timer to flash an LED these days.
[Samsung Galaxy Nexus] Matridom:
Tossed the new delay into a function accepting the time given, then added it to the main sketch. Maybe someone else can re-write it a little so that all the events happen on the same pin.

Here it is so far:

// Arduino sketch for an aTtiny85

Void delayCount(int x)
{
int i;
for (i = 0; i < (10 * x); i++)
{
delayMicroseconds(10000);
}
}

void wakeResponce()
{
detachInterrupt(0) // Turn Intterupt off
digitalWrite(1, HIGH);
delayCount(50); //Dock Type Delay, 50mS for desk, 100mS for car
digitalWrite(1, LOW);
delayCount(50); //Charge type delay, 50mS for High current, 100mS for low
digitalWrite(1, HIGH);
delayCount(100); //Audio Connection delay, 50mS for connected, 100mS for disconnected
digitalWrite(1, LOW);
delayCount(600);
attachInterrupt(0, wakeResponce, FALLING); // Turn intterupt back on
}

void setup()
{
pinMode(1, OUTPUT); // SPIDIF/Phone pin / hardware pin 6
pinMode(0, OUTPUT); // Led pin / hardware pin 5
attachInterrupt(0, wakeResponce, FALLING); // innterupt "o" is on digital pin 2 hardware pin 7
}

void loop()
{
while(1)
{
// Loop forever and blink led connected to pin0
count++;
if(count < 200000){
digitalWrite(0, HIGH);
}
if(count > 200000){
digitalWrite(0, LOW);
}
if(count == 400000){
count = 0;
}
}
}

Look good?
[Samsung Galaxy Nexus] silverchris:
It looks good. I might be able to take a look into how pin assignments work on the arduino later, and help you adjust it
[Samsung Galaxy Nexus] Matridom:
my supplies came in today, so i spent the past few hours mucking around. Needless to say, it's not working. I'm having trouble getting the contacts onto the pogo pins on the phone and stay contacted, so i'm going to address that challenge properly tomorrow, this might be the cause of my problems, but i'm not sure.

I'm using an atTiny85v, stepping down the voltage to 1.8 volts, so it should all be compatible. I unfortunately don't have access to an oscilloscope

I misread the decimal point in the micro/mili conversion of the seconds and cleaned up the blink code.

here is how it stands:

void delayCount(int x)
{
int i;
for (i = 0; i < x; i++)
{
delayMicroseconds(1000);
}
}

void wakeResponce()
{
detachInterrupt(0); // Turn Intterupt off
digitalWrite(1, HIGH);
delayCount(50); //Dock Type Delay, 50mS for desk, 100mS for car
digitalWrite(1, LOW);
delayCount(50); //Charge type delay, 50mS for High current, 100mS for low
digitalWrite(1, HIGH);
delayCount(100); //Audio Connection delay, 50mS for connected, 100mS for disconnected
digitalWrite(1, LOW);
delayCount(600);
attachInterrupt(0, wakeResponce, FALLING); // Turn intterupt back on
}

void setup()
{
pinMode(1, OUTPUT); // SPIDIF/Phone pin / hardware pin 6
pinMode(0, OUTPUT); //LED verification
attachInterrupt(0, wakeResponce, FALLING); // innterupt "0" is on hardware pin 7
}

void loop()
{
digitalWrite(0, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(0, LOW); // set the LED off
delay(1000); // wait for a second
}
[Samsung Galaxy Nexus] silverchris:
I had a similar problem with connecting the phone to test. I ended up pulling the rear case off, and using some clips onto the contacts on the board in the phone.

Are you getting a pulse on the led pin?
[Samsung Galaxy Nexus] Matridom:
Yup, I'll look at it again in the morning, it's well past when I'm normally in bed

Sent from my Galaxy Nexus
[Samsung Galaxy Nexus] Matridom:
This so far looks like the most accurate, still not working. The Blinking LED "Pauses" when i connect the phone, so i know it's reading and activating the interrupt.

When next I have time to tinker, I'm going to test the writing to the pin, I'll temporarly replace the wakeResponce routine with a test LED. Otherwise, the only thing i can see is that the whole program needs to be re-written to work off one pin. I'll do some research into that today.

void wakeResponce()
{
detachInterrupt(0); // Turn of the Intterupt
digitalWrite(1, HIGH);
delayMicroseconds(10000);
delayMicroseconds(10000);
delayMicroseconds(10000);
delayMicroseconds(10000);
delayMicroseconds(10000);
//delayCount(50); //Dock Type Delay, 50mS for desk, 100mS for car
digitalWrite(1, LOW);
delayMicroseconds(10000);
delayMicroseconds(10000);
delayMicroseconds(10000);
delayMicroseconds(10000);
delayMicroseconds(10000);
//delayCount(50); //Charge type delay, 50mS for High current, 100mS for low
digitalWrite(1, HIGH);
delayMicroseconds(10000);
delayMicroseconds(10000);
delayMicroseconds(10000);
delayMicroseconds(10000);
delayMicroseconds(10000);
delayMicroseconds(10000);
delayMicroseconds(10000);
delayMicroseconds(10000);
delayMicroseconds(10000);
delayMicroseconds(10000);
//delayCount(100); //Audio Connection delay, 50mS for connected, 100mS for disconnected
digitalWrite(1, LOW);
delayMicroseconds(10000);
delayMicroseconds(10000);
delayMicroseconds(10000);
delayMicroseconds(10000);
delayMicroseconds(10000);
delayMicroseconds(10000);
delayMicroseconds(10000);
delayMicroseconds(10000);
delayMicroseconds(10000);
delayMicroseconds(10000);
delayMicroseconds(10000);
delayMicroseconds(10000);
delayMicroseconds(10000);
delayMicroseconds(10000);
delayMicroseconds(10000);
delayMicroseconds(10000);
delayMicroseconds(10000);
delayMicroseconds(10000);
delayMicroseconds(10000);
delayMicroseconds(10000);
//delayCount(600);
attachInterrupt(0, wakeResponce, FALLING); // Turn intterupt back on
}

void setup()
{
pinMode(1, OUTPUT); // SPIDIF/Phone pin / hardware pin 6
pinMode(0, OUTPUT); //LED verification
attachInterrupt(0, wakeResponce, FALLING); // innterupt "0" is on hardware pin 7
}

void loop()
{
digitalWrite(0, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(0, LOW); // set the LED off
delay(1000); // wait for a second
}

Edit: What seems odd to me, is the "pause" lasts longer than a second, with all the delays, we should be hitting no more than 300ms MAX. So something else is off. If it's any help, I'm running the chip at 1 Mhz

Edit 2: I'm wondering if the chip running a 1Mhz is throwing off all the timings. In effect, 1 cycle = 1 Micro second. I've found this example where they are using the ms from start of program to cause and LED to blink, I'm going to try and recycle the code to get proper timing.
[Samsung Galaxy Nexus] Matridom:
Rather then spam the raw code into the posts, I'm going to start attaching a file containing the arduino code.

a flurry of reprogramming and I ended up with this.

I removed all delay functions and set everything up to work off the internal clock of the chip. This I believe will give the most accurate times for the signalling. I've also moved the majority of the functionality outside of the interrupt, hopefully making it more accurate. the LED flash rate got tweaked so that when the chip is in the settings mode (interfacing with the phone) it should create a very quick flash on the LED that should be apparent. All programmable variables got moved to the top, to make editing the sketch easier for people who don't understand the code.

I'll test this out tonight when I get back in front of my testing equipment.

Edit: found a logic problem and fixed.
[Samsung Galaxy Nexus] Matridom:
Success!!!!!!

It's working!!!

Proof plus sketches attached

Wiring diagram will go up tomorrow once i have a chance to label all the parts.
[Samsung Galaxy Nexus] aggie6600:
That is awesome looking forward to the wiring diagram
[Samsung Galaxy Nexus] soundwire:
That's great news. I'm glad you got it working I haven't had much time to work on it lately.
[Samsung Galaxy Nexus] Matridom:
Wiring diagram is now up. The diode and resistor are optional and are only really used to make sure the circuit is working.

The only improvements I can see is to add code to listen specificly for the signalling pulse from the phone (Rather then any pulse). Then redirect the SPDIF output to a different pin that could be used to attach an SPDIF decoder and audio jack. Code would also need to be added to determine when the phone get's disconnected so that the program can reset itself.

For me however, enough has been done for my needs, I don't need audio as i stream through bluetooth, so my next stage is moding my car dock and case.

I'll be creating over the next couple of weeks a full guide on how to make this mod from start to finish in a new thread. I'll also be covering the modification of my case (otterbox commuter) and Dock station (SlipGrip).
[Samsung Galaxy Nexus] soundwire:
Here a small parts list with an eagle schematic Now i need to find a case/dock to build it into and source the pogo pins.

MCP1702-1802E/TO 1.8v Voltage Regulator 0.52$- mouser

ATTINY85V-10PU Running at 1Mhz 1.62$ - mouser

2x 1uF ceramic caps (optional)

Led (optional)
[Samsung Galaxy Nexus] Matridom:
Much cleaner then mine. Do you mind if I use it in my upcoming diy thread documenting all the stages of modding my dock?

Sent from my Galaxy Nexus
[Samsung Galaxy Nexus] soundwire:
Not at all...
[Samsung Galaxy Nexus] BooDaddy:
Could you guys post what I would need to buy in order to start tinkering with this as well? I am wanting to learn electronics, and arduino, and this looks like an awesome way to begin :)

I know a little already, but want to dive in.

My goal is to build an IC that includes a switch to control which mode the dock is in (Car or Desk) and a switch for the charge rates.

I'd also like to tinker with using the spdif out to connect to a DAC and then convert that to a line level out to plug into my cars AUX jack :)

I have a metric crap ton of ideas I would like to tinker with, and reading this whole thread has me exicited to work on it for fun!

What components will I need?
[Samsung Galaxy Nexus] Matridom:
I have a list prepared for a new thread, so I happen to have everything handy.

BreadBoard	- http://www.digikey.ca/scripts/DkSearch/dksus.dll?vendor=0&keywords=438-1045-ND

Capacitor 1µF	- http://www.digikey.ca/product-detail/en/ECA-1HHG0R1/P5559-ND/245158

Capacitor 10µF	- http://www.digikey.ca/product-detail/en/ECA-1HM100I/P10425TB-ND/268510

arduino uno	- http://www.digikey.ca/product-detail/en/A000066/1050-1024-ND/2784006

atTiny85v	- http://www.digikey.ca/scripts/DkSea...go&lang=en&keywords=ATTINY85V-10PU-ND&x=0&y=0

Voltage Regulator	- http://www.digikey.ca/scripts/DkSearch/dksus.dll?vendor=0&keywords=MCP1825S-1802E/AB-ND

The ardiuno code as is will not allow the spdif output to function at all, I have a new draft of code I'm working on that should allow for the decoding of spdif for those who want to tinker on that aspect. If all goes well, I should have that code posted up by end of week.

The extensive thread i'm going to start will have step by step instructions on getting everything set-up. It will also point out areas where I had some problems getting things going. If you are patient, might be an idea to wait my follow-up thread.
[Samsung Galaxy Nexus] BooDaddy:
Matridom,

Thanks for the links! I will go ahead and get this stuff ordered. Hopefully by the time it arrives you will have your how-to thread going.

Do you think it will be possible to get the atTiny85v to support switching dock and charge modes with a toggle switch?
[Samsung Galaxy Nexus] Matridom:
The new thread well be a few weeks, I'll be out of town for a little while. As for the switches, I don't see any issues incorporating them, I'll let you figure out that part though ;)

Sent from my Galaxy Nexus
[Samsung Galaxy Nexus] quentin0:
Anyone wanna make me a pogo dock for the vzw LTE version? I'll pay ya for the parts + labor + shipping :)
[Samsung Galaxy Nexus] BooDaddy:
Matridom, I have found the parts cheaper on different websites. I will get all the links together and post them so you can use them in your thread. Never hurts to save a few bucks :)
[Samsung Galaxy Nexus] pchuk815:
You guys are awesome. This is my first project when I get home from my honeymoon in a few weeks.

Now that you have the electronics and code working, what are you guys planning on using for the physical dock?
[Samsung Galaxy Nexus] BooDaddy:
OK. So I found these on Amazon, so for folks with Prime you can get this stuff shipped free, or very very cheap for overnight:

Large breadboard: http://amzn.to/J6nKMt --- $8.00

1UF Capacitor: http://amzn.to/J6nOMp -- $.086

10UF Capacitor: http://amzn.to/JYXDDg --- $1.98

For the Arduino theres a few options. The first one, includes several accesories that we need such as a breadboard, jumpers and holders. Its a bit more expenisve at $37 but for a tinkerer it might just be the thing! This is the one I am buying today.

Here is a kit that has the Arduino UNO REV 3, plus a breadboard, jumper wires, Arduino holder, and a USB programming cable. This pretty much has the bulk of what we would need:

http://amzn.to/IVU4Nz --> $36.99

If you just need the Arduino UNO REV 3 (without all the other bits of kit) here it is much cheaper (This is still the REV 3 of the board):

http://amzn.to/JYVlUI --- $22.45

Here is a normal Arduino UNO (Non REV 3):

http://amzn.to/Kq6Vww --- $20.75
[Samsung Galaxy Nexus] Matridom:
Thank you for those links, however, do keep in mind, i'm in Canada and those where Canadian dollars, Amazon for example does not have an arduino available in it's Canadian version. The links are more for reference so people know what to get and, like you, find better pricing elsewhere. Me for example, everything was cheaper at the local electronics store.

I'm still working on some kinks to the new code. I'm trying to make the IC go "quiet" after it's signalled the phone and to only wake up on receiving the signalling pulse. This should allow the spdif to be tapped into and decoded. right now, it won't go quiet......
[Samsung Galaxy Nexus] BooDaddy:
Ah, that didnt register with me that you were Canadian.

Oh well, hope those links will be of use to Americans wanting to buy the materials.

I'm a Prime member so I use Amazon wherever possbile.
[Samsung Galaxy Nexus] ellesshoo:
for something that could be used as a car dock I would shy away from using a breadboard where some random jumper could pop out and you have to deal with a rats nest of wires (albeit a small rats nest in this case). Not sure if you have it as a part just for bench top prototyping or if you planned on running it on a breadboard though.

It's easy enough to make a PCB that would look cleaner, be smaller, and more rugged. Attached is an eagle board I made from the schematic posted earlier. Also attached two images for those without Eagle software, the B&W image could be made into a PCB as is. I didn't spend much time finding the best possible layout so you may wish to play around with it. Good luck.

PS: If this goes into getting SPDIF to work, a PCB might be even more advantageous.
[Samsung Galaxy Nexus] Matridom:
Thanx, the breadboard is mainly to program the ic before soldering it into the final project

Sent from my Galaxy Nexus
[Samsung Galaxy Nexus] ellesshoo:
Also, if you're still looking for a physical mounting solution I posted a topic about modding a Verizon dock with pogo pins (charging) a few months back. It's still in service and fits my GSM nexus like a glove.

http://xdaforums.com/showthread.php?t=1493797
[Samsung Galaxy Nexus] patrickl:
The official Samsung car dock is out though. Not much point in modding pogo pins into a version of the same dock (which is missing pogo pins) anymore.
[Samsung Galaxy Nexus] BooDaddy:
Its not out in the US is it? I haven't seen it anywhere. Its also very expensive.

Plus, with the mods were are doing, you could program your own car dock that would double as a desk dock with selectable charging rates, docking modes (car or desk), and audio outputs.
[Samsung Galaxy Nexus] Matridom:
No one has figured out the audio modes yet. If you look at the current code, the IC just signals out on any pulse it receives, this would drown out any audio signal trying to be sent. On top of that, someone needs to do the work of connecting a DAC and making it work properly. Needless to say, there is a LOT of work left to do.

The only reason I'm working on cleaning up the current code to only listen for the signal pulse is my need for elegance. I'm offended by the need to respond to each pulse. I have zero intention of working on the audio aspect as i stream through bluetooth.

Finally, this type of solution is only cheaper if you do the work yourself, hence the appeal to most of us. As soon you as you start paying for labor the price will go up very quickly and most people won't put the same amount of effort into work for someone else then in work they do for themselves.

I'm with BooDaddy on this one, if you are unwilling to get your hands dirty, buy the official dock.
[Samsung Galaxy Nexus] Matridom:
Code update

Getting the signalling to work "just right" is kicking my ass. For some reason, every time an interrupt runs, it re-runs Void setup(), this means that I can't change the interrupt mid application to track the pulse length. It also explains why the circuit, when it goes "on" stays on. I tried using attachinterrupt with the "CHANGING" method, but i'm concerned about getting out of sync and screwing everything up, besides, when i wrote test code to use "change" it did not work as expected, i've also read references (though nothing i could confirm) that the atTiny only supports rising/falling on an interrupt.

I found this thread relating to a similar problem, they solved it by using an add-on library.

So with all of these issues, I'm not sure if i should sludge it out with the interrupts or take a new approach. Thoughts?

On a side note, since i'm running the chip at 1 Mhz, microDelay is disabled.

While i wait for some feedback, I'm going to try an whole new approach and see how that works.
[Samsung Galaxy Nexus] pchuk815:
That's actually what I was planning on doing for the car dock.

Anyone have an idea for a desk dock? I just think the car dock on my desk might be too cumbersome.
[Samsung Galaxy Nexus] soundwire:
That's odd that void setup is running after every interrupt, only thing I can think of is the reset pin may need a pull up resistor to keep it high...or perhaps when it is sending the pulse to the phone the voltage is dropping below 1.8v and causes a reset
[Samsung Galaxy Nexus] Matridom:
Getting ride of the interrupts did the trick, here is code that works for me, though i had a few hiccups. Please, someone else test this code to make sure it works!

This version leaves the signalling pin "low" at all times except when it receives a pulse from the phone, this means that someone should be able to hook into it and get the DAC decoded (someone else's project).

My soldering is not the cleanest, but it does the job, this one is going into a deskdock. I'm going to make a new soldering project for the car dock as it needs to be compact. It's going to be featured in my a-z mod thread getting my otterbox powered to a slipgrip car mount.

Arduino sketch and photo proof attached.

Long weekend is coming, I'm taking the week off, see you guys on the flip side, I'll keep up to date on the thread, just don't expect any work from me once Friday hits.
[Samsung Galaxy Nexus] ellesshoo:
When you say a DAC hooking into this are talking in terms of your code or hardware? Where would one hook in hardware wise? I'd like to know so I can leave some connection point on the proto board. I'm assuming a DAC would require +V and GND, but are there certain pins on the IC that you would anticipate the need to run connections to a DAC?
[Samsung Galaxy Nexus] Matridom:
I've not looked into the DAC at all, so I do not know what requirements it has. I assumed it would need a clean signal from the phone to process the audio correctly, so I designed the arduino code to leave that signal quiet as much as possible, this will allow the DAC to get clean audio from the phone. Once the signalling is complete, the IC goes quiet and will not interact with the audio signal.

So the short answer, you will need to connect the DAC to the wire connecting the middle pogo pin to the pins 6/7 on the IC. as for any other pins? I really don't know. VCC/Ground sure.. but at what voltage? Does the audio feed need to be stepped up to 5vcc or is there a DAC that runs at 1.8v? I've seen some references that the DAC needs a reset to know when to start expecting a feed..

Too many unknowns around the DAC for me to answer.

I found this article that might be useful.

http://sound.westhost.com/project85.htm

If you want it to be flexible, Create header block where 5vcc, 1.8vcc, ground, spdif/out, and all unused pins of the IC can be found. This way, a daughter board can be added and easily connected to an existing build.

The code also forgoes all use of the "ledPin" so the LED/resitor can be removed from the diagrams. My code no longer makes it flash at all.
[Samsung Galaxy Nexus] zuberio:
Very, very cool. I know of a bunch of CDMA GNex owners who are very interested in this. I'll be sure to post a link to this thread for them to come shower you with praise ... and beg you for help (sorry about the 'beg you for help' thing in advance).

I'm hoping you can confirm something for me and probably a bunch of other people who know as little as I do about Arduino and ATtiny programming.

Basically, the Arduino Uno and the ATtiny85 are both microprocessors. And while the Arduino Uno is more than capable of doing this whole pulse response thing with the GNex - it's overkill. What you've done instead is use the Arduino Uno as a "bridge" to program the ATtiny85 for the pulse response instead.

Thus, the ATtiny does the pulse response thing, takes less power, costs less, and is smaller than the Arduino Uno. But you still need the Arduino Uno to program it ... it just makes life easier.

I've come up with the above assumption based upon this nice blog/video from makezine and this informative page from MIT Media Lab's High-Low Tech Group.

So ... am I right?
[Samsung Galaxy Nexus] soundwire:
Yes, that's correct.

Also the signal needs to be 1.8v and the lowest the uno can run is 3.3v so with the uno you would need convert the voltage down. Using the ATtiny85 you can run it as low as 1.8v and eliminate that conversion.