User Tools

Site Tools


courses:2010.02.02.vmusic2

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
courses:2010.02.02.vmusic2 [2010/02/03 01:30]
camille added vmusic2 connection image
courses:2010.02.02.vmusic2 [2010/12/07 14:20] (current)
camille updated Vmusic2 links
Line 1: Line 1:
 +====== VMusic2 player. Wireless Arduino: ZigBee/XBee ======
 +
 +==== VMusic2 audio player ====
 +
 +The VMusic2 audio player is an affordable and simple solution to playback audio in a controlled way. You put MP3 files on an USB flash disk and then issue commands to the player via serial communication. All modules from the Interaction Workshop have updated firmware. If you buy your own, make sure you upgrade the firmware before using it. 
 +  * [[http://​www.ftdichip.com/​Support/​Documents/​DataSheets/​Modules/​DS_VMUSIC2.pdf|Data Sheet]]
 +  * [[http://​www.ftdichip.com/​Support/​Documents/​AppNotes/​AN_VMusic_SPI_V101%20%20(FT_000029).pdf|Application Example using PIC microcontroller]]
 +  * [[http://​www.arduino.cc/​cgi-bin/​yabb2/​YaBB.pl?​num=1187669098|VMusic2 + Arduino]] on the Arduino forum.
 +  * [[http://​www.arduino.cc/​playground/​Main/​VMUSIC|Arduino Playground example]]
 +
 +**Preparing the USB flash drive**
 +
 +The VMusic2 module can be quite picky with the USB flash drive. Make sure it is formatted as FAT32 and that filenames are plain (8.3 notation always safest: //​myfile01.mp3//​)
 +
 +**Connecting the module**
 +
 +{{:​courses:​vmusic2_arduino.jpg|}}
 +
 +**Issuing commands over serial**
 +
 +From Arduino, Serial.println("​command"​) doesn'​t work properly. It is best and safest to split the command and CR (carriage return) over two calls:
 +<code c>
 +Serial.print("​V3A"​);​ // send the VMusic2 command
 +Serial.print(13,​ BYTE); // send the CR in raw byte 
 +</​code>​
 +
 +  VMUSIC COMMANDS:
 +  *** make sure you issue a CR after the command ***
 +  ​
 +  VPF·file ​      Plays a single file eg: "VPF 1.mp3"
 +  VRF·file ​      ​Repeatedly plays a single file
 +  VST            Stops playback
 +  V3A            Plays all MP3 files
 +  VRA            Repeatedly plays all MP3 files
 +  VRR            Repeatedly plays random MP3 files
 +  VSF            Skip forward one track
 +  VSB            Skip back one track
 +  VSD            Skip forward one whole directory
 +  VP             Pause playback
 +  VF             Fast forward 5 seconds
 +  VB             ​Rewind 5 seconds
 +  VRD·byte ​      Reads command register
 +  VWR·byte+word ​ Writes command register
 +  VSV·byte ​      Sets playback volume
 +
 +**Advanced stuff**
 +
 +The regular Arduino has only one hardware serial port (Pins 0 and 1). The Arduino Mega offers 4 serial ports. Note that with the use of a library ([[http://​arduiniana.org/​libraries/​NewSoftSerial/​|NewSoftSerial]],​ [[http://​www.ladyada.net/​make/​eshield/​AFSoftSerial.zip|AFSoftSerial]],​ [[http://​arduino.cc/​en/​Reference/​SoftwareSerial|SoftwareSerial]]),​ digital pins can be used as //software serial port//​. ​
 +
 +<code c>
 +#include <​NewSoftSerial.h>​
 +
 +NewSoftSerial mySerial(2, 3);  // soft serial: RX on pin 2, TX on pin 3
 +
 +void setup()  ​
 +{
 +  Serial.begin(57600);​
 +  Serial.println("​Goodnight moon!"​);​
 +
 +  // set the data rate for the NewSoftSerial port
 +  mySerial.begin(9600);​
 +  mySerial.println("​Hello,​ world?"​);​
 +}
 +
 +void loop() ​  // run over and over again
 +{
 +
 +  if (mySerial.available()) {
 +      Serial.print((char)mySerial.read());​
 +  }
 +  if (Serial.available()) {
 +      mySerial.print((char)Serial.read());​
 +  }
 +}
 +</​code>​
 +
 +The module provides a bidirectional serial communication,​ so you can get playback time and status, list of files, etc. Check the documentation and online for exploring these areas. ​
 +
 +
 +==== Wireless Arduino: ZigBee/​XBee/​802.15.4 ====
 +
 +The wonderful world of wireless definitely needs more than one hour to master. This is a highly condensed introduction,​ edges might be rough for now. If you are interested in the topic, please continue exploring on your own and ask questions. I'll try to help as much as I can.
 +
 +=== Wireless = No wire! ===
 +
 +The fundamental goal of this introduction is to replace the physical wired Serial communication (USB cable) with a wireless one. Graphically it looks like this:
 +
 +{{:​courses:​wired_serial.jpg|}}
 +
 +{{:​courses:​xbee_serial.jpg|}}
 +
 +=== ZigBee/​XBee/​802.15.4 , confusing, yes! ===
 +  ​
 +To put it simply (not 100% accurate, but close enough)
 +
 +  ZigBee ​   High level communication protocol for wireless personal area network (WPAN).
 +            Similar to Bluetooth but with a focus on low power
 +            ​
 +  XBee      Commercial product name from Digi (formally Maxstream)
 +            Series 1 (called 802.15.4) and Series 2.5 are not compatible (watch out we have both in the iWorkshop)
 +  ​
 +  802.15.4 ​ Standard at the base of wireless personal area network (WPAN), used in ZigBee and others
 +
 +
 +
 +=== Simple one-way USB cable replacement (Base Station + Node) ===
 +
 +Have a working Arduino + Processing wired combo. Arduino sends a sensor value over serial in a packet format like //1:255*// that Processing can read and decode.
 +
 +Arduino Sketch
 +
 +<code c>
 +int analogValue = 0;    // variable to hold the analog value
 +
 +void setup() {
 +  // open the serial port at 9600 (or 19200 bps for Xbee)
 +  Serial.begin(19200);​
 +}
 +
 +void loop() {
 +  // read the analog input on pin 0:
 +  analogValue = analogRead(0);​
 +
 +  // print out the packet in the format id:value*
 +  Serial.print("​1:"​);​
 +  Serial.print(analogValue);​
 +  Serial.println("​*"​);​
 +
 +  // delay 30 milliseconds before the next reading:
 +  delay(30);
 +}
 +</​code>​
 +
 +Processing Sketch: {{:​courses:​xbee_base_station_simple.zip|}}
 +
 +
 +Configure XBee Series 1 node and base station using [[http://​www.digi.com/​support/​productdetl.jsp?​pid=3352&​osvid=57&​s=316&​tp=5&​tp2=0|X-CTU software]] (simple) or [[http://​interactiondesign.se/​wiki/​xbee|AT commands]] (challenging). Remember to use your own PAN ID to avoid conflict with others.
 +
 +Enjoy!
  
courses/2010.02.02.vmusic2.txt · Last modified: 2010/12/07 14:20 by camille