Babygnusbuino: Difference between revisions

From SGMK-SSAM-WIKI
Jump to navigation Jump to search
No edit summary
 
(18 intermediate revisions by 2 users not shown)
Line 1: Line 1:
THERE's a '''NEW VERSION''' with more free pins n stuff ! Visit [[Babygnusbuino-v2]]
[[File:Babygnusbuino.jpg|640px]]
[[File:Babygnusbuino.jpg|640px]]


Line 7: Line 9:


[[File:babyGnusbuino_new_lifepatchversion3.jpg|640px]]
[[File:babyGnusbuino_new_lifepatchversion3.jpg|640px]]
[[File:BabyGnusbuino_2.jpg|640px]]


'''<span style="color:red">Attention</span> This project is still work in progress - more of a proof of concept. I'm able to upload a blink sketch and it works, but there is some testing to be done. Hardware design could change - not sure if this is the best pin configuration - and the bootloader is a bit sketchy…'''
'''<span style="color:red">Attention</span> This project is still work in progress - more of a proof of concept. I'm able to upload a blink sketch and it works, but there is some testing to be done. Hardware design could change - not sure if this is the best pin configuration - and the bootloader is a bit sketchy…'''
Line 78: Line 82:


[[File:BioBaby_v1_color_web.jpg|480px]]
[[File:BioBaby_v1_color_web.jpg|480px]]
[[File:BioBaby_boards.jpg|320px]]


====LIFEPATCH-BabyGnusbuino DIL-version====
====LIFEPATCH-BabyGnusbuino DIL-version====
Line 96: Line 98:


[[File:BabyHONFuino_v0_color_web.jpg|480px]]
[[File:BabyHONFuino_v0_color_web.jpg|480px]]
====BabyGnusbuino 2.0 with case====
[[File:BabyOD_v9_general.jpg|480px]]
'''Mask v2.0:''' [[File:BabyOD_v9_general.pdf]]


==Programming==
==Programming==
Line 103: Line 111:


===Building / Installing===
===Building / Installing===
Hardware schematics and source code are in the SV repository at http://gnusb.svn.sourceforge.net/viewvc/gnusb/branches/gnusbuino/
Hardware schematics and source code are in the SVN repository at http://gnusb.svn.sourceforge.net/viewvc/gnusb/branches/gnusbuino/


You can either download the two folders and add their contents to the corresponding folders in your Arduino working directory, or you can pull the latest version directly through svn.
You can either download the two folders and add their contents to the corresponding folders in your Arduino working directory, or you can pull the latest version directly through svn.
Line 130: Line 138:
Bootloader:
Bootloader:


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


Fuses:
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
  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
  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
maybe change the devices on your OS
Line 244: Line 252:
* set the usb pins as outputs and turn all them off at the end of the bootloader.
* set the usb pins as outputs and turn all them off at the end of the bootloader.
* implement the servo library http://www.cunningturtle.com/attiny4585-servo-library/
* implement the servo library http://www.cunningturtle.com/attiny4585-servo-library/
* what about a sound I/O port


== other stuff ==
== other stuff ==
Line 252: Line 261:
== Example Code ==
== Example Code ==


we got some pseudo PWM working using interupts... see example below. but the delay is wrong, something has to be fixed with the timers...
=== Baby is alive | BabyGnusbuino ===
 
=== setup() ===
 
best to set the pins used for programming via USB again as outputs and low, before starting your program


<syntaxhighlight lang="c">
<syntaxhighlight lang="c">


void setup()
/*
{ // Set pins
Fading hearbeat on pin 0
   
   
  pinMode(0, OUTPUT);
  pinMode(1, OUTPUT);
  pinMode(2, OUTPUT);
  digitalWrite(0, LOW);
  digitalWrite(1, LOW);
  digitalWrite(2, LOW);
}
</syntaxhighlight>
=== PWM Heartbeat ===
<syntaxhighlight lang="c">
/*
babygnusbuino: Fading
  */
  */


