Schematics and Hardware [Wiki]

This area will be used to post the most up to date schematics and hardware notes. Comments and discussion can thread below, but if we agree on a change then it should be updated here.

Flash Chip Schematics (temp/suggested/draft)

Copied from Flash cart(ridge)

Suggested Part for Production (needs to be as small as possible / what capacity?)

BGA format? @Mr.Blinky can you fill this suggestion in?

DRAFT - USB Audio Mod

Don’t even know if this works, but I want to do this.
Copied from Sending SOUND into the USB port?

audio-output

Is it compatible with off the shelf micro-usb to audio dongles? Even if not… if we sell enough of these we can make our own dongle that comes with the device.

Audio mod: So I’m curious if we can establish what the exact convention is for creating the “correct” method for OTG audio over the micro usb port.

I thought there is an approved convention for sending analog stereo audio through a micro usb. For sure there are adapters:

I guess I just buy a few of these and figure how they are wired? I think it comes from setting certain resistances on the data lines?

Anyways, I can say for sure on a standard usb cable they only have 4 wires, the 4th pin is not terminated to the wire. This is actually of little consequence to us if we are having our own adapters made, but I’m kind of trying to avoid that.

To be honest though, looking at the prices of the adapters on amazon and aliexpres, it’s probably just easier for me to have some cables custom made if I’m ordering more than 5,000.

Another thought, how to isolate the pin, if it’s not being used by the application would be potentially throw a switching transistor on the signal before it goes out, that would function as an enable pin.

Let’s not forget the link cable mod, too!

You could kind of theoretically use this same mod as a link cable utilizing a 1 wire protocol, but I don’t think you would also be able to use the speaker at the same time. Unless we put the audio out on a separate pin entirely…

Actually that makes me think about that transistor again. It might be possible to configure the circuit so that you’ve got the option of using a separate pin from the speaker to output, or you can connect it to the speaker for default carts. So if your cart supports multiplayer it would for sure not be able to support music out, at least not without an option in the menu.

Found a schematic for what is likely those adapters:

http://pinoutguide.com/HeadsetsHeadphones/microusb_headset_pinout.shtml

Pin Name	Description
1	VCC     NC
2	Data -	Left Channel
3	Data +	Right Channel
4	ID	 	Mic
5   GND     GND

Could we tap into the data lines, and if a data connection is not detected, have them connected to additional gpio through series resistors for audio out? If we can have floating GPIO connected in parallel to the USB data lines without negative effect, this would also easily allow for multiplayer with a micro-usb to micro-usb cable.

image

And if you pulled a sense pin off of the VCC line, that could actually be used to detect a USB cable!

Or… UVCC is already connected directly to the USB, can you detect UVCC in the code somehow?

Really this is just a question of not disturbing the data by leeching any/too much current off the data lines, or creating any ringing… etc… but, I don’t think our data rate is high enough for that to matter much?

I wouldn’t go for BGA chips unless it’s way cheaper. I’d recommend WSON for flash chips.

Are you prefering the resistor and diode levelshifting? A note on that is that the diodes are relatively big (almost same packaging size as the 6 pin charger chip)

for the levelshifting I’d prefer a TXB0104 in the small packaging I mentioned earlier (need to llok it up again)

Pin 4 is normally the ID pin and used for an OTG device to identify itself (by grounding this pin) on normal cables this pin is not used.

The resistor array acts as a simple 2 bit DAC adding the 2 audio channels together. and the audio is connected to the ID pin. An optional decoupling capacitor is added externally to leave all mixing/filters open for tinkeres.

No. The stock USB micro to headphones adapter won’t be useful as the audio channels are connected to the USB data lines.

It’s simple to make your own cable. Just two connectors and put a small 0.1uF capacitor in the audio connector.

Not needed. If you google for micro usb headphone pinout you’ll find enough wiring diagrams

Oh I see you already found out :blush:

You can’t connect SPK1 and SPK2 to the D- and D+ lines. It would cause a problem for USB functionality (when sound is playing or pins are configured as output)

Ok true, but it could be AUX1 and AUX2, so they are actually used ONLY for audio out once usb is not detected.

But only if sound is playing? I’m wondering if configured correctly if this schematic would work.

Yes as long as AUX1 and AUX2 remain in input mode for as long as USB is connected.

But in order to play music over AUX1 and AUX2 a seperate library is required.

No also when they are just configured as output both states high and low will cause issues and don’t forget the piezo speaker is also on the pins causing havoc to the USB signals.

