100% found this document useful (2 votes)
12 views

(Ebook) Introductory Programs with the 32-bit PIC Microcontroller: A Line-by-Line Code Analysis and Reference Guide for Embedded Programming in C (Maker Innovations Series) by Hubert Ward ISBN 9781484290514, 9781484290507, 1484290518, 148429050X - The ebook is available for quick download, easy access to content

The document promotes various eBooks on embedded programming, particularly focusing on the 32-bit PIC microcontroller by Hubert Ward. It outlines the aims and objectives of the book, emphasizing the skills readers will gain in programming with C, and discusses the necessary tools and prerequisites for learning. Additionally, it highlights the advantages of using 32-bit PICs over 8-bit versions for aspiring embedded programmers.

Uploaded by

hinsakiroro35
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
12 views

(Ebook) Introductory Programs with the 32-bit PIC Microcontroller: A Line-by-Line Code Analysis and Reference Guide for Embedded Programming in C (Maker Innovations Series) by Hubert Ward ISBN 9781484290514, 9781484290507, 1484290518, 148429050X - The ebook is available for quick download, easy access to content

The document promotes various eBooks on embedded programming, particularly focusing on the 32-bit PIC microcontroller by Hubert Ward. It outlines the aims and objectives of the book, emphasizing the skills readers will gain in programming with C, and discusses the necessary tools and prerequisites for learning. Additionally, it highlights the advantages of using 32-bit PICs over 8-bit versions for aspiring embedded programmers.

Uploaded by

hinsakiroro35
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 82

Instant Ebook Access, One Click Away – Begin at ebooknice.

com

(Ebook) Introductory Programs with the 32-bit PIC


Microcontroller: A Line-by-Line Code Analysis and
Reference Guide for Embedded Programming in C
(Maker Innovations Series) by Hubert Ward ISBN
9781484290514, 9781484290507, 1484290518,
148429050X
https://ebooknice.com/product/introductory-programs-with-
the-32-bit-pic-microcontroller-a-line-by-line-code-analysis-
and-reference-guide-for-embedded-programming-in-c-maker-
innovations-series-50493086

OR CLICK BUTTON

DOWLOAD EBOOK

Get Instant Ebook Downloads – Browse at https://ebooknice.com


Instant digital products (PDF, ePub, MOBI) ready for you
Download now and discover formats that fit your needs...

Start reading on any device today!

(Ebook) Introductory Programs with the 32-bit PIC Microcontroller by Hubert Ward
ISBN 9781484290514, 1484290518

https://ebooknice.com/product/introductory-programs-with-the-32-bit-pic-
microcontroller-50009494

ebooknice.com

(Ebook) Programming Arduino Projects with the PIC Microcontroller: A Line-By Line
Code Analysis and Complete Reference Guide for Embedded Programming in C by Hubert
Henry Ward ISBN 9781484272299, 1484272293

https://ebooknice.com/product/programming-arduino-projects-with-the-pic-
microcontroller-a-line-by-line-code-analysis-and-complete-reference-guide-for-
embedded-programming-in-c-34873434

ebooknice.com

(Ebook) Intermediate C Programming for the PIC Microcontroller: Simplifying Embedded


Programming by Hubert Henry Ward ISBN 9781484260678, 9781484260685, 1484260678,
1484260686

https://ebooknice.com/product/intermediate-c-programming-for-the-pic-
microcontroller-simplifying-embedded-programming-22417478

ebooknice.com

(Ebook) Biota Grow 2C gather 2C cook by Loucas, Jason; Viles, James ISBN
9781459699816, 9781743365571, 9781925268492, 1459699815, 1743365578, 1925268497

https://ebooknice.com/product/biota-grow-2c-gather-2c-cook-6661374

ebooknice.com
(Ebook) C Programming for the PIC Microcontroller. by kan

https://ebooknice.com/product/c-programming-for-the-pic-microcontroller-50195818

ebooknice.com

(Ebook) Matematik 5000+ Kurs 2c Lärobok by Lena Alfredsson, Hans Heikne, Sanna
Bodemyr ISBN 9789127456600, 9127456609

https://ebooknice.com/product/matematik-5000-kurs-2c-larobok-23848312

ebooknice.com

