© 2007 Emona Instruments Experiment 15 - PCM Decoding 15-2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

Experiment 15 – PCM decoding

Preliminary discussion
The previous experiment introduced you to the basics of pulse code modulation (PCM) which
you’ll recall is a system for converting message signals to a continuous serial stream of binary
numbers (encoding). Recovering the message from the serial stream of binary numbers is called
decoding.

At its simplest, decoding involves:

 Identifying each new frame in the data stream.

 Extracting the binary numbers from each frame.

 Generating a voltage that is proportional to the binary number.

 Holding the voltage on the output until the next frame has been decoded (forming a pulse
amplitude modulation (PAM) version of the original message signal).

 Reconstructing the message by passing the PAM signal through a low-pass filter.

The PCM decoder’s clock frequency is crucial to the correct operation of simple decoding
systems. If it’s not the same frequency as the encoder’s clock, some of the transmitted bits
are read twice while others are completely missed. This results in some of the transmitted
numbers being incorrectly interpreted, which in turn causes the PCM decoder to output an
incorrect voltage. The error is audible if it occurs often enough. Some decoders manage this
issue by being able to “self-clock”.

There is another issue crucial to PCM decoding. The decoder must be able to detect the
beginning of each frame. If this isn’t done correctly, every number is incorrectly interpreted.
The synchronising of the frames can be managed in one of two ways. The PCM encoder can
generate a special frame synchronisation signal that can be used by the decoder though this
has the disadvantage of needing an additional signal to be sent. Alternatively, a frame
synchronisation code can be embedded in the serial data stream that is used by the decoder
to work out when the frame starts.

15-2 © 2007 Emona Instruments Experiment 15 – PCM decoding


A little information about the DATEx PCM Decoder module
Like the PCM Encoder module on the Emona DATEx, the PCM Decoder module works with 8-bit
binary numbers. For 00000000 the PCM Decoder module outputs -2V and for 11111111 it
outputs +2V. For numbers in between, the output is a proportional voltage between ±2V. For
example, the number 10000000 is half way between 00000000 and 11111111 and so for this
input the module outputs 0V (which is half way between +2V and -2V).

The PCM Decoder module is not self-clocking and so it needs a digital signal on the CLK input to
operate. Importantly, for the PCM Decoder module to correctly decode PCM data generated
by the PCM Encoder module, it must have the same clock signal. In other words, the decoder’s
clock must be “stolen” from the encoder.

Similarly, the PCM Decoder module cannot self-detect the beginning of each new frame and so
it must have a frame synchronisation signal on its FS input to do this.

The experiment
In this experiment you’ll use the Emona DATEx to convert a sinewave and speech to a PCM
data stream then convert it to a PAM signal using the PCM Decoder module. For this to work
correctly, the decoder’s clock and frame synchronisation signal are simply “stolen” the PCM
Encoder module. You’ll then recover the message using the Tuneable Low-pass filter module.

It should take you about 45 minutes to complete this experiment.

Equipment

 Personal computer with appropriate software installed

 NI ELVIS plus connecting leads

 NI Data Acquisition unit such as the USB-6251 (or a 20MHz dual channel oscilloscope)
 Emona DATEx experimental add-in module

 two BNC to 2mm banana-plug leads

 assorted 2mm banana-plug patch leads


 one set of headphones (stereo)

Experiment 15 – PCM decoding © 2007 Emona Instruments 15-3


Procedure

Part A – Setting up the PCM encoder


To experiment with PCM decoding you need PCM data. The first part of the experiment gets
you to set up a PCM encoder.

1. Ensure that the NI ELVIS power switch at the back of the unit is off.

2. Carefully plug the Emona DATEx experimental add-in module into the NI ELVIS.

3. Set the Control Mode switch on the DATEx module (top right corner) to PC Control.

4. Check that the NI Data Acquisition unit is turned off.

5. Connect the NI ELVIS to the NI Data Acquisition unit (DAQ) and connect that to the
personal computer (PC).

