250a Haptics Lab Force-stick

From CCRMA Wiki
Revision as of 08:33, 20 October 2010 by Eberdahl (Talk | contribs) (Setup the Force-Stick with CCRMA@Satellite)

Jump to: navigation, search

Haptics Lab Using The Force-Stick for Music 250a

The goal of this lab is to introduce active force feedback. Each haptic effect can easily be coupled to a sound because the feedback loop is controlled directly in pd. Different haptic effects suggest different sounds; different sounds suggest different effects. What are the most interesting mappings? Which are appropriate, controllable, even "expressive". Try each sound control with and without haptic feedback enabled. Are there some that simply cannot be played without haptics?

Feel The Motors

Find the foam-core board that has motors mounted on it and try them out.

For the DC motors, connect one alligator clip to the 6V supply on the Triple Output Power Supply from Hewlett Packard, and connect the other alligator clip to ground, which is labeled COM. Careful! Don't use the 18V supply instead--you could burn out the motors! By adjusting the +6V knob, you can change what voltage you are applying to each of the DC motors. Which way does the solenoid pull? What are small motors good for and what are large motors good for?

For the AC motors, use the Tektronix Function Generator. Try sine waves in the audible range 20Hz-20kHz on the white-colored AC motor. For it to be loud, it needs to be connected to something that can vibrate. Try changing the sound by coupling it to the foam core or the violin body or something else. The other, smaller AC motor can be used to vibrate objects with iron or steel in them or magnets. Try to use it to vibrate the magnet glued to the foam core. Try to use it to vibrate the violin string directly, which contains some steel inside it. (Hint: You will have to place it very closely to the string without touching the string.) Do you know at which frequencies the violin string responds the most?

Setup the Force-Stick with CCRMA@Satellite

  • For your own edification, have a quick look at the datasheet for the DC motor with rotary encoder. This is what we will be using in the lab.
  • First startup your kit
    • Connect your ccrma@satellite kit to your laptop and boot it.
    • Use a terminal window to login to ccrma@satellite as usual using the command ssh -X ccrma@192.168.1.105 with the password temppwd
    • Check that your kit has access to the internet through you laptop. You can do this by trying to ping yahoo. Run the command ping yahoo.com. If it is successful, it will tell you how long it takes to send a packet from your ccrma@satellite kit to yahoo and back. If there is a problem, see the instructions in lab 3 for setting up the kit.
  • Now use your laptop to copy the lab files to your kit
    • On your laptop, download the lab files to your laptop by following the link to the haptic signal processing toolbox for pd. If you are using Safari on Mac OS X, then it will download the ZIP file and extract it creating the folder ~/Downloads/HSP.
    • Open a new terminal window on your laptop. Copy the lab files to your kit by using secure copy. If you are using Safari on your laptop, then you can do this by typing

scp -r ~/Downloads/HSP ccrma@192.168.1.105:~/250a

  • Now on your kit
    • Go back to the terminal window that is connected to your kit. Run the command arduino& to start the Arduino software. (If it asks you if you want to install a newer version of the Arduino software, tell it no.) Use the Arduino software to upload the firmware for this lab ~/250a/HSP/haptics_firmware/haptics_firmware.pde. Look at the main loop loop() in the source code for this firmware for a minute. You can see that it reads data from the serial connection from pd and uses this to set the direction of the motor and the PWM strength using analogWrite(). Then it writes data to the serial connection to pd about the position of the rotary encoder and the pressure applied to the FSR.

Touch-a-wall

  • Open the patch ~/250a/HSP/models/Touch-a-wall.pd
  • Read the text of the patch so that you can understand how the layout of the patch relates to the equivalent mechanical system of the Force Stick being connected by a conditional link contact~ to ground.
  • Turn on audio by clicking on compute audio
  • Verify that by moving the Force Stick back and forth, you can make the hslider shown in the patch change.
    • Hint: Remember that rotary encoders don't necessary know where 0 is--they just choose zero as being the position when the program first starts.
    • To zero the rotary encoder for the force stick being held in the middle, first rotate the force stick to the center, and then press the reset RST button on the Arduino.
    • Now hold the force stick in one hand, while you turn the power on for the motor amplifier board by switching the toggle switch to the ON position.
    • You should be able to feel a soft "wall" when you move the force stick to the right of the center position. (If not, then check your setup.)
    • Because of the spring action of the contact~ link c, the force increases when you move to the right. However, if you move far enough to the right, then the motors can no longer increase the force level any further due to mechanical limitations.
    • Try decreasing the stiffness of the contact~ link to 150 N/m. How does this feel?
  • When you are done with the patch, turn the motor amplifier board off again.