(Ebook) SAT II Success MATH 1C and 2C 2002 (Peterson's SAT II Success) by Peterson's
ISBN 9780768906677, 0768906679

https://ebooknice.com/product/sat-ii-success-math-1c-and-2c-2002-peterson-s-sat-
ii-success-1722018

ebooknice.com

(Ebook) Advanced PIC Microcontroller Projects in C: From USB to ZIGBEE with the PIC
18F Series by Dogan Ibrahim ISBN 9780750689823, 075068982X

https://ebooknice.com/product/advanced-pic-microcontroller-projects-in-c-from-
usb-to-zigbee-with-the-pic-18f-series-1123344

ebooknice.com

(Ebook) Programming 8-bit PIC Microcontrollers in C: with Interactive Hardware


Simulation by Martin P. Bates ISBN 9780750689601, 0750689609

https://ebooknice.com/product/programming-8-bit-pic-microcontrollers-in-c-with-
interactive-hardware-simulation-2530310

ebooknice.com
Hubert Ward

Introductory Programs with the 32-bit


PIC Microcontroller
A Line-by-Line Code Analysis and Reference Guide
for Embedded Programming in C
Hubert Ward
Leigh, UK

ISBN 978-1-4842-9050-7 e-ISBN 978-1-4842-9051-4


https://doi.org/10.1007/978-1-4842-9051-4

© Hubert Ward 2023

This work is subject to copyright. All rights are solely and exclusively
licensed by the Publisher, whether the whole or part of the material is
concerned, specifically the rights of translation, reprinting, reuse of
illustrations, recitation, broadcasting, reproduction on microfilms or in
any other physical way, and transmission or information storage and
retrieval, electronic adaptation, computer software, or by similar or
dissimilar methodology now known or hereafter developed.

The use of general descriptive names, registered names, trademarks,


service marks, etc. in this publication does not imply, even in the
absence of a specific statement, that such names are exempt from the
relevant protective laws and regulations and therefore free for general
use.

The publisher, the authors, and the editors are safe to assume that the
advice and information in this book are believed to be true and accurate
at the date of publication. Neither the publisher nor the authors or the
editors give a warranty, expressed or implied, with respect to the
material contained herein or for any errors or omissions that may have
been made. The publisher remains neutral with regard to jurisdictional
claims in published maps and institutional affiliations.

This Apress imprint is published by the registered company APress


Media, LLC, part of Springer Nature.
The registered company address is: 1 New York Plaza, New York, NY
10004, U.S.A.
Dedicated to my wife Ann.
You have been so supportive and patient while I typed away, forever, on
my laptop.
Love always.
Pinch Pinch Pinch
The Aims and Objectives of the Book
My main aim in writing this book is to introduce you to the 32-bit micro
and help you understand how to program them in the C programming
language. I also want to show you that you can program them and that
you can make a career as an embedded programmer. I hope that after
reading this book, you will have developed your understanding of C and
that you will have the confidence to go and develop your own
programs.

The Objectives of the Book


After reading this book, you should be able to do some or all of the
following:
Create a project using MPLAB X
Configure the 32-bit PIC
Write local and global header files
Write programs using timers to create a delay
Understand a range of C instructions
Create one-dimensional and two-dimensional arrays in C
Write C programs to control and use the following displays:
Seven-segment displays
8 by 8 dot matrix displays
Liquid Crystal Display, LCD
Create a real-time clock
Use analog inputs
Create square waves and PWM
Control RGB LEDs using the PWM
Write programs that use interrupts
Understand and use a range of logic operations
Understand and use binary and hexadecimal number systems
Introduction
This book will introduce you to the exciting world of embedded
programming. It will teach you how the main functions of C
programming work and how you can use them to control a 32-bit PIC
microcontroller. You might think that a 32-bit PIC is too far advanced to
start with and that you should try a simpler PIC first. Well, really, that’s
not the case. You can start with all the simple programs, such as simply
turning on and off an LED, using a simple delay, controlling a seven-
segment display, and writing a simple message to an LCD, with this 32-
bit PIC. However, you can progress to the more advanced programs that
are out of reach with most of the 8-bit PICs.
It really comes down to cost. I use the explorer 16 development
board with a plugin board for the 32-bit PIC. The development board,
shown in Figure 2, comes in at around £100, and the plugin 32-bit PIC,
shown in Figure 1, comes in at around £30. On top of that, you will need
a programming tool to download your programs to the PIC. I use the
ICD3 can or the PICKIT3 tool. The ICD3 can costs around £70. However,
this is no longer available, and the ICD4 can is very expensive. They do
have the PICKIT4 which I believe programs 32-bit PICs, and that costs
around £70. So, you could possibly be looking at spending around £200
or more. But you should see it as an investment in your career as an
embedded programmer. Working as an embedded programmer, one
can earn around £40 to £100 an hour if not more.
If you went down the 8-bit PIC route first, you would spend less, but
your programming experience could be greatly reduced.

Prerequisites
As to any prerequisites you need before reading this book, there are
none. I will assume you are a complete novice, and I will explain every
step as you progress through the book. Every instruction will be
analyzed to explain how the C instruction works and how it achieves
what we want from the instructions. The only things you will definitely
need to use this book are as follows.
MPLAB X
This is the IDE, integrated development environment, from Microchip. I
will be using versions 5.25 and 5.40, but any version from 2.2 will be
fine as there will be only some minor differences. Also, as I know
Microchip is constantly updating its IDE, I am confident that the
changes will only be minor. This means the procedures for the IDE that
you will learn from this book will still stand you in good stead for any
later versions of the IDE.
Compiler Software
You will need a 32-bit compiler software to compile your programs
within MPLAB X. I use v2.41, although for a lot of my programs, I use
the older version 1.32, as the newer versions have some of the libraries
missing.
MPLAB X and the compiler software are freely available from the
Microchip website. You may have to search the archive section for some
of the older compiler versions. You could upgrade to the paid version of
the compiler software, but I have not done that for any of my programs.
If you were to make a career in embedded programming, then the paid
version of the compiler may have some advantages, such as more
efficient code that uses less memory.
Simulation Software
MPLAB X does come with a simulation option for its PICs. This does
mean that you can try some of the programs without spending any
money on equipment. However, the simulation capabilities are not very
extensive, and they are used more for debugging your programs. I will
take you through using the simulation option within MPLAB X for some
of the programs in the book, but most will be carried out on the
explorer 16 development board. However, simulating the programs will
give you a chance to see if you can enjoy programming these PICs. It is
not just about making money, as you will earn more if you enjoy what
you do.
There are some ECAD (electronic computer-aided design) software
that you can use to simulate the programs. PROTEUS is one that I have
used for 8-bit PICs. Multisim is another one, but you must make sure
that it can support the PICs you want to use, and they are not free.
MPLAB Harmony
Microchip has invested a lot of time and money in creating its
programming environment named MPLAB Harmony. It is aimed at
saving a lot of time in developing PIC programs. If you just want to get
something working and are not really interested in learning how it
works, then this environment can be useful. However, be aware that
once you go down that route, you can become dependent upon the
environment, as you are not really learning how the programs work.
That’s great for Microchip but not for you. I believe this approach is
counterproductive, as it does far too much for you and doesn’t explain
how it works. If you really want to become a versatile and productive
programmer, then you need to really understand how every bit of your
program works. Only then can you really say you wrote it and not just
cobbled together bits of code that you don’t understand. My main aim
in writing this book is to show that it is not too difficult to learn how to
program these PICs yourself. If you learn how PICs work and how we
can write C instructions to make them do what we want, then you will
become that versatile and experienced programmer that will find an
exciting and useful career as an embedded programmer.
Why am I writing this book and not working as that embedded
programmer? Well, really, I ventured into programming PICs a bit too
late in my life. I have been in education, teaching electrical and
electronic engineering at HND level, for over 25 years. So now I am
ready to retire and concentrate on trying to pass my knowledge and
experience onto you younger guys. I hope that in reading this book, you
will learn enough to become that versatile and productive embedded
programmer.

Why the 32-Bit PIC


I have been working with PIC microcontrollers since 1996, using them
to teach the micros unit in the BTEC Higher National Certificate and
Higher National Diploma course. In those early days, I used the 8-bit
PICs starting off with the 16F88 and the 16F884, writing programs in
assembly language. I actually started teaching the micros unit with the
“Emma” boards that used the 6502 microprocessor. That did give me a
great foundation in micros, but the PICs were much more versatile and
relevant. My favorite 8-bit PIC is the 18F4525. I have written three
textbooks on that PIC, but now it is time to start writing about an
amazing 32-bit PIC that I have used, the 32MX360F512L. A picture of
this PIC is shown in Figure 1.

Figure 1 The PIC32MX360F512L Microcontroller


The name of the PIC is quite a mouthful, but then that is Microchip
for you. Microchip does make an extensive range of PICs.
There is one big drawback with this PIC, compared to the
PIC18F4525, and that is, it is a surface mount device, whereas the
PIC18F4525 comes in a 40-pin dual in-line package. This does make the
32-bit PIC much more difficult to use if you want to make simple circuit
boards, on say some veroboard. It is a 100-pin device, and it can be
bought from Microchip on a small self-contained board, as shown in
Figure 1, that you could mount on some veroboard, but you would have
to create a 100-pin housing for the PIC. The cost of this self-contained
board with the PIC is around £30.
A simple way of using this type of PIC is to use the explorer 16
development board that I use. A picture of this is shown in Figure 2.
When I bought it, some eight years ago, it came with a 24-bit PIC
already included with it, so I had to buy the 32-bit PIC separately.

Figure 2 The Explorer 16 Development Board from Microchip

This is a very useful board that has the following peripheral devices:
An LCD, Liquid Crystal Display
A variable resistor to provide an analog input
Four switches connected to four inputs
Eight LEDs connected to PORTA
A 25LC256 256k serial EEPROM
A TC1074A temperature sensor
These are just a few of the devices that are available to you on the
explorer board. All these make the board a very useful addition to your
embedded programming equipment. This can easily justify the cost of
around £100.
You will need a programming tool to download your programs from
MPLAB X to your PIC. There are a couple of tools that you can use, such
as
ICD3 can that I use but Microchip has now stopped supplying this.
Instead, they supply the ICD4 can. However, this is quite expensive at
around £210.
The PICKIT3 is a much cheaper device at around £30; however,
Microchip has now moved on to the PICKIT4 programmer which they
sell for around £70.
You can buy plugin boards to help expand the explorer board. One
such plugin board is shown in Figure 3. You will see that I use this
extensively in my book.

Figure 3 A Plugin Extension Board

You could be spending around £250 plus, but you should find it a
useful investment as you can earn a high rate of pay as an embedded
programmer. There are cheaper tools you can use, but I can only write
about the ones I have used.
There are many other programming environments, but I know these
that I have shown you work and work well. Indeed, I have used my
explorer boards, with the plugin expansion slot, to control a
sophisticated industrial control system.
Some Important Aspects of C Programming
Before we move deep into the book, I think it would be useful to
mention some aspects of C programming that we will come across in
the analysis of the program listings.
The Main Loop
All C programs work in loops, usually more than one. However, all C
programs must have the “main” loop. It is to this main loop that the PIC
will go to find the very first instruction of the C program. All the other
loops are within this main loop or are called, as subroutines, from the
main loop.
Curly Brackets
C programming uses brackets to define the confines of these loops.
These are what I call “curly brackets,” that is, the opening curly bracket
“{“ and the closing curly bracket “}”. These are used to group a series of
instructions together. For example:

void main ()
{
instructions go here
}

Normal Brackets
The C programming also uses what I call “normal brackets,” that is, the
opening normal bracket “(“ and the closing normal bracket “)”. These
are used in conjunction with subroutines and subroutine calls.
We will look at these brackets as we analyze the programs in the
book.
Subroutines or Functions or Methods
Subroutines are sections of instructions that lie outside the main loop
of the program. They are used, primarily, to save memory, as if you want
the PIC to carry out a section of instructions in exactly the same way
more than once, then you should write them as a subroutine. Some
programmers may call these “functions” or “methods,” as they normally
carry out a function of some sort. I am an old hat at programming, and
so I call them subroutines.
Subroutines may or may not want values to be passed up to them
and send data back to the main loop of the program. To create a
subroutine, we use the general format as shown here:
keyword name of subroutine (request type of possible value to be
sent up)
The keyword is used to indicate what type of data the subroutine
will send back to the main program. If the subroutine will not send any
data back, which is the most common type of subroutine, then the
keyword would be “void.” However, if the subroutine will be sending
data back to the main program, then the keyword would indicate what
data type the data would be, for example:
unsigned char
int
For example: void delay250 (unsigned char t)
Note the use of the “normal brackets.”
This will create a subroutine that will not be sending data back to
the main program, that is, the keyword “void.” It will be expecting the
main program to pass up a value of the data type “unsigned char.” The
subroutine will copy that value into the local variable “t.”
When the main loop calls these subroutines, it is done using the
general format:
subroutine name (send any variables that the subroutine may
require)
For example: delay250(4);
This will call the subroutine called “delay250” and send the value
“4” to be copied into the subroutine’s local variable “t.”
Local and Global Variables
As I have mentioned the term local variable, I thought I should explain
what they are. C programming uses variables, which are newly created
memory locations, whose number of bits depends upon the data type
the variable will be, to store useful values that you will use in your
program. You should give the variable a suitable name that helps
explain what the variable is used for. However, we can use just simple
letters if we wanted to. C has two main types of variables:
Local variables: These are variables that are created when we create
a subroutine, and they are only valid for use in the subroutine they
were created in.
Global variables: These are variables that we create when we
construct the whole program. I usually list all the global variables at
the beginning of the program listing. These global variables can be
used anywhere within the program, that is, the main loop and any
subroutines, etc.
We will look more closely at these aspects of C programming as we
analyze the program listings.

Summary
In this introduction, we have looked at MPLAB X, the IDE from
Microchip, and the possible development boards you may have to buy. I
have tried to explain the aims of this book, and I have detailed some of
my experiences in the hope of convincing you I do know enough about
C programming for PIC micros.
In the first chapter, we will learn how to create a project in MPLAB
X. We will look at creating a header file, within MPLAB X, and use it in
our programs. This header file will look at how we use the
configuration words to set the clocks of the PIC and some other
important aspects of the PIC. I hope you will find this book useful and it
will help you get started on your career as an embedded programmer.
Table of Contents
Chapter 1:​Creating Our First C Program
What Is MPLAB X
Creating a Project in MPLAB X
The Initial Comments
The Speed of the Clock
Writing the Configuration Words
Our First Program
Setting the PORTS
Exercise 1-1
The Hexadecimal Number System
The First Program Listing
Analysis of Listing 1-1
Simulating the Program in MPLAB X
Solution to Exercise 1-1
Summary
Chapter 2:​Header Files and Delays
What Are Header Files and Why We Use Them?​
Creating a Header File
Using the Header File
Slowing the PIC Down
Creating a Delay
The Variable Delay Subroutine
What Is a Subroutine
The Analysis of the Delay Subroutine
Creating a 1ms Delay
Good Programming Practice
The Algorithm
The Flowchart
Our First Useful Program
The Algorithm
The Allocation List
The Flowchart for the Program
Creating the Project
Analysis of Listing 2-3
Downloading the Program to a Prototype Board
Extending the Program to the Crossroads Traffic Lights
The Algorithm
Analysis of Listing 2-4
Simulating the Program Within MPLAB X
Summary
Chapter 3:​The Seven-Segment Display
Controlling a Seven-Segment Display
The Seven-Segment Display
Common Anode Seven-Segment Display
Common Cathode Seven-Segment Display
Controlling the Display with the PIC
The Seven-Segment Display Program
The Algorithm
The Flowchart
The Listing for the Seven-Segment Display Program
Analysis of Listing 3-1
Improving the Seven-Segment Display Program
The Problem with the Program
Arrays
Using Pointers
Analysis of Listing 3-2
The Improved Program
Exercise 3-1
Solution to Exercise 3-1
Summary
Chapter 4:​The LCD
The 1602 LCD
Instruction or Command Mode
Data Mode
The Control Pins of the LCD
The LCD Header File for PORTE
Analysis of Listing 4-1
Analysis of Listing 4-2
Creating Your Own Symbols to Display on the LCD
The Pixel Maps
The 8-Bit Binary Values for the Four Special Characters
The Program “Pixel to Matrix”
The Special Character Program
The Program Listing for the Special Character Program
Analysis of Listing 4-3
Summary
Chapter 5:​The Dot Matrix Display
The 8 by 8 Dot Matrix Board
The Single Dot Matrix Display
The Max7219 Driver IC
Writing to the Max7219
Analysis of Listing 5-1
Creating the Data for Each Row in the Two-Dimensional Array
Controlling Four 64-Bit Dot Matrix Boards
Analysis of Listing 5-3
Analysis of Listing 5-2
A Program to Scroll Text on the Matrix Display
Summary
Chapter 6:​Communication
The 25LC256 EEPROM
What Is an EEPROM Device
Writing to the EEPROM
Reading from the EEPROM
The Connections of the EEPROM on the Explorer 16
Development Board
The Algorithm for the EEPROM Program
Analysis of Listing 6-1
The Setting of the CKE and CKP Bits
The Message “Ann Ward”
Using the Parallel Master Port
The Data for the PMMODE Control Register
The PMCON Control Register
The PMAEN Control Register
Analysis of Listing 6-2
Analysis of Listing 6-3
Summary
Chapter 7: The I2C Communication
The I2C Protocol
I2C Communication Protocol
Writing to the Slave
The Start Bit
The Address Bits and Control Bit in the First Byte
The Acknowledgment Bit
The Data Byte
The Stop Bit
Reading from the Slave
The NACK or Not Acknowledgment Bit
Analysis of the I2C Protocol Header File
The I2C Expander Module
The LCD2004
The Connections of the I2C Expander
Analysis of Listing 7-2
The Program to Use the I2C Expander to Control the LCD2004
Analysis of Listing 7-3
Summary
Chapter 8:​Interrupts
Interrupts
The Fetch and Execute Cycle
The Program Counter or “PC”
Single Vectored Interrupts
Multivectored Interrupts
How Does the PIC Keep Track of Where It Must Go and
Where It Must Get Back To?​
The Stack and Its Main Use
The Sources of Interrupts in a 32-Bit PIC
Analysis of Listing 8-1
Using More Than One Interrupt Source with Single Vector Mode
Analysis of Listing 8-2
Interrupt Priority
Multivectored Interrupts with Priority
Analysis of Listing 8-3
Summary
Chapter 9:​The Real-Time Clock
The External Crystal 32.​768kHz Oscillator
The 24-Hour LCD Clock Program
Analysis of Listing 9-1
The TM1637 and the Four Seven-Segment Displays
The TM1637 Driver IC
Analysis of Listing 9-2
Summary
Chapter 10:​The Real-Time Clock and the DS3231
The DS3231 RTC Module
The Order the DS3231 Expects the Data
The Program Algorithm
Displaying the Temperature
Binary Numbers
Adding Binary Numbers
Reading the Temperature from the TC72
Examples of the Two’s Complement Process
Using the UART and a Terminal Software
Using the Alarms of the DS3231
The UART
The UxMODE Control Register
The UxSTA Register
Using Tera Term
Connecting the Devices to the PIC32
Analysis of Listing 10-1
Summary
Chapter 11:​The RTCC Module
The RTCC Module of the 32-Bit PIC
BCD (Binary-Coded Decimal)
Displaying the 32-Bit Value on the LCD
RTCC Module Program
Analysis of Listing 11-1
Understanding Instruction on Line 504 RTCALRM =​0x8403;
Summary
Chapter 12:​The Real Analog World
The Real-World Signals
An Analog Signal
The Digital World
A Simple Voltmeter Program
The Algorithm of the Voltmeter Program
Analysis of Listing 12-1
The ADC Process
The Acquisition Time
The 4–20mA Transducer
Controlling Two Analog Inputs
Analysis of Listing 12-2
Summary
Chapter 13:​The DHT11 Transducer
The DHT11 Humidity and Temperature Sensor
Communicating with the DHT11
The Use of a Pull-Up Resistor
The DHT11 Program Listing
Analysis of Listing 13-1
The Logical OR and AND Truth Tables
A Design Procedure
Know the Events You Want to Control
Analysis of Listing 13-2
Simulating the Program in MPLAB X
Summary
Chapter 14:​Creating a Square Wave
Creating a Simple Square Wave
Using the Output Compare Module (OCMP) of the PIC32
Using the Logic Analyzer Within MPLAB X
Creating Some Musical Notes
Creating a PWM Square Wave with the OC1MP Module
The Average of a Square Wave
Analysis of Listing 14-4
Varying the Brightness of a Lamp
Analysis of Listing 14-5
Summary
Appendix
Appendix 1:​Data Types
Appendix 2:​Some Useful Definitions
Appendix 3:​Mathematical and Logic Operators
Appendix 4:​Keywords
Appendix 5:​Numbering Systems Within Microprocessor-Based
Systems
Appendix 6:​The ASCII Character Set
Appendix 7:​The LCD Instruction Set
Index
About the Author
Hubert Ward
has nearly 25 years of experience as a college lecturer delivering the
BTEC, and now Pearson’s, Higher National Certificate and Higher
Diploma in Electrical and Electronic Engineering. Hubert has a 2.1
Honors Bachelor’s Degree in Electrical and Electronic Engineering.
Hubert has also worked as a consultant in embedded programming. His
work has established his expertise in the assembler and C
programming languages, within the MPLAB X IDE from Microchip, as
well as designing electronic circuits and PCBs using ECAD software.
Hubert was also the UK technical expert in Mechatronics for three
years, training the UK team and taking them to enter in the Skills
Olympics in Seoul 2001, resulting in one of the best outcomes to date
for the UK in Mechatronics.
About the Technical Reviewer
Mike McRoberts
is the author of Beginning Arduino by Apress. He is the winner of Pi
Wars 2018 and a member of Medway Makers. He is an Arduino and
Raspberry Pi enthusiast.
© The Author(s), under exclusive license to APress Media, LLC, part of Springer
Nature 2023
H. Ward, Introductory Programs with the 32-bit PIC Microcontroller
https://doi.org/10.1007/978-1-4842-9051-4_1

1. Creating Our First C Program


Hubert Ward1
(1) Leigh, UK

In this chapter, we will study the process of creating a project for the
32-bit PIC within Microchip’s IDE, MPLAB X. We will study the
important aspect of creating a clock for the PIC. Then we will create our
first program that will look at the ports and learn how to set the
direction of data through the ports. We will then write a simple
program to light an LED and simulate it within MPLAB X.
After reading this chapter, you will have studied how to create a
project in MPLAB X. You will also have a good understanding of the
configuration words and how we can control the ports, so that we can
write our first simple program.
You will also have used the simulation in MPLAB X to confirm our
first program works correctly.

What Is MPLAB X
MPLAB X is Microchip’s IDE, integrated development environment. It is
a collection of programs designed to make the development of
programs for the PIC microcontrollers an easy and enjoyable process. It
uses a dedicated text editor that has coloring for keywords and uses an
IntelliSense that works like predictive text on a mobile phone. It has a
range of debugging tools that aid the debugging of your programs. It
also has a simulation software that allows you to simulate most of your
PIC programs. All this and the required compilers are freely available
from the Microchip website.
Creating a Project in MPLAB X
Assuming you have downloaded the software and the compiler, you
simply click the mouse on the following icon to start the program.

Once the software has started, the opening screen, shown in Figure 1-1,
should appear.

Figure 1-1 The Opening Screen of the IDE

You should appreciate that when you create a project, a new folder
will be created on your hard drive, where all the files and directories for
the project will be stored.
To create a new project, simply click the word “File” in the main
menu, and then select “New Project” from the fly-out menu that
appears. An alternative approach would be to click the mouse on the
small orange box with the green cross in it, which is the second item
from the left on the second menu bar. The “Choose Project” window
shown in Figure 1-2 should appear.

Figure 1-2 The Choose Project Window


Most of our projects will be stand-alone Microchip embedded,
which means we can simply click Next here to move on to the next
window, as those options should be highlighted. If the options, shown
in Figure 1-2, are not already highlighted, you should select them now,
then click Next. The next window is the “Select Device” window as
shown in Figure 1-3.
Figure 1-3 The Select Device Window
In this window, we can select the actual PIC we will be using. In the
family slot, you should choose the 32-bit MCUs (PIC32) as shown in
Figure 1-3. Then, in the device slot, select the 32MX360F512L. Once
you are happy with your selections, you should click Next. If you are
using a different 32-bit PIC, then you should select it here.
This will move us onto the “Select Tool” window as shown in Figure
1-4.
Figure 1-4 The Select Tool Window
Here, you can select the actual tool you are using to download the
program from MPLAB X to the PIC. In this case, we will simply use the
simulator option of MPLAB X. With this option, we don’t need an actual
PIC, as we will be using the PIC simulator from within MPLAB X.
Once you have selected your chosen tool, you should click Next to
move on to the “Select Compiler” window as shown in Figure 1-5.
Figure 1-5 The Select Compiler Window
I am assuming you have downloaded the appropriate compiler
software. I have selected the up-to-date version 2.41. However, I also
have the earlier version v1.32 as shown here. As I said earlier, we will
need this older version; you will have to look in the archive section of
the Microchip website to find it. Indeed, it is when we look at using
interrupts that we will use this older version of the compiler software.
Once you have selected your compiler, simply click Next to move on
to the “Select Project Name and Folder” window as shown in Figure 1-6.
Figure 1-6 The Select Project Name and Folder
With this window, you can give the project a name and decide
where to save the project. I have named the project “ourFirst32Bit,” and
I am using what is termed “Camel Font.” This is where we combine
multiple words to make one long word. The first letter of the first word
is in lowercase, and the first letter of all subsequent words is in
uppercase. In this way, the separate words of the newly created long
word are still discernible.
I tend to save the projects on my root directory, but you must save it
where you want.
Once you are happy with your selection, you should click Finish, and
your project will be created.
The screen will now change to the main editing window as shown in
Figure 1-7.
Figure 1-7 The Screen with the Project Side Menu
Before we finish this chapter, we will create the program file for this
first project. We will call it “ourFirst32BitProg.” To create the file, we
will need to expand the project tree that is shown on the left-side plane
in Figure 1-7. This is simply done by clicking the mouse on the small
box with the + sign in it, at the side of the “ourFirst32Bit” name in the
project tree, as shown in Figure 1-7. If the project tree is not shown, you
can click the mouse on the word “Window” on the main menu bar. You
should then simply click the first choice, which depicts the orange box
and word project. The project tree should then appear. You may have to
move the box with the project tree in it around the screen. This can be
done by clicking and dragging the mouse with the box selected. It will
take some time to master the moving of the different boxes around the
screen, so I will just leave it for you to practice.
Once the project tree is opened, you should right-click the mouse on
the phrase Source Files. Then click the mouse on the option “New” from
the fly-out menu. Then click the option “main_c” that appears. This is
shown in Figure 1-8.
Figure 1-8 The New Main_C Source File
Once you do that, you will be presented with the “Name and
Location” for the source file as shown in Figure 1-9.
Figure 1-9 The Name and Location for the Source File
Here, you can give your c file a suitable name. I have given it the
name “ourFirst32BitProg.” The extension for the file is c, as shown in
the small extension window. Once you are happy with the name, you
should click Finish to create the file.
When you do this, you will create a new file that will appear in the
main editing window. However, Microchip does insert a lot of text that
you will not need at this starting level, if ever. Therefore, to make sure
we all have the same window, I would ask you to delete all the text that
is inserted in the file. After deleting that material, you should now have
a screen that looks like that shown in Figure 1-10.
Figure 1-10 The Empty Source File
We have now created our first project within MPLAB X. I suggest
you go through this process for every project you make. The more times
you go through this process, the easier it becomes.

The Initial Comments


You should always lay claim to your program, you have written it, and
you should be proud of what you have achieved. Therefore, the first
thing you should write in the file is a paragraph of comments along the
lines of what is suggested here:

/* A simple program to control an LED


Written by Mr. H. H. Ward for the PIC32
Dated 12/01/2020.*/

There are two types of comments:


Single-line comments: This is anything written on the current line
only after two forward slashes. For example, //the following are just
comments, and the compiler will ignore them.
Multiple lines or a paragraph of comments: This is anything
written on one or more lines that are between the following symbols,
for example, /* The next lines are comments*/.
As this is a paragraph of comments, we should enclose them
between the following symbols: /* */.
My initial comments are shown in Figure 1-11.
Figure 1-11 The Comments for the Program
You will notice I have changed the font of the comments. This is to
make them clearer in the book. If you want to do this, then you should
select the word “Tools” on the main menu. Then select the word
“Options” from the fly-out menu, and you should then be presented
with the window shown in Figure 1-12. You will notice I have selected
the term “Fonts & Colors” from the menu.
You should then be able to change the comments to what you want.
Once you are happy with your changes, simply click OK to close the
window and apply the changes.
Figure 1-12 The Options Window

The Speed of the Clock


The operation of all microcontrollers is synchronized to a clock signal.
With all PICs, the programmer has total control over the frequency of
this clock signal. It is therefore an important aspect of PIC programs
and one that you should understand how we can control.
Like all PICs, the 32-bit PIC has a wide selection of possible sources
for the oscillator that will form the basis of the clock. There are also
different clocks for different aspects of the 32-bit PIC. Figure 1-13
depicts the block diagram of the system clock sources.
Figure 1-13 Block Diagram of the 32-Bit PIC Clock System
There are four sources of oscillators for the PIC. The two external
sources are shown as the primary oscillator with terminals OSCI
(oscillator in) and OSCO (oscillator out) and the secondary oscillator,
shown as SOSCO and SOSCI. The other two oscillator sources are the
FRC (fast resistor capacitor) and the LPRC (low-power resistor
capacitor).
The primary oscillator and the FRC can be fed, unaltered, to produce
the clock signal, or they can be passed through a divider circuit, divider
one, then through a PLL (phase lock loop) circuit, where the frequency
can be multiplied, then through a final divider circuit, divider two,
before being used for the various clock signals.
The secondary oscillator and the LPRC sources are used to generate
a relatively low frequency around 32kHz for the LPRC and an exact
32.768kHz from a crystal oscillator. Both of these can be used for the
system clocks. The secondary oscillator can be used as an accurate
source for timer1 and for the RTCC (Real-Time Clock Calendar). The
LPRC can be used as the source for the WDT (the Watch Dog Timer) and
the PWRT (Power Watch Reset Timer).
The FRC and LPRC are both internal oscillators, and the ability to
use an internal oscillator is useful if you were short of I/O, as with the
PIC18F4525. However, with this 32-bit PIC, I/O, the number of input
and output pins, is not really a problem. Also, as the RC oscillators are
not as accurate as crystal oscillators, I will use the external oscillator
sources for my projects.
The primary oscillator on the explorer 16 development board is an
8MHz crystal. The board also has the 32.768kHz crystal as the
secondary source, which can be used to run the RTCC (Real-Time Clock
and Calendar). We have the option of increasing the frequency of the
oscillator to produce a faster clock signal, and to do this, we must run
the 8MHz crystal oscillator through the phase lock loop circuit.
However, the phase lock loop circuit requires an input frequency of
4MHz. That is why we have the ability to run the oscillator through the
divider one first. As we are using the 8MHz crystal, we must set the first
divider to divide by 2.
Once in the phase lock loop, we have the ability to multiply the
signal by a factor of 15 up to a factor of 24. At present time, the
maximum clock frequency for the 32-bit PIC is 72MHz; therefore, we
will multiply the 4MHz signal by 18. This means that the output of the
phase lock loop will be a 72MHz clock signal. This means we don’t need
to divide the clock further, so set the divider two to divide by 1, that is,
no change.
There is one final division we can make if we wanted to. This is to
make the peripheral bus clock, the PBCLK, run at a lower frequency
than the system clock, the CPU clock. We will choose to run the PBCLK
at 36MHz. This means we need to divide the CPU clock by 2 before
applying it to the PBCLK.
All of these changes can be achieved by writing the correct data to
the configuration words. As this is something you have to do in all your
projects, then Microchip has made this process as simple as possible.

Writing the Configuration Words


To start the process, simply click the mouse on the word “Window” on
the main menu bar. Then select “Target Memory Views” from the first
fly-out menu. Then select “Configuration Bits” from the second fly-out
menu. This is shown in Figure 1-14.

Figure 1-14 Selecting the Configuration Bits

The display will now show the configuration bits in the bottom half
of the editing window. This is shown in Figure 1-15.
You can now make the changes that we need as follows:
Change the second option FPLLIDIV, the input divider to the phase
lock loop, to DIV_2.
Change the third option FPLLMUL, the PLL multiplier, to MUL_18.
Change the fourth option FPLLODIV, the PLL output divider, to DIV_1.
Next, change the FNOSC option to PRIPLL, primary oscillator with
phase lock loop. This tells the PIC that we will be passing the
oscillator through the phase lock loop circuit.
Next, change the FSOCEN, the secondary oscillator enable bit, to off
to disable the secondary oscillator.
Next, change the IESO to off to disable the two-speed startup.
Next, set the POSCMOD, the primary oscillator mode, to XT. This is
because the 8MHz external crystal is less than 10MHz which is within
the XT range of frequencies.
Next, set the FPBDIV, the frequency of the peripheral bus divider, to
DIV_2. This is to reduce the frequency of the peripheral bus to
36MHz.
Change the FWDTEN to off. The WDT is the Watch Dog Timer which
will stop the program if nothing happens for a set period of time. This
is really used in production lines, and we don’t need this for our
programs, so we must turn it off.
This is displayed in the editing window as shown in Figure 1-15.
Note the changes will be highlighted in blue.

Figure 1-15 The Changes to the Configuration Bits

The changes are ready, but they will not take place until we have
written the source code into the program. This can be done by clicking
the mouse on the tab at the bottom of the window labeled “Generate
Source Code to Output.” When you do this, the source code for these
changes will appear in the output window. This is shown in Figure 1-
16.

Figure 1-16 The Source Code for the Changes to the Configuration Bits
You then need to select all the text, including the “#include <xc.h>”,
in that window and copy it into your program in the editing window.
Your screen should now look something like that shown in Figure 1-
17.
Figure 1-17 The Code Pasted into the Editing Window
Note, I have copied everything including the #include <xc.h>, the
last line in the code. I will explain the importance of this #include
option later.
There are a lot of changes we are making to the configuration bits.
We will make the same changes for all the projects we will create in the
book. This is because we will be using the explorer 16 development
board for all our programs. That being the case, it will be easier if we
create a header file for this. We will do this in Chapter 2, where we will
discuss the importance of header files.

Our First Program


Now we are ready to start writing our first program in earnest. We
need to know what it will do, so I will write the specification down now.
This program will wait until a momentary start switch is pressed.
When that happens, it will turn on an LED. It will then wait for a
momentary stop switch to be pressed at which point it will turn the
LED off. It will then go back to waiting for the start button to be pressed
and so repeat the process. Not a very exciting program, but for our first
step into embedded programming, it is more than enough. I think you
Other documents randomly have
different content
river Thames. Surely these was some of the execrable characters
whom Justice pursued, who, though “they escaped the sea, yet
vengeance suffered not to live. Acts 28.—4.” ... Having passed these
spectacles of horror, a fair wind and flowing tide smoothly carried us
towards the boundless ocean....

‘When we drew towards the conflux of the river Thames there were
two objects that attracted our notice: the one, the King’s guardship,
placed there for the purposes of good œconomy, the other a large
painted vessel which floated on the surface of the water, and is
called a buoy. While we were passing the king’s ship, I heard the
report of a cannon, and saw the flash of the charge at some
distance; and, on inquiring the reason of such a circumstance, was
informed it was customary for every ship which passed, by way of
obedience, to lower her topsail; but the firing of the gun made them
hasten to show their obedience, for fear of a more unfavourable
salute; for, though a flash of powder might give us some alarm, the
discharge of a ball might make us feel the effects of disobedience....
Hitherto the generality of our company appeared to carry jollity and
mirth in their countenances; but now we began to see the blushing
rose die in the sickly cheek, and several of our passengers began to
feel the sickening effects of the rolling sea; they withdrew from their
mirth, and in pleasure crept into a corner, and silently mourned their
lost pleasures in solitude.... Thrice happy the souls who are by divine
grace made sick of unsatisfying delights, and compelled to withdraw
from unsatisfying objects, and seek and find permanent bliss in the
friendship of Immanuel!

‘There had been the appearance of affability and good-humour kept


up among the passengers of our vessel, and a reciprocal exchange
of civilities had passed between them; our bad tempers were for
awhile laid aside, and we seemed mutually agreed to make each
other as innocently happy as our present. If the same mode of
conduct was observed through the whole of our department, how
would the ills of life be softened, and the ties of society
sweetened!...
‘The eyelid of the day was now nearly closed upon us, and the
gloom of darkness began to surround us, which, together with the
hollow bellowing of the wind, and dashing waves, had a tendency to
create very solemn ideas in the mind; and I, being a stranger to
such scenes, had my mind exercised upon things of greater
importance....

‘About ten o’clock on Friday night we were brought safely into the
harbour of Margate, and then cast anchor in order to set a great
number of our passengers on shore, who were bound for that place
of rendezvous. How great are the advantages of navigation! By the
skill and care of three men and a boy, a number of persons were in
safety conveyed from one part to another of the kingdom....

‘When we had safely landed our passengers at Margate, we weighed


anchor at eleven o’clock at night, in order to sail round the North
Foreland for Ramsgate. The North Foreland is a point of land which
stretches out some way into the sea, and is the extreme part of our
country on the right hand, when we sail down the river Thames; and
sailing round the point into the British Channel is esteemed by
sailors rather dangerous. However, there was danger enough to
awaken the apprehensions of a freshwater sailor. Yet here with some
degree of confidence in Him who exercises His power over the sea
and dry land, I laid me down and slept in quietness, while the
rattling waves drove against the sides of our vessel, and the rustling
winds shook our sails, and made our yielding masts to speak. I was
led to reflect that now there was but a feeble plank between me and
the bottomless deep, yet, by a reliance on the divine goodness, my
fears were hushed, and a divine calm prevailed within. “Thou will
keep him in perfect peace whose mind is staid on thee.” Isaiah 26.—
3.

‘On Saturday morning I awoke and heard a peaceful sound from


shore, which informed me it was two o’clock; and, inquiring where
we were, I found we were safe anchored within the commodious
harbour of Ramsgate. Being so early an hour, we again composed
ourselves to sleep, and lay till five o’clock; then leaving our sleeping
apartment, and mounting the peaceful deck—not like the frighted
sailor, who leaves the horrid hulk to view a thousand deaths from
winds, and waves, and rocks, without a friendly shore in view—but
to see one of the finest retreats from all these dangers, which
Providence has provided for the safety of those who are exposed to
the violence and rage of angry elements. The commodious Pier of
Ramsgate seems admirably calculated to shelter and protect vessels
which are threatened with destruction from winds and waves. This
beautiful piece of architecture is built in the form of a Crescent, or
half-moon, the points of which join to the land.... The whole of this
building of utility appeared to bear a clear resemblance to the
glorious Mediator in his offices, who is appointed for a refuge from
the storm....

‘By six in the morning we went on shore, and joyfully met our
friends, who were brought down the day before; but in their passage
were overtaken by a violent storm of thunder and lightning, whilst
our voyage was smooth and prosperous; but, in the morning, we all
met in peace and safety. Thus we sat down to a friendly breakfast,
and cheerfully talked over the adventures of the little voyage.
Something like this, I think, may take place in the state of
blessedness.... While we were thus employed, we consulted how to
dispose of ourselves while we continued at Ramsgate; we mutually
agreed to form ourselves into a little family, and though we could not
all lodge, yet we wished to board together in the same house.’ This
is a pleasing instance of bonne camaraderie engendered, in a short
time, among agreeable companions.

‘In order to pursue the design of our coming, some of our company
mixed among the bathers at the seaside. The convenience of
bathing, the coolness of a fine summer’s morning, the agreeable
appearance of company so early, and the novelty of the scene, had a
very pleasing effect.... We began to look around us; and though we
were not presented with objects of taste and elegance, yet the town
and environs afforded us some rural prospects, which yielded both
instruction and pleasure. Upon our left hand, as we ascended from
the sea-side, stands the seat of observation, erected on a point of
land, and commanding an extensive prospect over that part of the
sea called the Downs, where you behold a number of ships lying at
anchor, or on their passage to different parts of the world. From
thence you may likewise see the lofty cliffs of France, and
reverberating the light of the sun; while, at the same time, you may,
by way of amusement, watch the motions of every boat coming in
and going out of the harbour; and, as the sea is always varying, its
appearance altogether affords an agreeable amusement. Here the
Company frequently stop to rest themselves after a morning’s or an
evening’s walk, and are sweetly regaled by the cool refreshing
breezes of the sea....

‘It might be thought strange was I to say nothing of Margate, that


being the chief resort for bathers, and of growing repute. The town
of Margate is in a very increasing state, and its principal ornaments
consist of its late additions. The chief concern of the publick seems
to render it as much a place for pleasure as utility, as, under colour
of utility, persons can pursue pleasure without censure. A mother, for
instance, might be highly blamed by her acquaintance for leaving
her family for a month, and going to spend her husband’s money;
but who can blame her when her health requires it? They are
modelling it according to the taste of the times. They have, indeed,
built one place of worship, but a playhouse nearly four times as
large. Thus, when ill-health does not interrupt the company’s pursuit
of amusement, they are likely soon to be accommodated to their
minds. Such is the provision already made, that the consumptive
cough of a delicate lady may be furnished with the relief of the
fumes of a smoking hot assembly-room, and the embarrassed citizen
may drown his anxiety in the amusements of the Card-table....

‘The libraries are decently furnished, and may serve as a kind of


lounging Exchange, where persons overburdened with money and
time may ease themselves with great facility. The most healthful
amusement, and best suited to invalids, that is pursued at Margate,
is that of the bowling-green, where, upon the top of a hill, and in full
prospect of the sea, in a free open air, gentlemen may exercise their
bodies, and unbend their minds; this, if pursued for the benefit of
health and innocent recreation, with a serious friend, appears to
have no more criminality in it than Peter’s going a fishing....

‘Having staid as long at Ramsgate as our affairs at home would, with


prudence, admit; we went on board the same ship, and re-embarked
for London. In order, I suppose, to take the better advantage, we
sailed some leagues right out to sea; but, it being a dead calm, we
hardly experienced any other motion than was occasioned by the
tide and swell of the sea for that night. The cry of the sailors, Blow!
Blow! reminded me of that pathetick exclamation of the ancient
Church! The next day proved equally calm, so that we had little else
to divert us but walk about the deck, and watch the rolling of the
porpoises in the sea. We had an old sailor on board, whose patience
being tired, declared he preferred being at sea in a storm to being
becalmed on the ocean, which struck me with the propriety of the
observation, when applied to Christian experience; for a storm,
under Divine direction, is often made the means of hastening the
Christian’s progress, while a dead calm is useless and unsafe.’

It took them two days to get to Margate, and another day to reach
Gravesend. On their way they passed a vessel cast on shore, which
‘cut a dismal figure, such as they make, to an enlightened eye, who
make shipwreck of faith, whom Christians see, as they pursue their
course, run aground, and dash to pieces.’

By the time they came to Gravesend some of the passengers had


had enough of the Hoy—so they hired a boat and four men to row
them to London, but the wind getting up, the river became rough,
and the boat being over-loaded, the boatmen begged them to get
on board a fishing-smack, which they did, and arrived at Billingsgate
safely. We can hardly imagine, in these days of steam, that a
journey from Ramsgate to London would last from Monday morning
to Wednesday night, but people did not hurry themselves too much
in those days.
QUACKS OF THE CENTURY.

N all ages there have been pretenders to medical science,


and it has been reserved to the present century to
elevate the healing art into a real science, based on
proper physiological facts, aided by the searching
analyses of modern chemistry. The old alchemists had
died out, yet they had some pretensions to learning, but the
pharmacopœia at the commencement of the eighteenth century was
in a deplorable condition. Surgery, for rough purposes, had existed
since the earliest ages, because accidents would happen, then as
now; and, moreover, there were wars, which necessitated the
amputation of limbs, etc., but medicine, except in the knowledge of
the virtue of herbs and simples, was in more than a primitive state.
Anyone who chose, could dub himself Doctor, and, naturally, the
privilege was largely taken advantage of.

The name of quack, or quacksalver, does not seem to have been


much used before the seventeenth century, and its derivation has
not been distinctly settled. In the ‘Antiquities of Egypt,’ etc., by
William Osburn, junior, London, 1847, p. 94, he says: ‘The idea of a
physician is frequently represented by a species of duck, the name
of which is CHIN: the Egyptian word for physician was also CHINI.’
But neither Pierret, in his ‘Vocabulaire Hieroglyphique,’ nor Bunsen,
in ‘Egypt’s Place in Universal History,’ endorse this statement. Still
the Egyptian equivalent for cackling, or the noise of a goose, was Ka
ka, and in Coptic Ouok, pronounced very much like quack.
The Germans also use the word Quacksalber, and the Dutch
Kwaksalver, a term which Bilderdijk, in his ‘Geslachtlijst der
Naamwoorden,’ (derivation or gender of men’s names) says, ought
more properly to be Kwabsalver, from Kwab, a wen, and Salver, to
anoint. Be this as it may, the English word quack certainly means an
illegitimate medical practitioner, a pretender to medical science,
whose pretensions are not warranted by his knowledge.

The seventeenth century was prolific in quacks—a notable example


being John Wilmot, Earl of Rochester. Both Bishop Burnet and De
Gramont agree that, during one of his banishments from Court, he
lived in Tower Street (next door to the sign of the ‘Black Swan,’ at a
goldsmith’s house), and there practised as a quack doctor, as one
Alexander Bendo, newly arrived from Germany. There is a famous
mountebank speech of his extant, copies of which exist not only in
broad sheets, but in some of the jest-books of the seventeenth
century, which, genuine or not, is very amusing. It is far too long to
transcribe here, but perhaps I may be pardoned if I give a short
extract.

‘The knowledge of these secrets I gathered in my travels abroad


(where I have spent my time ever since I was fifteen years old to
this, my nine and twentieth year) in France and Italy. Those that
have travelled in Italy will tell you what a miracle of art does there
assist nature in the preservation of beauty: how women of forty bear
the same countenance with them of fifteen: ages are no way
distinguished by faces; whereas, here in England, look a horse in the
mouth and a woman in the face, you presently know both their ages
to a year. I will, therefore, give you such remedies that, without
destroying your complexion (as most of your paints and daubings
do) shall render them perfectly fair; clearing and preserving them
from all spots, freckles, heats, pimples, and marks of the small-pox,
or any other accidental ones, so that the face be not seamed or
scarred.
‘I will also cleanse and preserve your teeth white and round as
pearls, fastening them that are loose: your gums shall be kept
entire, as red as coral; your lips of the same colour, and soft as you
could wish your lawful kisses.

‘I will likewise administer that which shall cure the worst of breaths,
provided the lungs be not totally perished and imposthumated; as
also certain and infallible remedies for those whose breaths are yet
untainted; so that nothing but either a very long sickness, or old age
itself, shall ever be able to spoil them.

‘I will, besides, (if it be desired) take away from their fatness who
have over much, and add flesh to those that want it, without the
least detriment to their constitutions.’

By his plausible manners and good address, he soon gathered round


him a large clientèle of servants, etc., for he told fortunes as well as
cured diseases. These told their mistresses, and they too came to
consult the wise man. Even the Court ladies came incognito to see
him, and la belle Jennings, sister to the famous Sarah, first Duchess
of Marlborough, went, with the beautiful Miss Price, to have their
fortunes told, disguised as orange-wenches, and in all probability
their visit would never have been heard of, had they not met with a
disagreeable adventure with a somewhat dissolute gentleman
named Brounker, who was gentleman of the chamber to the Duke of
York, and brother to Viscount Brounker, President of the Royal
Society.

John Cotgrave87 thus describes the quack of his time:


‘My name is Pulse-feel, a poor Doctor of Physick,
That does wear three pile Velvet in his Hat,
Has paid a quarter’s Rent of his house before-hand,
And (simple as he stands here) was made Doctor beyond sea.
I vow, as I am Right worshipful, the taking
Of my Degree cost me twelve French Crowns, and
Thirty-five pounds of Butter in upper Germany.
I can make your beauty and preserve it,
Rectifie your body and maintaine it,
Clarifie your blood, surfle88 your cheeks, perfume
Your skin, tinct your hair, enliven your eye,
Heighten your Appetite; and, as for Jellies,
Dentifrizes, Dyets, Minerals, Fucusses,89
Pomatums, Fumes, Italia Masks to sleep in,
Either to moisten or dry the superficies, Paugh, Galen
Was a Goose, and Paracelsus a patch
To Doctor Pulse-feel.’

Then there was that arch quack and empiric, Sir Kenelm Digby, with
his ‘sympathetic powder,’ etc., and Dr. Saffold, originally a weaver,
who distributed his handbills broadcast, advertising his ability to cure
every disease under the sun.

Also in this century is a poem called ‘The Dispensary,’90 by Sir


Samuel Garth, who lived in Queen Anne’s time, which gives the
following account of a quack and his surroundings:
‘So truly Horoscope its Virtues knows,
To this bright Idol91 ’tis, alone, he bows;
And fancies that a Thousand Pound supplies
The want of twenty Thousand Qualities.
Long has he been of that amphibious Fry,
Bold to prescribe, and busie to apply.
His Shop the gazing Vulgar’s Eyes employs
With foreign Trinkets, and domestick Toys.
Here Mummies lay, most reverently stale,
And there, the Tortois hung her Coat o’ Mail;
Not far from some huge Shark’s devouring Head,
The flying Fish their finny Pinions spread.
Aloft in rows large Poppy Heads were strung,
And near, a scaly Alligator hung.
In this place, Drugs in Musty heaps decay’d,
In that, dry’d Bladders, and drawn Teeth were laid.
An inner Room receives the numerous Shoals
Of such as pay to be reputed Fools.
Globes stand by Globes, Volumns on Volumns lie,
And Planitary Schemes amuse the eye
The Sage, in Velvet Chair, here lolls at ease,
To promise future Health for present Fees.
Then, as from Tripod, solemn shams reveals,
And what the Stars know nothing of, reveals.’

Medicine in the last century was very crude. Bleeding and purging
were matters of course; but some of the remedies in the
pharmacopœia were very curious. Happy the patient who knew not
the composition of his dose. Take the following:92

‘Or sometimes a quarter of a pint of the following decoction may be


drank alone four times a day:
‘Take a fresh viper, freed from the head, skin, and intestines, cut in
pieces; candied eryngo root, sliced, two ounces. Boil them gently in
three pints of water, to a pint and three-quarters, and to the strained
liquor add simple and spiritous cinnamon waters, of each two
ounces. Mix them together, to be taken as above directed.

‘The following viper broth (taken from the London Dispensatory) is a


very nutritious and proper restorative food in this case, and seems to
be one of the best preparations of the viper: for all the benefit that
can be expected from that animal is by this means obtained:

‘Take a middle-sized viper, freed from head, skin, and intestines; and
two pints of water. Boil them to a pint and a half; then remove the
vessel from the fire; and when the liquor is grown cold, let the fat,
which congeals upon the surface, if the viper was fresh, be taken off.
Into this broth, whilst warm, put a pullet of a moderate size, drawn
and freed from the skin, and all the fat, but with the flesh intire. Set
the vessel on the fire again, that the liquor may boil; then remove it
from the fire, take out the chicken, and immediately chop its flesh
into little pieces: put these into the liquor again, set it over the fire,
and as soon as it boils up, pour out the broth, first carefully taking
off the scum.

‘Of this broth let the patient take half a pint every morning, at two of
the clock in the afternoon, and at supper-time.’

In the same book, also (p. 97), we find the following remedy for
cancer:

‘Dr. Heister, professor of physic and surgery in the university of


Helmstadt in Germany, with many others, greatly extols the virtue of
millepedes, or wood-lice, in this case; and, perhaps, the best way of
administering them is as follows:

‘Take of live wood-lice, one ounce; fine sugar, two drams; a little
powder of nutmeg; and half a pint of alexeterial water. Let the
wood-lice and sugar, with the nutmeg, be ground together in a
marble mortar, then gradually add the water, which being well
mixed, strain it with hard pressing. Two ounces of this expression
are to be taken twice a day, shaking the vessel, so that no part of it
may be lost.’

And it also seems that much virtue was attached to the great
number of component parts in a medicine, as may be seen in the
recipe for Arquebusade Water93 (from the same book, p. 101).

‘Take of comfrey leaves and root, sage, mugwort, bugloss, each four
handfulls; betony, sanicle, ox-eye daisy, common daisy, greater
figwort, plantane, agrimony, vervain, wormwood, fennel, each two
handfulls; St. John’s wort, long birthwort, orpine, veronica, lesser
centaury, milfoil, tobacco, mouse-ear, mint, hyssop, each one
handfull; wine twenty-four pounds. Having cut and bruised the
herbs, pour on them the wine, and let them stand together, in
digestion, in horse dung, or any other equivalent heat, for three
days: afterwards distill in an alembic with a moderate fire.

‘This celebrated water has for some time been held in great esteem,
in contusions, for resolving coagulated blood, discussing the tumors
that arise on fractures and dislocations, for preventing the progress
of gangrenes, and cleansing and healing ulcers and wounds,
particularly gunshot wounds....’

Amongst the empyrical medicines, the following is much cried up by


many people, as an infallible remedy:

‘Take two ounces of the worts that grow dangling to the hinder heels
of a stone horse,94 wash them in common water, then infuse them
in white wine all night, and afterwards let them be dried, and
reduced to powder. The dose is half a dram twice a day, in any
proper vehicle. A dram of Venice soap given twice a day, either in
pills, or dissolved in some proper liquor, is likewise said to cure a
Cancer.’
In the early part of the eighteenth century, the regular physicians
were very ignorant. Ward95 thus describes them, and, although his
language was coarse, he was a keen observer.

‘They rail mightily in their Writings against the ignorance of Quacks


and Mountebanks, yet, for the sake of Lucre, they Licence all the
Cozening Pretenders about Town, or they could not Practise; which
shows it is by their Toleration that the People are Cheated out of
their Lives and Money; and yet they think themselves so Honest, as
to be no ways answerable for this Publick Injury; as if they could not
kill People fast enough themselves, but must depute all the Knaves
in the Town to be Death’s Journeymen. Thus do they License what
they ought carefully to Suppress; and Practise themselves what they
Blame and Condemn in others; And that the Town may not be
deceived by Apothecaries, they have made themselves Medicine-
Mongers,96 under a pretence of serving the Publick with more
faithful preparations; in order to perswade the World to a belief of
which, they have publish’d Bills, where, in the true Quack’s Dialect,
they tell you the Poor shall be supply’d for nothing; but whoever is
so Needy as to make a Challenge of their promise empty-handed,
will find, according to the Mountebank’s saying, No Money, No Cure.
The disposal of their Medicines they leave to a Boy’s management,
who scarce knows Mercurius Dulcis from White Sugar, or Mint Water
from Aqua Fortis: So that People are likely to be well serv’d, or
Prescriptions truly observed by such an Agent.’

If this was a faithful portrait of a physician in the commencement of


the century, what must a charlatan have been? They sowed their
hand-bills broadcast. Gay, in his ‘Trivia,’ book ii., says,

‘If the pale Walker pants with weak’ning Ills,


His sickly Hand is stor’d with Friendly Bills:
From hence he learns the seventh born97 Doctor’s Fame,
From hence he learns the cheapest Tailor’s name.’
So universal was this practice of advertising that, to quote Ward98
once more, when talking of the Royal Exchange, he says,

‘The Wainscote was adorn’d with Quacks’ Bills, instead of Pictures;


never an Emperick in the Town, but had his Name in a Lacquered
Frame, containing a fair Invitation for a Fool and his Money to be
soon parted.’

The newspapers teemed with quack advertisements. These, of


course, we have; but we also have preserved to us a quantity of the
ephemeral hand-bills, which, presumably, were kept on account of
the intrinsic merits they possessed. They are a curious study. There
was the ‘Oxford Doctor at the Fleet Prison, near Fleet Bridge,
London,’ who would sell ten pills in a box for sixpence, warranted a
cure for the ‘Scurvy, Dropsie, and Colt-evil,’ would provide a remedy
for ‘Headach, Sore Eyes, Toothach, Stomachach, Bleeding,
Scorbutick Gums, Black, Yellow, foul Teeth, Cramp, Worms, Itch,
Kibes, and Chilblains; the Price of each proper Specifick, Twopence.
Teeth or stumps of Teeth, Drawn with Ease and Safety, Let Blood
neatly, Issues or Setons Curiously made; For Two Pence each, and
welcome. By the Doctor that puts forth this paper, you may be
Taught Writing, Arithmetick, Latin, Greek, and Hebrew, at reasonable
Rates by the great, Or Two Pence each of them by the Week.’
Presumably, as he does not advertise it, he could not teach manners
at the same traditional price.

There was another who sold the Elixir Stomachum which was sold at
the various coffee-houses about town, and he complains thus: ‘☞
Garrowaye, the Apple-man at the Exchange, who had it of me, to
sell, for five or six years, I have lately found out, is Counterfeiting it,
and have removed mine from him; and what he now sells is a
Counterfeit sort, and not the Right, as was formerly Sold there.’

There was a man, living in Blackfriars, who was so modest that he


veiled his identity under the initials R.C., who, from two in the
afternoon till night, ‘will give to all People a Secret how they may
utterly destroy Buggs without injury to their Goods, at reasonable
rates; do as you are Taught, and if any be doubtful of the truth of it,
they may have full satisfaction of them that have Experienced it.’

Here is a gentleman who gives a minute address. ‘In Petty France,


Westminster, at a house with a black dore, and a Red Knocker,
between the Sign of the Rose and Crown and Jacob’s Well, is a
German who hath a Powder which, with the blessing of God upon it,
certainly cures the Stone, &c.... If any person of known Integrity will
affirm that upon following their directions the cure is not perfected,
they shall have their Money returned. Therefore be not unwilling to
come for help, but suspend your Judgment till you have try’d, and
then speak as you find.’

There is another, which may belong to the previous century—but it is


so hard to tell, either by means of type or wood blocks—put forth by
‘Salvator Winter, an Italian of the City of Naples, Aged 98 years, Yet,
by the Blessing of God, finds himself in health, and as strong as
anyone of Fifty, as to the Sensitive part; Which first he attributes to
God, and then to his Elixir Vitæ, which he always carries in his
pocket adayes, and at Night under his pillow; And when he finds
himself distemper’d, he taketh a Spoonful or two, according as need
requireth.‘ It is needless to say that the Elixir was warranted to cure
every evil under the sun, including such diverse maladies as
catarrhs, sore eyes, hardness of hearing, toothache, sore throat,
consumption, obstructions in the stomach, and worms. The net was
arranged to catch every kind of fish. In fact, his business was so
profitable that he had a successor, ‘Salvator Winter, Junior,’ who says
thus: ‘My father, aged 98 years, yet enjoys his perfect health, which,
next to the blessing of God, he attributes to the Elixir Vitæ having
alway a bottle of it in his pocket, drinking a spoonful thereof four or
five times a day; snuffing it very strongly up his Nostrils, and bathing
his Temples; thus by prevention, he fortifies his vital Spirits.’

Nor did the sterner sex monopolise the profession of quackdom, for
‘At the Blew-Ball in Grays-Inn Lane, near Holborn Barrs, next Door to
a Tallow-Chandler, where you may see my Name upon a Board over
the Door, liveth Elizabeth Maris, the True German Gentlewoman
lately arrived.’ It seems that we were much indebted to Germany for
our quacks, for ‘At the Boot and Spatter dash,99 next Door but One
to the Vine Tavern, in Long-Acre, near Drury Lane, Liveth a German
Dr. and Surgeon, Who by the blessing of GOD on his great Pains,
Travels and Experience, hath had wonderful Success in the Cure of
the Diseases following,’ &c. There was also ‘Cornelius à Tilbourg,
Sworn Chirurgeon in Ordinary to K. Charles the II., to our late
Sovereign K. William, as also to Her present Majesty Queen Ann.’

A certain John Choke, whose motto was ‘Nothing without God,’ and
was ‘an approved Physician; and farther, Priviledged by his Majesty,’
advertised ‘an Arcane which I had in Germany, from the Famous and
most Learned Baptista Van Helmont, of worthy Memory (whose
Daughter I Wedded), and whose Prœscripts most Physicians follow.’

Curative and magical powers seem to have extended from seventh


sons of seventh sons to women—for I find an advertisement, ‘At the
Sign of the Blew-Ball, at the upper end of Labour in vain-Street, next
Shadwell-New-Market, Liveth a Seventh Daughter, who learn’d her
Skill by one of the ablest Physicians in England (her uncle was one
of K. Charles’s and K. James’s twelve Doctors), who resolves all
manner of Questions, and interprets Dreams to admiration, and hath
never fail’d (with God’s Blessing) what she took in hand.’ Also there
was a book published late in the seventeenth century, called ‘The
Woman’s Prophecy, or the Rare and Wonderful DOCTRESS, foretelling
a Thousand strange monstrous things that shall come to pass before
New Year’s day next, or afterwards—. She likewise undertakes to
cure the most desperate Diseases of the Female Sex, as the
Glim’ring of the Gizzard, the Quavering of the Kidneys, the Wambling
Trot, &c.’ A man who lived at the ‘Three Compasses’ in Maiden Lane,
also issued a hand bill that he would infallibly cure ‘several strange
diseases, which (though as yet not known to the world) he will
plainly demonstrate to any Ingenious Artist to be the greatest
Causes of the most common Distempers incident to the Body of
Man. The Names of which take as follow: The Strong Fives, the
Marthambles, the Moon-Pall, the Hockogrocle.’

Then there was a medicine which was administered to children even


in my young days, ‘Daffy’s famous Elixir Salutis, prepared by
Katharine Daffy. The finest now exposed to Sale, prepar’d from the
best Druggs, according to Art, and the Original Receipt, which my
Father, Mr. Thomas Daffy, late Rector of Redmile, in the Valley of
Belvoir, having experienc’d the Virtues of it, imparted to his
Kinsman, Mr. Anthony Daffy, who publish’d the same to the Benefit
of the Community, and his own great Advantage. This very Original
Receipt is now in my possession, left to me by my father aforesaid,
under his own Hand. My own Brother, Mr. Daniel Daffy, formerly
Apothecary in Nottingham, made this ELIXIR from the same Receipt,
and Sold it there during his Life. Those, who know me, will believe
what I Declare; and those who do not, may be convinc’d that I am
no Countefeit, by the Colour, Tast, Smell, and just Operation of my
Elixir.’ This was, however, disputed by one John Harrison—and the
rivals of nearly two centuries ago, remind us forcibly of the claimants
to the original recipe of Bond’s Marking Ink.

A man sold a useful medicine. ‘A most excellent Eye Water, which


cures in a very short time all Distempers relating to the Eyes, from
whatever Cause soever they proceed, even tho’ they have been of
seven, eight, nine, or ten Years’ continuance.... This excellent Water
effectually takes away all Rabies or Pimples in the face, or any Part
of the Body; it also dissolves any small, or new-come Wens or
Bunches under the Skin, so easily that it can hardly be perceived.’

One quack blossomed forth in verse, and thus describes himself: ‘In
Cripplegate Parish, in Whitecross Street, almost at the farther End,
near Old Street (turning in by the sign of the Black Croe, in Goat
Alley, straightforward down three steps, at the sign of the Blew Ball),
liveth one of above Forty Years’ Experience, who with God’s Blessing
performeth these cures following:
‘To all that please to come, he will and can
Cure most Diseases incident to Man.
The Leprosie, the Cholic, and the Spleen,
And most Diseases common to be seen.
Although not cured by Quack Doctors’ proud,
And yet their Name doth ring and range aloud,
With Riches, and for Cures which others do,
Which they could not perform, and this is true.
This Doctor he performeth without doubt, }
The Ileak Passion, Scurvy, and the gout, }
Even to those the Hospitals turn out.’ }

