Magazine Archive

Home -> Magazines -> Issues -> Articles in this issue -> View

Digital Signal Processing (Part 2)

Turn your ZX Spectrum into an echo machine with sound sampling capabilities using this month's unique project



Making Music: Adding a D to A Controller gives digital ECHO and a host of sound manipulating effects.


Echo times of two seconds at a bandwidth of about 7kHz; choice of delay time in intervals of one millisecond; choice of bandwidth allowing over five seconds delay for voice and similar applications; freezing of sounds or phrases up to the delay length set; single shot replay; sequencing of sounds created or captured which may then be shifted in pitch prior to playback manually or using virtually any low frequency oscillator; forwards or backwards playback from memory; and Fourier synthesis of sounds. Seems like a dream effects unit? Well, these are some of the additional facilities now available by adding a digital to analogue converter to the analogue to digital converter described last month. In fact the system contains a number of unique features and because many of the capabilities are generated with software there is remarkably little hardware in addition to the Sinclair 'Spectrum' microcomputer and its usual ancillaries.

For readers who may have missed Part 1 in the July 1983 issue of E&MM we will give a very brief summary of the objectives for the series. First, digital techniques are becoming commonplace and it behoves musicians to have a working knowledge of these techniques. Next, digital processing is becoming increasingly associated with microprocessor techniques, as distinct from hardware manipulation, and our main objective is to encourage exploration of micro techniques using a learning by doing approach. The software developed for the series is completely accessible to the user and additional information is provided with the cassettes containing the programs. Likewise the hardware is made as flexible as possible, particularly at the interfacing level, so that the more experimentally orientated users can add additional parts to suit their specific interests. Last, but by no means least, our emphasis will be on music making techniques as shown by the facilities described above.

Figure 1. Circuit diagram of the D/A Controller.
(Click image for higher resolution version)


Hardware



The overall arrangement of the signal processing scheme was shown in the Block Diagram in Part 1 but the processing of audio signals should also become clear by reference to the simplified circuit for the Digital to Analogue Controller, as shown in Figure 1. The signal to be treated is connected to J1 and amplified by IC2A using the Gain control, RV2. This amplifier will cope with line level inputs as well as most microphones. After amplification the signal is split two ways with part going to IC2B which connects with the analogue to digital converter described last month. This puts the signal into the memory of the microcomputer where it may be manipulated to provide a variety of effects, for example, delaying the signal in memory to produce an echo. After manipulation, the digital information has to be converted back to analogue form using, believe it or not, a digital to analogue converter which is described later. The reconstituted analogue signal returns, via a low pass filter, to IC2C which again allows the signal to be split. For repeat echo, and similar effects, a proportion of the signal may be re-cycled using the feedback control, RV3, connected to IC2B. The treated signal may also be mixed with the original signal by means of RV4 and IC2D. The output of the latter is connected to an amplifier. The Digital to Analogue Controller described above is in fact a fairly conventional 'front end' of the type found on most digital and analogue delay units. Another feature often found on digital units is the HOLD push button, S2, which is used for 'freezing' samples in memory. In the current design, however, it should be observed that this push button connects with one of the inputs of Port C of the 8255 PPI and so its function may be varied, by the software, to suit particular requirements.

The completed D/A Board.


The signal from the microprocessor, via the D to A converter need not originate from a signal applied to the input at IC2A. For example, in the A to D system described in Part 1 the program allowed samples of sound to be stored on cassette. Now these samples may be replayed from cassette and the signals will come via the memory of the micro direct to the D to A converter. In this situation only IC2C and IC2D are in use. We may also generate waveforms mathematically - more on this next time - and again only the D to A signal path is used.

Figure 2. Illustration of Quantisation error.

In view of the growing use of digital processing techniques it is worth mentioning some of the main features of digital to analogue converters in respect of their influence on performance/quality. Perhaps the first consideration is the number of bits used. The early digital delay units were based on 8 bits, as are the majority of low cost microcomputers available today. An 8 bit converter can only provide 28 (256) discrete steps whereas an original analogue signal will have infinite resolution. The difference between an original signal and the digitised reconstitution is shown in Figure 2. The black area between the voltage of the digital output and the original analogue voltage, shown by the smooth line, is known as the quantisation error and it manifests itself in much the same way as white noise in analogue systems. A little thought will make it obvious that if the width of the step is decreased then the 'volume' of the error (noise) will be reduced. In fact it can be proved that the maximum signal to noise ratio of a digital converter is equal to 6dB times the number of bits. Thus an 8-bit converter will give a signal to noise ratio of 48dB. This may seem very low but it is better, or comparable to, many recordings and AM broadcasts.

