Source Code From Chapter 18 Of C Unleashed

Introduction

C Unleashed Cover C Unleashed
Richard Heathfield
Lawrence Kirby
et al.
Sams Publishing 2000
ISBN 0672318962

Chapter 18 Digital Signal Processing

I was one of the contributing authors to C Unleashed. I wrote Chapter 18 Digital Signal Processing, and accompanying source code and text files that come with the book on the included CD.

I suggested addressing the subject by writing about several different aspects where C code is used to address real world situations most programmers, Internet surfers, and computer users deal with everyday. Since this was a book about C programming, and not about mathematical algorithms, I liked this approach better than a what I considered the "typical" subject matter, yet another description of the FFT (Fast Fourier Transform, do a net search if you like).

Also, I'm not sure I remembered all the math, since I've never actually had occasion to use an FFT in a project in my entire career...  :-)

I actually wrote about three aspects of real-world, everyday digital signal processing:

  1. Data compression and decompression, using the T.4 fax encoding protocol.

  2. Error detection and correction, discussing parity, checksums, CRC algotithms, and Hamming codes.

  3. Real world control applications, using the PID (Proportional, Integral, Derivative) algorithm.

The text in my chapter of the book is the property of MacMillan Computer Publishing, the parent company of Sams Publishing. I do not have the right to reproduce it here. If you want to read my deathless prose, and 28 other chapters on various aspects of advanced C programming by some of the best C programmers in the world, you will have to buy the book.

If you do decide to buy the book, shop around. Prices can and do vary widely and substantial discounts are available.

While I can't post the text of the chapter itself, all of the source code and text files that accompanied it were published and are copyrighted under the GPL (GNU General Public License) which allows free redistribution and modification, so I have placed them on this site with links to them on this page under the terms of that license.

You may view a copy of the license here. You may make any use you like of these files as long as you follow the terms of that license.

If you have questions or comments about any of these files, or the text of Chapter 18, please email me at this address, and not to my regular email address. If you have any issues with the book text or these files that you think warrants attention from a wider audience, feel free to post to the newsgroups comp.lang.c or comp.lang.c.moderated.


Errata

Richard Heathfield, one of the primary authors, maintains the errata page for C Unleashed. There are certainly some errata in Chapter 18, so if you have the book follow this link.


Graphics Mess!!!

A funny thing happened on the way to the printer...

I submitted sample graphics to Sams for their illustrators to use in generating the actual figures printed in the book. I am not terribly happy with the final six figures, the ones showing graphical results of the PID sample code. My originals were in color and I think they looked much better.

But the BIG PROBLEM is that the description of the graphics in the book is wrong!

At the top of page 829 it says: "For all the graphs in this section, the dashed line represents the set point and the solid line represents PV, the process variable."

Wrong!!! In figures 18.7 through 18.12, inclusive:

To help clear this up, I have converted my original sample graphics for these six illustrations to JPEG files and linked them from this page. In the JPEGS:

I hope that settles that!

File Size Description
Fig18-07.jpg 37,949 JPEG of my original sample for the illustration
Fig18-08.jpg 32,968 JPEG of my original sample for the illustration
Fig18-09.jpg 32,896 JPEG of my original sample for the illustration
Fig18-10.jpg 32,353 JPEG of my original sample for the illustration
Fig18-11.jpg 35,459 JPEG of my original sample for the illustration
Fig18-12.jpg 34,287 JPEG of my original sample for the illustration

The Source and Text Files

File Size Description
Chap18.txt 4,035 A text file describing the contents and use of some of the other files referenced on this page
encode.c 18,733 A program that encodes binary pixel data into Group 3 Fax (T.4) format (requires fax.h)
decode.c 30,833 A program that decides a T.4 file generated by encode.c back into binary pixel data (requires fax.h)
fax.h 1,276 A header file required for inclusion in both encode.c and decode.c
text2bin.c 240,894 This program generates binary pixel image files, suitable for encoding by encode.c, from ASCII text files (see Chap18.txt for more information). Note size, contains large character generator arrays!
lj300.c 3,213 This program will generate files for an HP LaserJet or compatible printer to output the images from encode.c, decode.c, and test2bin.c (see Chap18.txt for more information)
pidloopc.txt 8,662 Some documentation for the pidloop.c PID control loop simulator program and the *.pid files it can accept as input
pidloop.c 37,166 Source code for a PID control loop simulator, documentation in pidloopc.txt
accel1.pid
accel2.pid
id.pid
ionly.pid
pid.pid
step.pid
632
666
687
651
701
1,359
Assorted input files for pidloop.c, see pidloopc.txt for information
script.c 5,137 Program that parses the output from pidloop.c and generates an AutoCAD script to draw graphs of the results, can be used as a starting point if you have another graphic program that can process scripts
parity.c 1,987 Very simple program that generates a parity bits for strings of ASCII characters
chekline.c 1,731 Contains code to illustrate computing simple checksums on strings read from stdin with the standard function fgets()
hamming.c 7,090 Program for generating and checking (12,8) Hamming codes
crcccitt.c 4,682 Program for generating CRC-16 values using the CCITT algorithm used in Group 3 fax operations

[ Top ]
[ Home ]

This page validated by Valid HTML 3.2! W3C HTML Validation Service.

© 1999-2000 By Jack Klein. All Rights Reserved.
All trademarks are acknowledged to belong to their respective owners.
Updated 29-Oct-2000