Such ground as one did not cover, another did. Take, for instance,
the following: ‘In Surry-Street, in the Strand, at the Corner House
with a White-Balcony and Blue-Flower pots, liveth a Gentlewoman,
who

‘Hath a most excellent Wash to beautifie the Face, which cures all
Redness, Flushings, or Pimples. Takes off any Yellowness, Morpheu,
Sunburn, or Spots on the Skin, and takes away Wrinckles and
Driness, caused too often by Mercurial Poysonous Washes, rendring
the worst of Faces fair and tender, and preserves ’em so. You may
have from half a Crown to five Pound a Bottle. You may also have
Night Masks, Forehead Pieces, incomparable whitepots, and Red
Pomatum for the lips, which keeps them all the Year plump and
smooth, and of a delicate natural colour. She has an admirable Paste
to smooth and whiten the Hands, with a very good Tooth powder,
which cleanses and whitens the Teeth. And a Water to wash the
Mouth, which prevents the Scurvy in the Gums and cures where ’tis
already come.

‘You may have a Plaster and Water which takes off Hair from any
part of the Body, so that it shall never come again. She has also a
most excellent Secret to prevent the Hair from falling, causing it to
grow where it is wanting in any part of the Head. She also shapes
the Eye-brows, making them perfectly beautiful, without any pain,
and raises low Foreheads as high as you please. And colours Grey or
Red Hair to a lovely Brown, which never decays, changes, or smoots
the Linnen. She has excellent Cosmeticks to anoint the Face after
the Small Pox, which wears out any Scars, Marks, or Redness; and
has great skill in all manner of sore Eyes.

