Kit Instructions

advertisement
L.C.D. display for 2117202 waveform generator
PART NO. 2217300
After purchasing and assembling Jameco's waveform generator, I felt that a display of the signal would increase its functionality without
having to attach an oscilloscope to read the signal. Wondering why you cannot hear the signal is easier to troubleshoot if you know the
signal isn't above human hearing range.
This kit will offer a “rough idea” of what signal is being produced. The display will be limited from 250 Hz to 37.5 KHz, for wave forms
above 500mV peak to peak.
Time Required: two hours depending on experience
Experience Level: Intermediate Required tools and parts:




Soldering iron and soldering supplies
A vice makes life easier but not required
A FTDI cable
A working knowledge of how to program an Arduino via FTDI cable (Kit will be using an “Ardweeny” to drive the display).
Bill of Materials:
Qty
Jameco SKU
Component Name
1
526248
28 dip socket
1
683112
14 DIP SOCKET
1
2125042
Solderable PC Breadboard
1
2115768
Ardweeny
1
23683
LM324 QUAD OP-AMP
1
691171
20K OHM RESISTOR
RESISTORS #1, 6, 7, 11, 12, 14, & 15
1
691446
270K OHM RESISTOR
RESISTOR #2
1
691286
56K OHM RESISTOR
RESISTOR #3, & 10
1
691382
150K OHM RESISTOR
RESISTOR #4
1
691340
100K OHM RESISTOR
RESISTOR #5
1
691307
RESISTOR #8
68K OHM RESISTOR
1
691091
9.1K OHM RESISTOR
RESISTOR #9
1
94212
10uF ELECTROLYTIC CAPACITOR
CAPACITOR'S #1, 2, 3, & 4.
1
36311
1n914 switching diode
35975
1n4001 rectifier diode
36097
5.1v zener diode
1
51262
5v regulator
1
2146311
0.1uF Capacitor
diode #1
1
diode #3
1
diode #2
Capacitor's # 6, 7, & 8.
1
2118791
10k ohm trim pot
1
2118598
16x2 LCD display
1
2153553
22ga hook up wire
LCD contrast
Step 1 - BUILD THE MICROCONTROLLER
This display is driven by an Arduino clone (ardweeny - 2115768). The instructions with the clone are clear and easy to follow. Adequate
soldering skills are a plus. This project assumes that you have some Arduino background, including programming with an FTDI cable
or adapter. I do not explain these operations, there are plenty of tutorials online if you are unsure. If you do not have a FTDI cable you
will need to purchase one separately.
Step 2 - PREPARE THE P.C. BOARD
Cut copper traces on p.c. board as illustrated on "pcBoard" sheet.
Cut copper rows at red traces.
Note that illustrations of components are reversed due to the copper being on the BOTTOM of the board.
Step 3 - BEGIN INSTALLING COMPONENTS
Locate dip sockets in p.c. board and solder in place.
Bridge ardweeny's pin 22 to ground rail Bridge lm324's pin 11 to ground rail
Bridge lm324's pin 7 to 5v+ DC rail
Install resistors #1, 6, 7, & 10. Note- R10 is 56k ohm, NOT 20k ohm. Install capacitors #1, 2, & 3. Watch polarity.
Step 4 - POWER SUPPLY
Install 7805 regulator, back side toward lm324 socket, input pin towards C3.
Install protection diode D3 from Vin pin to output pin of 7805, cathode (stripe) towards Vin.
Install C5's anode in the same copper row as 7805's Vin.
Install C5's cathode to the next copper row (closer to 28 dip socket). Bridge that row to ground rail. Install C6 across ground & 5v+ rails
as close to 7805 as possible.
Step 5 - INSTALLING PARTS
Install resistors 13 & 14 out from "ardweeny" pins 15 & 28 (bridging cut copper traces)
Install resistors 5 & 9 (blue in picture) Install R12
Install D1 1n414 diode -cathode (stripe) away from pin 7
Install C4. Before soldering cathode of C4, bend its lead to bridge across the ground rail to the other side. (Bottom side of board) Be
sure to solder to ground rail.
Step 6 - INSTALLING MORE PARTS
Install D2, cathode towards pin 8 of lm324 socket.
Install resistors #3 & 11.
Cut five wire jumpers. One each, 75mm, 40mm, 30mm, 23mmand 15mm long. Strip the ends of the jumpers.
Install the 40mm jumper first from the copper row common with pin 8 of the lm324 socket to R13.
Install the 75mm jumper from the bottom most copper row up to R14. The other three jumpers will be used in step 7.
Step 7 - INSTALLING RESISTORS & JUMPERS.
Install resistor #2 from copper row common with lm324 socket pin 12 and 5v+ rail.
Install resistor #8 from copper row common with lm324 socket pin 10 and 5v+ rail.
Install resistor #2 from copper row common with R5 and 5v+ rail. Note-One side of R5 is connected to C4’s cathode. Use the 3 hole
copper row at the OTHER side of R5 for this step.
Leave the center of these three holes open for use in the next step.
Use a small piece of discarded capacitor lead to bridge from the center hole mentioned above to the center hole of the copper row that
the anode of C2 is soldered to.
Solder C7 & C8 from the positive rail to the ground rail as shown in photo Three Backside.
Bend the 30mm jumper into an ‘L’ shape (10 x 20mm). Install one side from the copper row that is common with lm325’s socket pin #12
to the copper row common with C1’s anode.
Install the 23mm jumper with one end in the copper row common with lm325’s socket pin #10 and going to the copper row common
with the anode of C3.
Install the 15mm jumper bridging the two bottommost copper rows together.
Step 8 - HELPFUL HINT
So now for those who read the instructions through ahead of time, here’s what I would have done differently if I was to make this
instruction sheet again. Instead of making the 15 mm jumper, a little time could be saved if, on the bottommost holes of the p.c.'s ground
and +tive rails (below pins 7 and 8 of the op-amp IC) were cut away from the rest of the rail (isolated, like with cutting the red traces)
Then bend the anode of C4 across to bridge the two sides, like you did to its cathode in step 5.
Step 9 - FINAL STRETCH
Cut a 50mm jumper and install it from lm324 socket pin4 to the copper row common with the anode of C5. This will be the 12v from the
waveform generator. It will bridge the input to the voltage regulator and the lm324.
Cut 9 jumpers each 100mm long. Different colors aren’t absolutely necessary, but will make life easier. Solder 7 of them to the L.C.D.’s
pins 3, 4, 6, and 11 through 14. Cut two 50mm jumpers and one 15 mm jumper. Pins 16, 5 and 1 are all connected to ground. Pins 15
and 2 are 5v+dc.
Step 10 - CONTRAST POTENTIOMETER
The unbent pin of the potentiometer will go in the copper row common with the 28 dip socket pin #8 (ground). The wiper pin of the
potentiometer goes in the second hole from the edge of the copper row that would be common with the 28dip socket pin#9 had we not
cut the trace in step 2. The last bent pin goes in the third hole in on the copper row common with the 28dip socket pin #7 (5vdc+)
Step 11 - INSTALLING THE L.C.D. DISPLAY
Solder the six data pins to the Arduino chip. Use 28dip socket pins 5, 6, 11, 12, 13, & 14. Use the holes closest to the socket. They
should all lie flat like a ribbon. Connect the LCD’s pin 1 (ground) to dip pin 7. Connect LCD pin 2 (Vcc) to dip socket 8. Connect LCD
pin 3 (contrast) to wiper pin next to, but not electrically connected to dip socket #9.
Step 12 - PROGRAM THE MICROCONTROLLER
// display for function generator
// pulseIn () command limits pulse measurement to 10uS (50 kHz) max
// final revision M.Squires
int sampleSize=10;
int freqInputPin=9;
int aInputPin=5;
long displayTimer=0;
float cycleLength,cyclesPerSecond,totalPulseLength,pulsePP;
float accumulatedPulseLow,accumulatedPulseHigh,pulseHigh,pulseLow;
#include <LiquidCrystal.h>
LiquidCrystal lcd(3,4,5,6,7,8); // for boarduino
void setup(){
lcd.begin(16,2);
}
void loop(){
if (displayTimer<(millis()-1000))// update display a maximum of once per second
{
if (millis()<displayTimer){ // in case of rollover
displayTimer=millis();
}
printFrequency();
printAmplitude();
displayTimer=millis(); // reset timer
}
cycleLength=findFrequency();
cyclesPerSecond=1/(cycleLength*.000001); //convert to Hz
pulsePP=analogRead(aInputPin);
} // end void loop()
float findFrequency(){
totalPulseLength=0;
// clear variable from last loop
accumulatedPulseLow=0; // clear variable from last loop
accumulatedPulseHigh=0; // clear variable from last loop
pulseHigh=0;
// clear variable from last loop
pulseLow=0;
// clear variable from last loop
for (int i=0;i<sampleSize;i++){
// take multiple readings and average them
do
// continue polling until pulse within expected range
{
pulseLow=pulseIn(freqInputPin,LOW,5000); //maxdelay for 100Hz
}
while(pulseLow<10||pulseLow>5000); // ignore samples outside expected range (10uS - .005S)
accumulatedPulseLow=accumulatedPulseLow+pulseLow; // add all the samples together
do
// continue polling until pulse within expected range
{
pulseHigh=pulseIn(freqInputPin,HIGH,5000); //maxdelay for 100Hz
}
while(pulseHigh<10||pulseHigh>5000); // ignore samples outside expected range (10uS - .005S)
accumulatedPulseHigh=accumulatedPulseHigh+pulseHigh; // add all the samples together
}
pulseHigh=accumulatedPulseHigh/sampleSize; // divide by sample size to find average
pulseLow=accumulatedPulseLow/sampleSize; // divide by sample size to find average
totalPulseLength=(pulseHigh+pulseLow); // "totalPulseLength" is the duration (in uS) of one complete cycle
return totalPulseLength;
} // end findFrequency()
void printFrequency(){
lcd.setCursor(0,0);
// clear display
lcd.print("
"); // clear display
lcd.setCursor(2,0);
if(cyclesPerSecond<250){
lcd.print("below 250 Hz");
}
else if(cyclesPerSecond>37500){
lcd.print("above 37.5 kHz");
}
else{
if (cyclesPerSecond<1000){
lcd.print(cyclesPerSecond,2);
lcd.setCursor(9,0);
lcd.print("Hz");
}
else{
cyclesPerSecond=cyclesPerSecond/1000;
lcd.print(cyclesPerSecond,2);
lcd.setCursor(9,0);
lcd.print("kHz");
}
}
} //end printFrequency()
void printAmplitude(){
lcd.setCursor(0,1);
lcd.print("
");
lcd.setCursor(2,1);
// clear display
// clear display
/*------when signal is 500mV p/p, the analog reading is roughly 337
when signal is 2000mV p/p, the analog reading is roughly 515
the next line maps these values so they can be displayed
*/ //----pulsePP=map(pulsePP,337,515,500,2000); // convert readings to mVolts
//pulsePP=pulsePP/1000;
// convert mV to Volts
if (pulsePP<500){
lcd.setCursor(0,1);
lcd.print("under 500mV p/p");
}
else{
if(pulsePP>1000){
lcd.print((pulsePP/1000),1);
// print voltage
lcd.setCursor(9,1);
lcd.print("V p/p");
}
else{
lcd.print(pulsePP,0);
// print voltage
lcd.setCursor(9,1);
lcd.print("mV p/p");
}
}
} // end printAmplitude()
Step 13 - THEORY OF OPERATION
First off, the signal is sent to a high impedance buffer on pins 1, 2 &3 of the lm324, this is to avoid effecting the signal being measured.
The signal is then split and sent to two more buffers biased to keep their outputs above zero volts.
The op-amp on pins 8, 9 &10 is configured as a comparator with some hysteresis. It takes the sine wave input and puts out a square
wave. The "pulseIn()" function reads this square wave on its digital input #9 on its pin#15. The length of time the signal is high is
measured and the length of time it is low is measured, ten times each, added together and averaged for better accuracy. The reciprocal
of this averaged time is the frequency. The output is passed by a 5.1v zener diode (D2) to limit the voltage to protect the Arduino’s I/O
pin. The resistor, R13, limits the current for the same reason.
The output of the op-amp on pins 5, 6 &7 goes to D1, C4 & R12 which together form “peak detector". The "high" of this sine wave is
held, stored and reloaded to the arduino's analog input (A5) on pin 28. The "map()" function in the code senses this output and converts
it to a corresponding voltage. For example, the line "map(pulsePP, 337, 515, 500, 2000);" When I was measuring a voltage of 500mV,
the analog reading was 337. When I was measuring a voltage of 2000mV, the analog reading was 500. Feel free to "tweak" these
numbers if you can get better accuracy.
Please keep in mind, I have no formal training. I am self-taught tinkerer with marginal coding skills. I'm sure there are better and more
accurate ways to do this, please share your ideas.
Step 14 - PARTS KEY
RESISTOR NUMBER(S) 1, 6, 7,11,12,13 &14
RESISTOR NUMBER(S) 2
RESISTOR NUMBER(S) 3, 10
RESISTOR NUMBER(S) 4
RESISTOR NUMBER(S) 5
RESISTOR NUMBER(S) 8
RESISTOR NUMBER(S) 9
CAPACITOR NUMBER(S) 1, 2 3 &5
CAPACITOR NUMBER 6, 7 &8
DIODE 1
DIODE 2
DIODE 3
20K OHMS
270K OHMS
56K OHMS
150K OHMS
100K OHMS
68K OHMS
9.1K OHMS
10uF
.1uF
1N914
1N4733
1N4001
RED BLACK ORANGE
RED VIOLET YELLOW
GREEN BLUE ORANGE
BROWN GREEN YELLOW
BROWN BLACK YELLOW
BLUE GRAY ORANGE
WHITE BROWN RED
Download