Note: Systems with feedback can become unstable if the right conditions arise. This is why it is a good idea to turn off the motor amplifier board when you are not using the system. (Otherwise, consider what can happen with a public address system if you leave it alone and it starts to squeal/howl.)

Wiggle-a-mass

  • Close any other open patches, and then open ~/250a/labs/HSP/Wiggle-a-mass.pd
  • Read the patch and notice how the layout of the patch matches the equivalent mechanical system of a Force Stick connected by a springy link~ to a virtual mass.
  • On the left, the position of the Force Stick is shown with an hslider, and on the right the position of the virtual mass m is shown with an hslider.
  • Turn on the motors and wiggle the Force Stick back and forth. Can you feel the virtual mass?
  • What happens if you change the virtual mass from 0.6kg to 0.3kg?
  • What happens if you change the damping in the link~ from 1 N/(m/s) to 0 N/(m/s)?
  • Is it a bad idea to make the damping negative?

Pluck-a-string~

  • First try interacting with the string without any haptic force feedback. Then turn on the power to the motor amplifier board and try to pluck the string. Is it easier to play with or without haptic feedback?
  • Clicking on the bang in the main patch will cause an impulse to be send into the string. What do you have to do with the Force Stick in order to be able to feel the impulse?
  • Open up the subpatch to have a look inside.
  • Try to imagine what it would look like if the delread~ and delwrite~ pairs were bypassed? Again, the layout of the patch should provide some indication for the equivalent mechanical model.
  • Optional: How could you change either of the DWG-end~ objects to increase the fundamental frequency of the string's sound?
  • Remember to turn off the power to the motor amplifier board when you are finished.

Human-robot-interaction~

  • Open the patch and notice the shaker sounds when you move the Force Stick back and forth.
  • Open up the pd Shakers~-abstraction to see the sound synthesis module.
  • Try changing some of the parameters to see how it changes the sound.
  • In particular, try choosing different gain sounds by clicking in the different boxes set in a row at the bottom of the patch. Which is your favorite?


  • Now hold onto the Force Stick while you turn on the motor amplifier board with the other hand. (Be careful because this patch is especially likely to become unstable! If the Force Stick should become unstable, turn off the motor amplifier board again.)
  • You should now feel a virtual "robot" that tends to shake the Force stick about 5 times per second.
  • Look at the mechanical analog inside pd subpatch-blocked-at-1. Again the Force Stick is connected by a link to ground. However, this time the position of ground g is modulated by osc~ 5 and neighboring objects.


  • There is an FSR mounted on the end of the Force Stick. We have not used it yet! To change this, click on the toggle in the main patch window. Now the pressure that you apply to the FSR should change the spring stiffness for link l1. That is to say, if you do not apply any pressure, then the spring stiffness is zero, so there is no force feedback. However, as you apply increased pressure, the spring stiffness becomes stronger, providing for stronger force feedback.


  • Note that in the previous patch, the same physical model was used to synthesize both the audio feedback and the haptic force feedback, in this case, the output from the haptic feedback model is used to control the shaker~.

Part 7: Build Your Own

Make your very own musical controller using the Falcon and one of the above patches as a starting point. Here are some ideas, but feel free to follow your own interests:

  1. Try to impart kinetic energy from your body into a physical model of an instrument.
  2. Make a record scratching interface allowing you to feel the record.
  3. Can you make a sphere that exerts a spring force on the musician if the musician ever tries to press into it? What sort of music would you put to that?
  4. Can you program the haptic interface so that it allows you to feel a texture?
  5. Make the virtual mass in part 5 increase if the "number of objects" parameter is increased.

Make us proud. (And be ready show off your controller at the next lab session!)