6. Turn on the NI ELVIS power switch at the back then turn on its Prototyping Board
Power switch at the front.

7. Turn on the PC and let it boot-up.

8. Once the boot process is complete, turn on the DAQ then look or listen for the
indication that the PC recognises it.

9. Launch the NI ELVIS software.

10. Launch the DATEx soft front-panel (SFP) and check that you have soft control over the
DATEx board.

11. Slide the NI ELVIS Variable Power Supplies’ positive output Control Mode switch so that
it’s no-longer in the Manual position.

12. Launch the Variable Power Supplies VI.

13. Set the Variable Power Supplies’ positive output to 0V by pressing its RESET button.

14. Locate the PCM Encoder module on the DATEx SFP and set its soft Mode switch to the
PCM position.

15-4 © 2007 Emona Instruments Experiment 15 – PCM decoding


15. Connect the set-up shown in Figure 1 below.

Note: Insert the black plugs of the oscilloscope leads into a ground (GND) socket.

MASTER FUNCTION PCM


SIGNALS GENERATOR ENCODER

PCM

TDM SCOPE
ANALOG I/ O CH A
1 0 0 kHz
SINE
1 0 0 kHz ACH1 DAC1 INPUT 2 FS
COS CH B
1 0 0 kHz
DIGITAL
8 kHz ACH0 DAC0 INPUT 1
DIGITAL VARIABLE DC TRIGGER
2 kHz
DIGITAL +
2 kHz CLK PCM
SINE DATA

Figure 1

This set-up can be represented by the block diagram in Figure 2 below. The PCM Encoder
module is clocked by the Master Signals module’s 100kHz DIGITAL output. Its analog input is
the Variable Power Supplies’ positive output.

FS
To Ch.A

IN PCM data
To Ch.B
CLK
Variable Power
Supplies 100kHz

Master
Signals

Figure 2

Experiment 15 – PCM decoding © 2007 Emona Instruments 15-5


16. Launch the NI ELVIS Oscilloscope VI.

17. Set up the scope per the procedure in Experiment 1 (page 1-13) with the following
changes:

 Scale control for both channels to 2V/div instead of 1V/div


 Coupling control for both channels to DC instead of AC
 Trigger Level control to 2V instead of 0V
 Timebase control to 10µs/div instead of 500µs/div

18. Set the scope’s Slope control to the “-” position.

19. Activate the scope’s Channel B input by pressing the Channel B Display control’s ON/OFF
button to observe the PCM Encoder module’s PCM DATA output as well as its FS output.

20. Vary the Variable Power Supplies positive output Voltage control left and right (but
don’t exceed 2.5V).

If your set-up is working correctly, this last step should cause the number on PCM Encoder
module’s PCM DATA output to go down and up. If it does, carry on to the next step. If not,
check your wiring or ask the instructor for help.

21. Close the Variable Power Supplies VI.

22. Slide the NI ELVIS Function Generator’s Control Mode switch so that it’s no-longer in
the Manual position.

23. Launch the Function Generator’s VI.

24. Press the Function Generator VI’s ON/OFF control to turn it on.

25. Adjust the Function Generator using its soft controls for an output with the following
specifications:

 Waveshape: Sine
 Frequency: 500Hz
 Amplitude: 4Vp-p
 DC Offset: 0V

26. Minimise the Function Generator’s VI.

27. Disconnect the plug to the Variable Power Supplies’ positive output.

15-6 © 2007 Emona Instruments Experiment 15 – PCM decoding


28. Modify the set-up as shown in Figure 3 below.

Remember: Dotted lines show leads already in place.

MASTER FUNCTION PCM


SIGNALS GENERATOR ENCODER

PCM

TDM SCOPE
ANALOG I/ O CH A
100kHz
SINE
100kHz ACH1 DAC1 INPUT 2 FS
COS CH B
100kHz
DIGITAL
8kHz ACH0 DAC0 INPUT 1
DIGITAL
VARIABLE DC TRIGGER
2kHz
DIGITAL +
2kHz CLK PCM
SINE DATA

