Author Topic: Building a Digispark compatible breadboard circuit  (Read 42771 times)

probono

  • Newbie
  • *
  • Posts: 17
Building a Digispark compatible breadboard circuit
« on: January 01, 2013, 02:05:17 pm »
The Digispark is basically an ATtiny85 running the Micronucleus bootloader. Here's how to build one yourself on a breadboard. This certainly doesn't look at good and definitely isn't as small as a real Digispark, but it can shorten the wait until you get your board.

Note that this is not the official circuitry (which I did not find online despite the board being advertised as "open hardware"), but from what I can see it's reasonably compatible.

CAUTION: While this works for me, I do not guarantee that it might work for anyone else. I assume no responsibity for any damage this might cause. Use on your own risk. Do not build this if you do not understand the circuitry.

Materials needed:
* 1 ATtiny85-20PU
* 1 Breadboard (could be saved if this is built on a PCB)
* 1 3.3V LDO voltage regulator, e.g., MCP1702
* 1 10 uF elko for the voltage regulator - it doesn't work otherwise
* 2 68R resistors
* 1 2.2K resistor
* 1 USB connector (could be saved if this is built on a PCB)

Schematic:
The entire MCU is powered at 3.3V obtained from a LDO regulator (I used a MCP1702 together with a 10 uF elko between its GND and OUT). ATtiny Pin 7 = D+, Pin 6 = D-. These must be connected to the MCU using 68R resistors. D- must additionally be "pulled high" though a 2.2K resistor (on the USB side, not on the MCU side of the 68R resistor).

First, flash the Micronucleus bootloader into the ATtiny and set the fuses (I used a USBasp):

wget https://raw.github.com/Bluebie/micronucleus-t85/master/firmware/releases/micronucleus-1.04.hex
./avrdude -C ./avrdude.conf -v -v -v -v -pattiny85 -cusbasp -Pusb -U flash:w:micronucleus-1.04.hex:i
./avrdude -C ./avrdude.conf -v -v -v -v -pattiny85 -cusbasp -Pusb -U lfuse:w:0xe1:m -U hfuse:w:0xdd:m -U efuse:w:0xfe:m

Now we should see the device show up in lsusb/dmesg as idVendor=16d0, idProduct=0753

At this point, we can use the micronucleus command line tool to upload Firmware
sudo ./micronucleus micronucleus-t85-master/commandline/cdc232.hex

Believe it or not, this now shows up as a serial adaptor in dmesg:
[13563.472052] cdc_acm 1-2.3:1.0: >ttyACM0: USB ACM device

To get rid of having to use sudo, do

sudo su
cat > /etc/udev/rules.d/49-micronucleus.rules <SUBSYSTEMS=="usb", ATTRS{idVendor}=="16d0", ATTRS{idProduct}=="0753", MODE:="0666"
KERNEL=="ttyACM*", ATTRS{idVendor}=="16d0", ATTRS{idProduct}=="0753", MODE:="0666", ENV{ID_MM_DEVICE_IGNORE}="1"
EOF
service udev restart
exit

Then install the Digispark Arduino integration. Since I use Ubuntu I had to compile some parts by hand:

sudo apt-get -y install g++ libusb-dev
wget https://github.com/digistump/avr-dummy/archive/master.zip
unzip master.zip
cd avr-dummy-master/
make
strip avrdude
cd ..

rm master.zip
wget https://github.com/Bluebie/micronucleus-t85/archive/master.zip
unzip master.zip
cd micronucleus-t85-master/commandline
make
strip micronucleus

Within the Arduino directory do the following as per the instructions in the Wiki:

* Go to hardware/tools
* Rename avrdude to avrdude_original
* Copy the avrdude executable compiled above into the directory
* Copy the micronucleus executable compiled above into the directory

Now you should have your own breadboard Digispark :-)
« Last Edit: January 01, 2013, 02:08:51 pm by probono »

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Building a Digispark compatible breadboard circuit
« Reply #1 on: January 01, 2013, 05:29:03 pm »
This is about right - but one major issue I see here, and maybe the source of the errors you\'ve seen trying to upload is that the micronucleus bootloader requires the Digispark to be powered with 5v not 3.3v so that it can properly run at 16.5Mhz - which is why we use 3.6v Zeners on the USB lines to tie it to ground.

In fact here is the schematic: https://s3.amazonaws.com/digispark/DigisparkSchematicFinal.pdf

We\'re still putting together the repository of all the board files and schematics, as well as the legal (ensuring they comply with any licenses they were derived from etc) and other work (cleaning them up, documentation, proper part numbers, etc) that surround them. But I\'m hopeful that the files will start to go up tonight, if not tomorrow.

probono

  • Newbie
  • *
  • Posts: 17
