This will be in part a tutorial, and in part, a project note.
As a newcomer to PSoC programming and building, I find that many of the example projects are not really aimed at beginners. Most seem intended to show experienced embedded systems developers as many cool things about PSoC in one file, and that is probably fair, since that is Infineon's established market.
For beginners, I'd like to see some simpler projects that focus on one thing at a time and explain some things that experienced devs would not need reminding of. So, I'll be trying to fill the gap a little by building stuff and sharing what I learn as I go.
This is the first part of a larger project. In a nutshell, I'm making a synthesizer module that uses the Infineon CY8CKIT-041-41XX PSoC™ 4100S CapSense Pioneer Kit (an evaluation kit for the PSoC 4100S) so I can produce 0-5v DC control voltages for a modular synthesizer. I am using a AE Modular format synth here because that's what I have, and its 0v-5v configuration is ideal for adding homemade modules. However, most analog synthesizers can accept voltage control in this range - it might just be limited if the receiving synth is expecting 10v or 12v. It will be enough to have fun with though.
Any PSoC board with CapSense will be able to make a proximity-based controller and some will have other CapSense widgets ready for use. I do have another PSoC4 and PSoC6 evaluation board on hand as well, so I'd like to see what I can do with them and will add versions of the projects for them.
The CY8CKIT-041-41XX kit has a cool CapSense x/y trackpad with two buttons and a proximity sensor, as well as some physical buttons and a thumb-wheel potentiometer. It also has some LEDs to give some visual feedback. My goal here is to find lots of different ways to control a synthesizer from the touch pad. For now, I'll concentrate on control voltage outputs as I know another Hackster is making a MIDI controller using the same kit.
This project is intended for beginners like myself who are coming from a much simpler environment such as Arduino, and are a bit bewildered by the flexibility and complexity that is the world of PSoC.
In this first installment we will make a simple Theremin-style module that senses proximity up to about 5cm and changes its output voltage accordingly. The main point is to get something happening quickly by modifying an existing project. In fact, we'll even get away with not writing any code, for now. In subsequent installments, I will add parts to this project as I go along (and as I learn more about what I am doing!).
... but first, I will talk a bit about the overall design idea...
Design ConsiderationsThe AE Modular is a budget and maker-friendly modular synthesizer format created by Robert Langer of Tangible Waves in Murnau, Germany.
It's main characteristics are:
- 5v single rail-to-rail power supply
- 0-5v audio signal (with 2.5v as centre of the wave)
- 101mm 'height' of panel face-plate
- 25mm 'width' for a single 'unit' of rack space
- 25mm 'depth' (from front panel to back of the case)
- simple 2x5 pin IDC headers on ribbon cable for bus and power
- cheap and compact patching with a slightly nicer version of du Pont style jumper cables as an alternative to more expensive and bulky phono and banana jacks
This is the synth I'll be working with, but it is easy to apply all this to a Eurorack-style system or any voltage-controlled instrument.
The CY8CKIT-041-41XX in its case measures 96mm x 64mm x 16mm (with back removed and headers installed)
So, to use the CY8CKIT-041-41XX with its case intact, it will need a very thin surround and some way of fastening it to the back of the rack case. My initial intention is to keep it intact but I may need to remove it to make it a permanent module. There is 10mm to spare at the sides, but only 2mm at top and bottom.
To use the reset, SW2 and SW3 buttons, it will need to protrude at least 5mm out from the normal front panel height. As long as this is less than the normal length of other knobs in the system, that is not a problem.
The LEDs on the opposite end are a problem though. My current thought is to make a piece of 2mm clear acrylic sheet cut with a 45 degree edge, polished to reflect the LEDs up the side.
The capsense flex PCB is stuck firmly to the case and the instructions don't recommend removing it. However, modern appliances have taught me that anything is possible with a guitar pick and careful application of heat. :)
The potentiometer, although perfect as a thumb wheel thingy, is in a bad spot for use when mounted in a modular rack. I may just have to move it, or simply re-map and break out the relevant pins to elsewhere.
Anyway, we are not gong to worry about any of these things for now. We are going to make something quick and dirty and get something happening!
Part 1: A Proximity-Sensor to Control-Voltage Thing...The first part of the project is a 1-channel proximity-based controller that uses just the CY8CKIT-041-41XX PSoC™ 4100S CapSense Pioneer Kit plus a couple of simple external components.
Setting up the Development EnvironmentAlthough Infineon have a new environment called Modus Toolbox, based around the Eclipse IDE, we'll be using the older PSoC Creator for this project because of its support for older PSoC devices and boards.
There are more comprehensive tutorials elsewhere but I'll try to include everything needed to get something happening as quickly as possible.
Installing PSoC CreatorThe latest version of PSoC Creator can be found here (you will probably need an Infineon account): https://www.infineon.com/cms/en/design-support/tools/sdk/psoc-software/psoc-creator/
Note here that PSoC Creator only works under Windows. Eventually, I imagine older boards will be supported on Modus Toolbox on all major OSs so, if you are in MacOS or Linux, it might be worth taking a look once in a while to see if any more examples have been ported across.
Once installed, we are going to set up our environment for the CY8CKIT-041-41XX PSoC™ 4100S CapSense Pioneer Kit
Be sure to also download and install
(CY8CKIT04141XXSetup_RevSA.exe from the link above) That should add all the example files and projects specific to this kit.
Once we have installed the software and the extra stuff for our kit, we open PSoC Creator and find some example code we can re-use for our nefarious purposes.
The screen will look something like this:
In the Start Page tab, we need to open the Kits entry in the Start list:
... which will give us something like this...
We need to select CE214023 Proximity Sensing.cywrk and open the workspace file (We'll be prompted to save it with a new name in our working directory).
Before we flash the project to our board, we'll probably need to update a few components. To do this, we go to the Project Menu and select Update Components.
To flash this project to our kit, we press the Program button (Ctl f5 - also available in the Debug menu):
If you have no success talking to your board or updating items, it's best to search in the Infineon forums, as most getting started issues need just a small adjustment to sort out. If you have trouble, leave a note in the comments and I'll update the project page with a solution, if I have one for you.
If all goes well, you should see the red LED fade up when your hand is close to the proximity sensor (a loop around the outside of the front panel). There are lots of cool things going on in this project. For example, it runs in a low-power, low speed scanning mode when it senses nothing for a while then, when it picks up your hand nearby, it switches into high-speed scanning mode for snappier response while it's in use. To learn all this and more, check out the PDF guide to this example project at the bottom of the Workspace Explorer list:
As amazed as we are about LEDs glowing at a mere wave of our hand, we want to get this thing talking to our synthesizer.
So, we need to know what pins are being used for the LED, so we can use that pin to get our PWM output.
Fortunately, if we look in our Process Explorer and open Design-Wide Resources, the Pins tab has all the info we need.
On the board, P3[4] is near the coin-cell battery and has a convenient GND terminal nearby.
The ideal way to provide precise voltages to a synthesizer from a board with digital outputs would be to use an external DAC (some PSoCs have high resolution DACs built-in). However, I am still figuring out the details and I want to keep things simple for now. Instead, we will use the kit's Pulse Width Modulation (PWM) output and smooth it out using a resistor and a capacitor to get a usable control voltage. Precision will not be much of a consideration for the moment.
Because PWM is often used to control LEDs, this gives us a few ready-made projects that we can hijack for our purposes.
As you might've encountered in Arduino-land, PWM can be used to control the brightness of a LED or the speed of a motor. PWM is not actually a smoothly-adjustable DC voltage at all. Instead, it is a fixed voltage AC waveform where the ratio of the 'ON' part of the wave and the 'OFF' part of the wave (the Duty Cycle) can be varied. LEDs and Motors have their own electrical characteristics that let them behave as if they were getting a nice neat DC voltage.
Unfortunately, this won't do for controlling a synthesizer component. So, we are going to make a crude little filter using a resistor and a capacitor to smooth the waveform into a passable DC voltage.
There are better explanations out there than mine, but, because a capacitor acts like a bucket that charges up then dumps its load, it can be used to give us a voltage somewhere in between the ON and OFF voltage values of the PCM wave, depending on how long the ON part lasts compared to the OFF part.
Skipping over the formulae for now, we'll just go with 1k for the resistor and 100uF for the capacitor and perhaps refine things a bit later.
This gives us a usable voltage out of between 0.1 and 4 volts that is a bit messy but good enough for our purposes.
The R/C filter circuit:Based on the circuit above, here is how it translates to breadboard, wired to our CY8CKIT04141XX board.
Now we are ready to hook up to our synthesizer...
Connecting to the SynthesizerOf course, I must say at this crucial point that connecting anything up to your precious synth is your own responsibility and bad things can happen. That said, the magic smoke should stay inside if you exercise due caution and don't connect this project up to an audio input or output, or to a voltage control output (or ANY AC power connector!).
First, we need to attach the ground wire from our project to our synthesizer. An AE Modular synth will usually have a Master I/O module that includes a female header for a ground connection.
If you have the BrAEdboard module, there is a ground connector available on the lower (black) breadboard.
Other analog synths will need the ground wire to be connected to the shield of a phono jack, or if using banana jacks, whatever is the common ground connection in your system.
The output 'signal' wire (maybe better named as Control Voltage wire?) can then connect to any input that accepts a CV (control Voltage) input. Avoid connecting it to any audio input or any type of output, just to be safe.
In the image below, I have connected to the VCO's pitch CV input for a wailing theremin sound...
In following parts, we will explore other parts of the Capsense experience and tidy this first project up a little as well.
Video:
Stay (approximately) tuned!
Comments