int ledPin = 0;    // LED connected to digital pin 9


int PWM_Pin = 0;    // LED connected to digital pin 0
void setup()  {
int PWM_value = 0;


int wait = 30;
  TCCR0B = TCCR0B & 0b11111011; //timer pre-scaler divided by 8
 
pinMode (ledPin, OUTPUT);


volatile unsigned char e = 0;
}
void setup()
  // Timer Init
  TCCR0A = (0 << WGM02) | (0 << WGM01) | (0<< WGM00);    // Normal Mode 000
  TCCR0B = (0 << CS02) | (0 << CS01) | (1<< CS00);      // Clock Select no prescaling 001
  TIMSK = (1 << TOIE1);                                  // Overflow interrupt is enabled
  sei();                                                // set Global Interrupt Enable
 
  // Set pins
  pinMode(PWM_Pin, OUTPUT);
  digitalWrite(0, LOW);


}
void loop() {  
  // fade in from min to max in increments of 5 points:
void loop()
   for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=1) {  
{
     // sets the value (range from 0 to 255):
     analogWrite(ledPin, fadeValue);        
   for (int c = 0; c < 255; c++) {
    // wait for 30 milliseconds to see the dimming effect   
     PWM_value = c;
    delay(1);                          
    delay (wait);
   }  
  }
 
  for (int c = 255; c > 0; c--) {
    PWM_value = c;
     delay (wait);
  }
 
}
//Overflow routine for Timer 1
ISR(TIM1_OVF_vect) {
  if(e==255) {
    e=0;
    digitalWrite(PWM_Pin, HIGH);
  }
  if (PWM_value == e) { 
    digitalWrite(PWM_Pin, LOW);
   }


   e++;
   // fade out from max to min in increments of 5 points:
  for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=1) {
    // sets the value (range from 0 to 255):
    analogWrite(ledPin, fadeValue);       
    // wait for 30 milliseconds to see the dimming effect   
    delay(1);                           
  }
}
}


</syntaxhighlight>
</syntaxhighlight>


=== 3 Channels PWM ===


<syntaxhighlight lang="c">
=== Midi to pd sieche | BabyMidiGnusbuino ===


/*
==== PD part ====
babygnusbuino: PWM 3 Channels
download the pd siech [[File:babyMidi.pd.zip]]


[[File:baby_midi_pd.png|320px]]


*/
==== arduino part ====
 
<syntaxhighlight lang="c">
 
int PWM_Pin0 = 0;    // LED connected to digital pin 0
int PWM_Pin1 = 1;    // LED connected to digital pin 0
int PWM_Pin2 = 2;    // LED connected to digital pin 0


int PWM_Pin0_value = 0;
/*---------------------------------------------------------------------------------------------
int PWM_Pin1_value = 0;
int PWM_Pin2_value = 0;


int wait = 300;
  Gnusbuino MIDI Library 2012 by Michael Egger
 
volatile unsigned char e = 0;
   
   
void setup()
  SEND CONTROL CHANGE EXAMPLE combined with RECEIVE NOTE
   Read a potentiometer and send its value as a continuous controller message
   // Timer Init
   Control an LED 
   TCCR0A = (0 << WGM02) | (0 << WGM01) | (0<< WGM00);    // Normal Mode 000
    
   TCCR0B = (0 << CS02) | (0 << CS01) | (1<< CS00);      // Clock Select no prescaling 001
   This example code is in the public domain.
   TIMSK = (1 << TOIE1);                                  // Overflow interrupt is enabled
  sei();                                                // set Global Interrupt Enable


  // Set pins
--------------------------------------------------------------------------------------------- */
  pinMode(PWM_Pin0, OUTPUT);
/* The circuit:
  pinMode(PWM_Pin1, OUTPUT);
* Potentiometer attached to analog input on pin 3, center pin of the potentiometer to the analog pin
  pinMode(PWM_Pin2, OUTPUT);
* one side pin (either one) to groundthe other side pin to +5V
   
  * Put an LED on pin 4 to turn it on and off.
}
  */
