All posts by Baird Soules

DP123 Monday Madness Crazy!!!

Who gave M5 a welder, and a grinder?  And all that safety gear and clothing that renders one anonymous, and rather frightening-looking?

Team Proteus5, subdivided into further teams, now has a cacophony of grinding and sawing noises to accompany their workings-on as the build team fires up the power tools in the corner of the backroom, the future site of the M5 fabrication lab, dubbed Fab5.

Fab5 is a the future facility that will expand the build capabilities of M5 to include metalworking, woodworking, and plastic and glass work.  We have, so far, a welder and grinder.

At this week’s Play the Room, we decided against playing the room in the literal sense, with solenoids on the pipes and ducts and such throughout the Good Room, primarily to cut down on the amount of tubing and mounting hardware required for such an endeavor, as to save time and fully realize our goal of an electromechanical, MIDI-controlled instrument.
We have decided, instead, to use a metal cabinet that housed some sophisticated-looking engineering equipment, including a piece at the bottom (the power supply, perhaps) that features a sign: DANGER / LETHAL VOLTAGE.
We gutted all the cables out of it and found some promising locations for the pneumatic actuators we have arriving soon.  Also–our arduino software is looking good!  More on all of this soon!

Programming an AVR using the Arduino (based on instructables)

So recently I was hoping I could start programming AVRs. I like using the Arduino IDE because it is incredibly easy, however, programming a chip using C or even Assembly is far more powerful. I was looking through everything to try and find a feasible solution to get my AVR programming started, so I searched through programming cables, dongles, DYI things, Sparkfun, Atmel, etc etc etc… I found out programming cables can get to be expensive, especially if your computer doesn’t have an RS-232 port.
Luckily, instructables.com exists and saved the day, since they have a pretty good step by step process on how to program an AVR using an Arduino!!! Making the Arduino a middleman in order to program your AVR… so brilliant and convenient! (an arduino costs about 20 dollars, much less than a USB stk mkii programming cable). The instructable is really good and I recommend following it, however I will explain the process I went through to burn a bootloader onto an ATMega168, and the same process can be used to burn a bootloader to any other AVR supported by the Arduino. I’ll also show how you can upload a hex file (from a C or ASM file) to your AVR through this Arduino circuit.

You can find the instructable here .

For the case and purpose of this blogpost, all you really need from this instructable is the Arduino circuit and where to get the code (which I’ll post a link to later on). The circuit involves hooking up the Arduino to the AVR and hooking up some nifty LED’s for debugging purposes (and because they look kind of cool when you reset the ARduino/do your AVR programming/etc). Installing WinAVR is recommendable! To do so, go to this site and get it donee!!!

The first thing to keep in mind is that these Atmel AVRs have an ISP programming option (acronym for In-System Programming). Also, the communication protocol that you can use for the programming of the hardware is SPI (Serial Peripheral Interface). Lucky for us, there are well labeled pinout diagrams for these AVR chips all over the internet, and there is a built in SPI interface on the Arduino boards (obviously, since the Arduino is based on the ATmega168/328/etc et al).
SPI is a basic protocol, but all that you need to know at this point is that you want to connect each respective Arduino pin to their “counterparts” on the AVR you wish to program.

Ok. Now, in order for your Arduino to work as a ‘middleman’ programmer, you’ll have to upload the proper code to it so that it does it’s job. I’m not taking credit for this code, because I obviously didn’t write it, so I’ll link the word after the semi-colon to the website you can find it: here. Download the latest avrisp.xx.zip and extract the code to your computer and upload it to the Arduino.

Bam! Now the LED’s in the circuit start flashing, and the last one is getting brighter, dimmer, brighter, dimmer, etc etc etc..Like a heartbeat! Its alive! You know your circuit is working! And the Arduino is ready to receive its instructions… How will it do that?? Serial Port?? nope! You’ll have to talk to avrdude from you command prompt (quite frankly it makes you feel like a pretty cool hacker). In order to have avrdude installed in your computer, you’ll need to either have Arduino installed (since you burned the code to the ARduino you probably already have that) or you can just download avrdude from its site… i think this one is pretty recent/legit. Anyhow, just make sure you have avrdude installed on your computer before proceeding, or else you’ll be communicating with a non existing entity on your computer, and your computer will think you’re crazy.

