by on Avr Development

Getting code onto the MidiMonster or Benito device.

Midi Monster Button Locations.

Midi Monster Button Locations.

Benito 7g Switch Positions.

Benito 7g Switch Positions.

Benito 2010 Switch Locations

Benito 2010 Switch Locations

Benito Without Buttons.

Benito Without Buttons.

All of the code on the Benito and MidiMonster devices is open source and references an open source library called the Lightweight Usb For Avr (lufa). Getting the code compiled and onto the device requires a few other open source tools.

AVR-GCC

The most current and stable release of the toochain for the AVR has untill recently been maintained by Eric Wedddington and released as WinAvr (http://sourceforge.net/projects/winavr/) Winaver integrates nicely into atmels avr studio http://www.atmel.com/dyn/Products/tools_card.asp?tool_id=2725 and I reccomend that you get both if you are running windows. Each Winavr Release is closely followed by objective developments CrossPack for avr http://www.obdev.at/products/crosspack/index.html and a script for building the current toolchain on linux which is hosted by AvrFreaks at present there is also a debian package that was put out last month http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=90172

HWB? DFU?

Most Atmel “atmega” devices have a pin dedicated to determining weather or not the device goes into the bootloader depending on the devices flag settings. This pin is labled HWB (for hardware boot) on most of  the datasheets. The usb avr family has this mode set up by default. When you hold the hwb pin low and reset the device it goes into the bootloader. On these devices the built in bootloader uses a usb device class called the Device Firmware Uploader (DFU). Atmel provides a tool called flip for programming DFU devices on  windows and linux. There is an open source programmer called dfu-programmer http://dfu-programmer.sourceforge.net/

That other guys stuff.

Those of you who have worked with the teensy boards from paul stoffregon will notice some subtle differences. Paul wrote his own (closed source) bootloader rather than use the bootloader tha comes installed on the chips. Then he uses a hardware trick similar to the auto reset hack to make a single button manipulate both the reset and the hwb pins to put his boards into the bootloader. I didnt feel that either the two button arrangement or the builtin bootloaders were broken so I like most people working with these chips dont fix them.

Using the dfu-programmer

All of the programs in Dean Cameras Lightweight Usb for Avr have a “dfu” target. Once you have the target into the DFU mode you can simply

$make dfu

This will cause the dfu-programmer to erase the flash reprogramm it with a new hex file and restart the chip. You can also do this manually with the following commands

$dfu-programmer atmega32u2 erase
$dfu-programmer atmega32u2 flash mycode.hex
$dfu-programmer atmega32u2 start

This will cause the dfu-programmer to erase the flash reprogramm it with a new hex file and restart the chip.

by on Avr DevelopmentDorkbotosx-avr

What: Focused workshop: programming Midi devices using the Lightweight Usb For AVR library (Lufa) and the MidiMonster.

When: Sunday 28 Feb 2010 1-5 pm.

Where: PNCA (NW 12th and Johnson) #205

Cost: $35 (includes Midi Monster)
(If you have a MidiMonster from the PD Workshop and wish to use it please bring $10)

Materials: you Should Bring, a laptop and a mini usb cable. Please install Arduino >16 as well.

In this workshop we will be going through the firmware built by Alex Norman as an example of how to develop midi devices using the avr microcontoller. Topics covered will include:

  • The Midi Specification
  • The USB Midi Specification
  • The Lightweight Usb for AVR  library.
  • Programming the avr using avr-gcc

To reserve a place in the class please rsvp at http://tempusdictum.com/tdproducts.html

by on Mac Development

Disks Die, Laptops break, Bags are Stolen.

It’s more or less a fact of life,

In the 4 year process of transitioning from a noisy sun E-250 in the garage to something that could actually be in the same room with you I arrived at the above network arrangement.

Most of the my data is hosted by a central server and when I had more systems all of the home directories were NFS mounted (which is a major PITA on OSX). In the last hear I have worked primarily on my MacBook, occasionally syncing my projects with the file server. After migrating to leopard I purchased a 1 Terabyte external disk and backed up both the file server and my laptop using “Time Machine”. As I worked more and more on the laptop I did less and less syncing of the work to the file server. The thing about time machine is that its thoughtless. Set it up and as long as you get your laptop home and leave it on for a few hours and it should keep your work safe for you.

Two weeks ago My Bag was stolen.

On top of the work I had actively been doing I lost two active sketchbooks and in the end this loss is probably the most painful. Since I couldn’t immediately restore the data using the process described below, I spent much of last week recreating the designs for this months workshops. Once the critical work was done I turned to see what I could recover. I had used time machine to restore a couple of files I had foobared but I had never had to restore all 270G of data and applications. My Intel Imac did not have enough disk nor did it have most of the software. So I bought a 1T disk from Old Town Computers and “CarbonCopyCloner“ed a bootable operating system onto it and put it into my Intel Imac (Ernesto).

WHERE’S MY BACKUP?!?

After googling around I found that I was supposed to restore my files using the “Migration Assistant” tool. I had used migration assistant to move users and applications to new systems but never to restore files. When I first tried the migration assistant I mounted the disk remotely but I couldn’t see the backup. So I moved the disk to the target machine. Even then I only saw the option of restoring the server and not my laptop.
Panic set in until I found a file named with my laptops name and a .sparsebundle extension. Right clicking on this lets me open it with the appropriate mounting utility. But…. Not until it had checked the file system. Walking away and doing something else for a few hours let me come back to the image mounted. When I ran the migration assistant again the option of restoring the laptop was there.

SUCCESS!

Starting the restore process and going to sleep I woke to find that it had successfully restored all of my data and applications! I was only out the extra time on the designs and the actual property.

FAIURE.

Now all of my active work was on a disk which was large enough to also contain the rest of my images/music/video and web content which had been kept on the file server. Since I could see the fileserver’s backup and I was so happy with my success I tried then to restore the file server data.

Mounting your home directories on external disks on OSX is a lot like mounting them remotely. It just plain sucks. Half the time if I made any changes in the disks connected to the file server it would mount them in a different place. Then when you logged in it would create a new mount point and empty directory and you could not remount the disk where it was supposed to be until you removed the new directory.

When I restored the file server user I had few options. I could restore the user (giving an estimated size of like 20 meg , not the >400G I expected) and on the next screen I could restore the file system at the top level directory. This did not show me enough data to represent the data directory either. I could also have restored the entire system and then re-restored the Intel files over it but I really didn’t want to deal with the mess.

So I punted.

I just plugged the file server disk in and dragged my home folder to the new disk. I will probably test the restore process to the file server with the external disk attached to make sure the data is recoverable on that system. Once this is done I will reformat the time machine disk for future backups and send the file servers external disk to another state. In the mean time I will rest better knowing that my time machine backups actually work transparently while I work.

by on Mac Development

I was finally able to get my ruby/rails environment setup with my database of choice.

It wasnt easy as postgres will not build with more than one architecture at a time, I had gone through similar hell the last time I tried to build anything on OSX that had to compile against libraries made for different architectures. Fortunately the solution was relatively simple.

My database is running 64 bit and I use it for many other applications that are compiled against either multiple architectures including 64bit but also some which are 64 bit only.

Ruby on the other hand is compled for 32 bit which worked flawlessly on mysql and most of the other gems i installed when I got to the postgres it puked in weird ways and when I tried every third solution on the net it was always the same.

Bash-3.2# gem install pg
Building native extensions.  This could take a while...
ERROR:  Error installing pg:
ERROR: Failed to build gem native extension.

The bottom line from one of the only success stories that I found on the net was that you either built everything 64bit or nothing. Easy enough if you want to build all of your dependencies by yourself. The whole point of gems is to have the tools work for you. I wasnt really able to figure this out in the web full of people beating their heads on the same problem each harder than the other and each reaching the same it doesnt work conclusion but I had the fortune of getting completely away from the web long enough to realize that only the client and libraries needed to match the architecture and since all interaction between rails and the database went through a socket the architecture of the client didn’t have to be the same as the database.

so going back to my postgres source tree i did a

...postgresql-8.3.6# make distclean

and then reconfigured the database using the prefix /usr/local32

..postgresql-8.3.6# ARCHFLAGS='-arch i386' ./configure --prefix=/usr/local32/

Then I just had to tel ruby/gem to use the 32 bit libraries. Since ruby uses pg_config I made sure that the 32bit version is in the path first.

# PATH=/usr/local32/bin/:$PATH ARCHFLAGS='-arch i386' 
gem install pg  -- --with-pgsql-dir=/usr/local32/

And we are off but my god what at PITA.

by on Dorkbotelectronics

At the eagle for fabrication workshop on sunday I started with a design that Thomas Lockney threatened to build about 2 years ago called the Low Fi Arduino Guitar Pedal.

(http://www.instructables.com/id/Lo_fi_Arduino_Guitar_Pedal/)

It was simple enough to get through the necessary parts of eagle that I was teaching and while it wasn’t perfect It beat the hell out of Craig Anderton’s circuits in terms of clarity and probability of actually working. To discuss from an over view perspective creating parts I decided to add the 1/4″ jacks from another great dorkbotpdx project from Hans Lindauer.

Once I got the library part together for the 1/4″ jack I had to rearrange things quite a bit but there was still pleanty of room. The next step was to add a power connector and a regulator. The idea is to be able to mount the resulting board in one of the cheapo danelectro pedels that I have around like this

In order to get the board to work out I had to create a new package for the potentiometers but I managed to get it all to fit on the board without resorting to surface mount components.

I will post the library example latere this evening.

by on Site News

As I am rebuilding our web server I am consolodating my nerdy stuff. This domain was origionally where I placed information on my installable package for the avr-gcc toolchain for OSX which came out of the stuff I was working on.

by on Dorkbot

Workshop: circuit design for fabrication (PNCA 29Nov09 1-5pm $35)

See: http://www.dorkbotpdx.org/workshop/circuit_design_for_fabrication

boardfancy

As many of you may be aware Laen has been putting together a group ordering process for circuit board fabrications somewhat like SparkFun’s BatchPCB service except with less time lag and the fabrication is done in the USA.

To introduce you to the tools needed to create circuit boards for this service (and most other circuit board services) we are presenting a workshop teaching you how to design a circuit board using Eagle PCB with an emphasis on getting designs that can be fabricated.

Workshop Time and Location

The workshop will be offered on two dates (Pick one):
* November 29th at PNCA (NW 12th and Johnson, room 205) (Google Calendar Link)
* December 5th through OpenTechSpace at Techshop (10100 SW Allen Blvd., Beaverton, OR 97005) (Google Calendar Link)

Follow-up Session:

A follow-up session will be offered on December 6th, 1pm-5pm at PNCA , to go over your designs, help with any problems, and getting them ready for submission for fabrication.

Fabrication included

Signing up for the class gets you three copies of your (up to 2 square inch) design in the December order. Designs submitted by the 10th of December will be included in this months PCB run and can be picked up at the meeting on the 21st (or mailed).

Topics covered.

  • Creating schematics
  • Organizing your files and libraries.
  • Laying out your parts effectively.
  • Routing your signals
  • Creating / finding parts that you need.
  • Documenting your board in the silkscreen
  • Using DRUs to design for a specific board fabricator
  • Using the ERC to check your designs for problems

What you will need

You should have some basic understanding of circuits but it is not critical You will need to bring a laptop which is capable of running eagle (linux,windows or mac — see http://www.cadsoft.de/info.htm). The class is $35 and is limited to 30 so it is best to reserve a space in the class. Please rsvp at http://tempusdictum.com/tdproducts.html (eagle for fabrication)

by on Dorkbot

I wanted to quickly demonstrate using a stepper motor from a floppy drive with the Arduino/Wiring platform as a follow up to the weekend’s workshop. By the time we got to the stepper parts I was a bit scattered. So here is an example that I set up yesterday.

I have a talking George Bush doll from several years ago that was ripped in half (by people watching my punk band (w.busholini.org)) so I went ahead and finished dismantling it. For Halloween I thought his head should turn around Linda Blair style.

I wired up a ULN2803 Darlington array and a floppy drive stepper motor from the workshop as shown in the diagram above .

I figured out which wire was the common wire by taking an ohmmeter to the wires on the stepper. Most of the combinations were about 150 except from one of the wires on the end that read 75 ohms. Checking the 75 against all of the other wires I was able to determine that one of the wires was the common one and marked it with a sharpie.

Then I ran up the arduino (v 17) example program for the stepper library. I modified it so that it just made steps in one direction. When I ran it the motion was really jittery so I checked to make sure that my wiring was good and then rather than rewiring the stepper physically I changed the line in the code from

Stepper stepper(STEPS, 9, 10, 11, 12);

to

Stepper stepper(STEPS, 9, 11, 10,12);

And Whah La! his head started spinning just like he was possessed by Dick Cheney! I wired the talk button to pin 8 and then added some random delays which gave me the following.

#include <Stepper.h>

// change this to the number of steps on your motor
#define STEPS 100
int relayPin=8;
int ledPin=13;
// create an instance of the stepper class, specifying
// the number of steps of the motor and the pins it's
// attached to
Stepper stepper(STEPS, 9, 11, 10,12);

// the previous reading from the analog input
int previous = 0;

void setup()
{ pinMode(relayPin,OUTPUT);
  pinMode(ledPin,OUTPUT);
  // set the speed of the motor to 30 RPMs
  stepper.setSpeed(100);
}

void loop()
{
  // get the sensor value
  int val = analogRead(0);

  // move a number of steps equal to the change in the
  // sensor reading
  //stepper.step(val - previous);
digitalWrite(ledPin, HIGH);
stepper.step(random(5,90));
delay(random(60,2000));
digitalWrite(relayPin, HIGH);
delay(20);
digitalWrite(relayPin, LOW);
digitalWrite(ledPin, LOW);
stepper.step(-random(15,200));
delay(random(90,3000));
  // remember the previous value of the sensor
  previous = val;
}