void loop()
{
  for (int c = 0; c < 255; c++) {
    PWM_Pin2_value = c;
    delay (wait);
  }
 
  for (int c = 255; c > 0; c--) {
    PWM_Pin2_value = c;
    delay (wait);
  }
   
}
   
//Overflow routine for Timer 1
ISR(TIM1_OVF_vect) {
  if(e==255) {
    e=0;
    digitalWrite(PWM_Pin0, HIGH);
    digitalWrite(PWM_Pin1, HIGH);
    digitalWrite(PWM_Pin2, HIGH);


    }
   
   
  if (PWM_Pin0_value == e) { 
#include "MIDI.h"            // you have to include the Gnusbuino MIDI library
    digitalWrite(PWM_Pin0, LOW);
  }
 
  if (PWM_Pin1_value == e) { 
    digitalWrite(PWM_Pin1, LOW);
  }
 
  if (PWM_Pin2_value == e) { 
    digitalWrite(PWM_Pin2, LOW);
  }


  e++;
MIDIMessage message;
}


</syntaxhighlight>
int LED = 4;
int sensorValue = 0;        // variable to store the value coming from the sensor
int sentValue = -1;          // we only want to send data when there's something changing
                            // so we have to keep track of the last value that was sent to the host
int sensorValueLB = 0;


=== RGB Led ===
void setup() {              // nothing to do in setup, pins are inputs by default


<syntaxhighlight lang="c">
}
 
/***
babygnusbuino blend
***/


#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>