‘She has a most excellent Dyet Drink which cures the worst of
Consumptions, or any Impurity of the Blood: And an Antiscorbutick
spirit, which, being taken one spoonful in the Morning, and another
at Night, with moderate Exercise, cures the Scurvy, tho’ never so far
gone, and all broke out in Blotches: with many other Secrets in
Physick, which you may be satisfied in when you speak with her....
She has an approved Remedy for Barrenness in Women.’

Very late in the preceding century (he died May 12, 1691), there was
a most famous quack, Dr. Thomas Saffold, one of whose handbills I
give as a curiosity:
‘Dear Friends, let your Disease be what God will,
Pray to Him for a Cure—try Saffold’s Skill,
Who may be such a healing Instrument
As will Cure you to your own Heart’s Content.
His Medicines are Cheap, and truly Good,
Being full as safe as your daily Food.
Saffold he can do what may be done, by
Either Physick or true Astrology:
His Best Pills, Rare Elixirs, and Powder,
Do each Day Praise him Lowder and Lowder.
Dear Country-men, I pray be you so Wise, }
When Men Back-bite him, believe not their Lyes, }
But go see him and believe your own Eyes; }
Then he will say you are Honest and Kind,
Try before you Judge, and Speak as you Find.

‘By Thomas Saffold, an Approved and Licensed Physician and


