Author Topic: a smaller, cost-reduced digispark (<$1)  (Read 28331 times)

CBcracker

  • Jr. Member
  • **
  • Posts: 80
a smaller, cost-reduced digispark (<$1)
« on: July 15, 2013, 04:57:47 pm »
I'm trying to design a cost-reduced digispark.  For people in BrIC countries and even poorer areas of G7 countries, I think the $12 shipped cost of the digispark poses a financial impediment.
After seeing Pro Mini 328P variants selling for $5.25 shipped for qty 1, I figured a barebones version of the digispark could be built for much less.
I figure the minimum parts required for a working ATiny85 USB stick are only 3 resistors, 1 cap(.33 uF), a 1.7v red LED, and the MCU (in addition to the board with a USB connection).
When making use of the Tiny85's power saving features, it only consumes a few micro-amps clocked by the internal 8Mhz oscillator.  When not connected to a computer, that would allow it to be powered for years on a single CR2032 cell.  A red LED between the USB 5v and VCC should provide a voltage drop of 1.6v to the MCU when running at 12.8Mhz and drawing ~5mA (figure 22-2, datasheet pg. 173).  Running at 12.8Mhz is supported by v-usb (and therefore micronucleus) and doesn't require any more than 3.3v for stable operation.
I've ordered a couple tiny85 DIPs to build my first prototype, which anyone good with a soldering iron should be able to build themselves for about $1.50:
3/4" x 1 3/4" prototyping board (cut from larger piece): 10c
male USB connector: 18c @DX
ATTiny85 DIP: 115c @ tayda
passives: 5-10c

I've also started on a redesign of the digispark PCB.  I figure my design would fit on a simple 12mmx20mm PCB, including 3mm on the end for solder pads for a user-provided 4x2 male header for ICSP and pin breakout.  The resistors and cap would go just after the USB pads, then the tiny85 SOIC with the power LED beside it, and then 4 3mm pads for connecting the 4x2 male header.  In >1000 unit quantities I estimate the BOM cost at ~75c.

I downloaded Eagle CAD and the digispark design, and started removing components.  I'm stuck now trying to remove traces from the PCB, because Eagle says it can't backtrace them, and to remove them from the schematic.  However the traces don't seem to be shown in the schematic.  I've attached the design (aka hatchet job) so far; I called it digispark-mini.  Can any Eagle users give me some help?


caseyjholmes

  • Newbie
  • *
  • Posts: 25
Re: a smaller, cost-reduced digispark (<$1)
« Reply #1 on: July 15, 2013, 05:10:26 pm »
I could plug a tiny chip into my AVRISPMKII and call it a day and be at 2x2mm for $1 or so.
But I like the digispark.. it's pretty user friendly for what it is!  8)

who needs PCB's.. solder the components together and glue them together and run magnet wire for traces.  ;D
« Last Edit: July 15, 2013, 05:12:04 pm by caseyjholmes »

CBcracker

  • Jr. Member
  • **
  • Posts: 80
Re: a smaller, cost-reduced digispark (<$1)
« Reply #2 on: July 15, 2013, 05:43:14 pm »
I should also credit Sparkfun for the idea of a really basic ATtiny85 stick:
https://www.sparkfun.com/products/9147

caseyjholmes

  • Newbie
  • *
  • Posts: 25
Re: a smaller, cost-reduced digispark (<$1)
« Reply #3 on: July 16, 2013, 05:54:34 am »
I have a very tiny board drawn up with express PCB software using the tiny13 MAHR 3x3mm chip if you'd like to take a look at the file.  It's not a USB plugging device like digispark or that chip you link to above, but its much smaller than that chip or digispark. You need to wire it to an ISP like AVRISPMKII.

It's fully featured and will take 1.8-5v, has power led and onboard user programmable LED, capacitors and reset circuit resistors.
The programming header breaks out to a six pin SIP socket row.


Eagle always seemed like more trouble than its worth to me.  I use pad2pad or express PCB. They both work very good and have their own free software you can do just about anything with. 
Only problem is with express PCB you have to learn to create custom components and work their solder masking feature which isn't so obvious.  Pad2pad will make you colored boards in any thickness and size or shape.  They can do things a bit more fancy than express PCB. 