Ok. To talk to avrdude, all you have to write in the command prompt (regardless in which directory you’re in) is:
avrdude

to see a list of commands, type in
>avrdude
to your command prompt, you should get the following:


pretty easy right?!?! now let’s actually talk to the Arduino! Make sure you know what SERIAL PORT your Arduino is connected to. Usually Com5 for windows, dev/tty/USB for Mac etc.. To find what port you communicate to, open the Device manager in your control panel and see which one is active ***OR*** just open the Arduino IDE and look for the Serial Port option (like you would usually do to program the Arduino). Ok, so now you know what Port you’ll be talking to, time to find out what CHIP you have! For this part, just look at the AVR thats in your circuit and read the AT***** part. OK, now type the following in your command line

>avrdude -c avrisp

You’ll get an error message and a long list with recognizable MCU names!

Great, now just look for the MCU you have and know which one it is… I’ll be using the ATMega168 as an example because that’s the chip i used. Likewise, my COM port was COM6.
So type in the following, just modify COM6 or m168 IF NECESSARY:

>avrdude c -avrisp -b 19200 -p m168 -P COM6
(then press enter)

I usually get an error message the first time I type that in saying:
avrdude:stk500_getsync(): not in sync: resp=0x15
So i try it again (shortcut, press the up arrow for the last command you typed)
You’ll see your circuit LEDs do a weird blinking cycle, and your command prompt should look like something like this:

Great, so now your computer is successfully talking to the Arduino!
Now let’s go step-by-step to see what that command did

>avrdude -c avrisp -b 19200 -p m168 -P COM6

-c avrisp => (avrdude, I would like to use the avrisp programmer!)
-b 19200 => (avrdude, I want to change the baudrate to 19200 baud)
-p m168 => (avrdude, the part I’m using is the ATMega168)
-P COM6 => (… my Arduino is on port COM6)

We will also use a -U command which writes a specified file or fuse bit to the AVR and the -e command which erases the AVR

Ok, so now to burn the bootloader to the Arduino, you must find the bootloader file on the arduino hardware\atmega folder. If you’re using the 168, you’re lookingfor the ATmegaBOOT_168_diecimila.hex file,if you’re not using the ATmega168, use some common sense to find out what file to specify. Ok so now you have the path that the bootloader file is located in, in my case it was .
Now write these commands (**adjusting it to your configurations**)(press enter after each line, or just copy the entire thing and paste it to the command line)

>avrdude -c avrisp -p m168 -P COM6 -b 19200 -e
>cd C:\Program Files\arduino-0016\hardware\bootloaders\atmega
>avrdude -c avrisp -p m168 -P COM6 -b 19200 -U lock:w:0x3f:m -U efuse:w:0x00:m -U hfuse:w:0xDD:m -U lfuse:w:0xFF:m
>avrdude -c avrisp -p m168 -P COM6 -b 19200 -U flash:w:ATmegaBOOT_168_diecimila.hex

(If you get error messages, check your configurations!!!!!)