int LED0 = 0; // Blue
void loop() {
int LED1 = 1; // Red
int LED2 = 2; // Green
 
volatile unsigned char e = 0;
volatile unsigned char BRGLed[3] = {0,0,0};
 
void setup()
{
  randomSeed(analogRead(0));
 
  // Timer Init
  cli();
 
  TCCR0A = 0x00;
  TCCR0B = 0x01;
  TIMSK = (1 << TOIE1); // Overflow
 
  sei();
    
    
   pinMode(LED0, OUTPUT);
   sensorValue = analogRead(3) / 8;                       // analogRead returns 0-1023, we need 0-127
   pinMode(LED1, OUTPUT);
   if (sensorValue != sentValue) {                        // compare actual readout to last sent value   
  pinMode(LED2, OUTPUT);
     
}
      //MIDI.write(MIDI_CONTROLCHANGE, controller number , controller value )


void loop()
        MIDI.write(MIDI_CONTROLCHANGE,1,sensorValue);     // put new control change message into MIDI sending queue
{
        sentValue = sensorValue;                         // store last sent value
  int r = random(0,255);
   }
  int g = random(0,220);
   int b = random(0,220);
    
    
  for (int a = 0; a < 60; a++) {
     delay(10);             // give some time for sending, otherwhise the MIDI queue could fill up
     delay(8000);
    blend(r,g,b,a); // r g b alpha   
  }
}


  if (MIDI.read(&message)) {
     
        switch(message.command) {
            case MIDI_NOTEON:
              digitalWrite(LED,message.value);        // MaxMSP actually sends "noteon x 0" instead of "noteoff"
              break;


/*
            case MIDI_NOTEOFF:
blend color
              digitalWrite(LED,0);      
@param r Red
           
@param g Green
        }
@param b Blue
@param da Alpha: the factor how much the new color will be blended with the existing color. da = 0: no change, da = 255: new color will be set (no blending).
*/
void blend(int r, int g, int b, int da) {
 
  // source alpha
  int sa = 255 - da;
 
  int tb = (sa * BRGLed[0] + da * b) + 128;
  int tr = (sa * BRGLed[1] + da * r) + 128;
  int tg = (sa * BRGLed[2] + da * g) + 128;
 
  BRGLed[0] = ((tb>>8)+tb)>>8;
  BRGLed[1] = ((tr>>8)+tr)>>8;
  BRGLed[2] = ((tg>>8)+tg)>>8;
 
}
 
// Overflow routine for Timer 1
ISR(TIM1_OVF_vect) {
  if(e==255) {
    e=0;
    digitalWrite(LED0, HIGH);
    digitalWrite(LED1, HIGH);
    digitalWrite(LED2, HIGH);
     }
     }
  if (BRGLed[0] == e) { 
    digitalWrite(LED0, LOW);
  }
  if (BRGLed[1] == e) { 
    digitalWrite(LED1, LOW);
  }
  if (BRGLed[2] == e) { 
    digitalWrite(LED2, LOW);
  }
  e++;
}
</syntaxhighlight>


=== Flickering RGB Led ===
<syntaxhighlight lang="c">
/*
flickering RGB LED!
*/
#include <avr/io.h>
#include <util/delay.h>
unsigned long lfsr = 1;
unsigned char temp;
/**
* delay
* @param ms duration in milliseconds
*/
void delay_ms(uint16_t ms)
{
  for (uint16_t i = 0 ; i < ms ; i++) {
    _delay_ms (1); // Loop delay
  }
}
void setup()
{
  DDRB = 0xff;
}
void loop() { 
  lfsr = (lfsr >> 1) ^ (-(lfsr & 1u) & 0xd0000001u); /* taps 32 31 29 1 */
  temp = (unsigned char) lfsr; // take lowest eight bits
  DDRB = ~temp; // declare those pins as output where temp is zero
  PORTB = temp << 2; // give the value of 0 to the output pins
  temp = (unsigned char) (lfsr >> 24);
  _delay_loop_2(temp<<7);
  delay_ms(100);
}
}


</syntaxhighlight>
</syntaxhighlight>


===8-bit Noise===
== more code examples ==


<syntaxhighlight lang="c">
[[BabyGnusbuino code examples]]


/* Pseudo-Random Bit Sequence Generator                    2009-11-25 */
== Experimental: Babygnusbuino v.2.0 ==
/* Copyright (c) 2009 John Honniball, Dorkbot Bristol                  */
/*
* For a discussion of PRBS generators, see The Art Of Electronics, by
* Horowitz and Hill, Second Edition, pages 655 to 660. For more info
* on Linear Feedback Shift Registers, see Wikipedia:
*  http://en.wikipedia.org/wiki/Linear_feedback_shift_register
* For the actual shift register taps, refer to this article on noise
* generation for synthesisers:
*  http://www.electricdruid.net/index.php?page=techniques.practicalLFSRs
*/
// Choose the same pin as the "Melody" example sketch
int speakerPin = 0;
int potiPin = A3;
unsigned int analogValue;
int samplingDelay;
unsigned long int reg;
void setup ()
{
  // Serial setup for debugging only; slows down the program far too much
  // for audible white noise
  //Serial.begin (9600);
  // Connect a piezo sounder between Ground and this pin
  pinMode (speakerPin, OUTPUT);
  // Arbitrary inital value; must not be zero
  reg = 0x551155aaL;
}
void loop ()
{
  unsigned long int newr;
  unsigned char lobit;
  unsigned char b31, b29, b25, b24;
  // Extract four chosen bits from the 32-bit register
  b31 = (reg & (1L << 31)) >> 31;
  b29 = (reg & (1L << 29)) >> 29;
  b25 = (reg & (1L << 25)) >> 25;
  b24 = (reg & (1L << 24)) >> 24;
  // EXOR the four bits together
  lobit = b31 ^ b29 ^ b25 ^ b24;
  // Shift and incorporate new bit at bit position 0
  newr = (reg << 1) | lobit;
  // Replace register with new value
  reg = newr;
  // Drive speaker pin from bit 0 of 'reg'
  digitalWrite (speakerPin, reg & 1);
  // Display 'reg' in the serial console for debugging only
//  Serial.println (reg, HEX);
  samplingDelay = 1 + (2*(analogRead(potiPin)>>0));
  // Delay corresponds to 20kHz, but the actual frequency of updates
  // will be lower, due to computation time and loop overhead
  delayMicroseconds (samplingDelay);
  // If the above delay is increased to a few tens of milliseconds,
  // and the piezo sounder is replaced by an LED and a suitable series
  // resistor, a randomly flashing light will result. Several LEDs
  // could be driven from various bits of the shift register.
}
 
</syntaxhighlight>
 
 
===Crazy shit 8-bit symphony generator===
 
<syntaxhighlight lang="c">
 
/* Crazy shit 8-bit symphony generator                  */
/*    */
/*
* inspired by:
*  http://countercomplex.blogspot.com/2011/10/algorithmic-symphonies-from-one-line-of.html
*/
int speakerPin = 0;
int potiPin = A3;
long t = 0;
int v = 0;
int c = 0;


unsigned int analogValue;
[[Babygnusbuino-v2|Version 2.0]] frees up RESET pin, uses PB5 (Reset) and PB3 for USB. Three Hardware PWMs. more to come
void setup ()
{
  // Connect a piezo sounder between Ground and this pin
  pinMode (speakerPin, OUTPUT);


Github repository: https://github.com/mirdej/babygnusbuino
}
void loop ()
{
  /*
  for(t=0;;t++){
    c = (analogRead(potiPin)>>3);
    v=t*((t>>14|t>>(8))&c&t>>c);
    analogWrite (speakerPin, v);
  }
  */
 
  for(t=0;;t++){
    c = (analogRead(potiPin)>>4);
    v=t*((t>>5|t>>11)&c&t>>c);
    analogWrite (speakerPin, v);
  }
 
  /*
    for(t=0;;t++){
    c = (analogRead(potiPin)>>4);
    v=t*((t>>7|t>>(c+4))&(c)&t>>(c*3));
    analogWrite (speakerPin, v);
  }
  */
 
}
</syntaxhighlight>

Latest revision as of 16:23, 27 September 2013

THERE's a NEW VERSION with more free pins n stuff ! Visit Babygnusbuino-v2

A ridiculously small Arduino with USB interface for bootloading and/or MIDI connection, based on the gnusb / Gnusbuino project.

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.

Attention This project is still work in progress - more of a proof of concept. I'm able to upload a blink sketch and it works, but there is some testing to be done. Hardware design could change - not sure if this is the best pin configuration - and the bootloader is a bit sketchy…

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

Circuit Schematic

Pin Definitions, v2

// ATMEL ATTINY85 / BABYGNUSBUINO
//
//                        +---\/---+
//   !RESET (AD 0) PB5   1|        |8  VCC
//     (D3/A3)PWM? PB3   2|        |7  PB 2 / USB+	
//     (D4/A4)PWM? PB4   3|        |6  PB 1 / USB-
//                  GND  4|        |5  PB 0 / USB-PULLUP (D0/A40)PWM?
//                        +--------+
//

New pin definitions file: File:Pins arduino.h.zip put in ./sketchbook/hardware/Gnusbuino/variants/attiny85

Pin Definitions, v3 as DigiSpark

Pin outs: All pins can be used as Digital I/O

  • Pin 0 → I2C SDA, PWM (LED on Model B)
  • Pin 1 → PWM (LED on Model A) Pin
  • 2 → I2C SCK, Analog
  • Pin 3 → Analog In (also used for USB+ when USB is in use)
  • Pin 4 → PWM, Analog (also used for USB- when USB is in use)
  • Pin 5 → Analog In
// ATMEL ATTINY45 / ARDUINO
//
//                         +-\/-+
//        Ain0 (D 5) PB5  1|    |8  Vcc
// USB+ / Ain3 (D 3) PB3  2|    |7  PB2 (D 2)  Ain1
// USB- / Ain2 (D 4) PB4  3|    |6  PB1 (D 1) pwm1
//                   GND  4|    |5  PB0 (D 0) pwm0
//                         +----+

PCB

File the board so that the brackets around the DIY USB connector are just barely visible, this should give the right fit.

Most PCB material is a little too thin, so this connector wiggles a lot inside the USB port - it's best to glue some cardboard or thin aluminum to the back of the board to make it slightly thicker.

Full SMD version

Scaled 400%

File:Babygnusbuino smd.pdf

DIL version

Scaled 400%, die löcher grad wegmachen oder.... ist ja pseudo-smd

File:Babygnusbuino dil.pdf


Bio Baby hackteria DIL/SMD-version

LIFEPATCH-BabyGnusbuino DIL-version

File:BabyPatchuino DIL v03.zip

!ATTENTION: DESIGN MISTAKE. THE USB PLUG IS TOO SHORT!

Mask v0.4: File:BabyPatchuino MASK v04.pdf

BabyHONFuino DIL-version

BabyGnusbuino 2.0 with case

Mask v2.0: File:BabyOD v9 general.pdf

Programming

Source Code

The source code can be found in the SVN repository of the Gnusbuino [[1]]

Building / Installing

Hardware schematics and source code are in the SVN repository at http://gnusb.svn.sourceforge.net/viewvc/gnusb/branches/gnusbuino/

You can either download the two folders and add their contents to the corresponding folders in your Arduino working directory, or you can pull the latest version directly through svn.

cd "the/path/to/Arduino/"    (for me on a Mac it is cd ~/Users/me/Documents/Arduino)
svn co https://gnusb.svn.sourceforge.net/svnroot/gnusb/branches/gnusbuino/hardware
svn co https://gnusb.svn.sourceforge.net/svnroot/gnusb/branches/gnusbuino/libraries

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

svn update

Flashing the bootloader

The Bootloader is based on the USBasploader-tiny85 [[2]] - and of course on V-USB [[3]], 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: [[4]]) - where the chip is mounted temporarily and held in place with a paper clip:

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

