Build An Eight-Channel MixerReady to learn several useful PSoC design techniques? Chris
describes a switched capacitor and continuous time modules. He also
walks you through an interesting PSoC project: an eight-channel
mixer with adjustment knobs.
The Cypress Semiconductor PSoC family of microcontrollers provides
a powerful mixed-signal capability with both analog and digital
user modules. This allows for some rather unique single-chip
solutions. However, a PSoC outsider might find it difficult to get
started, especially with designs involving switched-capacitor (SC)
analog modules.
SC modules are arguably the most versatile and unique feature of
the PSoC, aside from its dynamic reconfiguration capabilities.
There are two types of analog modules: SC and continuous time (CT)。
The latter modules are for simple analog functions such as
programmable gain amplifiers(PGAs) or comparators. SC modules can
be ADCs and DACs of varying resolution, fully configurable
op-amps,analog buffers, filters, and more. There is even a "Generic
SC" module available,which enables direct access to all switches
and capacitance values in the SC micro circuitry. But these modules
can be a bit difficult to work with.
BLOCKS AREN‘T CREATED EQUAL
Routing analog signals inside the PSoC can be a tricky process.
More often than not, the desired connections are not directly
available. An analog PSoC module's input choices are determined by
its location. Certain locations have access to the Port 0 input
multiplexers; others have direct access to the Port 2 inputs. Some
have access to only certain adjacent blocks and their column‘s
analog output bus.
CT analog blocks are easy to use. PGAs and comparators go here-no
mess, no confusion. All four CT blocks have access to at least four
Port 0 input pins (the two center blocks have extra multiplexers,
allowing connection to any of the eight Port 0 input pins), and the
column clock has little to no effect on operation. An example CT
PGA configuration window is shown in Photo 1. Note that the
AnalogBus setting can be enabled if direct PGA output is desired.
All four CT blocks are the same, and have similar
designations-"ACBxy,"where x equals the analog row (always 0)and y
equals the analog column number(0-3)。 These four blocks are all on
the top row of the analog section (see Figure 1).

SC analog blocks are the subtle bits of genius that grant the PSoC
so many capabilities. In fact, the blocks can perform such a
variety of real-time functions that they were given a completely
customizable user module instead of separate modules for each
function. This "Generic SC" module can be found as the only entry
under the "Generic" category. SC blocks come in two varieties:Type
C and Type D. Originally, in the CY8C25xxx and CY8C26xxx PSoC
families, they were Type A and Type B. This is detailed in
Cypress‘s application note AN2041, "Understanding Switched
Capacitor Blocks." Most, if not all,of it still applies to the
newer CY8C27xxx and CY8C29xxx chips. The old Type A blocks have
evolved into the new Type C blocks, and the old Type B blocks have
evolved into the new Type D blocks. Type C SC blocks are
designated"ASCxy," where x equals the analog row (1 or 2) and y
equals the analog column (0-3)。
Type D SC blocks are designated"ASDxy," where x equals the analog
row (1 or 2) and y equals the analog column (0-3)。 Type D blocks
include an additional option to allow BCAP to function as a regular
capacitor instead of a switched capacitor. Set this BSW to "on" for
normal operation. Type C and D SC blocks are arranged in a
checkerboard pattern, beginning with ASC10 (see Figure 1).
Only the outer blocks (ASD20,ASC10, ACB00, ACB01, ACB02,ACB03,
ASD13, and ASC23) have direct access to input pins. Restrictions
apply for specific pin connections,as well. The remaining SC blocks
in the middle have to rely on neighbors for indirect input signals.
Generic SC modules, as I already mentioned, may be used for a
variety of purposes. Providing isolated analog blocks with access
to just about any analog input is possibly one of the handiest
uses.
ADVANCED ANALOG ROUTING
Suppose you want to sample an audio signal with an ADC. The
simplest way, with a blank project, is to place the input block to
the ADC module in one of the outside blocks so it has direct access
to a pin input. This may or may not be possible with other
functionality in place. It also doesn‘t provide control over the
input signal level. It may be entirely too small or too large to
read accurately.
Passing the audio signal through a PGA in one of the top (CT)
blocks first enables more versatile placement of the ADC input. It
also applies a gain to the signal, which may be adjusted at either
design or run time. Unity gain (1.00×)will leave the signal level
unaltered.
As you place the ADC input block in various locations, you might
notice the different choices available with each placement. An ADC
placed in ASD11, for example, has access to signals present in
ACB00, ACB01,ASC10, ASC12, and ASC21. Changing the signal input to
the ADC during run time involves altering the value in one of the
control registers-specifically,ASD11CR1 (bits 7, 6, and 5)。 For
details, refer to the PSoC technical reference manual.
The ADC in block ASD11 has easy access to CT PGAs in blocks ACB00
and ACB01. Suppose your design had the resources available for only
a single ADC, and you had to cycle through and read signals present
in all four CT PGAs up top. There is a missing element.
The block ASC12 has easy access to PGAs in the other two CT blocks
ACB02 and ACB03. By configuring this block as an SC PGA with unity
gain, the ADC in block ASD11 can access all four CT PGAs with
simple register changes. An example of such a setup‘s analog
configuration is shown in Figure 2.
点击查看Figure 2
A generic SC module can be configured to act as a PGA and cleanly
amplify audio signals. The SC PGA does not have as large a range of
gains as the standard CT PGA module, but it is perfect for low and
unity gain applications. The standard CT PGA module provides gains
from 0.062× to 48×,whereas the SC PGA I created has a range of
0.062× to only 1.938×(with an FCAP value of 16)。 This range gets
smaller and finer when FCAP is set to 32 (see Table 1).