The choice of converter is not governed by the word (bit) size of the microprocessor. For example, we could use a companding 8-bit digital to analogue converter, as employed in the E&MM 'Digital Delay' and 'Transpozer' projects, and thus provide a theoretical 72dB signal to noise ratio. In other words such a converter has a performance comparable to a 12-bit D to A device and maintains a 35dB S/N ratio over a 35dB signal input range. This companding type DAC is not, however, very convenient for some of the applications provided with this project. The alternative would be to use, say, a straight 12-bit DAC and many such devices are designed for easy interfacing to eight bit micros. Such a converter would nevertheless reduce the sampling rates - which we cannot afford to do with the 'Spectrum' - and it would also effectively halve the amount of free memory available for storage or treatment. In view of these latter problems we have kept to the normal 8-bit type since they are capable of providing satisfactory quality for many situations.

We have stressed the point that the theoretical signal to noise ratio for a DAC represents the best performance that could be obtained and there are several aspects of conversion which can detract from its performance. The most serious is the lack of headroom in the conversion processes with the result that overloading immediately causes clipping and invariably this will result in severe distortion as modulation products are formed (this may be verified with the unit described in this article since it contains a precise overload indicator). There are also other sources of noise in digital conversion and most of it is of high frequency. The result is that although a digital effect unit may have a measured signal to noise ratios of, say, 72dB in practice it may not sound any better than an analogue unit with a S/N ratio of some 60dB.

Figure 3. Circuit diagram of the D/A Converter.
(Click image for higher resolution version)


The actual digital to analogue converter system used is shown in Figure 3. The data bits come from Port A of the 8255 PPI on the interface board described last month. The ZN 425 used has an on-chip voltage reference whose output at pin 16 is connected to the reference input at pin 15. C5 is for decoupling. The output of the ZN 425 goes to the non-inverting amplifier built around IC2. This has a fixed gain of about 1.55 to produce about 15mV per step, or about 3V8 full scale. RV1 is provided so that the offset of the op amp may be cancelled out and this is necessary when the converter is used for synthesiser control applications. In the latter event the D to A output is taken to a separate controller where, amongst other things, the output is further amplified to give 83.33 mV/step, ie., 1 step per semitone.

Signal overload indicators are provided on the digital inputs thus ensuring a very accurate response. IC 4 is connected to the two high bits and so the green LED, D2, will illuminate when these two bits are 'ON'. When lit it means that three quarters of the maximum signal input is present and so there is less than 3dB of headroom left prior to clipping. IC 3 is connected to the highest seven bits and so when the red LED, D1, illuminates the input is either clipping, or within one step (0.39% of total signal capability) of clipping.

Output 2 of Port C of the 8255 goes to the comparator IC 5 to generate a positive going gate pulse of about 10V5. Input 4 of Port C is used to accept the 'HOLD' input from the D to A Controller. These latter items are located on the D to A PCB so as to facilitate their connection to the PPI on the interface board.

Figure 4. Output from the A/D.


Figure 5. Output from The D/A.


When a signal is converted to digital form it may be represented as shown in Figure 4, that is, a series of pulses whose number will depend on sampling rate while the width of the pulse depends on conversion time. When this same signal is output from a D to A converter the waveform is continuous, as shown by Figure 5, since its output remains constant until new digital data is supplied. The waveform therefore contains high frequency components, which are related to the sampling frequency, and these components have to be removed by low pass filtering to leave the smooth waveform, shown by the dotted line in Figure 5. Removal of these high frequency components is essential, irrespective of the sampling rate, since even if they are not audible they can create problems with audio equipment, such as overheating of speakers. Filtering becomes even more important when some of the output is fed back into the analogue to digital converter for repeat effects and the like. In the latter circumstances the higher frequencies can form cross products with the sampling frequency to produce sounds within the audio spectrum which are not harmonically related to the signal input.

Figure 6. Circuit diagram of The 24dB/Octave Low Pass Filter.
(Click image for higher resolution version)


