Circuit Cellar, the Magazine for Computer Applications.
Reprinted
by permission. For subscription information, call (860) 875-2199, or
[Link]. Entire contents copyright ©2006 Circuit
Cellar Inc. All rights reserved.
APPLIED PCs by Fred Eady
Microcontroller-Free Design
A GP-22050 Plays the Role of MCU
Fred recently directed a GP-22050 waveform generator to play the role of microcontroller in
a simple mechanical design. Read on to learn how he put a mechanical design in “microcon-
troller mode” without the help a microcontroller.
I ’m just sitting here looking at my
desk. What a mess. Let’s see. There’s a
to alter the digitized analog signal’s
frequency components before spitting
less communications node relays digi-
tal commands and data to its onboard
pair of ZigBee boards stacked on top of it back out through a PWM channel. 802.11b CompactFlash radio card. In
an early ENC28J60 prototype that are This little digital filter board also uses addition to handling the communica-
stacked on top of various Compact- digital control via its on-board micro- tions channel, the microcontroller
Flash 802.11b radio cards, parts sam- controller to spin the virtual knobs on also transfers digital commands and
ples, programming tools, and batteries. a couple of digital potentiometer ICs, data between a temperature/humidity
My trusty HP-16C calculator must be which determine the band-pass fre- IC and the wireless Ethernet interface.
somewhere under all of this microcon- quencies of the board’s op-amp-based The aforementioned boards don’t
troller confusion. I don’t see it out in analog I/O stages. relate to each other in a mission
the open in its usual place on top of Stacked up below the digital filter sense, but they do share three things
that stack of datasheets that are cover- board is a miniature wireless Ethernet in common. All of the embedded elec-
ing the rest of my desk. node. The microcontroller on this wire- tronic devices I spoke of contain a
As I survey the electronic waste- microcontroller. Each microcon-
land that is my desk, all of my lit- troller on the various boards spews
tle brainchild electronic devices and absorbs zeros and ones. The
have one thing in common: they’re eruption and consumption of the
all based on someone’s microcon- digital data by each microcontroller
troller. I’ll bet that I’ve put as much is executed in reference to a stable
code into the gaggle of microcon- time base or clock.
troller-based devices on my desk as When you get down to the physi-
I have put lead into targets at Steve cal interface of most microcon-
Kennedy’s Merritt Island gun site. trollers, you’ll find yourself speak-
Success at the shooting range ing binary. Even the multifaceted
always requires a gun, a steady hand, Cypress PSoC, which is enriched
and ammunition. However, I’m about with the wonders of programmable
to show you that success with analog, has provisions to produce
microcontroller designs doesn’t and accept digital signals. Basically,
always require a microcontroller, a microcontrollers are simply tools
soldering iron, or a compiler. that are used to quickly and sys-
tematically manipulate zeros and
TYPICAL MCU TASKS ones to achieve a purpose and ulti-
After realizing that I actually mately perform a task.
come into physical contact with If you can logically move zeros
microcontrollers on a daily basis, I and ones to their proper preallocated
pondered as to why. Let’s take a locations fast enough and perform a
closer look at the mess on my desk. useful task while doing so, you can
I have a microcontroller-controlled technically be considered as operat-
Figure 1—Nothing fancy here. The GP-22050 stands in for a
board that converts an incoming ing in “microcontroller mode,”
microcontroller. The target device could just as well be a memory
analog signal to its digital equivalent device (e.g., EEPROM or a microcontroller) because the sys- even though a physical microcon-
and then uses digital filter algorithms tem’s logical stimulus is contained totally within the GP-22050. troller is nowhere to be found.
62 Issue 193 August 2006 CIRCUIT CELLAR® [Link]
MICROCONTROLLER MODE
Unless your project is complex or
computationally intense, you’re most
likely to find yourself writing code to
do simple binary transfers—which
may or may not correspond to internal
or external events—to a microcon-
troller’s I/O port pins. For instance,
I’m currently working on a real-world
project that basically monitors time,
switches, and sensors to determine
which of the device’s motors, fans, or
valves to activate or deactivate.
This month, I’ll cover the topic of
doing microcontroller things without
microcontrollers. I happen to have in my
possession a Byte Paradigm GP-22050
waveform generator that can be plugged
into a microcontroller’s I/O fabric
(e.g., the aforementioned microcon-
troller-controlled mechanical device).
It can perform the same basic I/O
operations as a microcontroller.
The GP-22050 wasn’t designed to
replace your project’s microcontroller.
It was designed to help you develop
Photo 1—By simply saving this configuration information, I created a configuration/data file with all of the cho-
and debug your microcontroller-based sen parameters laid out in text form. All that was left to do was fill in the control and data patterns needed to
projects. The GP-22050 easily attains drive the LCD.
[Link] CIRCUIT CELLAR® Issue 193 August 2006 63
microcontroller mode. It can clock
digital data in and out of its 16-bit I/O
port and 6-bit control/trigger port at
speeds ranging from 800 Hz to 50 MHz.
Thus, the GP-22050 easily ramps up to
attain microcontroller mode and allows
you to do microcontroller things with-
out a microcontroller.
The GP-22050 is touted as an arbi-
trary digital waveform generator. Its
six control signal outputs can also be
configured as a mix of control outputs
and trigger inputs. As with most digi-
tal applications, a clock is needed to
keep everything orderly. In addition to
providing a programmable output clock
signal, the GP-22050 can operate on
its own internal clock or use an exter-
nal reference clock. If you don’t need
to move bits at 50 MHz, you can run
it in Static mode, which allows you to
manually define static signal levels on
Photo 2—The @loop 1 3 command translates to looping the one line immediately following the @loop command
selected GP-22050 output pins.
three clock cycle times. Because each clock cycle is 1 ms in duration, the E signal is low for 3 ms, high for 1 ms,
The GP-22050’s control outputs can and low for a minimum of 3 ms following the transmission of a character or command to the LCD. The E signal puls-
also operate in Manual mode by speci- es and data follow the commands in the LCD initialization area of Listing 2.
fying default values. When the default
values option is invoked, clicking the will put a 1 on the related control pin. blank will output a 0 on the selected
associated default value check box Leaving the default value check box control pin.
64 Issue 193 August 2006 CIRCUIT CELLAR® [Link]
The GP-22050 can also be config- WATCH THIS! tasks. As it turned out, the only control
ured to act as a state analyzer. In State In the case of the GP-22050, arbitrary signal I needed for the LCD was the
Analyzer mode, the GP-22050’s 16 data waveforms are born from a configura- ENABLE (E) signal, which I assigned
lines act as inputs and the incoming bit tion/data file and a raw hexadecimal or to the least significant bit of the 6-bit
pattern is sampled and stored. Samples binary data file. The GP-22050 package control bit chain.
of incoming data patterns can also be includes a bunch of example files that Initializing an HD44780-based LCD
viewed in real time when the GP-22050 cover all of the bases. You can enter is a relatively slow process in the
is in Real-Time Monitor mode, which is configuration data to the best of your beginning. So, to make sure I could
a mode akin to a logic probe on steroids. ability into the 8PI control panel, which meet the initialization timing restric-
If you need to embed the GP-22050 is the GUI that aids in the configuration tions and still operate the LCD fairly
functionality into your application, of the GP-22050 (see Photo 1, p. 63). quickly, I chose to run the GP-22050’s
the GP-22050 package comes with a You’ll get a configuration/data file in internal clock at 1 kHz, which resulted
C/C++ DLL and scripting library. Also, return by simply saving the configura- in 1-ms clock cycles.
if you have a target that uses a JTAG tion data you entered. To conserve microcontroller I/O, I
interface, the GP-22050 provides basic The entries you see in Photo 1 show run HD44780-based LCD panels in
JTAG operational capability as well. that I considered everything I needed 4-bit mode. I do the same with the
Although the GP-22050 is capable of to drive the LCD in 4-bit mode using GP-22050. The least significant 4 bits
doing some really complex and amazing the GP-22050’s control and I/O inter- of the GP-22050’s 16-bit I/O port are
things, the GP-22050 feature I found face. As I mentioned earlier, the 6 con- dedicated to the LCD’s D4–D7 data
most useful was the ability to create an trol/trigger bits beyond the 16 I/O bits I/O pins, which the LCD uses in 4-bit
arbitrary digital waveform using infor- offered by the GP-22050’s I/O interface mode. Bit 4 of the GP-22050’s I/O port
mation stored in a configuration/data were used for control and triggering services the LCD’s backlight by way
file. To show you how this feature works, purposes. Because I didn’t need any of a ULN2003 high-current driver IC.
I attached an HD44780-based LCD panel triggering to drive the LCD, I allocated Toggling the LCD’s RS pin differentiates
to the GP-22050 (see Figure 1, p. 62). all of the six control pins to control commands and data sent to the LCD.
I assigned bit 5 of the GP-22050’s I/O
port to LCD RS pin duty.
Listing 1—There isn’t much here, but it’s a good start. The @header command uses the letter O to assign
pins as output. GP-22050 I/O and control pins that are identified with – signs are placed in a high-impedance After saving the configuration data, I
state and aren’t configured as outputs. opened the resultant file (lcd_driver.ini)
and found the command structure
# Define the clock frequency
shown in Listing 1. Track through
@freq 1000
# Define the clock type and the active edge Listing 1 and compare the commands
@clock source internal (which begin with the @ character)
@clock pll enable with the graphic configuration choices
@clock output disable
I entered in Photo 1. As you can see,
@clock outputratio 1
@clock type continuous Listing 1 is a skeleton template that
@clock polarity positive consists of essential commands that
@clock sample rising define the GP-22050’s control and data
# Define the trigger type and pattern
I/O pin assignments as well as the
@trigger type internal
@trigger ctrl 0x00 0x00 GP-22050’s clock state, operating fre-
# ---------------- quency, and trigger pattern. The next
# Begin of control section step involved filling in the binary pat-
#
terns I wanted to see emitted on the
@ctrl_begin
# pin 543210 GP-22050’s control and data pins.
@header ——-O I started by defining the LCD control
@default 000000 sequence to toggle the LCD E pin. Ini-
@ctrl_end
tializing the HD44780-based LCD panel
#
# End of control section in 4-bit mode required a minimum of
# ---------------- a 4.1-ms delay following the first
# ---------------- function set initialization command.
# Begin of data section
The wait time between subsequent
#
@data_begin function set commands was 100 µs.
# pin FEDCBA9876543210 As a result, setting the minimum wait
@header ------OOOOOO time to exceed 4.1 ms would have
@data_end
been overkill after the first function
#
# End of data section set wait time had expired. However, I
# ---------------- didn’t really care in this case because
LCD update speed wasn’t a factor. If
[Link] CIRCUIT CELLAR® Issue 193 August 2006 67
faster LCD update speeds were required, Listing 2—The LCD ENABLE (E) pin must be toggled low-high-low with every 4 bits of data or command that’s
I could have simply coded a separate sent to the LCD’s HD44780 chipset. So, it’s only logical to assign the LCD E pin to a GP-22050 control pin. On
LCD initialization configuration/data the other hand (as Randy Travis would say), it’s more prudent to assign the LCD RS signal and the LCD back-
file, run it, and then loaded and run light control to standard data pins just as you and I would do with a microcontroller.
another configuration/data file, which # Define the clock type and the active edge
would have performed only the LCD @clock source internal
data transfer tasks. @clock pll enable
@clock output disable
The control sequence defined in
@clock outputratio 1
Listing 2 was performed each time @clock type continuous
data was presented on the GP-22050’s @clock polarity positive
data bus. (The complete version is @clock sample rising
# Define the trigger type and pattern
posted on the Circuit Cellar FTP site.) @trigger type internal
I could have included multiple control @trigger ctrl 0x00 0x00
files in a configuration/data command # ----------------
# Begin of control section
set, but only the last control sequence #
coded into the command set was used. @ctrl_begin
So, only one control sequence was # E
# |
executed per configuration/data file. # pin 543210
I couldn’t have but one control @header ---O
sequence in my configuration/data @loop 1 3
@ctrl 000000
file, so I set the dwell before and after
@ctrl 000001
the raising of the LCD E signal to @loop 1 3
three clock cycles, which resulted in a @ctrl 000000
minimum six clock cycle (6-ms) delay @ctrl_end
#
between characters and commands # End of control section
issued to the LCD’s HD44780 chipset. # ----------------
That gave the LCD plenty of time to # ----------------
# Begin of data section
accept and execute instructions in the #
initialization phase and provide more @data_begin
than enough time for the HD44780 to # RS
# |
put characters on the display.
# |BL
The same command logic that I # ||
used in the control area applied in the # ||
data area. If you continue along the # pin FEDCBA9876543210
@header -----OOOOOO
GP-22050 command chain in Listing 2, # LCD INIT BEGINS
you’ll see that I didn’t set the bit to # send 0x03 3 times
illuminate the LCD backlight until @loop 1 3
@data out 0000000000000011
after the LCD initialization was com- # send 0x02
pleted. Note also that the LCD RS sig- @data out 0000000000000010
nal was at a low level for each instruc- # send init string
# send 0x28
tion sent; it went high to enable com- @data out 0000000000000010
munication with the LCD’s data regis- @data out 0000000000001000
ters. The coding of the GP-22050 com- # send 0x08
@data out 0000000000000000
mands was a bit different than writing
@data out 0000000000001000
code for a microcontroller, but the # send 0x01
logic behind the data patterns and the @data out 0000000000000000
way the data was transmitted to the @data out 0000000000000001
# send 0x06
LCD was very similar to the way a @data out 0000000000000000
microcontroller would do it. @data out 0000000000000110
The control pulse chain produced # send 0x0E
@data out 0000000000000000
by the first four @data out commands @data out 0000000000001110
in Listing 2 is shown in Photo 2 (p. 64). # LCD INIT ENDS
I used a USB-attached, PC-based
Cleverscope CS328 oscilloscope to cap-
ture both the control pin waveforms Analyzing the CS328 display from commands. Data4 in the logic cap-
and the data presented on the GP- left to right, the first three LCD E ture area of Photo 2 is physically con-
22050’s I/O pins that are configured as pulses are a result of the @loop 1 3 nected to the LCD DB4 data pin and
data outputs to the LCD’s data bus. and @data out 0000000000000011 the GP-22050’s D0 pin. Data5 is con-
68 Issue 193 August 2006 CIRCUIT CELLAR® [Link]
a) b)
Photo 3a—Ignore the trash in the background. Focus on the GP-22050 tied to the four-line LCD panel. The GP-22050 package comes with a connector kit that includes three
eight-conductor connectors and five two-conductor connectors. The quick clips are the Cleverscope logic probes, which are tied to the four LCD data lines D4–D7. b—And you
thought I just sat around writing columns in an ivory tower.
nected to the LCD DB5 pin, configured PUT THE GP-22050 TO WORK pin every 100 ms, which was plenty
as the GP-22050’s D1 pin, and so forth. While I was putting this column fast for my application. I didn’t use
The fourth LCD E pin pulse from the together, the lead engineer for the real- any triggering because I simply
left was produced by the @data out world mechanical project I told you stepped through the breadboard code
0000000000000010 command. The about brought over the breadboard for and noted the signal levels as I went.
final two E pulses are clocking out me to use while writing the application
0x28 to the LCD data pins. In 4-bit code for the final box. His idea of a CLOSING THE LID
mode, the high nibble of each ASCII breadboard was the subject of Photo 3b. The LCD in Photo 3b reads “LID
character is sent first and immediately My job was to consolidate the functions OPEN.” Well, I’ve got some more work
followed by the least significant nib- of the three separate microcontroller to do. I’ll use my GP-22050 to make
ble 7 ms later. subsystems into a single microcontroller sure that the mechanical contraption
I kicked off the capture session in subsystem that could monitor and runs as designed with the lid closed.
Photo 2 using the Operation window control the various motors and switches. I’ve shown you that the GP-22050 can
in the 8PI control panel. I selected File However, before I began work on the be applied in the role of a microcon-
mode and loaded the lcd_driver.ini file final consolidation, I was tasked with troller emulator or a multi-input, high-
shown in Listing 2. To capture the ensuring that all of the signal levels speed logic probe. The GP-22050 isn’t
first six commands shown in Photo 2, from the LCD control module were complicated, it’s embedded. I
I set the step size value to 6 and correctly timed and administered. It was
clicked the Step button. Clicking the a great opportunity for the GP-22050 Fred Eady (fred@[Link]) has more
Start button ran the entire 48-command sitting on my messy desk! than 20 years of experience as a sys-
sequence, which resulted in what you Using the GP-22050 eliminated the tems engineer. He has worked with
see in Photo 3a. one-by-one, probe-and-run drill I nor- computers and communication sys-
mally do when mating hardware to tems large and small, simple and
firmware. This particular project’s main complex. His forte is embedded sys-
microcontroller had six major motor tems design and communications.
control, fan and valve outputs, a pair
of TRIAC driver outputs, and seven
PROJECT FILES
switch closure inputs that I needed to
validate. Adding everything up, I had To download the complete version of
15 monitor points, which meant I could Listing 2, go to [Link]
put them all up on the GP-22050’s I/O com/pub/Circuit_Cellar/2006/193.
interface at the same time with one
GP-22050 I/O pin to spare. SOURCES
I like to keep things as simple as
GP-22050 Arbitrary waveform generator
possible, so I configured the first
Byte Paradigm
Figure 2—This pseudo schematic assumes that all of 15 GP-22050 I/O pins for input duty
the necessary driver circuitry is placed ahead of the [Link]
and left the triggering and control
breadboard’s physical devices. It’s also assumed that
only the logic levels needed to activate the driver cir-
lines in a benign state (see Figure 2). CS328 Oscilloscope
cuitry are being monitored by the GP-22050. Note that The GP-22050’s Real-Time Monitor Cleverscope Ltd.
the control/trigger pins D16–D21 are idle. mode checked the state of each input [Link]
[Link] CIRCUIT CELLAR® Issue 193 August 2006 69