Ok I drew this for a prototype. Added AUX1 and AUX2 and RX and TX for 2 player link cable.4 extra pins connected to the USB data lines. the resistors are there as a fail safe and I picked the same value as the ones required for the USB data lines to keep the BOM list simple.

If there are any unexpected issues with the added features the resistors can be simply be removed from the BOM list without needing a redesign of the PCB.

EDIT:

OOPS! I looked at the wrong pin numbering PORT D6 and D7 are already used as OLED control lines (CS,RST) so those pins will not work for AUX. Don’t think there are usable PWM pins available for that idea :confused:

If you like the link cable idea. I’ll need to reassign another pin for flash chip select. (Most likely D2 SDA as that’s an accessible pad on Arduboy PCB and it is high with current Arduboy sketches disabling the flash chip)

Proposal:
Add 2 player link pins, change flash chip select to Arduino pin 2 / SDA / PORTD1

Do we need to have the rx tx connected specifically? Is there any overhead saved for using the hardware pins? I guess the software serial library probably is bigger than the hardware ones?

We could just use the rx tx pins as aux couldnt we?

I dont know if i want to output the speaker directly. Any game that wants audio out would have to enable it as an option.

Wouls we blow anything up or create any problems if we are sinking or driving 5v on that line to any perheperals?

The advantage is. we can have full duplex communication with little overhead (in the background) and the standard serial library can be used (altthough a customized version would have a smaller size). Using software serial will delay everything.

If other pins would be as good or better. I wouldn’t suggest using Rx as it means I need to rewrite the flash chip select code of current bootloader and more :joy:

Yes. but they don’t support PWM meaning sound is purely bitbanging or sending bit patterns over serial (only Tx)

The speaker isn’t autput directly. it’s output over the resistor ladder.

Hmm I just realize the D+ and D- lines of ATMEGA32U4 are internally powered by 3V USB logic and must be in range 3.0V to 3.6V according to the datasheet. I think this whole idea goes down the drain. :confused: or run the ATMEGA32U4 on 3.3V completely? :thinking:

I’m tempted to hunt down some of the hardware these adapters are made for and buy them, disassemble and see how they are handling it. Since audio at only 3.3v would be kind of weak for headphones?

Yeah without buffered input/outputs to shield the arduino you probably don’t want to inject 5v there.

But other people obviously came up with some solution. Mono output on pin 4 maybe isn’t so bad really since its nearly always an unused pin, it just really pesky to try and get at it as finding a 5 wire usb cable is gonna be a PITA. Hacky solution is obviously to just wire your own cable. I’d want to include an adapter if we went this route… I just really like the idea of people being able to use off the shelf adapters but. Does anyone actually own those adapters, or want to pay north of 5 dollars for one on amazon if one is coming for free with the device anyways? No.

I’m still interested in how other people put audio or otherwise hijack the data lines of usb.

Doing multiplayer seems very attractive. Are micro-usb to micro-usb cables crossover? If not, then we would need to utilize a software serial library anyways.

It is possible of course also to do a 1 wire communication with the pin 4 method. But this is of course done in software and I imagine you run into all sorts of hiccups with timing and the asynchronous behavior on anything real time. Would work just fine for data transfer I imagine, sending pokemons and stuff but wouldn’t imagine working very well in a fighting game.

Sidetrack:
I’ve eyeballed USB-C which of course actually has a convention for audio but it has to go through a handshake. I found a really amazing chip that handles the switch over between data and audio and also includes a headphone amp… but it’s for usb-c. (hook that shit up to an ESP32 son, bluetooth, wifi, usb-c dev platform)

I’m loving this discussion.

1 Like

Anyone want to discuss templates instead?
No… Just me?.. Very well, carry on. :P

1 Like

This one says the following phones are compatible

Nokia 3110 3110C 5200 5300 5610XM 5700 6110 6110n 6120 6120c 6290 6300 6500s 7390 7500 E51 E62 E90

5610XM is the only one that is for sale on ebay in the USA

But a video also shows this unit has one of the smaller headset jacks that phones used to have.

I don’t know it’s the only one listed that I can buy. But all I see are reviews of people saying it doesn’t work. Don’t know if they are actually trying them on the correct phone though.

Gopro Hero4 had this for microphone. But I highly suspect it might be using pin 4, as mic only needs 1 pin!

And today is the day that I learn that Mini-USB has 10 pins

]

Seems like there is hope:

