Author Topic: USB hacking for beter prototyping  (Read 6451 times)

AlanSE

  • Newbie
  • *
  • Posts: 11
USB hacking for beter prototyping
« on: February 07, 2013, 09:09:59 am »
Several people have noted difficulty with getting the connection to a USB port to be solid.  The problem might be mostly in the power supply, although some people have suggested problems with data pin connectors.  This led me to a situation where I would like to extend a loose cord to my digispark, but I need to use a powered hub or connect it to a computer directly.  I've been thinking of a hack to fix this and create a more comfortable developing setup, and I want to ask if this project should work in the opinion of others.

Here's what I want to do:
  • Cut off the wire (including the male USB end) of an old mouse, then strip the end that was cut to get the 4 wires
  • Connect the data wires to P3 and P4
  • Connect my 9V battery to GND and Vin
  • Plug in the male USB when the editor prompts and get going
Can I do this?  Would it work?  Searching around I found a similar question on Twitter:

Quote
Tiago ''xrl''@xernobyl 
Does anyone know if I can cut the USB end of a #Digispark and program it by connecting an usb cable to P3, P4, VIN, and GND?
Digistump replied that it would need a 60-70 ohm resistor between them to match the USB specifications.  That wouldn't be a problem for me to add.  An extra question: would I still need this if I connected the data wires to the USB plug part of the digispark?  In other words, are those connection pads on the USB plug electrically the same buses as pins P3 and P4?

And obviously a concern of mine is the use of the external power source in conjunction with the data wires from the computer.  If it works, however, I could then work without having to deal with the mess of jiggling the digispark around in the USB slot, or a powered hub, and I could also keep it firmly placed on a solderless breadboard with decent cable length to the computer.

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: USB hacking for beter prototyping
« Reply #1 on: February 07, 2013, 01:31:24 pm »
This should work just fine:


You don't need the resistor if you attach to the USB end - it is inline between the USB data contacts and the pins.


No problem powering it externally through VIN - the grounds will be tied common, but the 5v will be protected from the USB 5v line by the schottky diode


If you used the USB for power instead of externally powering it then you could also put a switch on the 5v wire from the computer and turn it on and off that way isntead of having to plug and unplug.

AlanSE

  • Newbie
  • *
  • Posts: 11
Re: USB hacking for beter prototyping
« Reply #2 on: February 07, 2013, 02:35:32 pm »
Here's what I have in mind:

Stackable header on the pins 0-5, and just the row of slots above the GND, VIN, and 5 V.  This will be good to use as the designated breadboard digispark.  Since the slots are right there, it's not really any trouble to use a unique power source for it, and so far they've started up and executed their program fine with batteries.  Once that's verified I can try other configurations.

I might have to rethink how I'm going to disconnect and reconnect it.  It would be nice to use a breadboard switch for that since repeated alligator clipping isn't the ideal solution.  Actually, I might slit open a female USB connector and use the wires from that.

Hopefully I'll have a version working soon and pics to add to the projects board.

Bluebie

  • Sr. Member
  • ****
  • Posts: 486
Re: USB hacking for beter prototyping
« Reply #3 on: February 07, 2013, 06:09:24 pm »
I had some trouble where the diode on one of my digisparks broke, so I grabbed a USB->micro-usb cable I had, cut open the usb plug, desoldered the wires and cut away the white plastic on the top side of the connector so the prongs were open and exposed, then soldered the prongs down directly on to the digispark's USB connector. This extended the plug so I can plug it in to any port now, and made the USB power wire totally exposed so I could easily add another little wire connecting that far left prong (in the picture) to the 5v connection point. The digispark is alive and well now, and I prefer having a real USB connector so much that I did the mod to another digispark (pictured) while I was at it!


When you cut open your USB cable you should find four wires with these colours: red, white, green, and black. You can solder those wires directly on to the usb connector part of a digispark in that order going from the USB connection closest to the vcc/gnd/5v section of the digispark with red, then white, green, and black on the furthest part.  It's part of the USB standard that those colours be used for the wires inside USB cables, but if there are different colours inside you can always figure it out with a multimeter anyway. :)