That 3x3mm chip is about the smallest thing I can solder next to the 2x2mm tiny 10 in micro lead frame package. I have had success soldering both at home.  You should see how small they are.


Good luck whatever you do. 
« Last Edit: July 16, 2013, 06:00:12 am by caseyjholmes »

CBcracker

  • Jr. Member
  • **
  • Posts: 80
Re: a smaller, cost-reduced digispark (<$1)
« Reply #4 on: July 16, 2013, 09:15:28 am »
I want something that is compatible with the digistump (use the same bootloader & s/w tools), so I'll stick with the tiny85.

I doubt I could solder a 3x3mm MLF; you must have steady hands for that.  I've never done anything smaller than 1.27mm pitch surface-mount chips.  For my PCB design I plan to use 0805 passives instead of 0603 to make the hand-soldering of the prototypes easier...


CBcracker

  • Jr. Member
  • **
  • Posts: 80
Re: a smaller, cost-reduced digispark (<$1)
« Reply #5 on: July 16, 2013, 09:21:05 am »
I just realized dumping the 1.5k pullup will also solve the following power problem:
"in current versions of the Digispark hardware a couple of milliamps are consumed constantly by the USB connector circuitry, even if you aren't using the USB interface.
The power lost through the USB connector maybe able to be fixed in a future version, but no promises."
http://digistump.com/wiki/digispark/tricks

Bluebie

  • Sr. Member
  • ****
  • Posts: 486
Re: a smaller, cost-reduced digispark (<$1)
« Reply #6 on: July 17, 2013, 05:22:46 pm »
If you remove the pullup, your circuit will not be able to do usb. It is not possible to use the AVR's internal pullup. This is not because the internal pullup is over 10kohm - which could be a problem as well - it is because the AVR cannot switch between pullup mode and pull to ground - it can only switch between pullup and floating input, or switch between ground and vcc, or switch between those two modes (input and output) The V-USB software pushes the avr to it's limits to be able to communicate the 1megabaud USB protocol, so it simply does not have time to switch the pin between input and output as well as switching it's state between high and low, and it is not possible AFAIK to do both operations at the same time.

Bluebie

  • Sr. Member
  • ****
  • Posts: 486
Re: a smaller, cost-reduced digispark (<$1)
« Reply #7 on: July 17, 2013, 06:56:48 pm »
More stuff: When you use a circuit which runs the AVR at a lower voltage and omits zenner diodes, the 1.5kohm resistor only uses power when the digispark is communicating with the host computer actively over usb, or when you're using that pin and have it set as an output written low (connected to ground). So to efficiently sleep on battery, you just need to set the pin high (connect to vcc), or set it to be an input. Either will work fine.


I have some devices which run v-usb and use two diodes in series to drop VCC down to about 3.8v, and they seem to work, but I'm unsure because my computers are all 5v tollerant on usb ports - that is to say, a digispark running at 5v without zenners works fine for me. 3.6v is in the USB specifications as the absolute maximum voltage a usb device should connect to a data pin when trying to communicate with the host, and people say there are some computers which do not in fact talk to 5v devices (though they aren't damaged by them at all - it just doesn't work). If I had a computer which was intolerant like that I'd feel a lot better about experimenting and making recommendations for circuits like this. In some ways, the USB port reliability is actually improved by getting rid of zenners and running at 5 volts, because the zenners add some capacitance and so make the data less clear and precise in both directions. I think running the AVR at 3.6v while using micronucleus at 16.5mhz will probably work, but a word of warning - I tried running at about 3.0v while programming through micronucleus at 16.5mhz and I bricked my chip. I don't have a high voltage serial programmer and it was embedded in a chunk of plastic, so I ended up having to cut the chip out with a power tool!


When you do the maths on this stuff, keep in mind that USB power is between 4.5 and 5.5v, and it seems more often than not usb host ports output 5.5v exactly, to make up for the voltage drop caused by resistance in usb cables and stuff like that, so a 1.7v LED may only drop the voltage down to 3.8v on some computers, which is still slightly out of spec, but maybe the 5v intolerant computers will tolerate 3.8v.


The 12.8mhz stuff is really interesting. If you have any success playing with that, I'd love to see. My only reservation is that 12.8mhz would be a really annoying clock speed for doing stuff like serial, OneWire™,