Figure 3

This set-up can be represented by the block diagram in Figure 4 below. Notice that the PCM
Encoder module’s input is now the Function Generator’s output.

Function FS
Generator To Ch.A

500Hz IN PCM data


To Ch.B
CLK

100kHz

Figure 4

As the PCM Encoder module’s input is a sinewave, the module’s input voltage is continuously
changing. This means that you should notice the PCM DATA output changing continuously also.

Experiment 15 – PCM decoding © 2007 Emona Instruments 15-7


Ask the instructor to check
your work before continuing.

Part B – Decoding the PCM data

29. Deactivate the scope’s Channel B input.

30. Return the scope’s Slope control to the “+” position.

31. Modify the set-up as shown in Figure 5 below.

MASTER FUNCTION PCM PCM


SIGNALS GENERATOR ENCODER DECODER

GND

PCM
TDM
TDM SCOPE
ANALOG I/ O CH A
1 0 0kHz
SINE
1 0 0kHz ACH1 DAC1 INPUT 2 FS FS
COS CH B
1 0 0kHz
DIGITAL
8 kHz ACH0 DAC0 INPUT 1 PCM OUTPUT2
DIGITAL DATA
VARIABLE DC TRIGGER
2 kHz
DIGITAL +
2 kHz CLK PCM CLK OUTPUT
SINE DATA

Figure 5

The entire set-up can be represented by the block diagram in Figure 6 on the next page.
Notice that the decoder’s clock and frame synchronisation information are “stolen” from the
encoder.

15-8 © 2007 Emona Instruments Experiment 15 – PCM decoding


Message
To Ch.A
"Stolen" FS
PCM Decoder
OUTPUT
500Hz IN To Ch.B
PCM
CLK DATA "Stolen" CLK

100kHz

PCM Encoding PCM Decoding

Figure 6

32. Adjust the scope as follows:

 Scale control for both channels to 1V/div


 Coupling control for both channels to AC
 Trigger Level control to 0V
 Timebase control to 500µs/div

33. Activate the scope’s Channel B input to observe the PCM Decoder module’s output as well
as the message signal.

Question 1
What does the PCM Decoder’s “stepped” output tell you about the type of signal that it
is? Tip: If you’re not sure, see the preliminary discussion for this experiment or for
Experiment 13.

Ask the instructor to check


your work before continuing.

Experiment 15 – PCM decoding © 2007 Emona Instruments 15-9


The PCM Decoder module’s output signal looks very similar to the message. However, they’re
not the same. Remember that a “sampled” message contains many sinewaves in addition to the
message. The next part of this experiment lets you verify this using the NI ELVIS Dynamic
Signal Analyzer.

34. Close the scope’s VI.

35. Launch the NI ELVIS Dynamic Signal Analyzer VI.

36. Adjust the Signal Analyzer’s controls as follows:

General

Sampling to Run

Input Settings

 Source Channel to Scope CHB  Voltage Range to ±10V

FFT Settings Averaging


 Frequency Span to 10,000  Mode to RMS
 Resolution to 400  Weighting to Exponential
 Window to 7 Term B-Harris  # of Averages to 3

Triggering

 Triggering to FGEN SYNC_OUT

Frequency Display

 Units to dB  Markers to OFF (for now)


 RMS/Peak to RMS
 Scale to Auto

37. Activate the Signal Analyzer’s markers by pressing the Markers button.

38. Use the Signal Analyzer’s M1 marker to examine the frequency of the sinewaves that
make up the sampled message.

39. Use the M1 marker to locate the sinewave in the sampled message that has the same the
frequency as the original message.

15-10 © 2007 Emona Instruments Experiment 15 – PCM decoding


Ask the instructor to check
your work before continuing.