If you're keen to not solder on to the USB connector, I'd note that 60-70ohms is a bit stricter than reality requires. @Ihsan's LittleWire circuit uses 28ohm resistors. I think you'll find that a wider variety of resistors from 20-150ohm will probably work just fine - they exist primarily to protect the AVR from being severely damaged if there is a momentary short circuit while plugging the digispark in to the USB port. That said, you could also need zenner diodes, depending on how well your computer tollerates 5v IO on USB devices. I've found that my recently purchased Mac's seem not to mind, but some computers will refuse to talk to devices which don't have the zenner diodes, so soldering to the USB connector really is easiest.


@DigiStump it'd be neat if a future revision of the spark added plated through holes on the USB connector section on each pin, on the ends closest to the microcontroller. It'd be especially neat if those through holes could be arranged so they work with pin headers too. It would make these sorts of cabled spark mods quite a bit easier, and would make things easier for people wanting to solder on a real USB connector - they could use this through-hole variety http://www.alibaba.com/product-gs/629595239/USB_AM_R_A_dip_Connector.html and at a price of about $0.04 a piece, you could probably budget just tossing a few in with each order anyway for anyone having trouble with usb ports not loving the PCB connector.

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: USB hacking for beter prototyping
« Reply #4 on: February 07, 2013, 07:07:56 pm »
That said, you could also need zenner diodes, depending on how well your computer tollerates 5v IO on USB devices. I've found that my recently purchased Mac's seem not to mind, but some computers will refuse to talk to devices which don't have the zenner diodes, so soldering to the USB connector really is easiest.


The zener diodes aren't needed even if you connect a USB cable via P3 and P4 - they are still in the circuit and should do their job when the pin goes high.




Bluebie

  • Sr. Member
  • ****
  • Posts: 486
Re: USB hacking for beter prototyping
« Reply #5 on: February 07, 2013, 09:32:19 pm »
Aren't the zenner diodes after the 68ohm resistors? So p3 and p4 are still at 5v aren't they?

barnacleBudd

  • Newbie
  • *
  • Posts: 21
Re: USB hacking for beter prototyping
« Reply #6 on: February 07, 2013, 10:49:59 pm »
I like your idea, but see it going a little further.  If you're going to hack your own cable, why not put a switch in it? Then instead of plugging and unplugging the USB you just flip the switch.  I would like to know if this could be done with just the two center pads in the USB connector.  A push button with two sets of pins would be great.
I think I could build a little USB dongle that had such a switch or button. You've got a great idea here.
http://mypetdigispark.blogspot.com/
 

Bluebie

  • Sr. Member
  • ****
  • Posts: 486
Re: USB hacking for beter prototyping
« Reply #7 on: February 08, 2013, 03:13:46 am »
to reboot the digispark (for programming) don't bother doing anything to the centre pads, just remove power from the V+ pad (furthest left in my photo - the one next to the power holes on the digispark). If you disconnect the two data lines then reconnect them without powercycling the digispark as well, it wont enter the bootloader.

AlanSE

  • Newbie
  • *
  • Posts: 11
Re: USB hacking for beter prototyping
« Reply #8 on: February 08, 2013, 06:20:18 am »
from barnacleBudd's blog:

Quote
It is clever though, that they spaced everything so that the GPIO pins fan out along the side of the main breadboard workspace and the 5V and GND pins fit right into the power rails along side the board, IF you have two rails on the side of the board.

Say what?  Has anyone actually used this setup?  Even if you have the two power rails, then I'd imagine that the VIN pin wouldn't have space to dangle.

Bluebie

  • Sr. Member
  • ****
  • Posts: 486
Re: USB hacking for beter prototyping
« Reply #9 on: February 08, 2013, 04:36:30 pm »
Yeah if you want to hook a digispark in to breadboard power rails you have to solder only gnd & 5v or gnd & vin - can't have both. I only realised this aspect of the digispark design a few days ago too, but I don't have any breadboards with power rails - I only have the tiny little ones