2-line-by-16 character LCD module, 142f
3-volt signals, 171f
4 MHz setting, 324
5-volt TTL-level signals, 170f
6-inch rulers, 161
12-volt signals, 169–171
15-volt logic, 170f
24-volt signals, 169
40-pin MCUs, 8
40-pin PICs, 11
abbreviations, 341–343
ac (alternating current), 166
acceleration instruments, 331
ADCON0 register, 75
ADCON1 register
A-to-D conversions in, 75
controlling digital and analog settings, 56
dual thermometer instruments, 264
setting values before LCD use, 44
using PORTA as digital device, 29–30
aircraft servomotor control, 238
alternating current (ac), 166
amplifiers, 333
analog devices, 29
analog input pins, 259–261, 263t
analog-to-digital conversion capabilities, 75, 140
PIC 16F877A microcontroller unit
capacitance, 28
frequency, 28
overview, 26–27
POT command, 27–28
reading switches, 28
voltage, 28
artificial horizon table project
building, 275–277
discussion, 270–271
gravity sensor exercises, 277
hardware connections overview, 271–273
single-axis software, 273–275
two-axis software, 275
Axelson, Jan, 115
Bargraphs exercise, 82
BASIC Compiler instruction set, 35–37
battery backup, clock, 123
battery monitor instrument, 347–348
battery terminal monitors, 332
beeps, 60–63
bicycle instruments, 332
biological sensors, 160
Bit C0, 31
Bit C1, 31–32
Bit C2, 31
Bit C3, 31
Bit C4, 31
Bit C5, 31
Bit C6, 31
Bit C7, 31
blinking LEDs, 43–44
boards, microEngineering Labs, Inc., 16
Bray terminal program, 319
breadboarding, PIC 16F877A microcontroller unit, 8–9
busy flag, 151–154
Busy Flag/Address Read command, 156t
bytes, Timer1, 224
CA (common anode) displays, 195–197
capacitance, 28
car battery terminal monitors, 332
car odometers, 161
car speedometers, 160
cardboard table mechanism, 276–277
CCP trigger output, 257
CD-ROMs, 18
circuitry diagrams
additions to tachometer for metronome, 225f
for controlling an RC servo from potentiometers, 65f
dual thermometer, 262f
generating tones on piezo speaker, 60f
input from Hall effect sensor into PICs, 193f
input of tachometer signal into PICs, 193f
overview, 45
potentiometer, 59f
pulse generator, 190f
thermistor connection to PIC, 297f
Clear Display command, 155t
clock frequency, 83
clock ICs, 122–124
codes, LCD, 141t
common anode (CA) displays, 195–197
compilers, 17
BASIC Compiler instruction set, 35–37
PICBASIC PRO Compiler (PBP)
example program, 43–44
free demo, 45
overview, 42–43
tips and cautions, 44–45
PICBASIC PRO Compiler instruction set
math functions/operators, 40–42
overview, 37–40
setting up for one-keystroke operation, 339
conditioning signal
input
alternating current (ac), 166
direct current (dc), 166–167, 169–171
keyboards, 167
overview, 165
relays, 167–168
resistances, 168
output
inductive loads, 174
parallel interface, 174
resistive loads, 174–175
serial interface, 173
connections, programmer, 221, 266, 271
cost of components, 16
COUNT command, 190–192
counters, 34
exercises, 112
function of, 104–105
prescalars and postscalars, 111
using Timer0 as, 105–107
using Timer1 as, 107–111
crystal oscillation checks on hardware side, 316–317
checks on software side, 317–318
Cursor at Home command, 155t
Cursor/Display Shift command, 155t
data logging, 179
data sheets
abbreviations, 341–343
PIC 16F877A microcontroller unit
downloading, 10–11
fast Internet connections, 10
overview, 9–10
dc (direct current), 166–171
dc motors, 189f
debouncing capabilities, 28
debugging
commands that provide
debug output to serial port, 319
configuration, 326–327
configuring 16F877A, 324–326
crystal oscillation
checks on hardware side, 316–317
checks on software side, 317–318
dumb terminal programs, 319
if chip refuses to run, 318
options, 327
overview, 315
at practical level, 320–324
programmer-related error messages, 328
setting ports, 329
settings, 326
simple checks, 327–328
solderless breadboards, 320
using PBP Compiler commands, 319
deceleration instruments, 331
decision-making capability of instruments, 183–184
decision-making code segment, 204
DEFINE statements, 44–45, 53, 55, 139–140
devices, LAB-X1, 6
diagrams
circuitry
additions to tachometer for metronome, 225f
for controlling an RC servo from potentiometers, 65f
dual thermometer, 262f
generating tones on piezo speaker, 60f
input from Hall effect sensor into PICs, 193f
input of tachometer signal into PICs, 193f
overview, 45
potentiometer, 59f
pulse generator, 190f
thermistor connection to PIC, 297f
wiring
counting into counter TMR1, 249f
IR-LED phototransistor pairs, 240f
programmable pulse counter, 201f
set of 4 seven-segment displays, 197f
seven-segment displays, 199–200f
single IR transmitter–phototransistor pairs, 284–285f
single-point programmable controllers, 295f
solar collector instrument, 305f
testing sensitivity of phototransistor response, 254f
testing TMR1 counter, 253f
touch panels, 282f
digital devices, 29
digital mode, 55
digital protractors, 331–332
direct current (dc)
circuitry for conditioning signals, 169–171
overview, 166–167
disabling low-voltage programming, 324
Display ON/OFF Control command, 155t
DOS environment, 15
downloading data sheets, 10–11
DS1302 real-time clock, 123–124
DS1620 temperature sensors, 128–129
DS1820 temperature reading devices, 126–128
dual thermometer project, 180–181, 259–267
dual-axis artificial horizon program, 275
dumb terminal programs, 132–133, 319
editing software, 5
Editor exercise, 82
EEPROMs, 115
encoder pulse counter program, 106–107
Entry Mode Set command, 155t
Epson SED series controller, 143
errors, syntax, 17
escapement, counting with, 240–243
escapements, 234–237
Evil Genius books, 164
execution routines, 286
expansion, PIC 16F877A microcontroller unit, 7–9
external interrupts, 30
fans
solar data collector project, 310
fast Internet connections, 10
feedback devices, 318
folder, PIC Tools, 16–17
Forty Characters exercise, 82
Fosc/4 frequency, 83
Four lines exercise, 82
frames, touch panel, 280f, 281
FREQOUT command, 63
Function Set command, 156t
gates, escapement, 237
global interrupt enable (GIE), 213–214
gravity sensor exercises, 277
gravity sensors, 269–270, 272–273
hall effect sensors, 192, 193f
hardware programmers, 5
hardware pulse width modulation (HPWM) command, 61–62, 104, 212
hardware setup, 13–15
hearing, 159
“Hello World” program, 53–55
HEX files, 17–18
high nibble, PORTB, 71
high voltage, 166
Hitachi 44780 datasheet, 141
Hitachi HD44780U controller, 143
“hot air” solar collectors, 302
house thermostats, 160
HPWM (hardware pulse width modulation) command, 61–62, 104, 212
HS setting, 324
HSEROUT command, 134
HyperTerminal program, 133, 136
I2C memory, 115–117
I2C SEEPROM memory, 113
IC DS1202 clock, 122–123
IC DS1302 clock, 122–123
IC NJU6355 clock, 121f, 122–123
inductive loads, 174
infrared (IR) light beams, 281, 283–284, 287
inhibit code, 296
initialization, LCD, 149–151
input capabilities, LAB-X1, 5
inputs/outputs
beeps, 60–63
creating, 48–50
exercises controlling LCD, 80–81
controlling LEDs, 80
miscellaneous, 81–82
overview, 79
flexibility, 78–79
LCD displays
digital and analog settings, 56
overview, 53–55
reading keyboard and displaying key number on, 73–74
writing binary, hex, and decimal values to, 56–57
LEDs
blinking eight in sequence, 51–52
blinking one, 50–51
dimming and brightening one, 52
overview, 47
potentiometers
reading and displaying results on LED bargraphs, 57–59
reading and displaying
value on LCD, 74–76
reading three and displaying values on LCD, 76–77
programs that create
inputs/outputs, 48
RC servos, controlling from keyboard, 63–67
reading inputs, 67–72
reading keyboard, 67–70
reading keyboard and displaying value on LCD, 70–72
turning on LED only while button is down, 67
INTCON (interrupt control register)
bit values of, 89–90
bits 6 and 7, 103
bits that affect Timer0, 215
marble counter project, 258
PORTB interrupt capability, 30–31
Timer1 control, 107
interactivity of instruments, 183
interrupt capability, PORTB, 30
interrupt control register. See INTCON
interrupt enable bits, 213
interrupt latency, 213
interrupts, 212–213. See also timers
counting to register using, 244–246
intervals between, 98–99
lost by PAUSE commands, 83
routine for Timer0 program, 216–217
structure of routine of, 99f
timers, 33–34
intervals, timer, 98–99
“IntRoutine” routine, 88
I/O interfaces, LAB-X1, 5
I/O pins, 10
IR (infrared) light beams, 281, 283–284, 287
IR-LED phototransistor pairs wiring diagram, 240f
isolators, 170
J7 Servo position control, using servo at, 66–67
jumper J4, 123
jumper J5, 121
keyboards, conditioning output signal, 167
LAB-X1 board
debugging with, 320–321
determining use of pins and ports, 23–26
hardware features, 5–6
image of, 27f
metronome program based on Timer0 and, 220–221
modifications for solar collector, 304
overview, 4
programmable tachometer project on, 187–188
LCD (liquid crystal display)
ADCON1 settings, 44
code table, 155–156t
codes, 141t
connecting, 322
design intent
busy flag, 151–154
hardware needed, 146
information needed, 147–151
programmer needed, 146
software needed, 146
digital and analog settings, 56
exercise, 80–81
exercises, 154–156
hardware and software interaction, 143–144
hardware of, 144–146
module, 142f
reading keyboard and displaying key number on, 73–74
solar data collector project
overview, 310–311
problem, 314
sending data to computer, 311–314
talking to, 144
testing program, 323
in touch panel programming, 286–287
using in projects, 142–143
writing binary, hex, and decimal values to, 56–57
lead acid batteries, 166–167
LEDs (light emitting diodes) blinking eight in sequence, 51–52
blinking, EX, 43–44
blinking one, 50–51
dimming and brightening one, 52
dimming using PWM command, 61–62
exercise, 80
interrupt-driven tasks, 85–88
program using Timer0, 101–102
seven-segment displays, 195
in temperature controlling device, 185
turning ON, 67
turning ON and OFF program, 49
light emitting diodes. See LEDs
liquid crystal display. See LCD
LM34 temperature sensors, 259
LM34-based controller, 296
loading software, 15
loops, 318
low nibble, PORTB, 71
low voltage, 166
low-voltage programming, 324–325
LTC1298 12-Bit A-to-D converter, 124–126
magnitude, dc signal, 167
marble counter project, 178
counting
directly into internal counter, 246–248
with escapement, 240–243
to register using interrupts, 244–246
notes, 243
servos, 238–239
Timer1
in asynchronous counter mode, 256–257
in counter mode, 248–255
INTCON interaction, 258
oscillator, 257
prescalars, 257
resetting register pair (TMR1H, TMR1L), 257
resetting using CCP trigger output, 257
Timer2, 258
materials, solar collector, 304t
math operations
BASIC Compiler instruction set, 37
PICBASIC PRO Compiler instruction set, 40–42
MCLR pins, 316
mechanical stop watches, 161
memory, non-volatile, 314
Memsic 2125 dual-axis accelerometer, 269–270
metronome project
terminology, 212–214
watchdog timer, 230–231
Microchip MPLAB editor, 42
Microchip Technology Corporation Inc.
16F877A Microcontroller datasheets downloads, 23
overview, 21
Web site, 10–11
MicroCode Studio editor
checking for problems with, 317
“one mouse click”, 339
overview, 41–42
program shortcut, 17
starting programmer software from, 14
microcontrollers, 316
microEngineering Labs
notes on software, 18–19
overview, 21
preassembled boards, 16
program for DS1620 readings, 128–129
program for DS1820 readings, 126–128
program to read from 12-Bit LTC1298 A2D chip, 124–126
RS232 Communications program, 131–132
voucher for, 16
Microwire memory, 115, 118–120
Microwire SEEPROMs, 118–120
Mirror exercise, 82
Model ACM 1602K display, 147
Motorola Semiconductor, 115
motors, dc, 189f
National Semiconductor, 115
National Semiconductor LM34 temperature sensors, 259
NMBR, POT command, 28
nonvolatile memory, 314
oil level reading devices, 332
“one mouse click” set up, 43
open drain output, 30
OPTION_REG (option register), 88–89
bit 6, 30–31
bit assignment, 88–89
bits that affect Timer0, 214–215
effect on Timer0 counter, 107
using Timer0 as counter, 104
opto isolators, 170
oral thermometers, 160
oscillators
marble counter project, 257
oscilloscopes, 316
output capabilities, LAB-XI, 5
output information, instrument’s, 184
output set point control devices, 185
oven thermometers, 160
Parallax Inc., 269
parallel interface, conditioning input signal, 174
parallel port programmer, 14
PAUSEUS command, 274
PBP. See PICBASIC PRO Compiler
PC boards, 259
pendulums, 332
period register, Timer2, 102
phototransistors, 254f, 283–284, 287
PIC 16F84A program, 9, 153, 154f
PIC 16F877A microcontroller unit
40-pin MCUs, 8
40-pin PICs, 11
additional hardware, 7–8
breadboarding, 8–9
core features, 22
data sheets
downloading, 10–11
fast Internet connections, 10
overview, 9–10
expansion, 7–9
peripheral features
analog-to-digital conversion capabilities, 26–28
overview, 23–26
ports
configuring and controlling properties of, 29
PORTA, 29–30
PORTB, 30–31
PORTC, 31–32
PORTD, 32–33
PORTE, 33
precautions, 9
software compiler, 7
timers
counters, 34
overview, 33–34
prescalars and postscalars, 34
watchdog, 34
PIC Tools folder, 16–17
PICBASIC PRO Compiler (PBP), 4, 7, 15
commands, 319
example program, 43–44
free demo, 45
instruction set, 37–42
overview, 42–43
tips and cautions, 44–45
PICBASIC PRO programs, Web site, 345
PIE1 control register, 108
pin B7, 9
pin out designations, 40-pin 16F877A PIC microcontroller, 8f
Pin, POT command, 28
pins
LAB-X1 board, 23–26
LCD, 145t, 147–148t
PIR1 control register, 107
PLCs (programmable logic controllers), 243
PORTA, 29–30
PORTB, 30–31
lines set as inputs, 26
reading keyboard, 70–71
reading switches, 67–68
Servo Position Control for an R/C servo from, 63–64
PORTC, 31–32
PORTD, 32–33
LCD data, 53
loading potentiometer readings, 58
PORTD LED bargraph circuitry, 51f
ports
configuring, 29
controlling properties of, 29
LAB-X1, 23–26
PORTA, 29–30
PORTB, 30–31
PORTC, 31–32
PORTD, 32–33
PORTE, 33
setting, 329
postscalars, 34, 85, 99, 103, 111, 212
POT command, 27–28
potentiometers
controlling an RC servo from, 64–65, 78–79
reading and displaying results on LED bargraphs, 57–59
reading and displaying value on LCD, 74–76
reading three and displaying values on LCD, 76–77
in single set point controllers, 294
for single-axis artificial horizon, 274
in solar collector, 304
in temperature controlling device, 185
counters, 111
increasing time between interrupts, 99–100
marble counter project, 258
overview, 85
program to see effect on Timer0 operation, 218–219
Timer1, 100
for Timer2, 103
programmable logic controllers (PLCs), 243
programmer-related error messages, 328
projects
artificial horizon table, 181
dual thermometer, 180–181
marble counter, 180
metronome, 179–180
single-point controller, 181
solar collector, 182
tachometer project, 179
techniques, 177–182
touch screen, 181
Web site, 177
Proton+ Lite BASIC editor, 42
protractors, digital, 331–332
proximity detectors, 243
pulse generators, 189, 190f, 191f
Pulse Width Modulation (PWM) command, 60–62, 104
quotation marks, 44
RadioShack, 164
R/C servos, 78–79
RC servos, controlling from keyboard, 63–67
Read Data command, 156t
reading clock program, 309
reading switches, 28
real-world projects, 331–333
receive buffers, 135
register names, 44
relays, 167–168
resistance, 26–28, 57–58, 168, 298
resistive loads, 174–175
resistor R17, 9
RS232 Communications program, 131–132, 134–136
RS485 communications, 137
rulers, 161
saving programs, 18
Scale, POT command, 28
scaling ability, timer. See postscalars
prescalars scan routines, 286
Schmitt trigger input buffers, 31–33
sensors (transducers)
overview, 159–161
reasons for building, 161–162
resources, 164
types of, 163–164
serial EEPROMs, LAB-X1, 6
serial interface, conditioning input signal, 173
serial one-wire memory devices, 113–115
serial peripheral interface (SPI) memory, 115, 117–118
servos, 238–239
Set CG RAM Address command, 156t
Set DD RAM Address command, 156t
set point adjustment devices, 294
seven-segment displays, 195–207
shortcut, MicroCode Studio program, 17
sight, 159
signal latching and clearing, 168f
single-axis software, 273–275
single-point controller project
control statement, 293–296
LM34-based controller, 296
overview, 181
reading thermocouples, 298–299
thermistor-based controller considerations, 296–298
slave port functions, PORTE, 32–33
smell, 159
sockets
EEPROMs, 115
U10
making sure working, 134–137
overview, 131–133
using RS485 communications, 137
U3, 115–117
U6
clock ICs, 122–124
DS1302 real-time clock, 123–124
LTC1298 12-Bit A-to-D converter, 124–126
overview, 120–122
U7, 126–129
U8, 126–129
U9
making sure working, 134–137
overview, 131–133
using RS485 communications, 137
software compiler, PIC 16F877A microcontroller unit, 7
software setup
loading, 15
notes from microEngineering Labs, 18–19
overview, 13–14
using in Windows environment, 15–18
solar data collector project
controlling fan, 310
microcontroller hardware, 304–305
software
overview, 306–307
reading sensors, 309–310
setting internal clock, 307–309
updating LCD
overview, 310
problem, 314
sending data to computer, 311–314
solder joints, 316
soldering iron accessory, 332
solderless breadboards, 320
solid state relays (SSRs), 174, 175f
speakers, 31–32
SPI (serial peripheral interface) memory, 115, 117–118
SSRs (solid state relays), 174, 175f
stabilized output, 184
startup, LCD, 322
steel tape, 161
syntax errors, 17
T1CON control register
bit assignment, 100
bits used to control Timer1, 224, 226
functions of, 108
T1OSCEN control bit, 257
T1SYNC control bit, 256
T2CON control register, 102–103, 228–229
table mechanisms, 276–277
tachometer project
detection, 192–193
high speed considerations, 191–192
low rate considerations, 189–191
options, 187–189
overview, 179
seven-segment displays, 195–207
software, 194–195
tachometers, 178, 221–224, 225f
taste, 159
telephone key tones on piezo speaker, 63
temperature sensors, 185
thermistor-based controllers, 296–298
thermocouples, 298–299
thermostats, 160
Timer0, 84, 104, 211, 214–224, 246–248
INTCON (interrupt control register), 89–90
LCD clock program using ON INTERRUPT, 90–93
OPTION_REG (option register), 88–89
overview, 85–88
using as counter, 105–107
marble counter project
in asynchronous counter mode, 256–257
in counter mode, 248–255
INTCON interaction, 258
oscillators, 257
prescalars, 257
resetting register pair (TMR1H, TMR1L), 257
resetting using CCP trigger output, 257
metronome project, 211, 224–227
overview, 93–100
prescalars, 100
register pair (TMR1H, TMR1L), 257
running critical interrupt-driven tasks, 100–102
using as counter, 107–111
Timer2, 84
making sure working, 104
marble counter project, 258
metronome project, 212, 228–230
overview, 102–104
watchdog timer, 104
timers. See also Timer0
Timer1
Timer2
counters, 34
exercises, 112
prescalars and postscalars, 34
watchdog, 34
TMR1H control register, 108
TMR1L control register, 108
touch, 159
touch panel project
building, 282–285
exercise, 291
hardware needs, 281
overview, 279–281
software, 286–291
software needs, 281–282
touch screen project, 179, 181
transducers. See sensors
TRIS registers, 325
TRISA register, 29–30
TRISB register, 30–31
TRISC register, 31
TRISD register, 32
TRISE register, 32
two-axis software, 275
U10 socket
making sure working, 134–137
overview, 131–133
using RS485 communications, 137
U3 socket, 113–117
U6 socket
clock ICs, 122–124
DS1302 real-time clock, 123–124
LTC1298 12-Bit A-to-D converter, 124–126
overview, 120–122
U7 socket, 126–129
U8 socket, 126–129
U9 socket
making sure working, 134–137
overview, 131–133
using RS485 communications, 137
universal instruments
basic temperature controlling device, 184–186
notes, 186
properties and capabilities of, 183–184
USB port programmer, 14
variables, 317
voltmeters, 160
volt/ohm meters (VOMs), 183–184
voucher, microEngineering Labs, 16
wall thermometers, 332
watchdog timers (WDTs), 34, 89, 215
metronome project, 230–231
Timer2, 104
Web site
PICBASIC PRO programs, 345
project, 177
support, 349–350
Wi-Fi Internet service, 10
Windows environment, software use in, 15–18
wiring
checking, 316
diagrams
counting into counter TMR1, 249f
IR-LED phototransistor pairs, 240f
programmable pulse counter, 201f
set of four seven-segment displays, 197f
seven-segment displays, 199–200f
single IR transmitter—phototransistor pairs, 284–285f
single-point programmable controllers, 295f
solar collector instrument, 305f
testing sensitivity of phototransistor response, 254f
testing TMR1 counter, 253f
touch panels, 282f
touch panel, 281f
writable counting registers, 102
Write Data command, 156t
writing to clock program, 308–309
XT setting, 324