yashsingh1/xdaforums huggingface dataset:
[Samsung Galaxy Nexus] silverchris:
Schematic(Didn't bother with the power sections...)

The transistor provides the level shifting from 1.8V to 5V, but also inverts the signal, so keep that in mind when reading the code.

My proto typed board:

#include <p30f3014.h>
#include <InCap.h>
//config
_FOSC(CSW_FSCM_OFF & FRC);
_FWDT(WDT_OFF); //Turn off the Watch-Dog Timer.
_FBORPOR(MCLR_DIS & PWRT_OFF); //Enable MCLR reset pin and turn off the
//power-up timers.
_FGS(CODE_PROT_OFF); //Disable Code Protection

#define FOSC 7370000LL // clock-frequecy in Hz with suffix LL (64-bit-long), eg. 32000000LL for 32MHz
#define FCY (FOSC/4) // MCU is running at FCY MIPS
#define delay_us(x) __delay32(((x*FCY)/1000000L)) // delays x us
#define delay_ms(x) __delay32(((x*FCY)/1000L)) // delays x ms
#define __DELAY_H 1
#include <libpic30.h>

void __attribute__((__interrupt__)) _IC1Interrupt(void)

{
IFS0bits.IC1IF = 0;
CloseCapture1();
delay_ms(2);
PORTDbits.RD2 = 1;
delay_ms(50); //Dock Type Delay, 50mS for desk, 100mS for car
PORTDbits.RD2 = 0;
delay_ms(50); //Charge type delay, 50mS for High current, 100mS for low
PORTDbits.RD2 = 1;
delay_ms(100); //Audio Connection delay, 50mS for connected, 100mS for disconnected
PORTDbits.RD2 = 0;
delay_ms(600);
ConfigIntCapture1(IC_INT_PRIOR_1 & IC_INT_ON);
T3CON = 0x8000;
OpenCapture1(IC_IDLE_STOP & IC_TIMER3_SRC & IC_INT_1CAPTURE & IC_EVERY_RISE_EDGE);
Nop();
}

//main loop
int main(void)
{
/* Enable Timer1 Interrupt and Priority to '1' */
ConfigIntCapture1(IC_INT_PRIOR_1 & IC_INT_ON);
T3CON = 0x8000; /* Timer 3 On */

/* Configure the InputCapture in stop in idle mode, Timer
3 as source, interrupt on capture 1, I/C on every fall
edge */
OpenCapture1(IC_IDLE_STOP & IC_TIMER3_SRC & IC_INT_1CAPTURE & IC_EVERY_RISE_EDGE);
long count = 0;
//Set up Clock
//Loop forever
TRISBbits.TRISB0 = 0;
TRISDbits.TRISD2 = 0;
while(1)
{
count++;
if(count < 200000){
PORTBbits.RB0 = 1;
}
if(count > 200000){
PORTBbits.RB0 = 0;
}
if(count == 400000){
count = 0;
}
}
}

I am making use of the dsPICs input capture to interrupt on the falling edge of the wake pulse(We detect the rising edge on the pic pin because of it being inverted.) We then toggle RD2, first high for 50mS then low for 50mS then back high for 100mS. This signals the phone that the dock is desk dock, with high current charging, and that the audio output is not connected.

If you want the Microchip MPLAB project I can also put it up somewere.

My recommendations for this project would be to use a 1.8V microcontroller to avoid all the level shifting.
[Samsung Galaxy Nexus] pdxbill:
How could we get SPDIF out of there too? After signaling POGO_ID_AUDIO, does SPDIF just start to flow? Not sure of the signaling voltage levels for coax SPDIF either...

--Bill
[Samsung Galaxy Nexus] silverchris:
It does look like it is outputting data, I don't have fast enough equipment at my disposal to see if it is true SPDIF data, but all the code seems to call it that. If it is just SPDIF data then you should just need to shift it to the correct voltage level, and feed it to a dac
[Samsung Galaxy Nexus] pdxbill:
Do you have an A/V receiver or similar with a coax digital in? If so, give it a try!

--Bill
[Samsung Galaxy Nexus] bentglasstube:
Their site is kind of janky. They are three pin, 3mm pitch, 5.7mm working height.
[Samsung Galaxy Nexus] CNLiberal:
How do you go about attaching the 3 wires to the pogo pin adapter you have? Solder? Or is there some kind of through-hole?
[Samsung Galaxy Nexus] bentglasstube:
I haven't crossed that bridge yet. They aren't through-hole, and I probably won't even mount them on the actual PCB because they need to be positioned pretty specifically. I think I will end up just soldering wires to them and to the board in the end.
[Samsung Galaxy Nexus] subvertz:
Here is a pic of the circuit board inside the official desktop dock mod thread. I know ya'll are past this point already, but it cant hurt.
[Samsung Galaxy Nexus] zuberio:
Hi All,

Just thought I'd provide an update on my version of the circuit. I've sold all 7 of the kits I made - don't know if I'll make any more. The latest (final?) version is 8.1.

Here's a link to a zip containing diagrams, schematic, and the Arduino sketch I used.

Schematic:

Circuit Board Layout (with part labels):

Clean Layout (top):

Clean Layout (bottom):
[Samsung Galaxy Nexus] CNLiberal:
OK, so that company is telling me they have no samples available. I'd have to purchase 1000. Obviously that's not gonna work. Any other options?
[Samsung Galaxy Nexus] zuberio:
http://www.ebay.com/itm/10pcs-P50-J...114?pt=LH_DefaultDomain_0&hash=item3a7828b9e2

The trick is making sure they're placed 3mm apart. I built my dock using project pogo pins like the above.

http://xdaforums.com/showpost.php?p=27500763&postcount=36

Another option is this

http://xdaforums.com/showthread.php?t=1497881
[Samsung Galaxy Nexus] aksolanki:
Hi, I recently bought a pogo pin dock for my GNEX, it is great. I use my dock on my bedside table to simply charge it overnight, and then to hear the alarm go off in the morning. But when ever I put the handset in the dock the night clock mode kicks in.

I have Googled this and searched for apps on the play store that will allow me to simply kill the display and put the handset to sleep, but no luck. I have found apps that will let me customise the desk clock, colour, font, brightness etc. I sleep in total darkness and even at the lowest brightness setting in various apps, the damn screen is too bright. And anyhow, I do't like the screen being on even if it is not displaying an image, or the time. An AMOLED screen is never truly black or off, it just looks that way when other pixels are illuminated.

I have even flashed an AOKP ROM such as JellyBro hoping that the dock settings would have more features, no joy. Anyone have a suggestion on how to achieve the phone being in sleep ode whilst in the dock?

Many thanks. Anil
[Samsung Galaxy Nexus] Mach3.2:
CM10 have a power control button that allows you to turn off the display by pressing that on screen button.

Beamed from my Maguro.
[Samsung Galaxy Nexus] aksolanki:
Hi Mach3.2, I have just tried your suggestion and it worked perfectly, thanks. Anil
[Samsung Galaxy Nexus] subvertz:
The app "Button Saviour" will also let you perform any physical or soft key function in the on screen area. Combined with "PGM slide-to-wake" you never have to touch the power button.
[Samsung Galaxy Nexus] aksolanki:
Hi subvertz, thanks for the application suggestions, I will try them out.

Have fun. Anil
[Samsung Galaxy Nexus] AvErNaN:
I've just read through all the topic, and found it very very interesting. And it's also so plainly explained, that even a total ignorant like me can try this (and maybe also succeed :D)

Any news? I mean, did you do that? And is it working? I'm asking because my idea is quite similar to yours, both in the no-audio feature and in the LED status sensible to the charging status.

So, I have some final questions for you:

- Anyone knows which are the currents involved in charging the GNex? I mean, does it charge at constant current, or it decrease it when approaching the charged status? If no one knows, I think that I can figure it out by myself, probably using the arduino to read the current during charging.

- Is the current sensor working? Otherwise, I've read that you can calculate current measuring voltage drop across a small (shunt) resistance. In principle one could do this using the free pin of the micro-controller, right?

Last, but probably most important: may I use what you've posted? Sketch and wiring scheme? You know, I just want to be sure it's not a problem.

So, thanks for all the thread. And thanks in advance for any answer :D
[Samsung Galaxy Nexus] zuberio:
You can use whatever I've posted - I wouldn't have posted it if I didn't want other people to use and build upon it :)

I'm just making an assumption here, but I believe the GNex charges at full 500mA or 1A (depending on USB/AC charge mode) until it hits 99 or 100 percent and then goes into trickle charge mode. I'm basing this on how my battery pack reacts by shutting off when my phone hits 99% - because I guess it doesn't have a trickle charge mode.

Thinking about the shunt resistor idea ... I don't think that will work. Because the charger that's supplying the voltage to the circuit will try to maintain the same voltage by varying the current it is supplying. However, if you put a very small resistance in series with the power to the phone, you can measure the slight voltage drop across that to determine the current passing through. V=IR, so more current means higher voltage drop.
[Samsung Galaxy Nexus] AvErNaN:
Ok, thanks. I agree with you, but I've asked just to be sure :D

Mh. Well, on monday I'll go to buy everything I need. Probably I will have to order something on the web, so it'll take time. Then I'll try to put up the circuit and to see if I can measure the current :D

In case I succeed, the ATTiny's pins can be used as analog input to read the voltage drop? Otherwise my idea is useless.

Mh, just as a funny (and totally OT) observation: my English is a lot better when I'm tired :D
[Samsung Galaxy Nexus] zuberio:
You'll have to use either pin 2 or 3 in ADC (analog-digital converter) mode to make it work. Good luck!
[Samsung Galaxy Nexus] AvErNaN:
Thanks! I'll tell you if it works :D

Inviato dal mio GT-S5830 con Tapatalk 2
[Samsung Galaxy Nexus] gravis86:
If all I want to do is enable my phone to charge in AC mode while connected to the dock, do I have to do your full kit? or is there some easier way for just that one function?
[Samsung Galaxy Nexus] Mach3.2:
Ground to the pin closest to the power button, nothing for the middle join, 5v for the last pin. And a kernel with usb fast charge.

Beamed from my Maguro.
[Samsung Galaxy Nexus] bentglasstube:
With fully stock, you need something to tell the phone it is safe to charge in AC mode from the connected device. If you have a modified kernel it might work by just connecting the outer pins.
[Samsung Galaxy Nexus] rptw:
Hey guys, I first want to thank everyone for all they have done on this project. I've read the thread through a few times to get familiar with what's going on and such. I'm planning to make some kind of dock very soon but there are a few things I want to clarify before I begin.

1. Can I use a pull down resistor setup for the switches instead of pull up? I understand the code would have to be adjusted for high/low on the pins but I'm just wondering why you initially wanted to use pull up resistors, don't they use more electricity?

2. Would it be harmful for any part of the circuit of my charger if I plan to hard code it to always charge in fast mode (1A)? I plan to use a micro USB female connector on for the board and I know some cables/wall warts have shorted data pins to get fast charge in normal USB situations but if I have a cable and wall wart that doesn't have shorted data pins, would this damage anything? Also, if I am planning to splice a USB cable, when people say to tape off the green and white cables (data cables), do they mean to short them or just to put them aside as I won't be needing them.

3. How to I purchase things off the Yokowo website? Have people just be calling to ask them for samples? Are there any local or other online places I can get them at? I'm located in Toronto, Canada.

4. With the way the code is set up with the huge loop and then the 3 intermediate steps to setup the parameters for the dock, how does this code not get affected with there is data (SPIDF) spitting out of the middle pin on the phone? Clearly it works since you guys have proven so but I just want to know logically how that works.

5. What does the line buffer do/how does it work? I tried using google but didn't get answers that seemed to make sense. Currently the way I see it makes me wonder why the middle pin can't just directly be connected to pin 3 on the audio jack.

Thanks in advance for your help.
[Samsung Galaxy Nexus] txoof:
Can you please explain the necessity of the voltage regulator? Does it serve to regulate the signaling voltage? I'm curious because the ATTINY appears to function at 1.8-5.5V which a USB charger should provide nicely.

Thanks for your help and great diagrams!
[Samsung Galaxy Nexus] txoof:
I finally read through everything and figured it out. The voltage regulator is for the signaling. I'll have to cobble one together using an LM317 for now as Norgestan has exactly zero local parts providers.
[Samsung Galaxy Nexus] qwertymodo:
I know I'm a bit late to the party here, but I recently upgraded from a Droid X to a used GNex due to not wanting to mess with upgrading and risk losing my VZW grandfathered unlimited plan. Anyway, all of the work here in this thread inspired me to build my own dock. I've re-worked the hardware design from scratch to use a PIC10LF320 instead of the ATtiny13 (though the board will accept an ATtiny4/5/9/10, if I felt like using one instead, though the PIC is a better choice because of one of its peripherals, called the CLC). I have the board size down to 1"x0.4" with 2.8mm mounting holes (size chosen for #4-40 hardware). I already have most of the software written (I went with a fully interrupt-driven state machine, so it should be pretty robust), but I can't test it until I get boards back, which should take a couple of weeks. Initially, I don't plan on implementing the audio output (a silly mistake in my first run of PCB's means that those probably won't be able to do it anyway, but I've fixed that and I may eventually order some boards with the fix implemented), but if I do implement it, I'll leave the physical connector to a separate board, which will probably also contain a USB port for plugging in the charger (this just has pins for +5v and GND to save space). I don't know if anybody else is still interested in this particular project, but if so, I'll drop by with an update once I get my boards in.
[Samsung Galaxy Nexus] mpolo:
I'm looking to start this project in the next few weeks. So I'd appreciate your comments & updates.

Some quick questions for you. How are you programming the PIC10LF320? Can an arduino serve as a programmer? Also what service are you using to make your board?
[Samsung Galaxy Nexus] qwertymodo:
I'm using a PICkit 3 to program the chips and getting my boards manufactured by OSHPark.
[Samsung Galaxy Nexus] ILA:
I've also upgraded to an used GNex from my HTC DHD and would like to build a dock for it... I'm looking forward to seeing the board and the code with audio output. Wish you the best of luck!
[Samsung Galaxy Nexus] aggie6600:
So this will allow you to fast charge without needing a custom kernel?
[Samsung Galaxy Nexus] soundwire:
I haven't tried this out yet as I don't have an aTtiny85 handy but I put together a quick arduino sketch for the microcontroller novice like myself.

// Arduino sketch for an aTtiny85

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

void loop()
{
digitalWrite(0, HIGH);
delay(1500);
digitalWrite(0, LOW);
delay(1500);
}

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

---------- Post added at 07:27 PM ---------- Previous post was at 07:22 PM ----------

The idea is to be able to make a dock with a microcontroller in it that signals the phone the right settings for the dock. So yes it will set the phone to (AC) fast charge mode if you have it set to that.
[Samsung Galaxy Nexus] silverchris:
A small thing I was going to note, and add to my firmware, is that we should be measuring the wake pulse if possible. As my code is right now, it responds to all pulses, including spdif data. Which will really mess with the data, resulting in something the SPDIF receiver/DAC will not enjoy.

But otherwise, that code gets the general gist of it.

Other note, the phone does report that it is in AC Charge mode when docked.

I am going to see if I can find something that I can drag out to my shop to see if the SPDIF data will feed directly into a stereo
[Samsung Galaxy Nexus] subvertz:
You guys are incredible for actually going through with this. Its way more work that just using the fast charge kernels, but inspiring! Don't know if you saw or not, but Expansys said the Samsung docks are all manufactured, and they are trying to get an early shipment to France by the end of the month. Ya'll might still beat 'em!

I might even tear apart my Frankendock to solder something to the middle pin...
[Samsung Galaxy Nexus] mephi:
Couldn't you get it to respond to the first wake pulse and just not reattach the interrupt? That'd stop it from responding to the spdif audio signals.

Matt
[Samsung Galaxy Nexus] anton2009:
Hey guys. How would I go about taking apart my galaxy nexus pogo dock? I want to do some remodeling so that it will fit the i515 variant...

---------

Never mind i figured it out
[Samsung Galaxy Nexus] ellesshoo:
Any chance you could undo those screws, flip the board over, and get us a good shot of the component side of that board?
[Samsung Galaxy Nexus] silverchris:
Ya, but then if you took the phone out and put it back in, nothing would happen, because your microcontroller isn't listening for the pulse anymore.
[Samsung Galaxy Nexus] soundwire:
I have already posted pics awhile ago..

http://xdaforums.com/showthread.php?t=1626139
[Samsung Galaxy Nexus] jonnyg1097:
I wish I knew what I was reading in this thread so I could help out in some fashion
[Samsung Galaxy Nexus] Matridom:
I'm going to see if i can, in my limited understanding get this to work properly. I've attached a crude drawing of how i think the wiring should be, if someone with a little more know-how could double check everything and let me know?

Power source would be a 5v 1 Amp usb outlet charger.

I've assumed that the atTiny85 is programed using the code supplied by soundwire, the diagram schematics, i've taken from silverchris.

Thanks to everyone helping out with this in the thread!
[Samsung Galaxy Nexus] silverchris:
soundwires code is assuming that the input and output are on the same pin, were my schematic is on different pins.

You will have to adjust the digitalWrite function calls to take that into account, also you will want to adjust the delay calls to match those for dock
[Samsung Galaxy Nexus] Matridom:
OK, so I took more time to look into the code, I know programming, but not andriuno specificly, I was also a little rushed to get things posted yesterday. Could you clarify a few things?

attachInterrupt(0, wakeResponce, FALLING); // innterupt "o" is on digital pin 2 hardware pin 7

This would indicate that the wakeResponce function is attached to interupt 0, on pin 7. The Function is doing it's digitalwrites to pin 1. This would indicate to me that they are on two different pins?

I also noticed that both PIN1 and interrupt 0 where attached to the wrong pins in my diagram. Both leads needed to be shifted up on the microprocessor.

Hardware pin 5 was only being used to blink an LED (very annoying in a car at night) so I'm going to drop that section of the code.

If I'm wrong, and I probably am, would you be able to explain a little more on what I'm missing?

End result so far is:

// Arduino sketch for an aTtiny85

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

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

void loop()
{
}
[Samsung Galaxy Nexus] soundwire:
A few things,

Your pins on your diagram are backwards the transistor is signaling the interrupt, also I think your collector and emitter are backwards.

I haven't actually gotten this to work on an attiny85v my thought was it should work at 1mhz and 1.8v to the attiny85v and we would not have to use a transistor. The arduino 1.0 IDE doesn't like wakeResponce(); so I just use wake();

The blinking led was just to prove the program was running.
[Samsung Galaxy Nexus] perdurabo2:
What are you using/planning to use (pogo-pin-wise) instead of the real dock?
[Samsung Galaxy Nexus] Matridom:
Again, thanks for the help. I've had to go back to my high-school years to remind myself about electronics, I really should have kept up as a hobby, but I guess a late start is better than a non-start.

OK, so if understand the changes properly, we would need the following:

Power source 5V, 1A.

32 ohm resistor T'd off the 5v feed to lower the voltage to 1.8v, this would power the attiny85v, the 5v would continue on to the phones 5V pogo pin

Pins 6 and 7 could be connected together and this in turn would be connected to the middle pogo pin. Since the attiny is operating at 1.8 volts, there is no need to step up or down the voltage to the middle pin.

the third pogo pin would be connected to the power source ground and the attiny85v's ground would also tie in.

I would revert back to the original code while changing the wakeResponse function to "wake"

Sorry guys if I'm being a pain, I don't mind tinkering, but I also know I lack a lot of knowledge in this field. I feel that this is still cheaper then going the route of the official dock (vaporware?), as I'm estimating electronic parts will cost no more then 5$, an andruino uno to program the chip will cost $30, and say $30 in materials for the physical dock, still makes this option much cheaper then the estimated $90 for the official car dock. As an added bonus, the more docks that are made, the more return on investment one gets from the andruino uno.
[Samsung Galaxy Nexus] silverchris:
You will probably want to use a 1.8V regulator of some sort to power the microcontroller. Also, you most likely do not want to tie the 2 pins of the microcontoller together.

You are best of to use a single pin to both interrupt on, and signal on. This should also let you drop all of the external components between the phone and the microcontroller.
[Samsung Galaxy Nexus] soundwire:
I'm not sure if using the arduino IDE is going to work. Delay() doesn't work in an interrupt function...:(
[Samsung Galaxy Nexus] Matridom:
I think at this stage, I'm going to leave it to the experts to work out the kinks, I don't mind getting my hands dirty. When I don't fully understand the language, I can tweak code, but troubleshooting it is well above and beyond what I can do.

On a side note.. Would this have been an appropriate voltage regulator?

http://parts.digikey.com/1/parts/1423387-ic-ldo-reg-500ma-1-8v-to220-3-mcp1825s-1802e-ab.html

Edit:

I can't help but google...

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1241202529
[Samsung Galaxy Nexus] aggie6600:
So which diagram and audrino sketch should we be using?

I took a couple of electronics classes in college, but I know enough to know that I didn't remember anything.

I am very interested in the project and I have already made a dock sans pogo pins. (still looking for those). I just need to figure out the electronics.
[Samsung Galaxy Nexus] soundwire:
This doesn't work either... the max delayMicrosecond is "16383" if the pulse has to be 100 millis the microseconds would be 100000 no?