Professional Documents
Culture Documents
org/2011/11/waveform-generator-with-max038/
Waveform generator with MAX038
There are several pieces of workbench any intermediate hobbyst can build. Waveform generator is one
of them.
Design considerations
Unofficial mantra for this project was make it sufficient. Think three basic waveforms (sine, triangle,
square), four settings (frequency, duty cycle, amplitude, DC offset) and upper frequency in range of
few MHz. Built-in frequency meter would be handy. Also no craploads of components please; we are
not building analog synth here. And no DDS yet. This might become another project next year,
unless featuritis brings me to the point where its more practical to spend $500+ on a factory made box.
On the other hand, all related popular analog ICs are now discontinued. And most are/were older than
Mother Earth, like XR2206 or OMG! ICL8038. A notable exception is MAX038 (released 1994).
Big suppliers dont have it anymore. Wanna get one, try less known and second-hand sources: local
stores/hobbysts, Futurlec, Littlediode, eBay. CPP version costs around $20.
As for other nonstandard components, external amplitude/duty cycle control requires fast video type
opamp. LT1364 meets orientational specs (300V/us slew rate, 50MHz gain bandwidth) at +/-8V supply.
Schematics dissected
Prototyping was all common sense, the art of reading datasheet, opamp math, basic Ohms laws, stuff
like that:
Power supply
PSU design is standard linear. IC1 and IC2 (7808/7908, TO-220 package) provide +/-8V for all
operational amplifiers. IC3 and IC4 (78L05/79L05, TO-92) give +/-5V for MAX038 and frequency
meter components.
Recommended input voltage is +/- 10-15V. Be aware that PSU does not have any special means of
protection. If you want to prevent famous ohnosecond moments like connecting generator to bench
PSU and accidentaly turning it up towards 30V think about dedicated +/-12V supply.
relying on opened pins (treated as 1s) is not recommended, therefore both pins
are pulled down with 10k resistors.
its better to use MBB (make before break) switches than BBM (break before
make). With latter waveform shortly changes to square (00) during mechanical
transition between contacts.
Caps are known to have notorious tolerances and pickin em manually with LCR
meter wont hurt.
smallest capacitor is slightly smaller than calculated (39pF instead of 47pF) to
compensate for parasitic capacitances on PCB.
again, MBB switch is preferred. BBM ones disconnect COSC before contacts
settle down causing frequency to ramp up for fraction of second.
DC offset control
Fourth and last slow opamp (IC7B) provides [-REF...+REF] range for DC offset. Thats enough to push
5Vpp signal to [0V... 5V] or [-5V... 0V]. Output is routed to summing fast amplifier.
If we select square wave, max out amplitude and DC offset then OUT will generate TTL-compatible
signal.
Side note: most of googled schemas use single amp in output stage, probably to keep signal
degradation at minimum. The downside is less natural DC offset control, because it is added BEFORE
amplification.
Pots orientation
There must be psyhcological explanation why people tend to screw up decisions based on only two
choice. Ah yes, theres no third one to cacth onto reference.
In this case, Eagle library didnt have vertical plastic pots (Piher). I created custom library, added
symbol, device, part and miswired A/E pins. Error went all the way through PCB design. Since pots
are soldered directly, fixes were less than aesthetically pleasing. Corrections are added in final
schematic and PCB. Lets check em again:
frequency: higher voltage -> higher current -> higher frequency -> E to +REF, A
to +0.2V
duty cycle: higher voltage -> lower duty cycle -> inverting output (IC8A) ->
higher duty cycle -> E to +2.0V, A to -2.0V
amplitude: greater value -> higher amplitude -> E to OUT, A to GND
DC offset: higher voltage -> greater DC offset -> inverting output (IC8A) ->
smaller DC offset -> E to -REF, A to +REF
Summing amplifier (IC8A) must be of inverting type, which effectively turns waveform upside down.
Duty cycle of 20% actually becomes 80%. Other two waveforms visually dont behave that way; 20%
means triangle will be angled to the left, not right. Because duty cycle control makes the most sense for
square waves, this had been taken as reference.
Frequency meter
F-meter is implemented with PIC16F876 ICs and 216 chars LCD. This PIC model is a bit of overkill,
plenty of pins and 85% of memory remained unused but nevermind. Three routes connect MAX038
and micro: A0->RA0, A1->RA1 and SYNC->RC0. First two give an information about waveform
displayed in first row of LCD. Last one is source for counting. Module TMR0 derives 1-second
timebase from master clock (6.144MHz). TMR1 is configured for async mode with no prescaler; it
counts rising edges of SYNC signal (thats why its important to minimize OUT glitch) and overflows
every 65536 counts. Most of number crunching is done within interrupt handler. Main loop merely
checks for changed values and updates display.
Normally when prescaler is off PIC cannot count above FOsc/4. Looks like that limitation does not
apply here; meter works all the way to 11MHz with 1Hz resolution. I tried to do the same with RTC
4.194 XT crystal and measuring peaked around ~1MHz as expected. Accuracy is of course smaller.
Compared to software-based f-meter in Rigol scope, worst-case deviation is less than 0.1%.
LCD is labeled 1602. Niiice. It has standard dimensions for 162 chars, 1-16 pin layout in top left
corner, HD44780 interface and blue background. Not all hung-lo 1602s have the same pinout; some
have shifted pins 15 and 16, others have 116 pin strip bottom left or 28 sideways etc in any case,
check before buying some.
PCB/case design
Enclosure was kinda handheld-sized (166x100x25mm), meaning all controls had to be soldered
directly on PCB. This greatly affected board layout:
PCB itself is single-sided, 160x93mm with 10 jumpers and ground plane pour. None of ICs has socket
for various reasons; MAX038 and to some extent LT1364 dont like it (search above for stray
inductance), for PIC one there wasnt enough room and NE5532s are dirt cheap.
Rotary switches were kind of tricky. It took me some time to find small enough ones that fit into
enclosure (no-name, just Made in W.Germany. Go figure). Unfortunately their setup was 112
without any setup ring or rotation limiter you can typically find on larger switches a la Lorlin or ELMA
that would let me constraint movement to 13 and 17. I had to solder short raised dummy jumpers
(both ends on ground plane) 2mm in front between pins 3/4 and 7/8 respectively.
Two male pin header connectors exist on board: 16-pin for LCD, 2pin for output signal (via tiny
microphone cable + BNC). Supply connector is 6-pin mini-DIN at bottom left corner.
In action
Although my artistic skills are roughly nil, I was satisfied with final look & feel. Crap picture quality
comes from Nokia cell phone :X:
How generator works in practice? As mentioned before, up to 4MHz results are OK. Then bandwidth
limitation slowly kicks in. Waveforms are stable, controls are linear. OUT glitch does not exist. All fine
within given (analog) limitations.
Things Im occasionally missing are few on/off switches: for powering up and to enable/disable OUT
signal. Regarding usability, large BNC adapters sometimes get in the way of display and controls. And
LCD doesnt have excellent viewing angle so it might take some contrast tweaking to get clear readout
while generator is on the bench