PID2008 Lab Two

From CCRMA Wiki

(Difference between revisions)
Jump to: navigation, search
Line 118: Line 118:
<center>[[PID 2007]]</center>
<center>[[PID 2007]]</center>
-
[[Category:PID_2007]]
+
[[Category:PID_2007]][[Category:PID]]

Revision as of 13:27, 13 August 2007

Lab 3: Circuits, Sensors, OSC
Assigned Wednesday June 27


For this lab you need your AVR , Power Supply, Jumpers, Resistors, Sensors and one LED from the MaxLab. Sensors: 2-buttons, 2-potentiometers, FSR, photo-resistor, IR Emitter-Detectors.

Contents

Load meter.c onto the AVRmini

Create a lab3 Directory

                ~> cd pid2007/
        ~/pid2007> mkdir lab3
  • Copy avrlib-demos/meter there.
        ~/pid2007> cd lab3
   ~/pid2007/lab3> cp -r ../avrlib-demos/meter .

Load the "meter" onto the AVR

        ~/pid2007/lab3> cd meter
   ~pid2007/lab3/meter> make load
  • This will turn your AVRmini into a rudimentary multimeter with two inputs. Use a jumper from the point at which you want to measure the voltage to A0 or A1 on the AVRmini. The voltages will be shown on the LCD.
  • Note that the signals are numbered starting at zero (A0 - A7) while the pins on the header that carry those signals are numbered starting at one (1 - 8). The 8-bit analog to digital conversion gives 0..255.
  • Here is the pin-out for PORTA, PORTB, PORTC, PORTD (only 1.2 and 9.10 are labelled on the board):
    2  4  6  8  10
    1  3  5  7  9
  • The same pin configuration is shown bellow with the signal names.
    A1  A3  A5  A7  5V
    A0  A2  A4  A6  GND

Build Sensor Circuits

  • Build the circuit that is detailed in the folowing figures. Use components and jumpers to construct your circuits on the solderless bread-board.

Image:Breadboard.png

  • Here's how to wire a simple 2-resistor circuit on the solderless bread-board (for example R1 = 10K, R2 = 10K):

Image:Jumper.png

What will A0 read?


Build the Button and LED Circuit

  • On the left is the circuit, on the right, the diagram.

Image:Button.png

  • Try replacing the one button with two buttons in series or in parallel.

Hook-up Sensors to A0 or A1 and Watch the Voltage Change

  • potentiometer:

Image:Pot.png

  • force-sensitive resistor (FSR):

Image:FSR.png

Try both circuits. Test the resistance range of your sensor. If you want 2.5 volts to be the middle, make the comparison resistor (33k in the diagram) the "average" value of the FSR's resistance. Test this with a multimeter.

  • Bend Sensor

Image:Bend_sensor.png

  • photo-resistor:

Image:Photo.png

  • Reflective Optical Sensor:

Image:Optical.png

The Musical AVRmini

  • The program running on the AVR will beep at frequencies controlled by the voltages on A0 and A1 when you press buttons on S6 and S7 on the display. Wire up four buttons to each of the B4-7 pins (this are the pins B4, B5, B6 and B7 in PORT B) according to one of these two circuits. (The one on the left is recommended -- it is at 5v unless the button is pressed.) Check that you can read in the AVR display the buttons on port B4-7.


Read Sensor Values to PD

Using osctest.c (in the avrlib-demos):

                         ~> cd ~/pid2007/lab3
            ~/pid2007/lab3> cp -r ../avrlib-demos/osctest .
            ~/pid2007/lab3> cd osctest
    ~/pid2007/lab3/osctest> make load

and osctest.pd:

   ~/pid2007/lab3/osctest>  pd osctest.pd &

send data from your protoboard circuits (analog input on A0 and A1), and to PD.

  • Note: we use the Pd [serialIO] object to read OSC data from the serial port. When you open a patch containing a [serialIO] object, you must send it a [start] message in order to begin polling the USB port. If you want to reprogram your AVR, you should send [serialIO] a [close] message to release the port for the AVR downloader to use, then you can do a make load. When you want to resume using [serialIO], you should send it a message [open /dev/ttyUSB0] to reopen the port, followed by [start] to resume polling.
  • Let A0 "float" while A1 is tied to a potentiometer by removing the wire from its socket. What happens to A0's value when A1 is changed? Try the same experiment with the PORTB[4-7] buttons. Why does this happen? How can we prevent it?


Putting it all Together

  • Create a Pd patch to make sounds based on button and sensor values from the AVR. You can try to adapt your patch from Lab 1, or come up with a new patch. You can also use as a starting point the patch osctestsoundout.pd, located in the same folder.
  • Try to make a simple musical interaction. Think about music -
    • does it have dynamics?
    • can you turn the sound off?
    • can it be expressive?
  • You may need to make a copy of osctest and modify it to send the appropriate control signals.
PID 2007
Personal tools