It will be evident from the foregoing that a filter with a steep cut-off will allow the widest signal bandwidth. The circuit diagram for a 24dB/octave filter used in the D to A Controller is shown in Figure 6. It is based on the CEM 3320 voltage controlled filter IC produced by Curtis Electromusic Specialties. It is a low noise, low distortion device and its use greatly simplifies design as well as providing some useful features for the user. A single potentiometer, RV1, allows the cut-off frequency to be adjusted anywhere between 20Hz and 20kHz whereas most digital effect units often only provide one output filter with a fixed cut-off frequency. The latter approach may be somewhat lower in cost but they are often restrictive in use. For example, the delay time is a function of memory capacity and sampling rate and in many units the latter is reduced to provide a long delay. If, therefore, only one filter is used then it must be set to limit bandwidth for this slowest sampling rate whereas the bandwidth could be increased for shorter delays. Similarly, manufacturers usually set the cut-off frequency of the filter significantly lower than dictated by sampling theory this being a trade off between cut-off rate and the type of signals that may be encountered. For some signals the filter cut-off could be set higher. In the software controlled system described in this article we have the capability to alter sampling rates over a wide range and so a variable filter is especially useful.

Another feature of the CEM 3320 is that it contains a separate gain cell whose output is connected to the input of the filter and this facility is often used to control resonance. In the present application resistor, R16, feeds a proportion of the output signal to the gain cell and by applying a current, via R17, the filter will oscillate at, or close to, its cut-off frequency. The current is obtained by closing switch S1 which connects +12 volts to R17. One of the programs provided allows the measurement of frequency, as described in Part 1, and so by putting the filter into oscillation the user can set the filter to specific cut-off frequency points. This is an extremely useful feature for those wishing to understand the mechanics of digital signal processing.

The final piece of hardware is another filter which is incorporated into the A to D Controller described in the previous issue. It was mentioned at that time that the signal entering the A to D converter should not contain any components with a frequency greater than half the sampling rate. Failure to observe this rule will result in foldover distortion and we will discuss this effect in a later article. The filter used is exactly the same as that described for the D to A converter so that it may be set to provide maximum bandwidth for specific circumstances. Fitting of the filter is only required when the system is used for treatment of audio signals. It does not have to be fitted for the storage oscilloscope nor when the A to D is used for DC or Keyboard sequencing applications. In fact, the filter would be bypassed for the latter.

Figure 7. Component overlay for The D/A.
(Click image for higher resolution version)


Construction



Construction of the three parts described above is very straightforward so long as the usual care is taken with orientation of the IC's and the electrolytic capacitors.

First, for the Digital to Analogue Converter PCB, whose component overlay is shown in Figure 7. Install and solder the components in order of increasing height. The wire links may be made with unscreened tinned copper wire so long as the links are taut so that there is no likelihood of them touching one another. Orientation of the LED's is indicated in Figure 7 by the 'flat' on one side of the component representation which corresponds to the 'flat' on the lens of the LED. The final component to be soldered is the 10-pin Molex connector which should be properly seated onto the PCB. Now carefully check the underside of the PCB for potential shorts caused by solder blobs and splashes. If everything is satisfactory then solder the fifteen wires at the rear of the board. 1/0.6mm wire is preferred for this step and each piece should be about 6 to 7 cms. long. The D to A PCB is now mounted above the interface PCB using plastic mounting pillars. The pointed end of these pillars go into the four holes in the interface PCB and the D to A board sits on these pillars and is secured with four plastic studs which should be firmly pressed home. Lastly, neatly bend, cut and strip the free ends of the fifteen wires so that they may be neatly soldered to the corresponding holes in the interface board. There are two rows of holes on the latter and those furthest from the edge should be used so as to facilitate other additions. The positions of the holes on the D to A PCB line up with those on the interface PCB but double check the connections by reference to Figure 7 and to Figure 4 of Part 1. Placing the D to A above the interface board has been made in such a way as to allow easy access to the latter if required.

Figure 8. Component overlay for The D/A Controller.
(Click image for higher resolution version)