I'm also toying with another bootloader idea now: I want to make a much more compact bootloader which works over a single wire, or possibly two wires, but does not do usb. My idea is that this bootloader be under 1kb big, that it speak some really simple protocol, and that I have a USB programming device which plugs in to it and exposes the micronucleus usb interface so it would still be compatible with everything. It could potentially program quicker because the micronucleus implementor device can disable the usb hacks used to work around the sleeping the attiny85 has to do when self programming, so the device can run at absolute maximum speed all the time. This could make programming happen as much as twice as fast!! The other thing I am interested in is making it somehow work with an audio device, so you could have a very compact attiny85 bootloader which you plug in to an audio jack on a phone or computer, and play a wav file to it and it uploads a program. It would be slower - it could take a few more seconds than the digispark bootloader, and there could be upload errors if you get a notification sound on your phone or set the volume level badly or something like that, but I think the possibility of having precompiled arduino apps embedded in to webpages, which then can modify bits of data in the program and upload them in to a device even on a phone or tablet without having to install any crazy drivers or mess around with java and arduino junk, could be pretty great for making things that you give to friends or even sell to people. If you fix some bugs, you can distribute it to them as a wav file in an email!


There is a project like this called Audioino, which works on atmega chips. It might be cool to port it to attiny85. What do you guys think? would audio be a useful kind of bootloader?

CBcracker

  • Jr. Member
  • **
  • Posts: 80
Re: a smaller, cost-reduced digispark (<$1)
« Reply #8 on: July 17, 2013, 07:48:31 pm »

But it only has to do VCC pullup during the detection phase.  Once the host has recognized it (through the presence of the voltage of the data line), V-USB can switch to normal floating input.
The pullup resistor is not necessary for data transfer; only for device detection.  In fact, once the device is detected the 1.5K pullup resistor just wastes power.
The 10K internal pullup shouldn't be a problem since the spec requires at least 15K pulldown resistors on the data lines on the host side.  Most hosts use more than that minimum; I've seen 22K used in home routers that have USB ports.  And if the 10K pullup did cause problems, then putting the port in output mode and going high for ~100ms should be more than enough time for the host to detect it.

If you remove the pullup, your circuit will not be able to do usb. It is not possible to use the AVR's internal pullup. This is not because the internal pullup is over 10kohm - which could be a problem as well - it is because the AVR cannot switch between pullup mode and pull to ground - it can only switch between pullup and floating input, or switch between ground and vcc, or switch between those two modes (input and output) The V-USB software pushes the avr to it's limits to be able to communicate the 1megabaud USB protocol, so it simply does not have time to switch the pin between input and output as well as switching it's state between high and low, and it is not possible AFAIK to do both operations at the same time.

CBcracker

  • Jr. Member
  • **
  • Posts: 80
Re: a smaller, cost-reduced digispark (<$1)
« Reply #9 on: July 17, 2013, 08:48:08 pm »


More stuff: When you use a circuit which runs the AVR at a lower voltage and omits zenner diodes, the 1.5kohm resistor only uses power when the digispark is communicating with the host computer actively over usb, or when you're using that pin and have it set as an output written low (connected to ground). So to efficiently sleep on battery, you just need to set the pin high (connect to vcc), or set it to be an input. Either will work fine.




Good point about no power loss w/o the zener diodes.


I have some devices which run v-usb and use two diodes in series to drop VCC down to about 3.8v, and they seem to work, but I'm unsure because my computers are all 5v tollerant on usb ports - that is to say, a digispark running at 5v without zenners works fine for me. 3.6v is in the USB specifications as the absolute maximum voltage a usb device should connect to a data pin when trying to communicate with the host, and people say there are some computers which do not in fact talk to 5v devices (though they aren't damaged by them at all - it just doesn't work). If I had a computer which was intolerant like that I'd feel a lot better about experimenting and making recommendations for circuits like this. In some ways, the USB port reliability is actually improved by getting rid of zenners and running at 5 volts, because the zenners add some capacitance and so make the data less clear and precise in both directions. I think running the AVR at 3.6v while using micronucleus at 16.5mhz will probably work, but a word of warning - I tried running at about 3.0v while programming through micronucleus at 16.5mhz and I bricked my chip. I don't have a high voltage serial programmer and it was embedded in a chunk of plastic, so I ended up having to cut the chip out with a power tool!



