Babygnusbuino-v2

From SGMK-SSAM-WIKI
Jump to: navigation, search

Overview

Babygnusbuino.jpg

A ridiculously small Arduino with USB interface for bootloading and/or MIDI connection, based on the gnusb / Gnusbuino project by a n y m a

Really bare-bones, no protection, no FTDI chip, single-sided PCB, no holes. The USB connector is directly etched on the board, so you actually plug in the PCB itself to upload a new sketch to the Arduino.

see the older version, no obsolete Babygnusbuino

New BabyGnusbuino V2

By disabling the RESET pin and moving the USB lines to the two least interesting pins we're able to free up four inout/output pins with the most needed functions. This allows for example for a RGB-Led (3 Hardware PWMS) and an analog sensor. Or a complete serial communication device over SPI, or a I2C sensor chain and 2 pushbuttons… all while retaining full MIDI communication to the host over USB.

Babygnusbuino-ports.gif

Apart from the special functions, each pin can function as a general purpose digital input / output.

Please note the rather bizarre numbering scheme on the Attiny85. Available pins are PB0, PB1, PB2 and PB4. If you want MIDI functionality you should not connect anything to PB3 and never write anything to this pin, otherwise the USB connection will drop. PB5 can sink a status led (a logic low on PB5 will light the led). Here again: don't ever write to this pin if you want to keep a MIDI connection -but you can see a faint blinking if there's activity on the USB line, and a more visible blinking every time the line is driven low to disconnect/reconnect the device.

If you don't need USB/MIDI functionality, you can use PB5 and PB3 for status leds (as long as you use high enough series resitors to not disturb the USB line - 1kOhm should be ok). Push buttons are ok too, but you should not try to use these two pins for analog input - it could disturb the USB lines of the bootloader.

A word of warning

This is minimalist hardware with no safety features whatsoever.

Inserting a Babygnusbuino in your computers USB port exposes its electrical components to the outside world - this is the equivalent of running around with a double edged sword IN YOUR MOUTH: it's fun and exciting but you better not trip over… Take special care with external power sources - you can easily fry your computers USB port and ALL the devices (webcams, mice etc..) connected to the same port.

You've been warned. but dusjagr has been warned too late :-(

Building

Parts List

The only parts needed are:

  • 1 Atmel Attiny85 microprocessor
  • 2 resistors 68 Ohms
  • 2 zeners 3.3V
  • 1 resistor 1k6
  • 1 capacitor 100n

optional: another 1k6 resistor and LED

Schematic

Babygnusbuino2Schematic.gif

Variants

Reference design

This version can be equipped with normal SMD or smd-style through hole parts… (500%) Baby2013-08-01.gif Baby2013-08-01-parts.png IMG 2428.JPG File:15babies.pdf

Breadboardbabygnusbuino

Midify your breadboard with this version of the Babygnusbuino:

Bbbgnusbuino.png Breadboardbabygnusbuino-pcb.png File:Breadboardbabygnusbuino-pcb.pdf

Download

Babygnusbuino now lives on Github. There's an Arduino hardware description folder (goes into …sketchbook/hardware/ ) and the GnusbuinoMIDI library for USB-MIDI functionality (goes into …sketchbook/libraries/ ). You can either download the two folders and add their contents to the corresponding folders in your Arduino working directory (if they do not exist yet, you have to create them manually), or - better - you pull the latest version directly through git:

Cloning the repository on Github

cd "the/path/to/Arduino/"    (for me on a Mac it is cd ~/Documents/Arduino/  and on Ubuntu it is cd ~/sketchbook/ )
git clone https://github.com/mirdej/babygnusbuino.git hardware/babygnusbuino
git clone https://github.com/mirdej/GnusbuinoMIDI.git libraries/GnusbuinoMIDI

later on, you can always update to the latest version by typing

git pull

Flashing the bootloader

The Bootloader is based on the USBasploader-tiny85 [[1]] - and of course on V-USB [[2]], the virtual USB driver from objective-development.

To get as small as possible, the board does not contain a ISP connector. We'd need it only once to flash the bootloader, anyway. From then on the chip can be reprogrammed directly trough USB. In order to flash the small outline smd chip, I made an adapter plate for the Gnusb-Prog (see: [[3]]) - where the chip is mounted temporarily and held in place with a paper clip:

Tiny smd prog.jpg Tiny smd prog clip.jpg

File:Babygnusb programmer eagle.zip

File:Tiny prog smd.pdf


Bootloader:

avrdude -P /dev/ttyUSB0 -b 19200 -c avrisp -p t85 -U flash:w:attiny85.hex:i

Fuses:

new: avrdude -P /dev/ttyUSB0 -b 19200 -c avrisp -p t85 -U lfuse:w:0xe1:m -U efuse:w:0xfe:m -U hfuse:w:0x5d:m
old: avrdude -P /dev/ttyUSB0 -b 19200 -c avrisp -p t85 -U lfuse:w:0xe1:m -U hfuse:w:0xdd:m -U efuse:w:0xfe:m

maybe change the devices on your OS

Patching avrdude

The Babygnusbuino has a bootloader ("ATtiny85 USB Boot Loader" by Louis Beaudoin / embedded creations) and can thus be reprogrammed directly via USB without the need for a AVR ISP programmer. Unfortunately, because of the architecture of the ATTINY85, this has to be done a bit slower than usual and the avrdude uploader program that ships with the Arduino IDE is a bit too fast. You will get errors like "broken pipe" and "transmission stalled" and your upload will fail miserably.