You have probably just noticed that many of the extra sinewaves in the sampled message are
at audible frequencies (that is, between about 20Hz and 20kHz). This means that, although
the message and sampled messages are similar in shape, you should be able to hear a
difference between them.

40. Add the Amplifier module to the set-up as shown in Figure 7 below leaving the scope’s
connections as they are.

MASTER FUNCTION PCM PCM NOISE


SIGNALS GENERATOR ENCODER DECODER GENERATOR

GND 0dB

PCM -6dB
TDM
TDM -20dB
ANALOG I/ O
100kHz
SINE AMPLIFIER
100kHz ACH1 DAC1 INPUT 2 FS FS
COS
100kHz
DIGITAL
8kHz ACH0 DAC0 INPUT 1 PCM OUTPUT2 GAIN
DIGITAL DATA
VARIABLE DC
2kHz
DIGITAL +
2kHz CLK PCM CLK OUTPUT IN OUT
SINE DATA

Figure 7

41. Locate the Amplifier module on the DATEx SFP and turn its soft Gain control fully anti-
clockwise.

42. Without wearing the headphones, plug them into the Amplifier module’s headphone
socket.

43. Put the headphones on.

44. Turn the Amplifier module’s soft Gain control clockwise until you can comfortably hear
the PCM Decoder module’s output.

45. Listen to how the sampled message sounds and commit it to memory.

Experiment 15 – PCM decoding © 2007 Emona Instruments 15-11


46. Disconnect the Amplifier module’s lead where it plugs to the PCM Decoder module’s
output.

47. Modify the set-up as shown in Figure 8 below, again leaving the scope’s connections as
they are.

MASTER FUNCTION PCM PCM NOISE


SIGNALS GENERATOR ENCODER DECODER GENERATOR

GND 0 dB

PCM -6 dB
TDM
TDM -2 0dB
ANALOG I/ O
1 0 0 kHz
SINE AMPLIFIER
1 0 0 kHz ACH1 DAC1 INPUT 2 FS FS
COS
1 0 0 kHz
DIGITAL
8 kHz ACH0 DAC0 INPUT 1 PCM OUTPUT2 GAIN
DIGITAL DATA
VARIABLE DC
2 kHz
DIGITAL +
2 kHz CLK PCM CLK OUTPUT IN OUT
SINE DATA

Figure 8

48. Compare the sound of the two signals. You should notice that they’re similar but clearly
different.

Question 2
What must be done to the PCM Decoder module’s output to reconstruct the message
properly?

Ask the instructor to check


your work before continuing.

15-12 © 2007 Emona Instruments Experiment 15 – PCM decoding


Part C – Encoding and decoding speech
So far, this experiment has encoded and decoded a sinewave for the message. The next part
of the experiment lets you do the same with speech.

49. Close the Signal Analyzer VI and launch the NI ELVIS Oscilloscope VI.

50. Adjust the scope so that you can observe two or so cycles of the original and sampled
messages again.

Tip: Don’t forget to set the scope’s Trigger Source control to the CH A position.

51. Completely remove the Amplifier module from the set-up while leaving the rest of the
leads in place.

52. Disconnect the plugs to the Function Generator’s output.

53. Modify the set-up as shown in Figure 9 below.

MASTER SEQUENCE PCM PCM


SIGNALS GENERATOR ENCODER DECODER
LINE
CODE
O
GND
1
PCM
OO NRZ-L
SYNC TDM
O1 Bi-O
1 O RZ-AMI TDM SCOPE
1 1 NRZ-M CH A
1 0 0 kHz
SINE X

1 0 0 kHz INPUT 2 FS FS
COS Y
CH B
1 0 0 kHz CLK
DIGITAL
SPEECH
8 kHz INPUT 1 PCM OUTPUT2
DIGITAL DATA
TRIGGER
2 kHz
DIGITAL
GND
2 kHz CLK PCM CLK OUTPUT
SINE DATA
GND

Figure 9

54. Set the scope’s Timebase control to the 500µs/div position.