That's what I'd expect from a couple of 1N diodes; 0.6v drop each, so you'd get 3.8v left from a 5.0v supply.  A standard red led has a forward voltage drop of 1.7v@20mA, and ~1.6@5mA, so the voltage to the tiny85 should be ~3.4v.  The high-brightness LEDs wouldn't work since they have a Vf of ~2.2v.

When you do the maths on this stuff, keep in mind that USB power is between 4.5 and 5.5v, and it seems more often than not usb host ports output 5.5v exactly, to make up for the voltage drop caused by resistance in usb cables and stuff like that, so a 1.7v LED may only drop the voltage down to 3.8v on some computers, which is still slightly out of spec, but maybe the 5v intolerant computers will tolerate 3.8v.


That's not what I've seen.  On PC's it's usually dead on at 5.0v.  Even cheap $2 USB battery chargers are usually in the 5.0-5.2v range.  You should never see anything over 5.25v as that should fail compliance testing; it has to be between 4.75 and 5.25v to pass.
www.usb.org/developers/devclass_docs/USB_Battery_Charging_1.2.pdf
A word of warning; don't test the voltage by sticking multimeter leads into your usb port.  It's easy to short the 5v to the shield ground and fry it.  Cut up a USB cable instead.


The 12.8mhz stuff is really interesting. If you have any success playing with that, I'd love to see. My only reservation is that 12.8mhz would be a really annoying clock speed for doing stuff like serial, OneWire™,

I would have thought 12.8 is no less annoying than 16.5Mhz.  Is 16.5 close enough to 16 so that code expecting a 16Mhz clock will still work at 16.5?
The V-USB site states that 12.8 is one of the supported frequencies.  I guess I'll find out how well it is supported once I try it out.


I'm also toying with another bootloader idea now: I want to make a much more compact bootloader which works over a single wire, or possibly two wires, but does not do usb. My idea is that this bootloader be under 1kb big, that it speak some really simple protocol, and that I have a USB programming device which plugs in to it and exposes the micronucleus usb interface so it would still be compatible with everything.


It sounds like a fun project, but not so practical for general use.  I only ordered my first Arduino board a couple weeks ago (still waiting for it to arrive from Hong Kong), but I've already dug up a DB25 from my parts bin to make a simple parallel port programmer.  I think the attraction of the digispark is that it's great for those who are not hardware inclined and just want to learn embedded software development.  If you don't want to make your own programmer or don't have a computer with a parallel port and want a small bootloader, buy a $4 USBASP using a mega8, and go with optiboot at only .5KB.
https://www.fasttech.com/products/0/10000022/1002900-atmegaattiny-51-avr-isp-usbasp-usb-programmer-down
http://code.google.com/p/optiboot/


Bluebie

  • Sr. Member
  • ****
  • Posts: 486
Re: a smaller, cost-reduced digispark (<$1)
« Reply #10 on: July 18, 2013, 06:19:32 am »
on clock speeds, if you want to delay 2us, you just need to waste 16*2+1 cycles. The minimum amount of time you can delay that lines up to microseconds like that on 12.8 would be quite a bit larger. 16.5mhz is easier to deal with because in many instances you can fix the timing of some precise bit of code by just adding an extra NOP instruction somewhere. And for many things it is close enough to 16.0 that it works okay without any adjustment - certainly code written for 16.0mhz which interfaces ws2811 LEDs generally works fine at 16.5mhz because all of the timing is still within the tolerances of the receiving devices.


Arduino has only ever shipped 1mhz, 8mhz, and 16mhz devices AFAIK too, so 12mhz isn't very close to any of those, meaning timing specific code - anything which prescales the system clock to run a peripheral like PWM or serial or even the ADC need to be reconfigured, and any assembly code with specific timing needs to be adjusted. There's much less chance of things being close enough to work without adjustment.

gogol

  • Sr. Member
  • ****
  • Posts: 398