Avrdude issues

Unfortunately, the current ATTINY85 bootloader does not cope well with the speed at which it gets its data from avrdude, so the Arduino IDE does not work out of the box to program the Babygnusbuino. You'll have to compile a slower version of avrdude and replace the one that comes with Arduino (inside the Arduino Application).

(from my read me file:)

  • download avrdude source code here[[5]] (I was using 5.11)
  • replace the file usbasp.c with the one in variants/attiny85/avrdude patch
  • compile avrdude:
        ./configure
          make
  • replace the file /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avrdude with the newly compiled one

see also https://github.com/embedded-creations/USBaspLoader-tiny85/issues/1

Still, I sometimes have to try uploading three times until the "broken pipe" errors go away. Still work to do on this bootloader, guys…


Precompiled Binaries

MacOS X

Here is a patched version of avrdude - compiled for MacOS X 10.7. Nut sure if it works with other versions.

File:Avrdude tiny85 hack.zip

this is the compiled version of avrdude with libusb, i tested it on snow leopard and mountain lion so it should works on lion too (manticore)

File:Avrdude.5.11.1-libusb.zip

win 7

Here is a version of avrdude - compiled for Windows 7 x64

File:Avrdude-5.11-win7-x64-Gnusbuino-Hack.zip

A manual on how to compile avrdude for windows from source can be found here: http://tomeko.net/other/avrdude/building_avrdude.php (Note for the manual: in the libusb version 1.2.6.0 you have to rename "lusb0_usb.h" to "usb.h" so the avrdude source compiles fine.)

