Difference between revisions of "S16: Laser Harp"

From Embedded Systems Learning Academy
Jump to: navigation, search
(Hardware Design)
(Testing & Technical Challenges)
Line 224: Line 224:
  
 
=== My Issue #1 ===
 
=== My Issue #1 ===
Talk about voltage drop?
+
There was an issue with sending the note off command in the MIDI task because our queue only accounted for the note to be played, therefore some instruments would play the note forever. What we wanted to do was to have the note play as long as the sensor was blocked (indicated by bool variable in the ADC task), but we couldn't properly access the bool variable from the MIDI task. Therefore we have the note turn off in the ADC Task when the sensor is no longer blocked.
  
 
=== My Issue #2 ===
 
=== My Issue #2 ===
There was an issue with sending the note off command in the MIDI task because our queue only accounted for the note to be played, therefore some instruments would play the note forever. What we wanted to do was to have the note play as long as the sensor was blocked (indicated by bool variable in the ADC task), but we couldn't properly access the bool variable from the MIDI task. Therefore we have the note turn off in the ADC Task when the sensor is no longer blocked.
+
When starting to wire the whole system on the prototype board, the 3.3V rail was unstable and was noticeable during SPI transactions. So we kept the connections on a breadboard instead.
  
 
== Conclusion ==
 
== Conclusion ==

Revision as of 00:03, 25 May 2016

Grading Criteria

  • How well is Software & Hardware Design described?
  • How well can this report be used to reproduce this project?
  • Code Quality
  • Overall Report Quality:
    • Software Block Diagrams
    • Hardware Block Diagrams
      Schematic Quality
    • Quality of technical challenges and solutions adopted.

Laser Harp

Front View of Frame

Abstract

Our plan is to design a budget version of a laser harp. This can be accomplished using infrared LEDs and infrared sensitive photodiodes. The two diode system will emulate strings of a harp. When the infrared sensor has detected an note that is played, the microcontroller will read the input from the ADC and send out a control signal to the MIDI board and the corresponding sound will play from the speaker. Controls include changing the loudness of the speaker.

Objectives & Introduction

The objective of this project is to design and build a harp that plays a note when you run your hand over the strings. Instead of a real string, a pair of IR emitter and photodiode emulates the action. This project uses seven pairs of IR emitters and photodiodes, a real-time audio decoder, and is programmed in the FreeRTOS environment.

1. Read multiple sensors through ADC.

2. Write tasks in software that handle reading values from the ADC and playing notes with the MIDI decoder.

3. Build a wooden frame and mount sensors.

4. Create a circuit to power 5V and 3.3V to system.

Team Members & Responsibilities

  • Abraham Carrillo
    • Sensor Circuit Design
    • Interfacing/Programming Sensors with ADC
    • Frame Assembly
  • Kristen Kan
    • Interfacing/Programming MIDI with SJ One Board/Sensors
    • Power Supply Circuit Design

Schedule

Week# Date Task Status Notes
1 4/3 Finalize following circuit designs and order parts

1. MIDI 2. ADC 3. Power Supply

Complete -Schematics completed 4/7.

-Physical circuits completed week of 4/10 due to parts coming in after.

-Power supply completed towards the last week due to wanting to finish other tasks first.

2 4/10 1. Interface MIDI with SJ One Board

2.Test sound projection and different commands

Complete -Completed 4/19. Issues with datasheet, improper wiring.
3 4/17 1. Lay out ADC, sensors, and power supply on prototype board

2. Calibrate sensors 3. Write drivers for ADC/MIDI circuit

Complete -Completed 4/22, except for power supply.
4 4/24 Basic input/output testing Complete -Completed 4/30.
5 5/1 Volume/Instrument Complete -Completed 5/12. Volume and Instrument change with SJ One push buttons.
6 5/8 Design improvements (Range/Sensitivity/Control) Complete -Completed 5/19.
7 5/15 Final product testing Complete -Completed 5/23. Power supply completed.

-Transfer from breadboard to prototype board not completed.

7 5/24 Demo

Parts List & Cost

Part Quantity Price (Total) Description
SJOne Board 1 $80 Main microcontroller
Adafruit VS1053 Board 1 $25 Sound Decoder, used to produce sounds
MCP3008 1 $2.32 Analog to Digital Converter
SFH 4550 7 $2.87 Infrared 850 nm diode
SFH 213 7 3.08 Infrared Photodiode
220 Ohm resistor 7 $0 Resistor for Photodiode
170 Ohm resistor 7 $0 Resistor for Infrared Diode
Part # $

Design & Implementation

The design section can go over your hardware and software design. Organize this section using sub-sections that go over your design and implementation.

Hardware Design

Discuss your hardware design here. Show detailed schematics, and the interface here.

Figure #: Proposed Circuit Diagram

Figure #: Sensor Circuit

Figure #: Frame layout and dimensions

Figure #: ACD Circuit