The component overlay for the D to A Controller is shown in Figure 8 and the only additional point to observe is ensuring that the potentiometers are properly seated on the PCB prior to soldering. After installation of the components on the PCB then prepare a piece of 10-way ribbon cable, about a metre long. At one end, six of the wires are soldered to Molex pins and inserted into a 10-way Molex shell. The selection of wires and their sequence is shown by the component overlay of Figure 7 and note that no connections are made to the 'GATE' pin or to pins marked 'NC' and these represent the four unused wires which may be shortened. The other end of the ribbon cable passes through a slot made in the rear of the case and the later should be about 12 to 15 mm wide and in the middle of the case on the curved portion. The free ends of the wire connect up with the appropriate holes on the Controller PCB. These connections are in the same sequence as those on the D to A PCB so there should not be any crossing or twisting of wires. Next place an extra nut on each of the four potentiometers and secure to the panel - the component side of the PCB faces towards the top of the panel. Very little wiring remains: a connection from the points shown in Figure 8 to the corresponding jack sockets: a ground wire to each of the four sockets; a wire from '+12V TO S1' to switch S1 and the return wire to the point marked 'FROM S1'; and a wire from point marked '+5V TO S2' and a return wire to 'HOLD FROM S2'.

Figure 9. Component overlay for The Low Pass Filter.
(Click image for higher resolution version)


Lastly, if the anti-aliasing filter is being installed into the A to D Controller then the components should be installed on the PCB in accordance with the overlay shown in Figure 9. Including power there are seven connections to be made and it will be easier if the wires are connected to the filter PCB prior to using the potentiometer, RV1, to secure the unit to the panel. The power supplies are readily accessible on RV4 (see Figure 6 of Part 1) while the 0V is available on the A to D Controller PCB (see Figure 5 of Part 1) or at the ground of the jack sockets. Wiring of the 'IN', 'OUT', 'RES 1' and 'RES 2' is to switches S4 and S5 which should already be installed in the Controller, the exact connections shown in Figure 6 of Part 1.

The completed DAC controller board.


Connecting Up



To configure the system for treatment of audio signals the units should be set up as follows -

1. The interface remains as in Part 1 and if a printer is available it could be usefully connected up since the programs contain facilities for plotting and printing of the waveform in memory, or at least the first few hundred bytes of memory. The A to D Controller should be connected to Channel A on the interface board (normal position).

2. The D to A Controller is connected to the Molex on the D to A PCB (check orientation). At this time set trimmer, RV1, on the latter board to its mid position.

3. Connect a signal source, such as a microphone or musical instrument, to the INPUT of the D to A Controller and turn the GAIN control anti-clockwise. The approximate setting of the GAIN control will quickly become a matter of experience and in use its setting can be adjusted by reference to the LED's on the D to A board. In general the green LED should be 'ON' most of the time but illumination of the red LED should be intermittent and for very short duration. Set the MIX control mid-way at this time so that you will hear both the original and the treated signal. Start with the FEEDBACK control anticlockwise and FILTER f control at about setting 6. The OSC(illator) switch, S1, should be off. The remaining connections are from OUTPUT to an amplifier and from 'TO ADC' to the input of the A to D Controller. The filter on the latter should be switched to 'ON' and the frequency again at position 6 to begin with. The input of the A to D Controller should be set to AC, its attenuator to 2V full scale, and the 'ZERO' and 'f TEST' switches off.

Screened cable should be used for all signal leads, although, if a 'hum' occurs it is likely to be due to a ground loop being formed with the two Controllers. In this event remove the screened wire from one of the plugs making the connection between the two Controllers.

Check that the power is connected to the interface board and the usual connections (power, cassette, TV, etc.) made to the 'Spectrum' and switch on all power simultaneously. The copyright message should appear on the TV screen. If not switch off quickly and re-check connections.

Software



The combination of analogue to digital and digital to analogue converters together with their Controllers provides extremely versatile and flexible hardware. Additionally, the DIGISCOPE 3 programs described fully last month plus the DIGISOUNDER 3 programs this month provide a wealth of software. There is in fact a danger of users being overwhelmed and so discussion is confined to using the 'echo' program on the DIGISOUNDER 3 cassette. This program is ideal since it allows full experimentation of the various controls. Note, however, that these latest programs will only operate with a 48K 'Spectrum'.