Student in Astrology, who (through God’s Mercy), to do good, still
liveth at the Black Ball and Old Lilly’s Head, next Door to the
Feather-Shops that are within Black-fryers Gate-way, which is over
against Ludgate Church, just by Ludgate in London. Of him the Poor,
Sore, Sick, and Lame may have Advice for nothing, and proper
Medicines for every particular Distemper, at reasonable Rates ready
prepared, with plain Directions how to use them, to cure either Men,
Women, or Children of any Disease or Diseases afflicting any Body,
whether inward or outward, of what Name or Nature soever (if
Curable); Also of this you may be sure, he hath Medicines to prevent
as well as Cure.

‘Lastly, He doth with great certainty and privacy: Resolve all manner
of Lawful Questions, according to the Rules of Christian Astrology,
and more than Twenty One Years’ Experience.’
Talk of modern quacks—they are but second-rate to Saffold! His
Pillulæ Londinenses, or London pills, were advertised that ‘not only
the meaner sort of all Ages and each Sex, but people of Eminence,
both for their Rank in the World and their parts, have found
admirable success in taking these Pills.’

This panacea was warranted to cure ‘Gout, Dropsy, Coma, Lethargy,


Caries, Apoplexy, Palsy, Convulsions, Falling Sickness, Vertigo,
Madness, Catarrhs, Headache, Scald, and Sore Heads, sore Eyes,
Deafness, Toothache, sore Mouth, sore and swollen Throat, foul
Stomach, bad Digestion, Vomiting, Pain at the Stomach, sour
Belching, Colic, Twisting of the Guts, Looseness, Worms, all
Obstructions of the Pancreas, of the Mesaraic Veins, of the passages
of the Chyle, and of the Liver and Spleen, the Jaundice, Cachexy,
Hypochondriac Melancholy, Agues, Itch, Boils, Rheumatism, Pains
and Aches, Surfeits by Eating and Hard Drinking, or by Heats and
Colds (as some call them).’