55. Hum and talk into the microphone while watching the scope’s display.

Ask the instructor to check


your work before continuing.

Experiment 15 – PCM decoding © 2007 Emona Instruments 15-13


Part D – Recovering the message
As mentioned earlier, the message can be reconstructed from the PCM Decoder module’s
output signal using a low-pass filter. This part of the experiment lets you do this.

56. Locate the Tuneable Low-pass Filter module on the DATEx SFP and set its soft Gain
control to about the middle of its travel.

57. Turn the Tuneable Low-pass Filter module’s soft Cut-off Frequency Adjust control fully
anti-clockwise.

58. Disconnect the plugs to the Speech module’s output.

59. Modify the set-up as shown in Figure 10 below.

MASTER FUNCTION PCM PCM TUNEABLE


SIGNALS GENERATOR ENCODER DECODER LPF

GND

PCM f C x10 0
TDM
TDM SCOPE
ANALOG I/ O CH A
100kHz
SINE
100kHz ACH1 DAC1 INPUT 2 FS FS
COS fC CH B
100kHz
DIGITAL
8kHz ACH0 DAC0 INPUT 1 PCM OUTPUT2
DIGITAL DATA
VARIABLE DC TRIGGER
2kHz
DIGITAL + GAIN
2kHz CLK PCM CLK OUTPUT
SINE DATA
IN OUT

Figure 10

The entire set-up can be represented by the block diagram in Figure 11 on the next page. The
Tuneable Low-pass Filter module is used to reconstruct the original message from the PCM
Decoder module’s PAM output.

15-14 © 2007 Emona Instruments Experiment 15 – PCM decoding


Message
To Ch.A
Tuneable
FS Low-pass Filter

Message
500Hz IN To Ch.B
PCM
CLK DATA CLK

100kHz

PCM Encoding PCM Decoding Reconstruction

Figure 11

60. Slowly turn the Tuneable Low-pass Filter module’s soft Cut-off Frequency control
clockwise and stop the moment the message signal has been reconstructed (ignoring
phase shift).

The two signals are clearly the same so let’s see what your hearing tells you.

61. Add the Amplifier module to the set-up as shown in Figure 12 below leaving the scope’s
connections as they are.

MASTER FUNCTION PCM PCM TUNEABLE NOISE


SIGNALS GENERATOR ENCODER DECODER LPF GENERATOR

GND 0 dB

PCM f C x10 0 -6dB


TDM
TDM -2 0dB
ANALOG I/ O
1 0 0 kHz
SINE AMPLIFIER
1 0 0 kHz ACH1 DAC1 INPUT 2 FS FS
COS fC
1 0 0 kHz
DIGITAL
8 kHz ACH0 DAC0 INPUT 1 PCM OUTPUT2 GAIN
DIGITAL DATA
VARIABLE DC
2 kHz
DIGITAL + GAIN
CLK PCM CLK OUTPUT IN OUT
2 kHz
SINE DATA
IN OUT

Figure 12

Experiment 15 – PCM decoding © 2007 Emona Instruments 15-15


62. Turn the Amplifier module’s soft Gain control fully anti-clockwise.

63. Put the headphones on.

64. Turn the Amplifier module’s soft Gain control clockwise until you can comfortably hear
the Tuneable Low-pass Filter module’s output.

65. Commit the recovered message’s sound to memory.

66. Disconnect the Amplifier module’s lead where it plugs to the PCM Decoder module’s
output and connect it to the Function Generator’s output (in the same way that you did
when wiring the set-up in Figure 8).

67. Compare the sound of the two signals. You should find that they’re very similar.

Question 3
Even though the two signals look and sound the same, why isn’t the reconstructed
message a perfect copy of the original message? Tip: If you’re not sure, see the
preliminary discussion for Experiment 14.

Ask the instructor to check


your work before finishing.

15-16 © 2007 Emona Instruments Experiment 15 – PCM decoding

You might also like