Table 1a-This table illustrates the various gain settings available
to an SC PGA‘s channels when FCAP is set to 16. This value may only
be 16 or 32. b-This table illustrates the various gain settings
available to an SC PGA's channels when FCAP is set to 32. This
value may only be 16 or 32.
SC PGAs have the unique capability of mixing two inputs and
controlling their gains independently. An SC PGA can also invert
its non-inverting input. The ratio between FCAP and either ACAP or
BCAP controls the gain applied to either the A or B inputs, as
shown in the following equations:
Empirically, an analog column clock of 4 MHz was found to be
optimum for an audio SC PGA. Faster clocks resulted in distortion
because the SC blocks do not perform quite as well near their upper
limit of 8 MHz.
The parameters necessary to create an SC PGA intended for use with
AC signals (or audio) from a generic SC module are shown for the
two types of SC blocks in Photos 2a and 2b. To pass just one
signal, set the unused channel (A or B) capacitance to 0. If your
signals are not referenced to analog ground (AGND = VCC/2), then a
different reference setting may be selected for ArefMux (just like
the reference setting of a CT PGA).
CREATE AN 8-CHANNEL MIXERNow that you have the capability to route analog signals anywhere
at will, you can create a single PSoC project to perform a function
not typically thought of as possible: the eight-channel mixer.
Using both CT and SC PGA modules,all eight simultaneously routable
analog input signals (four CT inputs from Port 0 and four
end-column SC inputs from Port 2) can be mixed into three outputs:
Left, Right,and Mono. The basic mixer schematic and internal
routing is shown in Figure 3.
点击查看Figure 3
The left output consists of a mix of input channels La, Lb, Lc, and
Ld. The right output consists of a mix of input channels Ra, Rb,
Rc, and Rd. The mono output is a mix of all eight inputs.
Lc, Ld, Rc, and Rd are routed through CT PGAs before entering the
mix, and can therefore have a preamp gain of up to 48× applied to
them. These channels are ideal for use with microphones or
small-signal input sources.
This mixer design operates passively without logic. The only code
required is to initialize the CT PGA modules. The SC PGA modules do
not need start commands when their power level is set in the device
editor to low,medium, or high.
If you can preset all of your gains,then you are done! However, you
might want some sort of real-time control over the gains.
DIGITALLY TIME POT INPUTS
One relatively simple way to provide real-time control over
the mixer‘s gains involves three buttons and a serial display
terminal. This does not lend itself to a user-friendly
interface-knobs or sliders would make much more sense. Typically,
potentiometer inputs are read with an ADC in the analog
domain;however, there is an interesting way to utilize the
remaining digital resources of the PSoC to implement adjustment
potentiometers for up to 16 adjustments simultaneously (see Figure
4).