With the system connected up as described above load the DIGISOUNDER 3 program by entering LOAD " " followed by ENTER. After a successful load a menu will appear on the screen and selecting "e" will initialise the echo program. The screen will display the messages: 'real time echo'; 'sample rate = 14.8kHz'; 'delay = ms'; and at the bottom a response is required to 'delay (1 to 2000ms)'. The required delay time is entered and after pressing ENTER the screen will now display the delay time and also show the message 'press HOLD to return'. To start with we suggest you enter the maximum delay, ie., 2000 (milliseconds) since the effect of the controls will be most obvious with a high delay time. At any time, however, the delay program may be terminated by pressing the HOLD button on the D to A Controller. If you then re-enter "e" a new delay time may be set. The cassette also contains a routine for altering the sampling rate which in turn will affect the maximum delay time. This and the many other features will be fully discussed in Part 3 but in the meantime you can become familiar with the effect of the various hardware controls including filter settings. Have fun!

DIGITAL TO ANALOGUE CONVERTER PARTS LIST

D/A Board

Resistors. 1/4W. 5% carbon film unless stated
R1 10k (1% metal film)
R2 18k (1% metal film)
R3,4 470R 2 off
R5 100k
R6 10k

Potentiometers
RV1 100k cermet trimmer

Capacitors
C1,2,3,4 100nF polyester 4 off
C5 220nF MKH polyester

Semiconductors
IC1 ZN 425E-8
IC2,5 TL 081, or equivalent 2 off
IC3,4 74LS30 2 off
D1 Red 5mm LED
D2 Green 5mm LED

Miscellaneous
8 pm DIL sockets 2 off
14 pm DIL sockets 2 off
16 pm DIL sockets
10 way Molex connector
PCB Mounting Pillars 4 off

D/A Controller

Resistors. 1/4w, 5% carbon film
R1,4,8,11 91k 4 off
R2,5,7,10,14,18,20, 21,23,24,25 100k 11 off
R3,6,9 200k 3 off
R12,19,22,26 1k0 4 off
R13 820k
R15 1k8
R16,17 47k 2 off
R27 4k7

Potentiometers
RV1,2,4 100k lin. rotary
RV3 47k lin. rotary

Capacitors
C1,2,9,10,11 100nF polyester 5 off
C3,8 1u0 PCB electrolytic 2 off
C4,5,6,7 180pF 1% polystyrene 4 off
C12 220p polycarbonate
C13 10uF PCB electrolytic
C14,15,16 10uf axial electrolytic 3 off

Semiconductors
IC1 CEM 3320
IC2 TL 074

Miscellaneous
J1,3 0.25" Mono Jack Socket 2 off
J2,4 3.5mm Mono Jack Socket 2 off
S1 SPDT sub min. toggle switch
S2 Sub min. push to make switch
14-pin DIL socket
18-pin DIL socket
10 way ribbon cable approx 1 metre
Case with punched and printed panel
Control knobs 4 off

Anti-Aliasing Filter

Resistors 1/4w 5% carbon film
R1,4,8,11 91k 4 off
R2,5,7,10,14 100k 5 off
R3,6,9 200k 3 off
R12 1k0
R13 820k
R15 1k8
R16,17 47k 2 off

Potentiometers
RV1 100k lin. rotary

Capacitors
C1,2 100nf polyester 2 off
C3,8 1uf PCB electrolytic 2 off
C4,5,6,7 180pF 1% polystyrene 4 off

Semiconductors
IC1 CEM 3320

Miscellaneous
18-pin DIL socket

The Digital to Analogue Converter, Controller and the DIGISOUNDER 3 programs are available from Digisound Limited, (Contact Details) for £43.10 inclusive of P&P and VAT. The inclusive price for the antialiasing filter is £8.05. The kits include all parts noted in the components lists plus the PCB's. For information on ready-built units, using other micros and other sales enquiries then write to Digisound Limited at the above address or telephone (Contact Details).


Series

Read the next part in this series:
Digital Signal Processing (Part 3)



Previous Article in this issue

America


Electronics & Music Maker - Copyright: Music Maker Publications (UK), Future Publishing.

 

Electronics & Music Maker - Aug 1983

Topic:

Computing

Electronics / Build


Series:

Digital Signal Processing

Part 1 | Part 2 | Part 3 | Part 4


Previous article in this issue:

> America


Help Support The Things You Love

mu:zines is the result of thousands of hours of effort, and will require many thousands more going forward to reach our goals of getting all this content online.

If you value this resource, you can support this project - it really helps!

Please Contribute to mu:zines by supplying magazines, scanning or donating funds. Thanks!

We currently are running with a balance of £100+, with total outgoings so far of £1,036.00. More details...
muzines_logo_02

Small Print

Terms of usePrivacy