Building a Digispark compatible breadboard circuit
« Reply #2 on: January 01, 2013, 05:43:04 pm »
Thanks for the schematic. I had issues with Zener-based v-usb circuits in the past so I thought it might be cleaner to power the whole thing with 3.3V. But I will experiment with your advice and see if it improves the reliability of the upload.

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Building a Digispark compatible breadboard circuit
« Reply #3 on: January 01, 2013, 07:28:20 pm »
The type of zener diode used is very important - I found that a 250mw or less one worked best. And of course it is still pushing things out of spec, but to have a stable 16.5Mhz to use the internal clock for USB I haven\'t found any alternatives to running at 4.5 ot 5.5v.

Bluebie

  • Sr. Member
  • ****
  • Posts: 486
Building a Digispark compatible breadboard circuit
« Reply #4 on: January 03, 2013, 02:46:38 pm »
I wouldn\'t run the attiny85 at < 4v if you care about bricking it. That puts the chip out of spec and the results are unpredictable - in my experience sometimes the bootloader will overwrite bits of itself and brick the device requiring a high voltage serial programmer (or regular ISP programmer if you didn\'t disable the reset pin) to recover.

The zenner thing is annoying, lots of people have issues with it, I hope there\'s one day a better solution but it is tricky to do voltage level conversion as both of the data lines are bidirectional.

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Building a Digispark compatible breadboard circuit
« Reply #5 on: January 03, 2013, 04:32:05 pm »
A voltage level conversion version of the Digispark is in the works, but I\'ve yet to decide if it will make sense to take that route as it adds quite a bit to costs and components and possibly size.

Bluebie

  • Sr. Member
  • ****
  • Posts: 486
Building a Digispark compatible breadboard circuit
« Reply #6 on: January 04, 2013, 06:16:30 pm »
How would you convert it, @digistump? Is there some sort of gadget for bidirectional voltage conversion like that, which operates fast enough to not mess up USB communications?

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Building a Digispark compatible breadboard circuit
« Reply #7 on: January 05, 2013, 12:57:47 am »
I\'m planning to try a few different methods - some of the fancy bidirectional converter chips (which require 3.3v as well as 5v) as well as some good old fashioned voltage dividers (which are still out of spec but might get it closer)

Bluebie

  • Sr. Member
  • ****
  • Posts: 486
Building a Digispark compatible breadboard circuit
« Reply #8 on: January 05, 2013, 03:54:46 pm »
Voltage divider! That\'s a cool idea, especially since you already have the 68ohm or whatever resistors there. Mmmmmm.

probono

  • Newbie
  • *
  • Posts: 17
Building a Digispark compatible breadboard circuit
« Reply #9 on: January 05, 2013, 04:48:11 pm »
Tried it... using zeners gives less errors when uploading, but makes the device very picky (e.g., it doesn\'t work without a hub on my computer). Other zener-based devices (e.g., 3 different USBasps from 2 different manufacturers) behave the same way on my computer. So I think we could improve the reliability by using a MCU that can handle 3.3V properly, e.g., the ATmega168P or 328P? But that\'s probably the \"Pro\" version you\'re talking about then...
« Last Edit: January 05, 2013, 04:48:38 pm by probono »

Bluebie

  • Sr. Member
  • ****
  • Posts: 486
Building a Digispark compatible breadboard circuit
« Reply #10 on: January 05, 2013, 06:20:33 pm »
Yeah, a chip with an external crystal oscillator would be able to run at low enough clock speeds to run on 3.3v while doing USB stuff, but the atmega\'s cost quite a bit more than attiny85. Digispark\'s schtick is cheap smallness. Arduino Nano already has the expensive smallness market covered.

bobricius

  • Newbie
  • *
  • Posts: 49
Building a Digispark compatible breadboard circuit
« Reply #11 on: January 06, 2013, 02:20:50 am »
is usable? \"PCA9306 Level Translator\" https://www.sparkfun.com/products/10403?

The PCA9306 is a dual bidirectional I2C-bus and SMBus voltage-level translator with an
enable (EN) input, and is operational from 1.0 V to 3.6 V (Vref(1)) and 1.8 V to 5.5 V

probono

  • Newbie
  • *
  • Posts: 17
Building a Digispark compatible breadboard circuit
« Reply #12 on: January 06, 2013, 02:47:57 am »
For the added cost of this chip I wouldn\'t be surprised if we could go straight to a MCU that handles 3.3V natively...

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Building a Digispark compatible breadboard circuit
« Reply #13 on: January 06, 2013, 10:21:47 am »
Once you get to chips like that you might as well grab something like a tinyduino (another kickstarter project run by Ken Burns, a great guy). To clarify the Attiny85 is 3.3v capable - you just need to use an external crystal which would use 2 of the i/o.

RussNelson

  • Newbie
  • *
  • Posts: 23
Building a Digispark compatible breadboard circuit
« Reply #14 on: January 16, 2013, 11:49:51 am »
The teensy 2.0 is a nice micro if you want a larger board with more pins. And the teensy 3.0 if you want a LOT more pins, a LOT more storage, a LOT more ram, and a LOT more speed. I\'m fine with the digispark as it\'s currently conceived.