Difference between revisions of "7745 Breadboarding lab"

From CCRMA Wiki
Jump to: navigation, search
Line 10: Line 10:
  
  
<!-- == Power Up and Prepare Arduino ==
 
* Use the same procedure as [https://ccrma.stanford.edu/wiki/Stompbox_Lab_0_2013 described before] to power up Satellite CCRMA and login as the user ''ccrma'' with the password ''temppwd''.
 
 
* Don't forget to stop the default patch from running by executing the command
 
 
'''stop-default'''
 
 
* After you are logged in, see which devices are attached to Linux by running the command following command.  They will appear the be files.  Wow, there are so many!
 
 
''ls /dev''
 
 
* To list only the serial interface devices type
 
 
''ls /dev/tty*''
 
 
* Now use the retractable USB cable to plug the Arduino into one of the USB ports of the Raspberry Pi.  As the Arduino powers up, you should see some lights come on.
 
 
* Now run
 
 
''ls /dev/tty*''
 
 
again, and you should now see the new device ''/dev/ttyUSB0'' appear also, which represents the Arduino Nano. 
 
 
Troubleshooting:  If you do not see  ''/dev/ttyUSB0'', then try rebooting using ''sudo reboot'' to see if that fixes this problem. (If you reboot, this will take about 45 seconds, and you will have to login again using ''ssh''. If that doesn't work, come talk to us. If you are a Linux pro, you can try to debug the problem yourself by typing ''dmesg'' and looking at the result.)
 
 
* The next step is to install some simple firmware onto the Arduino so that it knows what we want it to do.  Start the Arduino software in the terminal by typing
 
 
''arduino &''
 
 
* Open ''StandardFirmata'' from the Arduino software pull-down menus File|Examples|Firmata.  Look at the program.  This is what will control the Arduino.
 
 
* Select ''Arduino Nano w/ ATMega328'' under Tools->Board and ''/dev/ttyUSB0'' under Tools->Serial Port.  Then hit the Play button to verify and compile the program. 
 
 
* Upload the Firmata firmware to your Arduino Nano using upload button, the second square button from the left (the one with the sideways arrow).
 
 
* Close the Arduino program by closing all of the Arduino windows. (This is important because it frees up the USB serial port so that Pd can talk to the Arduino board later.)
 
 
-->
 
  
  
Line 68: Line 30:
  
 
[[Image:circuit0.jpg]]
 
[[Image:circuit0.jpg]]
 +
  
  
Line 74: Line 37:
 
== First Circuit: Potentiometer ==
 
== First Circuit: Potentiometer ==
  
Now you will build the following voltage divider circuit, to connect one potentiometer to analog input A0.
+
* Use the same procedure as before to power up Satellite CCRMA and login as the user ''ccrma'' with the password ''temppwd''.
 +
 
 +
* Don't forget to stop the default patch from running by executing the command
 +
 
 +
'''stop-default'''
 +
 
 +
* Start pd using the following command
 +
 
 +
'''pd &'''
 +
 
 +
* Open the pd patch
 +
 
 +
~/pd/labs-2016-Music-7745/5.breadboarding-sensors/test-Arduino-only.pd
 +
 
 +
* Now you will build the following voltage divider circuit, to connect one potentiometer to analog input A0.
  
 
[[Image:pot-A0.jpg]]
 
[[Image:pot-A0.jpg]]
Line 143: Line 120:
 
** would you want to use it live?
 
** would you want to use it live?
 
*** If not, what is missing still?
 
*** If not, what is missing still?
 +
 +
 +
 +
 +
 +
== More Reading About Arduino ==
 +
 +
 +
* After you are logged in, see which devices are attached to Linux by running the command following command.  They will appear the be files.  Wow, there are so many!
 +
 +
''ls /dev''
 +
 +
* To list only the serial interface devices type
 +
 +
''ls /dev/tty*''
 +
 +
* Now use the retractable USB cable to plug the Arduino into one of the USB ports of the Raspberry Pi.  As the Arduino powers up, you should see some lights come on.
 +
 +
* Now run
 +
 +
''ls /dev/tty*''
 +
 +
again, and you should now see the new device ''/dev/ttyUSB0'' appear also, which represents the Arduino Nano. 
 +
 +
Troubleshooting:  If you do not see  ''/dev/ttyUSB0'', then try rebooting using ''sudo reboot'' to see if that fixes this problem. (If you reboot, this will take about 45 seconds, and you will have to login again using ''ssh''. If that doesn't work, come talk to us. If you are a Linux pro, you can try to debug the problem yourself by typing ''dmesg'' and looking at the result.)
 +
 +
* The next step is to install some simple firmware onto the Arduino so that it knows what we want it to do.  Start the Arduino software in the terminal by typing
 +
 +
''arduino &''
 +
 +
* Open ''StandardFirmata'' from the Arduino software pull-down menus File|Examples|Firmata.  Look at the program.  This is what will control the Arduino.
 +
 +
* Select ''Arduino Nano w/ ATMega328'' under Tools->Board and ''/dev/ttyUSB0'' under Tools->Serial Port.  Then hit the Play button to verify and compile the program. 
 +
 +
* Upload the Firmata firmware to your Arduino Nano using upload button, the second square button from the left (the one with the sideways arrow).
 +
 +
* Close the Arduino program by closing all of the Arduino windows. (This is important because it frees up the USB serial port so that Pd can talk to the Arduino board later.)
  
  

Revision as of 07:51, 11 February 2016

Breadboarding lab: Controlling Physical Models using Breadboarded Sensors
Designed by Edgar Berdahl


For this lab you need your Satellite CCRMA kit, a laptop computer with Ethernet adaptor to program it, and some headphones with a mini 1/8" (2.54mm) stereo jack.


Note: In this lab, the images will show the Beagle Board xM instead of the Raspberry Pi, but actually all of the wiring is essentially the same.




Power Connections

  • In order to run circuits on the breadboard, you need to get power to it. The Arduino gets 5V from the USB connection, so in this section you will make the 5V accessible to the breadboard.
  • Make sure that your Arduino is mounted at the very end of the breadboard with the higher-numbered rows, as shown in the following picture. In that case, the GND and 5V pins will end up in the 19th row. (Otherwise if your Arduino isn't mounted this way, you simply won't be able to rely on the row numbers, but you can still figure out how to wire things up!)
  • Recall first that that holes in the solderless bread board are wired together as shown:

Breadboard.png

  • Using short jumpers, connect the GND row to the blue "GND" bus on the breadboard, and connect the 5V row to the red "power" bus on the breadboard.
  • Connect the "GND" and "power" busses from both sides of the breadboard together as shown.

Circuit0-big.jpg


Viewed from further away, your breadboard should now look like the following:

Circuit0.jpg



First Circuit: Potentiometer

  • Use the same procedure as before to power up Satellite CCRMA and login as the user ccrma with the password temppwd.
  • Don't forget to stop the default patch from running by executing the command

stop-default

  • Start pd using the following command

pd &

  • Open the pd patch

~/pd/labs-2016-Music-7745/5.breadboarding-sensors/test-Arduino-only.pd

  • Now you will build the following voltage divider circuit, to connect one potentiometer to analog input A0.

Pot-A0.jpg

For some help on placing the wires, please see the following picture. In order to ensure the correct orientation, ensure that the text on the potentiometer is facing away from the Arduino (see also oblique picture in next section). Circuit2.jpg



Add A Second Potentiometer

Now connect a second potentiometer to analog input A3 using the same voltage divider circuit.

SBcircuit3-direct.jpg


Again, ensure that the text on the potentiometer is facing *away* from the Arduino (see the red boxes in the following figure):

SBcircuit3.jpg





Other Voltage Dividers

The circuit you just used for the potentiometer was a voltage divider circuit in which the potentiometer serves as two resistors. Other resistive sensors only have two wires, so to build a voltage divider with them, you need to combine them with a second, fixed resistor. Examples in your kit are the force sensitive resistor (FSR) and the bend or flex sensor. The idea is that you put two resistors in series between power and ground: one that changes resistance (your sensor), and one of a known, fixed resistance. At the point in between the two resistors, you can measure how much the voltage has dropped through the first resistor. This value changes as the ratio of resistances between variable and fixed resistors change. More formally:

Res divider.png

  • potentiometer:

Pot.png

  • force-sensitive resistor (FSR):

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

Bend sensor.png



Conclusions

Read more about other sensors in the lecture notes.



Optional: Build A New Effect

  • Build a new effect whose parameters are adjustable by the potentiometers and button. We will ask for volunteers to demonstrate this the following morning in class. You can build on what you did in lab 1 if you like.
  • Think about the result
    • do the controls allow the entire space of parameters to be explored?
    • is it easy to choose any desired set of parameters?
    • does the effect sound good?
    • does it have dynamics?
    • would you want to use it live?
      • If not, what is missing still?



More Reading About Arduino

  • After you are logged in, see which devices are attached to Linux by running the command following command. They will appear the be files. Wow, there are so many!

ls /dev

  • To list only the serial interface devices type

ls /dev/tty*

  • Now use the retractable USB cable to plug the Arduino into one of the USB ports of the Raspberry Pi. As the Arduino powers up, you should see some lights come on.
  • Now run

ls /dev/tty*

again, and you should now see the new device /dev/ttyUSB0 appear also, which represents the Arduino Nano.

Troubleshooting: If you do not see /dev/ttyUSB0, then try rebooting using sudo reboot to see if that fixes this problem. (If you reboot, this will take about 45 seconds, and you will have to login again using ssh. If that doesn't work, come talk to us. If you are a Linux pro, you can try to debug the problem yourself by typing dmesg and looking at the result.)

  • The next step is to install some simple firmware onto the Arduino so that it knows what we want it to do. Start the Arduino software in the terminal by typing

arduino &

  • Open StandardFirmata from the Arduino software pull-down menus File|Examples|Firmata. Look at the program. This is what will control the Arduino.
  • Select Arduino Nano w/ ATMega328 under Tools->Board and /dev/ttyUSB0 under Tools->Serial Port. Then hit the Play button to verify and compile the program.
  • Upload the Firmata firmware to your Arduino Nano using upload button, the second square button from the left (the one with the sideways arrow).
  • Close the Arduino program by closing all of the Arduino windows. (This is important because it frees up the USB serial port so that Pd can talk to the Arduino board later.)



Important Note

Some small amount of the text and images here was taken from prior laboratory exercises for the course Music 250A. We regret that we do not know who contributed these elements, but these people are likely to include Wendy Ju, Bill Verplank, Michael Gurevich, and possibly more.


7745