Then there comes a charming bit of candour almost sufficient to


disarm the unwary: ‘They are also good in taking the Waters. I
would not advise them by any means in the Bloody Flux, nor in
continual Fevers, but they are good to purge after either of those
Diseases is over, or to carry off the Humor aforehand. They must
also be foreborn by Women with Child. Otherwise they are good for
any Constitution, and in any Clime. They are Durable many years,
and good at Sea as well as on Land.’

Thomas Saffold knew well the value of advertising, and scattered his
very varied handbills broadcast. Presumably, like modern quacks, he
made money. Of course he died, and his epitaph is as follows (he
originally was a weaver):
‘Here lies the Corpse of Thomas Saffold,
By Death, in spite of Physick, baffled;
Who, leaving off his working loom,
Did learned doctor soon become.
To poetry he made pretence,
Too plain to any man’s own sense;
But he when living thought it sin
To hide his talent in napkin;
Now Death does Doctor (poet) crowd
Within the limits of a shroud.’

There was a harmless remedy advertised, even though it was a


fraud—and this was the loan, or sale, of necklaces to be worn by
children in teething.

THE FAMOUS AND VIRTUOUS NECKLACES.

‘One of them being of no greater weight than a small Nutmeg,


absolutely easing Children in Breeding Teeth without Pain; thereby
preventing Feavers, Ruptures, Convulsions, Rickets, and such
attendant Distempers, to the Admiration of thousands of the City of
London, and Counties adjoining, who have experienced the same, to
their great comfort and satisfaction of the Parents of the Children
who have used them. Besides the Decrease in the Bills of Mortality,
apparent (within this Year and a half) of above one half of what
formerly Dyed; and are now Exposed to sale for the Publick good, at
five shillings each Necklace, &c.’