All we in that code was say “Hey avrdude, erase whatevers on the chip, then i want you to overwrite the fuses (-U xfuse:w:#x##:m) and this program on the flash memory (-U flash:w:ATmegaBOOT_168_diecimila.hex) I’ll leave it up to you to figure out what the fuse bits are adjusted to (but essentially you need it to se the AVR to work off an external oscillator).

To burn a HEX file, you’ll need to convert the C or ASM file to HEX (using WinAVR or AVRStudio). When you build the project, there will be a folder that saves the HEX version of your code.

now just modify the following according to your computer specifications and type

>avrdude -c avrisp -p m168 -P COM6 -b 19200 -e
>cd
>avrdude -c avrisp -p m168 -P COM6 -b 19200 -U lock:w:0x3f:m -U efuse:w:0x00:m -U hfuse:w:0xDD:m -U lfuse:w:0xFF:m
>avrdude -c avrisp -p m168 -P COM6 -b 19200 -U flash:w:.hex

GREAT! You can use and Arduino to program an AVR and to burn bootloaders.

Any question feel free to find me at M5 or e-mail me at: dbercht@student.umass.edu

PartyDuino Update

Hey y’all!

We are back with an update on the design of partyduino. The team has made significant progress with the project and is getting ready for production. The design group finished their design by adding a low-pass filter to the output. Dan and Mat created a barebones version of the partyduino that closely represents the actual PCB. They ran into issues with the bootloader but overcame those issues swiftly and had the partyduino up and running by the end of the lab. While the other teams were working on design aspects of the circuit, Mike was preparing the parts list and datasheets that will assist in the design of the PCB. The datasheets will be used to gather the dimensions of each part and to help design the footprint of the parts to be out on the PCB.

We will be back next week with another update!!!

ECE-UMass Theater Collaboration

A man eating plant that sings early Motown-esque music and a deranged laughing gas addicted dentist who sings 1960s-esque rock and roll?! The DP123 UMass theater class is assisting the theater department beginning with the production of Little Shop of Horrors. Controls are being built to raise and lower an elevator, interact with pneumatics to enlarge the man eating plant, rapidly spin clocks, and anything that’s being asked. To start, students are reverse engineering the box in the picture above.

The box contains a PLC and motor driver for a 5 hp motor (trying to stop the motor from rotating is like trying to stop a small elephant). Earlier today, the controls were dissected to the point where messages from a knob can be understood by the PLC to interact with the motor driver to control the motor.

The project’s overarching goal is to create a simple-to-use and completely adaptable control box. Such a box that can control all electronic props for virtually any theater production with an interface that my grandfather could figure out in a few minutes. It’s a little too early to show a diagram of the final design but what we hope to be the final design was completed today. Now everything just needs to be built…


 

Top: The theater department’s tech shop where much of the class work takes place
Bottom: Students discussing the project with Michael Cottom, the tech director

Play The Room – Third Class

Imagine this.  You sit before a humble, MIDI keyboard.  It looks like a truncated piano.  You can’t help but notice the colored wires spewing from a small box behind it to places scattered around the room.  The walls.  The ceiling.  You press down a key, and involuntarily clench as a clang from overhead rings out, as a solenoid’s core slams into the ventilation duct.  You hit the key again.

We at the Play the Room class are getting there, and quickly.  By the end of this week’s class, we had a fully functional proof of concept–a solenoid controlled by MIDI keyboard.  Check out the schematic.

A MIDI cable carries the performance information from the source, whether it is a computer sequencer (Ableton Live in the video below) or a keyboard, into the Arduino.  The software in the Arduino detects the incoming MIDI message, and sends a pulse of power to the solenoid, which then strikes whatever is before it.  The software in the Arduino must be able to filter out irrelevant MIDI information (there are many kinds of messages useless to us in this context), and as we add more solenoids to be controlled, the software must send a voltage pulse to the correct solenoid depending on the MIDI note that is received.  That is, when you hit different notes on the keyboard, it plays different solenoids.  Both of these goals are easily achieved in software.

Issues we will consider in future classes include the design of a robust mounting scheme and velocity control.  Ideally, the solenoids and their control mechanism will remain intact and usable for decades, or until our neighbors tire of the noise.  And if you were to hit the key on the keyboard softly (or strike it proudly with vigor), wouldn’t it be great if the solenoid responded with appropriate force?  To be continued…

VIDEO!!!
http://www.youtube.com/watch?v=4s2aRMzjkhg

Arduino Code (thank you Alden!)

//****************************************
byte incomingByte;

void setup () {
Serial.begin(31250);
pinMode(11, OUTPUT);
}

void loop () {
if (Serial.available() > 0) {
incomingByte = Serial.read();
if (incomingByte > 143 && incomingByte < 160) {
//note on
digitalWrite(11, HIGH);
} else if (incomingByte > 127 && incomingByte < 144) {
//note off
digitalWrite(11, LOW);
}

}
}
//****************************************