Uploading a sketch

When you plug in the Babygnusbuino it will first start into the bootloader and present itself as "USBasp" to the host computer. After about five seconds, if there's no activity, it will automatically start the main program. To upload a sketch:

  1. plug in Babygnusbuino
  2. within 2-3 seconds hit the "upload" button in Arduino

Sometimes I have to try several times - the timing is not always easy to get right. Also, bootloader is still a bit shaky, doesn't work every time. Be sure to read the results in the debug window.

Questions

  • what to do with the boards.txt file? (dusjagr)
    • Just leave it in .Documents/Arduino/hardware/Gnusbuino/
  • where to put stuff in linux? (avrdude is here: ./arduino-1.0.1/hardware/tools/)
    • I'd rename ./arduino-1.0.1/hardware/tools/avrdude to avrdude_bak or something, just in case. Then put new hacked avrdude at its place
  • what about the reset pin, aka PB5?
    • still no sure about that one. I wanted to leave it a reset so I can jump into bootloader without unplugging/replugging the thing. But on my board that doesn't seem to work, somehow. Otherwise you can set fuses to have it as a normal pin - but then you cannot reflash the bootloader anymore. As this project is pretty fresh (and the bootloader seems somewhat crappy, that doesn't seem to be very clever, for the moment).
    • Another Pin that could probably be freed up is PB0 - and tying D- through 1k6 directly to VCC. I needed this mechanism on the original gnusb for usb disconnecting and reconnecting but I'm not sure if it is really needed in this case. Will make some more research (don't disable RESET, yet ;-)
      • just hack the pins_arduino.h and add PB0 as Pin 2, and there you go. dont even need to change the resitor. we soldered the PD0 to the pads, where reset used to go
    • seems the easy logger just has a 2.2k resistor from vcc to D-....
  • can i send info/data to a computer? to use it in pd or similar software?
    • UPDATE: MIDI seems to work now on the Babygnusbuino, too. Use svn update to get the newest versionI'll try to adapt the Midignusbuino core for the Attiny85 as soon as I can. The first idea was to emulate a standard serial-class-device (CDC-Class) but apparently that could prove to be more difficult: "The back door to the low-speed bulk transfer is gradually closing on the newer OS. After enjoying this USB technology, switch to the HID protocol or to MCU having on-chip USB controller." [6] (mirdej)
    • MIDI works super for PD

  • I choose the Babygnusbuino in the arduino /Tools/Board but which programmer?
    • no need to chose a programmer - the boards.txt file defines USBasp as the programmer
  • can i burn the bootloader from the Arduino IDE, with eg. Arduino-ISP? using an ISP connection?
    • should work (before soldering the chip on board)
  • on what internal clock is the Attiny85? 1MHZ? 8MHZ?
    • 16.5 Mhz internal PLL, calibrated to +/- 1% by listening to USB packets
    • 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 (something like this?)
      • exactly the fuses I used, too: -U lfuse:w:0xe1:m -U hfuse:w:0xdd:m-U efuse:w:0xfe:m
  • my arduino IDE doesnt see the USBasp
    • check your soldering and make sure u had the right parts
    • timing when you plug in your Baby..