This guy has these headphones come with a chinese smart watch and says it’s worked in a few different devices. He even mentions it working in a tablet and being recognized by the software. Which is incredible, because if that’s android he is talking about that gives me real hope it’s some kind of “standard”.

I actually had a credit card cell phone come with headphones like this but I tossed it a long time ago. Didn’t realize how rare or important it was at the time!!

this is supposedly from samsung?

This is true, in most cases, if you plug a USB to aux cable into your phone and connect it to your head unit. Some phones and MP3 players are designed to output audio signals via USB connection, like the original HTC Dream that used a single micro-USB connector for both power and audio output, but most phones and MP3 players come with a standard 3.5mm or 2.5mm TRRS headphone jack for a reason.

Many phones and MP3 players aren’t specifically designed to output sound via their USB connection. The USB connection is capable of transferring digital data back and forth, and can likely also be used to charge the device, but it usually won’t be designed to output an audio signal.

The only case where you would want, or need, to output audio from a phone’s USB connection to an aux input in your head unit is if the phone didn’t also include a headphone jack. Some phones, like the original G1/HTC Dream, omitted a headphone jack in favor of the ability to output sound via the USB connection.

Ordered an HTC Dream to check out, it says motherboard is tested but doesn’t say if it actually like, turns on? There is a working one for $80 bucks but not totally sure I want to go in on that. I should be able to tell a lot from just looking at the PCB. But I kind of expect 2 things, one is that the chip is fancy enough that the data lines for the usb can also just be internally switched to being audio lines, or what I expect is it has a dedicated chip to handle the switchover, just like the usb-c example I had.

It might be impossible to route on a 2 layer board, but if we go to 4 layers and we are already putting a level shifter on the board… Could pass everything through the level shifter and just have audio be at 3.3v.

Functionally I’m leaning to the one wire solution, but asynchronous data transfer by hijacking the data lines is really what I want to do.

Also found this page:

Compatible With Lg Xenon GR500 GU295 DLite GD570 Sentio GS505 CF360 Vu Plus GR700 Shine II GD710 eXpo GW820 Arena GT950 Opera TV

So I ordered an LG Xenon also. Going all in on usb hijack.

Leaning in:

The cable doesn’t handle anything. It’s just two connectors with wires. It’s the device that they are hooked too that support an Audio over USB switching mode.

Even if there would be an AUX1 and AUX2 pin connected to the USB that would work. You can’t connect headphones directly to them. They would draw too much current and danage the AUX pins.

Thats my thought too.

I doubt they excist as a regular cable. The extra wire is an ID pin for OTG devices.
They would have to be custom made / self made. They’re easy to make.

I doubt there are micro USB male to micro USB male cables. But if there were they should be crossover cables. They would have to be custom made / self made too. They’re also easy to make.

Yes definitely. Using Rx and Tx has the bennefits of using the hardware USART and interrupts.

The easiest way to do this would be to make run Arduboy on 3.3V (or 3.6V) by adding an LDO voltage regulator. the Battery voltage could still be fed into the OLED (VCC) to maintain the same brightness level. Another advantage would be not requiring parts for level shifting.

According to my experience there is no combination of USB cables that do not exist although 90% of them are not allowed or according to the spec.

Regarding the link cable. What if we would use the cable above? There is no VBUS supplied from the Arduboy so none of the USB blocks with do anything when connected together. Then we should be free to use the OTG pin for message transfer. The game could ask for link cable detection and then “sense” the other Arduboy via the OTG pin and start a kind of one wire communication protocol. Maybe we can even make use of the DP/DM pins if we could “route” them to something like a regular gpio pin? The sense should be deactivated as soon as a USB connection is detected.

1 Like

Yeah I know, my assumption is all these cables will be wired to the same schematic as the one that I posted above. I’m interested in taking apart the devices and see how they handle the usb switching. Does usb come straight into the primary processor of the device? Is there a USB/communications chip? Are they doing any manipulation of the data signals or do they go straight into a chip? Like I mentioned before I kind of expect them to have a dedicated chip for this purpose.

You can’t hook up headphones to Arduino gpio? What? Don’t people do this all the time? Do you mean we would need a headphone amp?

As @veritazz notes they are available, actually if you look at my cart screenshot I’ve already ordered one. My suspicion is that it’s a pass through and not crossover because… that’s how usb works right?

Lol good point, it looks like we will need to use pin 4 as a sense pin to enable a multiplayer cable if we decide to go that route.

Finding out usb-mini has 10 pins and was designed for A/V output makes me sad that it isn’t a viable option.