The problem and a description of the great job Louis did to get a working bootloader for the Attiny in more detail here: http://embedded-creations.com/projects/attiny85-usb-bootloader-overview/details/

The solution is to patch avrdude (compile a customized version of it) so that it recognizes when we try to program an Attiny85 and slows down its speed - and to replace the version that comes bundled with Arduino with our patched version.

gnubl

An additional benefit: the new avrdude contains some special command that kicks (or tries to kick) the Babygnusbuino into bootloader-mode before programming. No need to unplug/replug and quickly hit upload in under 5 seconds… This feature only works when the Babygnusbuino is connected as a functional MIDI device.

On Mac

Either: use the binary

You can try to use the binary in ~/Documents/Arduino/hardware/baygnusbuino/patch/mac/

cd ~/Documents/Arduino/hardware/baygnusbuino/patch/mac/
 sudo ./install.sh (removed because too dangerous)

OR: Compile from source

cd path/to/downloaded/avrdude-6.0rc1
./configure
make

patched avrdude binary goes into: /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin

avrdude.conf goes into /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc

On Ubuntu

Either: use the binary

maybe you can use the precompiled binary in ~/sketchbook/hardware/babygnusbuino/patch/linux:

cd ~/sketchbook/hardware/babygnusbuino/patch/linux/
sudo ./install.sh

otherwise you have to compile a patched avrdude yourself

OR: Compile from source

Then


sudo apt-get install bison
sudo apt-get install flex
sudo apt-get install libusb-dev
cd path/to/downloaded/avrdude-6.0rc1
./configure
make


I also had to correct permissions for libusb. Not sure this is the right way, but anyway:

sudo gedit /lib/udev/rules.d/50-udev-default.rules

change

# 'libusb' device nodes
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", MODE="0664"

to

# 'libusb' device nodes
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", MODE="0666"

see http://unix.stackexchange.com/questions/44308/understanding-udev-rules-and-permissions-in-libusb

testing the midi with alsamidi

http://linux.die.net/man/1/amidi

list midi devices

amidi -l

show what's happening on the midi port

amidi -p hw:1,0,0 -d

send a control change to the midi device (in our example it turns on the LED on PB0)

dusjagr@dusjagr-pink:~$ amidi -p hw:1,0,0 -S 'B0 01 01'
dusjagr@dusjagr-pink:~$ amidi -p hw:1,0,0 -S 'B0 01 00'

here is the MIDI test code for the baby http://wiki.sgmk-ssam.ch/index.php/BabyGnusbuino_code_examples#test_MIDI_send_receive

Application examples

various code examples

see Babygnusbuino version 1.0 for some examples. adapt pins accordingly

  • Don't use PB3/PB5 if you want MIDI
  • Software PWM is not needed anymore

8bit Mix Tape

8bit mixedTapev03.jpg

8bit mixedTapev05.jpg

See the details on the other project page about the 8bit Mix Tape

ThereMIDI

BabyThereMIDIGnusbuino V2.jpg

the question is whether to stick to classic theremin and heterodyne principle reduce it to some extent into arduino - derive the fixed freq oscillator from some clock or to just measure the high frequency directly and translate this to midi tones in this last case there needs to be just one outside oscillator - there is some schematics around from Koeln - i'm sure you are familiar with - uses one 4011 and they made a freqmeasure (or something) library for arduino

http://interface.khm.de/index.php/lab/experiments/theremin-as-a-capacitive-sensing-device/ http://interface.khm.de/index.php/lab/experiments/arduino-frequency-counter-library/

that library uses a lot of counters and timers that are not available on the attiny. maybe it can be rewritten...

another use is just with arduino CapSense library between two pins - one output, the second one input output send a short pulse via large resistor (much over 10Mohms) to digital input pin, which measures the time the voltage drops to low (something like that) - the hand is the capacitor to ground - the closer the more speedy drop to low

http://playground.arduino.cc//Main/CapacitiveSensor?from=Main.CapSense

Codes

see BabyGnusbuino_code_examples#2_10bit_sensors_to_MIDI

DIY turbidity meters

Daphnia-2-MIDI3.jpg

see hackteria wiki

BabySoftModem

Baby talks modemStaayle.jpg

Loads of more info about that stuff on hackteria-wiki about turbidity meters

This is the modified version of SoftModem, adapted for the BabyGnusbuino by Bengt Sjolen. File:SoftModem.zip

the free software Sigmira is kinda useful to test http://www.saharlow.com/technology/sigmira/

Test Code to send

<syntaxhighlight lang="c">

  1. include "SoftModem.h"
  2. include <ctype.h>

SoftModem modem;

void setup () {

 delay (10);
 modem.begin ();
 

}

int value=0; void loop () {

 //int c = modem.read ();
 modem.print ("hello blip blip blup blup world");
 value+=1;
 delay(500);

}

</syntaxhighlight>

Todo

  • Make nice pictures of new Babygnusbuinos and post them here
  • More examples
  • Clean up schematic and pcb layouts


recent issues

  • dusjagr (on ubuntu) has troubles with the new GnusbuinoMIDI library. did the newest avrdude patch... the device constantly resets. something buggy cos of gnubl?
  • bengt somehow got the new one to work on ubuntu
  • different versions of avr-gcc issues...

other related projects

older version of Babygnusbuino

Babygnusbuino.jpg

http://learn.adafruit.com/introducing-trinket/introduction