Installing it on ubuntu 12.04/linux (dusjagr)

  • download the gnusbuino folder from here: http://gnusb.svn.sourceforge.net/viewvc/gnusb/branches/gnusbuino/
  • copy the folder ./gnusbuino/hardware/Gnusbuino into your personal arduino folder ~/sketchbook/hardware/* create the hardware folder yourself if needed.
  • make the avrdude as described above
    • had to install: (in addition to many things already there)
      • bison
      • flex
      • libusb-devel
    • and remove:
      • byacc-j
  • copy avrdude into folder ./arduino-1.0.1/hardware/tools
  • device showed up with "lsusb" as: Bus 001 Device 007: ID 16c0:05dc VOTI shared ID for use with libusb
  • had to change "only root access" for usbasp as described here:
    • The fix: Create a file called 10-usbtinyisp.rules in directory /etc/udev/rules.d
# USBtinyISP Programmer rules
SUBSYSTEMS=="usb", ATTRS{idVendor}=="1781", ATTRS{idProduct}=="0c9f", GROUP="adm", MODE="0666"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="0479", GROUP="adm", MODE="0666"
# USBasp babygnuspuino Programmer rules
SUBSYSTEMS=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="05dc", GROUP="adm", MODE="0666"
    • Then execute:
sudo restart udev

Ideas

  • what about a short digitalRead in the beginning of the bootloader (maybe at one of the USB pins?) so if a jumper is set, it directly goes into the program. so it start faster if installed.
  • set the usb pins as outputs and turn all them off at the end of the bootloader.
  • implement the servo library http://www.cunningturtle.com/attiny4585-servo-library/
  • what about a sound I/O port

other stuff

der frickelt auch mit ner spezial version von arduino.... http://www.kickstarter.com/projects/digistump/digispark-the-tiny-arduino-enabled-usb-dev-board/posts/350928

Example Code

Baby is alive | BabyGnusbuino

/*
 Fading hearbeat on pin 0
 
 */