Figure 4-This is the matrix of potentiometer/level control inputs
used to provide real-time control over the various gains and
settings available for use in the eight-channel mixer project. This
setup enables a single digital timer module to read 16
potentiometers while consuming only eight I/O pins (four input and
four output).
An 8-bit timer module captures one of four input lines, which is
multiplexed to four control lines in a keypad-matrix style. This
allows timing of up to 16 signals,which will be our
potentiometers(or knobs, sliders, and more)。 The potentiometer‘s
resistance controls how long the RC circuit takes to charge up,
transforming a voltage measurement into a time measurement (easily
measurable in the digital realm)。 The PSoC's digital High-Z inputs
switch at VCC/2 (behaving exactly as an analog comparator
referenced to ground with the trip point at 0.500), which works out
great for this.
To measure a specific line, after the input is connected to the
timer module‘s capture input, all four capacitors are discharged.
Then, the timer module is reset and started just before the
capacitors are released and allowed to begin charging. When the
selected line charges up above VCC/2, the capture input triggers an
interrupt-during which, the timed value is converted into an
appropriate R/C gain ratio and written to the channel's gain
register.
If any of the eight audio input lines are left floating, the PSoC
will allow some noise in from the potentiometer scanning process.
At extremely high gains, some digital noise might still leak in
even without floating inputs.
A simple solution to both is to use a pin as a "Scan Enable" line.
Scanning the potentiometers is performed only while P2[7] is high;
it ceases when P2[7] is low. A button might be labeled"Hold to
adjust or push to update." A switch might be labeled "Down to lock
out changes and Up to adjust."
There was another situation caused by leakage in this application.
The bank select outputs were originally driven as Open Drain High,
which should theoretically mix without diodes in the potentiometer
scanning circuitry. The bank selects were driven high to select a
particular bank, and released to float otherwise. Unfortunately,
when floating,the bank outputs sharing Port 1 with the inputs were
affected by the various charging capacitors. This resulted in
multiple gains being adjusted unintentionally.
For this reason, the bank selects are now strong outputs. They are
driven high to select a bank, and driven low otherwise. To ensure
that the low drives do not affect the potentiometer
readings,blocking diodes (D1, D2, D3, and D4) are now required on
these lines.
A flowchart describing the operation of this adjustable
eight-channel mixer project is shown in Figure 5.
A COUPLE OF NOTESBy enabling the Agnd bypass in the global settings and selecting
external Agnd on P2[4], a few hundred microamps are available to
bias the AC-coupled inputs. The two 100-μF bypass capacitors (C14
and C15) are arranged in series with the supply to facilitate a
quick initial charge-up. The ACAP and BCAP settings in the device
editor have no effect because they are set in the software.
The option also exists to convert one of the eight channels into an
intercom line, which would make this firmware perfect for mixing at
the individual level in the studio. This would enable musicians to
control each relevant channel level in their headphones and
simultaneously maintain communication with the control room. Just
some simple configuration changes in the PSoC Designer,and this may
be achieved (disconnect PGA_Rd from SC_Rcd, and directly connect
PGA_Rd to Analog Output 3 to isolate it from the mix)。 Actually,
don‘t worry about doing this yourself. Next month, you'll read how
this is implemented as a separate mode.
The optional serial terminal display output looks like what you see
in Figure 6. At power-up, the title line is transmitted. This
provides labels for the data. Then, whenever the potentiometers are
scanned, the applied gains will be looked up and displayed on the
terminal. Because it all fits on a single line, special software
isn‘t needed for a stationary, updating display. (Carriage returns
without linefeeds typically result in overwriting the same line
repeatedly in terminal applications.)
In this article, I described how to build an eight-channel mixer
with adjustment knobs, using a Cypress Semiconductor CY8C27443 PSoC
as the only active component. Next month, I will explain how to
further enhance this single-chip design with DSP effects, an
intercom mode, a user interface, speech capability, and permanent
setting memory.
Author‘s note: Many of the application notes referenced in this
article were recently submitted, so they may or may not be
available on Cypress's web site at this time. For your convenience,
the original,unedited versions of the relevant application notes
are available on my web site, along with their project and related
files. Go to www.chrispaiano.com for more information. In addition,
I have a few homemade PSoC-based electronics kits and devices for
sale on my site. The project described in this article is available
as either a kit or an assembled unit
Chris Paiano has written more than 30 application notes for the
Cypress PSoC chipset over the years, including such novelties as
PongSoC and the Video RTA. You may contact him at
chris.paiano@gmail.com.
PROJECT FILESTo download code, go to
ftp://ftp.circuitcellar.com/pub/Circuit_Cellar/2008/216.
RESOURCESCypress Semiconductor, "PSoC Mixed-Signal Array: Technical
Reference Manual,"001-14463,
www.psocdeveloper.com/uploads/media/PSoC_TRM_00.pdf.
D. Van Ess, "AN2041: Understanding Switched Capacitor Blocks,"
Cypress Microsystems, 2004,
www.future-mag.com/0707/docs/analog_understanding_switched_capacitor_analog_blocks_an2041_12.pdf.
SOURCE
CY8C27443 PSoC
Cypress Semiconductor Corp.
www.cypress.com