Re: a smaller, cost-reduced digispark (<$1)
« Reply #11 on: July 18, 2013, 08:30:24 am »
I have just detected, that this thread answers some of the question, I posted in http://digistump.com/board/index.php/topic,986.0.html.
My problem is, that the zeners and the pullup rendering the ports unusable for analog-read, as the voltage is limited to about 3.5V.
I created a diagram in this message http://digistump.com/board/index.php/topic,986#msg3959

I solved that problem for me now, that i destroyed the zeners and the pullup with a scalpel, and modified a programming tool (http://digistump.com/products/42) soldering those components on the backside.

Now I am still able to program the digisparc and can use analog inputs.  However its tricky to kill the components and there is always a risk, killing the digisparc complete by this action.

gogol

CBcracker

  • Jr. Member
  • **
  • Posts: 80
Re: a smaller, cost-reduced digispark (<$1)
« Reply #12 on: July 18, 2013, 09:48:35 am »

When you do the maths on this stuff, keep in mind that USB power is between 4.5 and 5.5v, and it seems more often than not usb host ports output 5.5v exactly, to make up for the voltage drop caused by resistance in usb cables and stuff like that, so a 1.7v LED may only drop the voltage down to 3.8v on some computers, which is still slightly out of spec, but maybe the 5v intolerant computers will tolerate 3.8v.


That's not what I've seen.  On PC's it's usually dead on at 5.0v.  Even cheap $2 USB battery chargers are usually in the 5.0-5.2v range.  You should never see anything over 5.25v as that should fail compliance testing; it has to be between 4.75 and 5.25v to pass.

www.usb.org/developers/devclass_docs/USB_Battery_Charging_1.2.pdf
A word of warning; don't test the voltage by sticking multimeter leads into your usb port.  It's easy to short the 5v to the shield ground and fry it.  Cut up a USB cable instead.

Just finished checking the voltage output on a few devices around the house.  PC: 5.05v, Motorola satellite decoder: 5.03v, Blu-ray player: 4.96v.
I've also been reading more USB specs, and figure the 1.5v D- pullup will have to stay; suspend mode requires it.
http://www.beyondlogic.org/usbnutshell/usb2.shtml

I've also been looking at the I-V curves for red LEDs, and a red LED rated 1.7v@20mA has a forward voltage of ~1.5v@5mA.  So connected to a typical PC @5.05v, the data lines would be at 3.55v and within the 3.6v maximum in the USB spec.

CBcracker

  • Jr. Member
  • **
  • Posts: 80
Re: a smaller, cost-reduced digispark (<$1)
« Reply #13 on: July 20, 2013, 06:10:32 pm »
The 12.8mhz stuff is really interesting. If you have any success playing with that, I'd love to see. My only reservation is that 12.8mhz would be a really annoying clock speed for doing stuff like serial, OneWire™,

I downloaded the v-usb code, and found out the code for 12.8Mhz is 244 bytes bigger than for 16.5Mhz!
So instead I'm going to try micronucleus @16.5Mhz when I finish building my digispark clone.
First I need to get some different red LED's to try for dropping the voltage.  I tested the 3mm red LEDs I have on hand and they appear to be 2.2v.  With a 1400Ohm series resistor and power from a couple NiMh cells the current was 0.6mA, and the drop across the resistor was 1.825v (& 0.8v drop from the resistor).  I figure I'll need at least 3.5v to safely be able to run an ATtiny85 @16.5Mhz.

CBcracker

  • Jr. Member
  • **
  • Posts: 80
Re: a smaller, cost-reduced digispark (<$1)
« Reply #14 on: July 20, 2013, 06:24:12 pm »
3.6v is in the USB specifications as the absolute maximum voltage a usb device should connect to a data pin when trying to communicate with the host, and people say there are some computers which do not in fact talk to 5v devices (though they aren't damaged by them at all - it just doesn't work).

After reading more of the spec, the host port must be able to handle >3.6v for speed detection.  With a 1.5K pullup to vbus (+5) on the usb device and 15K pulldown on the host side, the voltage will settle out at 4.5v.
If people are having problems interfacing AVR MCUs @5v, the problem could be improper termination.  The following document indicates a low-speed device should have 50-150pf capacitors to ground on D+ and D-:
http://www.semtech.com/images/datasheet/usb_line_termination.pdf
The digispark doesn't have any, and I haven't seen any used on the usbasp schematics or on Stephan's tinyusbboard.