Figure #: Power Circuit

Figure #: VS1053b Pin Connections

The VS1053b breakout board is an audio decoder that has hundreds of different instruments and can play musical notes. It is connected to the SJ One Board with the above pin connections and receives input via SPI for serial data interface, which is activated by XDCS chip select. To enable real-time MIDI, GPIO pin 0 must low, and GPIO pin 1 must be high. Unused GPIO pins need to have a pull down resister and the RX pin needs to be tied to high as UART is not being used.

Hardware Interface

Communication is done with SPI protocol. Since the SJ One board has two SPI modules, SSP0 was used for ADC communication, and SSP1 was used for MIDI communication. GPIO was used for control signals such as such as chip selects and switches.

For the SPI drivers, both SSP0 and SSP1 were initialized with the same parameters.

Software Design

There are two tasks: the MIDI Task(consumer) and the ADC Task (producer). Data is sent between modules over SPI and the value in which a sensor has been triggered is stored in a FreeRTOS queue. The consumer task sleeps while waiting for the queue to receive a value.

The MIDI Task is high priority and handles sending commands to the VS1053 to turn a note on. When a note is received in the queue, the task wakes and processes the note type. Communication is done with the SJ One Board through SSP1.

The ADC Task is medium priority handles reading values from the sensors through the ADC converter by looping through every channel and checking if the value is above 835. If it is, it sends a corresponding note type to the queue, which signals the MIDI to play a note. This task also includes the volume and instrument controls, because the MIDI Task may be asleep when the button is pressed. Communication is done with the SJ One Board through SSP0.

Implementation

MIDI Task Algorithm

1. Sleep while queue is empty.

2. When a note is received, a message is sent to MIDI to turn note on.

3. Return to sleep.

4. Repeat.

ADC Task Algorithm

1. Read 'change volume/instrument' push buttons.

2. If active, perform relevant functions.

3. Read ADC channels 0-7 via SPI.

4. If data is below a certain value for channels 1-7, the note to be played is sent to the queue.

5. A message is sent to MIDI when the data returns to default to turn the note off.

6. Repeat.

Testing & Technical Challenges

The sensor to ADC communication and MIDI to SJ One Board communication were tested separately before bringing the parts together and adding the power supply. The ADC and MIDI tasks were first written to test their corresponding circuits, then the queue and GPIO buttons were added.

When building the ADC-Sensor circuit, it was difficult to line up the IR diode and photodiode to get a correct reading throughout the whole range. The range of the frame was tested at the farthest point successfully at first with one pair of sensors, however after everything was placed, some of the sensors didn't register towards the top of the frame.

The VS1053b breakout board took a little extra time because the datasheet lacks some information, especially regarding sending commands through SPI. Some commands only require one data byte following, and others require two. The data bytes that follow are the parameters that need to be set for each command, however not all commands are specified. There is also a need to add byte padding between each SPI transfer. Most of this information was found through research and some inferring.

Once the tasks were brought together and the frame was built, it became fairly simple since everything had already tested fairly successfully. There were still three diodes that only registered about three-quarters of the way. From here, additional features such volume and instrument control were added and tested. Minor improvements to the code were also made, one of them being setting a bool to hold a false value before every channel read to lower the chance of unwanted signals.

We would recommend having a clearer vision as to the physical layout of the frame and spending more time on creating a PCB. We wanted something that was similar to the feel of a harp, however it got pretty messy with all the wiring to 14 sensors and didn't end up very aesthetic. With a PCB, you can ensure that voltages will be more stable because we did come across some issues with voltages dropping.

My Issue #1

There was an issue with sending the note off command in the MIDI task because our queue only accounted for the note to be played, therefore some instruments would play the note forever. What we wanted to do was to have the note play as long as the sensor was blocked (indicated by bool variable in the ADC task), but we couldn't properly access the bool variable from the MIDI task. Therefore we have the note turn off in the ADC Task when the sensor is no longer blocked.

My Issue #2

When starting to wire the whole system on the prototype board, the 3.3V rail was unstable and was noticeable during SPI transactions. So we kept the connections on a breadboard instead.

Conclusion

Overall the basic features of the project were completed. We had some issues with unstable voltages and sensor calibration that set us back in schedule. If we were to add to the project, we would add LEDs to light up with activated sensors and implement a way to play multiple sounds at the same time.

Conclude your project here. You can recap your testing and problems. You should address the "so what" part here to indicate what you ultimately learnt from this project. How has this project increased your knowledge?

Project Video

Upload a video of your project and post the link here.

Project Source Code

References

Acknowledgement

Any acknowledgement that you may wish to provide can be included here.

References Used

VS1053b Breakout Board Datasheet, [1]

SFH4550 Infrared Emitter Datasheet, [2]

SFH213FA Silicon Photodiode, [3]

MCP3008 8-Channel 10-Bit ADC [4]

MIDI Commands, [5]

Appendix

You can list the references you used.