Then there was a far higher-priced necklace, but, as it also operated


on adults, it was perhaps stronger and more efficacious. ‘A necklace
that cures all sorts of fits in children, occasioned by Teeth or any
other Cause; as also Fits in Men and Women. To be had at Mr.
Larance’s in Somerset Court, near Northumberland House in the
Strand; price ten shillings for eight days, though the cure will be
performed immediately.’ And there was the famous ‘Anodyne
Necklace.’

In the preceding century there were some famous quacks, notably


Sir Kenelm Digby, who, with his sympathetic powder, worked
wonders, especially one instance, an account of which he read to a
learned society at Montpellier. He recounted how a certain learned
gentleman, named Howell, found two of his friends engaged in a
duel with swords, how he rushed to part them, and catching hold of
one of their blades, his hand was severely cut, the other antagonist
cutting him severely on the back of his hand. Seeing the mischief
they had done, they bound up his hand with his garter, and took him
home. Mr. Howell was of such note that the King sent his own
physician to him, but without avail; and there was expectation that
the hand would mortify and have to be amputated. Here Sir Kenelm,
who knew him, stepped in, and, being applied to by his friend to try
his remedies, consented. Let him tell his own tale.

‘I asked him then for anything that had blood upon it; so he
presently sent for his garter, wherewith his hand was first bound,
and as I called for a basin of water, as if I would wash my hands, I
took a handful of powder of vitriol, which I had in my study, and
presently dissolved it. As soon as the bloody garter was brought me,
I put it in the basin, observing, in the interim, what Mr. Howell did,
who stood talking with a gentleman in a corner of my chamber, not
regarding at all what I was doing. He started suddenly, as if he had
found some strange alteration in himself. I asked him what he ailed.

‘“I know not what ails me; but I feel no more pain. Methinks that a
pleasing kind of freshness, as it were a wet cold napkin, did spread
over my hand, which hath taken away the inflammation that
tormented me before.”
‘I replied, “Since, then, you feel already so much good of my
medicament, I advise you to cast away all your plasters; only keep
the wound clean, and in a moderate temper, betwixt heat and cold.”

‘This was presently reported to the Duke of Buckingham, and, a little


after, to the King, who were both very curious to know the
circumstances of the business; which was, that after dinner, I took
the garter out of the water, and put it to dry before a great fire. It
was scarce dry before Mr. Howell’s servant came running, and saying
that his master felt as much burning as ever he had done, if not
more; for the heat was such as if his hand were betwixt coals of fire.
I answered that although that had happened at present, yet he
should find ease in a short time; for I knew the reason of this new
accident, and would provide accordingly; for his master should be
free from that inflammation, it might be, before he could possibly
return to him; but, in case he found no ease, I wished him to come
presently back again; if not, he might forbear coming. Thereupon he
went; and, at the instant, I did put the garter again into the water;
thereupon he found his master without any pain at all. To be brief,
there was no sense of pain afterwards; but within five or six days
the wounds were cicatrized, and entirely healed.’

Faith worked wonders, and a credulous imagination formed an


excellent foundation for healing. Take another instance in the same
century—the case of Valentine Greatraks (who cured by the
imposition of hands), who was nearly contemporary with Sir Kenelm.
It would serve no good purpose to go minutely into his history:
suffice it to say that he was an Irishman of good family, and, as a
young man, served under Cromwell. After the disbandment of the
army he was made Clerk of the Peace for the County of Cork,
Registrar for Transplantation (ejection of Papists who would not go
to church) and Justice of the Peace, so that we see he occupied a
respectable position in society.

After Greatraks settled down in his civil capacity, he seems to have