int ledPin = 0;    // LED connected to digital pin 9

void setup()  { 

  TCCR0B = TCCR0B & 0b11111011; //timer pre-scaler divided by 8
  
pinMode (ledPin, OUTPUT);

} 

void loop()  { 
  // fade in from min to max in increments of 5 points:
  for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=1) { 
    // sets the value (range from 0 to 255):
    analogWrite(ledPin, fadeValue);         
    // wait for 30 milliseconds to see the dimming effect    
    delay(1);                            
  } 

  // fade out from max to min in increments of 5 points:
  for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=1) { 
    // sets the value (range from 0 to 255):
    analogWrite(ledPin, fadeValue);         
    // wait for 30 milliseconds to see the dimming effect    
    delay(1);                            
  } 
}


Midi to pd sieche | BabyMidiGnusbuino

PD part

download the pd siech File:BabyMidi.pd.zip

arduino part

/*---------------------------------------------------------------------------------------------

  Gnusbuino MIDI Library 2012 by Michael Egger
 
  SEND CONTROL CHANGE EXAMPLE combined with RECEIVE NOTE
  Read a potentiometer and send its value as a continuous controller message
  Control an LED  
  
  This example code is in the public domain.

--------------------------------------------------------------------------------------------- */
/* The circuit:
 * Potentiometer attached to analog input on pin 3, center pin of the potentiometer to the analog pin
 * one side pin (either one) to ground,  the other side pin to +5V
 * Put an LED on pin 4 to turn it on and off.
 */

 
#include "MIDI.h"            // you have to include the Gnusbuino MIDI library

MIDIMessage message;

int LED = 4;
int sensorValue = 0;         // variable to store the value coming from the sensor
int sentValue = -1;          // we only want to send data when there's something changing
                             // so we have to keep track of the last value that was sent to the host
int sensorValueLB = 0;

void setup() {               // nothing to do in setup, pins are inputs by default

}


void loop() {
  
  sensorValue = analogRead(3) / 8;                       // analogRead returns 0-1023, we need 0-127
  if (sensorValue != sentValue) {                         // compare actual readout to last sent value    
       
      //MIDI.write(MIDI_CONTROLCHANGE, controller number , controller value )

        MIDI.write(MIDI_CONTROLCHANGE,1,sensorValue);     // put new control change message into MIDI sending queue
        sentValue = sensorValue;                          // store last sent value
  }
  
    delay(10);              // give some time for sending, otherwhise the MIDI queue could fill up

  if (MIDI.read(&message)) {
      
        switch(message.command) {
            case MIDI_NOTEON:
              digitalWrite(LED,message.value);        // MaxMSP actually sends "noteon x 0" instead of "noteoff"
              break;

            case MIDI_NOTEOFF:
              digitalWrite(LED,0);        
             
        }
    }

}

more code examples

BabyGnusbuino code examples

Experimental: Babygnusbuino v.2.0

Version 2.0 frees up RESET pin, uses PB5 (Reset) and PB3 for USB. Three Hardware PWMs. more to come

Github repository: https://github.com/mirdej/babygnusbuino