Sound tone detection with a PSoC
Now I want to focus on a specific kind of sensor, the most complicated one for people used to design digital circuits: audio sensor. Its design requires a good knowledge about analog circuits. Fortunately modern op-amp chips help a lot for this kind of design, reducing the complexity and instability typical of such circuits, but you still need a good background on both practical and theoretical analog issues to avoid unwanted results. Once more, the evolving technology helps us. Cypress Semiconductor Corporation developed a Programmable System on Chip (PSoC) that contains several analog and digital blocks easily connectable together.
You have many "bricks" representing different kind of functions and, like a Lego system, you have to arrange them in order to have a circuit that transforms the analog signal according to your needs. You still need some knowledge about analog electronic circuits, you must know the theory behind but, also if you don't have enough practice on building this kind of circuits, you can tackle such a project. You can use point and click instead of soldering iron, you don't need to test many discrete passive components on a perfboard but you can simply reprogramming your PSoC until the goal is achieved.
The PSoC is quite different from usual MCU, CPU or FPGA. It allows flashing a program inside to perform some tasks but it’s not just a microcontroller. It allows mixing different electronic functional blocks but it’s not an FPGA. Its unique feature is the possibility to modify an analog signal keeping it analog and the characteristics of the analog blocks can be modified on-fly by the program. You have the alternative to use a Digital Signal Controller to sample your analog signal and apply some mathematical transformations on it but you still need before some amplification, mixing, filtering out noise, in short: some op-amps. Very often a PSoC can do all this job (and more) for you. The analog blocks are… really analog! They are real operational amplifiers, it is not a software simulation of an analog behavior or a mathematical elaboration. The only digital stuff is that the capacitance can vary using switched capacitors technique. Adjusting switching frequency and/or duty cycle, you can modify the capacitance and therefore the parameters of the analog blocks, without adding external components. Looking at the electrical characteristics on the data sheets, you can find the same parameters of a normal op-amp datasheet: GBP, noise factor, common mode rejection ratio and so on.
An example for all. There is a module that is unique on programmable devices, an instrumentation amplifier. This is one of the trickiest circuits to realize even with expensive op-amps. It requires a good knowledge to obtain very high impedance, enough bandwidth, a good common mode rejection ratio and everything needed to have a good measuring instrument. This is not achievable with a standard MCU.
I don't want to write down a PSoC manual, there are a lot of them. I’m not going to explain every feature of the PSoCs, I would just like to explain how to build a tone detector circuit with a Cypress device, focusing on some specific issues I've found. Even if you don't need a 4KHz tone detector circuit, the same basic principles I'm going to describe can be useful for many kind of other projects. This could be considered as a "training on the job".