been a blameless member of society; but his religious convictions
were extremely rabid, and strong on the Protestant side. Writing in
1668, he says: ‘About four years since I had an Impulse, or a
strange perswasion, in my own mind (of which I am not able to give
any rational account to another) which did very frequently suggest
to me that there was bestowed on me the gift of curing the King’s
Evil: which, for the extraordinariness of it, I thought fit to conceal for
some time, but at length I communicated this to my Wife, and told
her, That I did verily believe that God had given me the blessing of
curing the King’s Evil; for, whether I were in private or publick,
sleeping or waking, still I had the same Impulse; but her reply was
to me, That she conceived this was a strange imagination: but, to
prove the contrary, a few daies after there was one William Maher of
Salterbridge, in the Parish of Lissmore, that brought his Son William
Maher to my house, desiring my Wife to cure him, who was a person
ready to afford her Charity to her Neighbours, according to her small
skill in Chirurgery; on which my Wife told me there was one that had
the King’s Evil very grievously in the Eyes, Cheek, and Throat;
whereupon I told her that she should now see whether this were a
bare fancy, or imagination, as she thought it, or the Dictates of God’s
Spirit on my heart; and thereupon I laid my hands on the places
affected, and prayed to God for Jesus’ sake to heal him, and then I
bid the Parent two or three days afterwards to bring the Child to me
again, which accordingly he did, and then I saw the Eye was almost
quite whole, and the Node, which was almost as big as a Pullet’s
Egg, was suppurated, and the throat strangely amended, and, to be
brief (to God’s glory I speak it), within a month discharged itself
quite, and was perfectly healed, and so continues, God be praised.’

This may be taken as a sample of his cures, albeit his first; and,
although he excited the enmity of the licensed medical profession,
he seems to have cured the Countess of Conway of an inveterate
head-ache, which greatly enhanced his reputation. He died no one
knows when, but some time early in the century.

And in our time, too, have been the quacks, the Zouave Jacob and
Dr. Newton, who pretended to have the miraculous gift of healing by
the imposition of hands, so that we can scarcely wonder that, in an
age when the dissemination of accurate and scientific knowledge as
the present is (imperfect though it be), a man like Valentine
Greatraks was believed in as of almost divine authority at the period
at which he lived. But it is a very curious thing that some men either
imagine that they have, or feign to have a miraculous gift of healing.
Witness in our own day the ‘Peculiar People,’ who base their peculiar
gift of healing on a text from the Epistle of St. James, chap. 5, v. 14
—‘Is any sick among you? let him call upon the elders of the Church;
and let them pray over him, anointing him with oil in the name of
the Lord.’

So also the Catholic and Apostolic Church (Irvingites) teach this


practice as a dogma, vide their catechism,100 ‘What are the benefits
to be derived from this rite?’ ‘St. James teaches us again that the
prayer of faith shall save the sick, and the Lord shall raise him up;
and, if he have committed sins, they shall be forgiven him.’ After
this, who can say that the age of faith is passed away?

With them, also, is a great function for the benediction of oil for
anointing the sick; the rubric for which is as follows:101 ‘In the
Celebration of the Holy Eucharist on a Week-day, immediately before
the elements are brought up and placed on the Altar, the Elder or
Elders present shall bring the vessel containing the oil to the Angel,
who shall present it uncovered upon the Altar; and then kneeling
down at the Altar, and the Elders kneeling down at the access to the
Sanctuary, the Angel shall say this Prayer of Benediction.’

Here follows a not very long prayer, in which the Almighty is


intreated to impart to the oil the virtue which is dogmatically
asserted that it possesses, in the catechism. The rubric then
continues, ‘The oil which has been blessed shall remain on the Altar
until after the Service, and shall then be delivered by the Angel to
the senior Elder, that it may be reverently carried to the Sacristy, and
there deposited in the proper place by the Angel.’
In the ‘Order for anointing the Sick’ (p. 602), the rubric says: ‘This
rite shall be administered only to such as have, in time past,
received the Holy Communion, or to whom it is intended presently to
administer the Communion; also, only in such cases of sickness as
are of a serious or dangerous character. In order to the receiving of
the rite, opportunity should, if possible, be previously given to the
sick person to make confession of his sins.

‘A table should be provided in the sick person’s room, with a clean


cloth thereon, upon which may be placed the vessel of holy oil....
The Elder in charge shall be accompanied, when possible, by the
other Elders, the Pastor, and the Deacon.’

A somewhat lengthy service follows, and in the middle is this rubric:


‘Then the Elders present shall anoint the sick person with the oil on
the head or forehead, and, if the sick person request it, also on any
part affected.’ And it winds up with the subjoined direction, ‘All the
holy oil that shall remain after the anointing shall be forthwith
consumed by Fire.’

I had intended to confine my subject entirely to English quacks, but


the name of Mesmer is so allied to quackery in England that I must
needs refer to him. He was born at Merseburg in Germany on May
23, 1733, and died at the same place March 5, 1815. He studied
medicine, and took a doctor’s degree in 1766. He started his
extraordinary theory in 1772 by publishing a tract entitled, ‘De
Planetarium Influxu,’ in which he upheld that tides exist in the air as
in the sea, and were similarly produced. He maintained that the sun
and the moon acted upon an etherial fluid which penetrated
everything, and this force he termed Animal Magnetism. But there is
every reason to believe that he was indebted for his discovery to a
Jesuit father named Hel, who was professor of astronomy at Vienna.
Hel used peculiarly made steel plates, which he applied to different
portions of his patient’s body. Hel and Mesmer subsequently
quarrelling about the prior discovery of each, the latter discontinued
the use of the plates, and substituted his fingers. Then he found it
was unnecessary to touch his patient, but that the same magnetic
influence could be induced by waving his hands, and making what
are called mesmeric passes at a distance.

But the Viennese are a practical race, and his failures to cure,
notably in one case, that of Mademoiselle Paradis (a singer), who
was blind, caused charges of deceit to be brought against him, and
he was told to leave Vienna at a day’s notice. He obeyed, and went
to Paris, where he set up a superb establishment, fitted up most
luxuriously. The novelty-loving Parisians soon visited him, and here,
in a dimly lit room, with pseudo-scientific apparatus to excite the
imagination, and a great deal of corporal manipulation, tending to
the same purpose, to the accompaniment of soft music or singing,
hysterical women went into convulsive fits, and laughed, sobbed,
and shrieked, according to their different temperaments.

Having reached this stage, Mesmer made his appearance, clad in a


gold embroidered robe of violet silk, holding in his hand a magnetic
rod of wondrous power. With slow and solemn steps he approached
his patients, and the exceeding gravity of his deportment, added to
their ignorance of what might be coming next, generally calmed and
subdued those who were not insensible. Those who had lost their
senses he awoke by stroking them, and tracing figures upon their
bodies with his magnetic wand, and, on their recovery, they used to
testify to the great good his treatment had done them.

A commission of scientific and medical men sat to make inquiry into


‘Animal Magnetism,’ and they reported adversely. He then
endeavoured to get a pecuniary recognition of his services from the
French Government, but this being declined, he retired to Spa,
where, the bubble having been pricked, he lived for some time in
comparative obscurity.

Mesmerism was introduced into England in the year 1788, by a Dr.


De Mainauduc, who, on his arrival at Bristol, delivered lectures on
‘Animal Magnetism’; and, as his somewhat cautious biographer, Dr.
George Winter, observes, he ‘was reported to have cured diseased
persons, even without the aid of medicines, and of his having the
power of treating and curing diseased persons at a distance.’ He
found many dupes, for the said authority remarks, ‘On looking over
the lists of Students that had been, or then were under the Doctor’s
tuition, it appeared that there was 1 Duke—1 Duchess—1
Marchioness—2 Countesses—1 Earl—1 Lord—3 Ladies—1 Bishop—5
Right Honourable Gentlemen and Ladies—2 Baronets—7 Members of
Parliament—1 Clergyman—2 Physicians—7 Surgeons—exclusive of
92 Gentlemen and Ladies of respectability, in the whole 127.

‘Naturally fond of study, and my thirst after knowledge being


insatiable, I also was allured to do myself the honour of adding my
name to the list; and to investigate this very extraordinary Science:
and, according to the general terms, I paid 25 Guineas to the Doctor,
and 5 Guineas for the use of the Room; I also signed a bond for
£10,000, and took an affidavit that I would not discover the secrets
of the Science during the Doctor’s natural life.’

So we see that this wonderful power had a market value of no mean


consideration, and, indeed, an anonymous authority, who wrote on
‘Animal Magnetism,’ states that Dr. Mainauduc realised £100,000. So
lucrative was its practice, that many pretenders sprung up, notable
one Holloway who gave lectures at the rate of five guineas the
course, besides Miss Prescott, Mrs. Pratt, Monsieur de Loutherbourg
the painter, Mr. Parker, and Dr. Yeldal; but the chief of these quacks
was Dr. Loutherbourg, who was assisted in his operations by his
wife. A book about his wonderful cures was written by one of his
believers, Mary Pratt, ‘A lover of the Lamb of God,’ in which he is
described as ‘A Gentleman of superior abilities, well known in the
scientific and polite Assemblies for his brilliancy of talents as a
Philosopher, and Painter: this Gentleman is no other than Mr. De
Loutherbourg, who with his Lady, Mrs. De Loutherbourg, have been
made by the Almighty power of the Lord Jehovah, proper Recipients
to receive divine Manuductions, which heavenly and divine Influx
coming from the Radix God, his divine Majesty has most graciously
condescended to bestow on them (his blessing) to diffuse healing to
all who have faith in the Lord as mediator, be they Deaf, Dumb,
Lame, Halt, or Blind.’

That thousands flocked to these charlatans is undoubted, for Dr.


George Winter (above quoted) says, ‘It was credibly reported that
3,000 persons have attended at one time, to get admission at Mr.
Loutherbourg’s, at Hammersmith; and that some persons sold their
tickets for from One, to Three Guineas each.’ And this is
corroborated by crazy Mary Pratt. ‘Report says three Thousand
People have waited for Tickets at a time. For my own part, the
Croud was so immense that I could with difficulty gain the Door on
Healing Days, and I suppose, upon conviction, Report spoke Truth.’
De Loutherbourg charged nothing for his cures, and Mary Pratt is
extremely scandalized at those who, having received a ticket gratis,
sold them from two to five guineas.

Many cases are given in her book of the cures effected by this
benevolent couple; how the blind were made to see, the deaf to
hear, the lame to walk, or the dumb to speak—nay, could even cast
out devils—as the following testimonial will show.

‘The second case I shall mention is that of a woman possessed with


Evil Spirits, her name Pennier, lives at No. 33 Ogle Street, Mary-le-
bone, near Portland-Chapel; her husband lives with the French
Ambassador: her case was too terrific to describe; her eyes and
mouth distorted, she was like a Lunatic in every sense of the word;
she used to say that it was not her voice that spoke, but the devil in
her. In short, her case was most truly distressing, not only to her
family, but the neighbourhood; she used to invite people in with
apparent civility, then bite them, and scratch like a cat; nay, she
would beg a pin of women, and then scratch them with it, &c., &c.,
&c.’

‘Mrs. De Loutherbourg, a lady of most exquisite sensibility and


tenderness, administered to this Mrs. Pennier; she daily amended,
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebooknice.com

You might also like