Usblinky: Unterschied zwischen den Versionen

aus Metalab Wiki, dem offenen Zentrum für meta-disziplinäre Magier und technisch-kreative Enthusiasten.
Zur Navigation springenZur Suche springen
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
 
(11 dazwischenliegende Versionen von 3 Benutzern werden nicht angezeigt)
Zeile 3: Zeile 3:


'''usblinky'''
'''usblinky'''
* is a small usb stick with 4 wires on on end
* is a small usb stick with 4 wires on one end
* controls up to 150 addressable RGB lights (for example WS2812B)
* controls up to 150 addressable RGB lights for example WS2812B, the current is the limiting factor here. if you run them directly form your USB port 20 individual pixels will work
* can run stand alone from a USB power supply once programmed
* can run stand alone from a USB power supply once programmed
* consists of:
* consists of:
Zeile 12: Zeile 12:




== Media ==


{| border=0 cellspacing="0" style="border-collapse:collapse;"
{| border=0 cellspacing="0" style="border-collapse:collapse;"
|-
|-
|style="vertical-align:top"|[[Bild:usblinky_stick.jpg|thumb|300px|...]]
|style="vertical-align:top"|[[Bild:usblinky_stick.jpg|thumb|300px|Assembled Stick]]
|style="vertical-align:top"|[[Bild:usblinky_parts.png|thumb|300px|...]]
|style="vertical-align:top"|[[Bild:usblinky_parts.png|thumb|300px|All the parts]]
|style="vertical-align:top"|[[Bild:usblinky_ledstrip.png|thumb|300px|...]]
|style="vertical-align:top"|[[Bild:usblinky_ledstrip.png|thumb|300px|Shine on!]]
|-
|-
|style="vertical-align:top"|[[Bild:usblinky_orb.png|thumb|300px|..]]
|style="vertical-align:top"|[[Bild:usblinky_orb.png|thumb|300px|3D ORB]]
|style="vertical-align:top"|[[Bild:usblinky_orb2.png|thumb|300px|...]]
|style="vertical-align:top"|[[Bild:usblinky_orb2.png|thumb|300px]]
|style="vertical-align:top"|[[Bild:usblinky_orb_printer.png|thumb|300px|..]]
|style="vertical-align:top"|[[Bild:usblinky_orb_printer.png|thumb|300px]]
|-
|-
|}
|}
Zeile 34: Zeile 31:
(in case there is no embedded video look [https://www.youtube.com/watch?v=iY2UvfaMfJs here] and  [https://www.youtube.com/watch?v=cYPhyNVSkh4 here]
(in case there is no embedded video look [https://www.youtube.com/watch?v=iY2UvfaMfJs here] and  [https://www.youtube.com/watch?v=cYPhyNVSkh4 here]


 
== Software ==
 
 
 
 
 
 
===Software===
usblinky uses the [https://github.com/micronucleus/micronucleus micronucleus bootloader] that speaks USB in software and enables the ATTINY85 to be programmed directly over USB.
usblinky uses the [https://github.com/micronucleus/micronucleus micronucleus bootloader] that speaks USB in software and enables the ATTINY85 to be programmed directly over USB.


Zeile 50: Zeile 40:




== How ==
== How / Why==
I started this project after [[Benutzer:pl|pl]], [[Benutzer:Crazy-chris|chris]] and [[Benutzer:overflo|I]] went to make munich 2015 to represent the metalab and the hackerspaceshop.com project there.
I started this project after [[Benutzer:pl|pl]], [[Benutzer:Crazy-chris|chris]] and [[Benutzer:overflo|I]] went to make munich 2015 to represent the metalab and the hackerspaceshop.com project there.


Zeile 71: Zeile 61:
But this microcontroller was too small to do fancy effects and so i made a completely new design for this job.
But this microcontroller was too small to do fancy effects and so i made a completely new design for this job.


Later on I finally found a reason to check out [http://www.openscad.org/ OpenSCAD] and boy do I like that. What a great tool!


 
I made a fully parametric design to use with the usblinky as a psychedelic nightlight.


== Alternate usecases ==
== Alternate usecases ==
Zeile 78: Zeile 69:


This stick illuminated a big white button that spits out "PING\n" over USB keyboard when pressed
This stick illuminated a big white button that spits out "PING\n" over USB keyboard when pressed




Zeile 88: Zeile 80:
They speak USB over vUSB but enumerate the device as a usbtiny programmer.
They speak USB over vUSB but enumerate the device as a usbtiny programmer.


The arduino sees a programmer and progremms the ATTINY85 as a target, when it actually overwrites its own FLASH with the user program.
The arduino sees a programmer and programms the ATTINY85 as a target, when it actually overwrites its own FLASH with the user program.


I liked that nifty approach and used the Trinket bootloader when i started this project.
I liked that nifty approach and used the Trinket bootloader when i started this project.


But then i read that adafruit does not wnt you to use their USB ID in a product that you sell.
But then i read that adafruit does not want you to use their USB ID in a product that you sell.


I contacted them but got no meaningful reply, only a standardized answer that i should come back once my product launched.
I contacted them but got no meaningful reply, only a standardized answer that i should come back once my product launched.
Zeile 98: Zeile 90:
Later on i found out that the bootloader on the trinket is fragile.
Later on i found out that the bootloader on the trinket is fragile.


Under some special circumstances it can happen that the bootloader falsy triggers and the FLASH on the MCU is damaged and it can not be programmed any more over USB.
Under some special circumstances it can happen that the bootloader wrongful triggers and the FLASH on the MCU is partially overwritten and it can not be programmed any more over USB.


It can still be recovered with a dedicated programmer but this was to fragile for my usecase.


===Digispark / micronucleus===
===Digispark / micronucleus===
Zeile 107: Zeile 100:
This bootloader is significantly smaller (2k versus 3.5k) and the code is much more straight forward than the trinket bootloader.
This bootloader is significantly smaller (2k versus 3.5k) and the code is much more straight forward than the trinket bootloader.


The drawback is that you need to modify the arduino environment, but there are packages available for that.
The drawback is that you need to modify the Arduino environment a little more than with the Adafruit Tinket but there are packages available for that.


When I used the usblinky as a BUTTON for the selfiebooth setup I realized that the pinout differs on the trinket.
When I used the usblinky as a BUTTON for the selfiebooth setup I realized that the pinout differs on the trinket.


D+ and D- are switched on the MCU side.
D+ and D- are swapped on the MCU side.


In theory not a big deal, but a lot of libraries that are available for the digispark project (for example the USB keyboard emulation) has this pinout hardcoded and I needed to modify the .cpp files in the Arduino environment to make that work.
In theory not a big deal, but a lot of libraries that are available for the digispark project (for example the USB keyboard emulation) has this pinout hardcoded and I needed to modify the .cpp files in the Arduino environment to make that work.
Zeile 117: Zeile 110:
Future versions of USBlinky have the pins swapped as on the original digispark design.
Future versions of USBlinky have the pins swapped as on the original digispark design.


=== Merging the .hex files ===


When i programmed the first few usblinky sticks i just uploaded the bootloader and flashed the usblinky program later directly over USB.


That worked great but was timeconsuming, so i looked into merging the bootloader and the userprogram into one .hex file to flash at once.
Turns out that is difficult.
I tried many different approaches but didn't succeed till I did this:
* flash the bootloader
* load the userprogram over USB
* read back the flash from the attiny (avrdude -p attiny85 -P usb -c usbtiny -U flash:r:flash.hex:i)
* write that dump to future usblinky sticks
All the relevant script for reading and writing and a script for semi-automated flashing in a loop can be found [https://github.com/hackerspaceshop/usblinky/tree/master/software/builds/scripts here on github]


== Who ==
== Who ==
* [[Benutzer:Overflo|Overflo]] -The whole USBLINKY project.
* [[Benutzer:Overflo|Overflo]] -The whole USBLINKY project.
* [[Benutzer:clifford|clifford]], [[Benutzer:marius|marius]]  - OpenSCAD  THANK YOU!!  
* [[Benutzer:clifford|clifford]], [[Benutzer:MariusKintel|marius]]  - OpenSCAD  THANK YOU!!  
* [[Benutzer:cs|cs]] - vUSB from OBDEV is amazing. Thank you so much.
* [[Benutzer:cs|cs]] - vUSB from OBDEV is amazing. Thank you so much.


==Links==
[http://www.hackerspaceshop.com/blinky/usblinky.html hackerspaceshop, buy one there]


 
[https://www.tindie.com/products/hackerspaceshop/usblinky/ also available on tindie]
 
 
==Links==
[http://www.hackerspaceshop.com/blinky/usblinky.html hackerspaceshop]


[https://github.com/hackerspaceshop/usblinky github]
[https://github.com/hackerspaceshop/usblinky github]

Aktuelle Version vom 16. März 2015, 09:18 Uhr

What

usblinky

  • is a small usb stick with 4 wires on one end
  • controls up to 150 addressable RGB lights for example WS2812B, the current is the limiting factor here. if you run them directly form your USB port 20 individual pixels will work
  • can run stand alone from a USB power supply once programmed
  • consists of:
    • ATTINY85
    • micronucleus 1.11 bootloader based on vUSB



Assembled Stick
All the parts
Shine on!
3D ORB
Usblinky orb2.png
Usblinky orb printer.png


{{#ev:youtube|iY2UvfaMfJs}} {{#ev:youtube|cYPhyNVSkh4}}

(in case there is no embedded video look here and here

Software

usblinky uses the micronucleus bootloader that speaks USB in software and enables the ATTINY85 to be programmed directly over USB.

A modified arduino environment for this task can be found here

All the sources are available on github.


How / Why

I started this project after pl, chris and I went to make munich 2015 to represent the metalab and the hackerspaceshop.com project there.

It was a blast!

On the second day a guy asked for a microcontroller and a high power led to illuminate a 3D-printed vase he made.

We had no Highpower RGB leds on hand but we gave him a microcontroller and a piece of ws2812 ledstrip (thanks to pl for that great idea!)

Turns out it looked pretty groovy.

So the next day the guys returned the microcontroller and ledstrip and asked if this could be available as a kit.

I said that a full blown ATMEGA32U4 is a waste of resources for that kind of application.. and this is how this project started.

Johannes from ehajo was also there showing off a usbstick with an attiny2313 on board that can be used as a AVR programmer.

I got a handful of these sticks and made a new firmware to drive ledstrips with it.

But this microcontroller was too small to do fancy effects and so i made a completely new design for this job.

Later on I finally found a reason to check out OpenSCAD and boy do I like that. What a great tool!

I made a fully parametric design to use with the usblinky as a psychedelic nightlight.

Alternate usecases

A usblinky stick was used in the selfiebooth installed for the time travellers party.

This stick illuminated a big white button that spits out "PING\n" over USB keyboard when pressed



Pitfalls and lessons learned

Adafruit Trinket

Adafruit built another bootloader that uses a similar trick than micronucleus.

They speak USB over vUSB but enumerate the device as a usbtiny programmer.

The arduino sees a programmer and programms the ATTINY85 as a target, when it actually overwrites its own FLASH with the user program.

I liked that nifty approach and used the Trinket bootloader when i started this project.

But then i read that adafruit does not want you to use their USB ID in a product that you sell.

I contacted them but got no meaningful reply, only a standardized answer that i should come back once my product launched.

Later on i found out that the bootloader on the trinket is fragile.

Under some special circumstances it can happen that the bootloader wrongful triggers and the FLASH on the MCU is partially overwritten and it can not be programmed any more over USB.

It can still be recovered with a dedicated programmer but this was to fragile for my usecase.

Digispark / micronucleus

That was the point that i took a closer look at the micronucleus bootloader.

This bootloader is significantly smaller (2k versus 3.5k) and the code is much more straight forward than the trinket bootloader.

The drawback is that you need to modify the Arduino environment a little more than with the Adafruit Tinket but there are packages available for that.

When I used the usblinky as a BUTTON for the selfiebooth setup I realized that the pinout differs on the trinket.

D+ and D- are swapped on the MCU side.

In theory not a big deal, but a lot of libraries that are available for the digispark project (for example the USB keyboard emulation) has this pinout hardcoded and I needed to modify the .cpp files in the Arduino environment to make that work.

Future versions of USBlinky have the pins swapped as on the original digispark design.

Merging the .hex files

When i programmed the first few usblinky sticks i just uploaded the bootloader and flashed the usblinky program later directly over USB.

That worked great but was timeconsuming, so i looked into merging the bootloader and the userprogram into one .hex file to flash at once.

Turns out that is difficult.

I tried many different approaches but didn't succeed till I did this:

  • flash the bootloader
  • load the userprogram over USB
  • read back the flash from the attiny (avrdude -p attiny85 -P usb -c usbtiny -U flash:r:flash.hex:i)
  • write that dump to future usblinky sticks

All the relevant script for reading and writing and a script for semi-automated flashing in a loop can be found here on github

Who

  • Overflo -The whole USBLINKY project.
  • clifford, marius - OpenSCAD THANK YOU!!
  • cs - vUSB from OBDEV is amazing. Thank you so much.

Links

hackerspaceshop, buy one there

also available on tindie

github

Digispark Arduino