Thanks for give us this amazing project, great design with few elements to build.
i will buy some elements that need to make a full test.
Glad you like this. Do let us know of your experience tinkering with this design.
An interesting takeway from this project, is that with 2 APIs - PWM_Write_Period() and PWM_Write_Compare() you can control pitch and volume of a PWM-driven speaker.
You can use this concept in your noise-makers as well..
Thanks Antonio for your excellent explanations.
Gracias por los conceptos explicados, imagino hablas español.
I wil play with this design , so first need to buy some components to make a full test.
Estoy dispuesto a ayudar, J. Antonio.
En realidad, yo no hablo español, pero portugués.
/* ********************************************************** */
I am happy to help, J. Antonio.
I actually don't speak any Spanish, but Portuguese.
Some of you may be wondering - why are 2 PWMs needed to drive the speaker?
Well, the 2 PWMs can be used to create dual-tone music, and as a result, some fun sound effects. By default, the second PWM an octave higher (double the frequency) than the first PWM.
To change the relative pitch of the 2nd PWM to the first, in main.c, line 215, change NOTES_TO_OCTAVE to NOTES_TO_JARRING (2nd MIDI note above the base note) or NOTES_TO_THIRD (3rd midi note above the base note).
Do experiment with other combinations as well, to make your own special sounds!
If your speaker is sounding soft, reduce the volume scale-down performed in lines 205 and 206 (the volume is reduced by a factor of 16 (4 shifts right) ). I scaled down the volume for peace of mind (especially for my colleagues )
I hope you have as much fun with the Theremin as I had developing it. Maybe one of you could improve the design and post a video of you playing your own custom version of the Theremin. That would be cool!
Should you have any questions, do let me know.
PS: The video above has a caption for the speaker that reads 'PWM Based Speaker', but means 'PWM Driven Speaker'... Don't get confused!.
Good morning Gagan/Antonio,
I will definitely be building this project!
I haven't installed the development environment yet, I suspect my question would be answered if I had, but what are the component values? Also I could not find an 18 Ohm speaker, 16 Ohm (or maybe 1.8KOhm?). I should imagine this would be ok?
Thanks in advance
Actually, you need just one 100ohm resistor and one 8ohm/0.1W speaker (see image below). You could use a speaker with a different rating as well - for this application, it doesn't matter too much. I have tested it out with speakers with different ratings, and get similar results.
Thanks for the question,
Today i tested this .
Thanks for the video.
Did you try it in discrete mode as well ? (By pressing the SW2 on the board)
Also, feel free to play around with the code as I mentioned in Post 2. and see the results you get.
Super work, J. Antonio!
This just in:
By implementing some of the Theremin functions in UDBs, I have written a much more efficient Theremin.
1. Instead of two 16-bit UDB PWMs (4 UDBs) for Tone generation, there is now a single 16-bit DualPWM that does the job in 2 UDBs
2. Instead of 3 TCPWMs for RGB LED Control, there is a single 8-bit triple-compare PWM.
This new project thus saves you 3 TCPWMs and a UDB over the previous example!
Here's the new schematic:
The project can be found in the Cypress Community Component forum: http://www.cypress.com/?app=forum&id=2492&rID=82045
Have fun with this.
And by the way: Sneak preview of another cool project to come - PSoC 4 driving an LED Matrix like this one: http://www.adafruit.com/products/420
Thanks for update this project, and thanks too for the link of adafruit i did not know this women and her company. amazing women. so the display with the you will work is excellent , i will buy this and stay tune with you.
It is a new video with the last file project..
Excellent work, J. Antonio!
Thanks for the video,
Another possible option is to put an audio transformer between your output and an 8-Ohm tiny speaker. Radio Shack offers a terrific little audio output transformer for $2.99. Input impedance is 1000 Ohms, output impedance is 8 Ohms.
Just a little electronic correction for the value of the serie resistor:
The absolute maximum current per GPIO of PSOC 4 is 25mA
Rspeaker = 8ohm
Vdd= 3V3 (or 5V? here take the absolute maximum)
the resistor must be strictly greater than : Rmin = Vdd/Igpio-Rspeaker = 3.3/0.025-8 = 124 ohm
add 10% if it's a E12 series resistor: 137 ohm -> take a 150 ohm
A quick update to share with the community -
The PSoC 3 in this design handles the CapSense touch and MIDI controller functions of the products.
"Both the Kaossilator 2 synthesizer and mini KAOSS PAD 2 apply Cypress's CapSense capacitive touch technology to implement the ultra-fast responsiveness of the touchpad and slider, improving upon the performance of the resistive touch controls in KORG's previous generation of products. PSoC 3's programmable digital logic drives the signal converter of the products' Organic Electroluminescent (OEL) displays while freeing up their central processing units (CPUs) for optimal performance."
Spectacular, no words, psoc opens the doors for many applications. Psoc is a powerful platform to create products, kaoss pad 2 and kaossilator 2 are great designs.
This project is a great job, but i had a few questions about the Hyperterminal software.
In fact I download it but I have no idee how to make it work, I looked on youtube but that was useless.
I want to create a platform on Labview but i need to receive the information from the Psoc on my computer.
If you have a better solution let me know.
Thank you for your answwers,
Today's project is a personal favorite of mine because it got the amateur/wannabe musician inside me very excited. Building on yesterday's example of how to do proximity sensing with the CapSense Component, today we're going to use that concept in an application. This example project implements a Theremin, a 1920s electronic musical instrument played without physical contact.
The project uses two proximity sensors - one for Pitch and another for Volume. The proximity sensing itself is done using wires that act as antennas, input to the PSoC 4 using the CapSense block.
The theremin has 2 modes - discrete and continuous notes, toggled by using the pushbutton (SW2) on the board. Pitch information is indicated by the color of the LED, while Volume information is indicated by the brightness of the same LED.
The Cortex-M0 CPU takes the analog input from the CapSense proximity sensors and send a parameter indicating distance to the hardware PWMs, that in-turn modulate the LED. The CPU also sends data to the 2 other PWMs that are used to drive the a Buzzer that creates the musical notes.
The project also includes a UART Component so you can read the CapSense proximity sensor data over hyperterminal.
What's cool about this project?
- It uses 5 (five!) hardware 16-bit PWMs - 3 of which are implemented on the TCPWM block (modulating the RGB LEDs), wheres 2 more implemented using UDBs (to drive the buzzer).
- It implements distance sensing using CapSense proximity
- It lets you make music in the air! Check out the demo video above.
The RGB LED and the pushbutton switch are on the board. In addition to the PSoC 4 Pioneer Kit, you're going to need -
- an 18 ohm Speaker/Buzzer (P2)
- 2 resistors, 2 capacitors
- hanful of jumper wires
The project is attached below, its all ready to go. Just build and program on to your PSoC 4 Pioneer Kit, and wire up a small buzzer.
Have fun making music!