Tags

, ,

It is time to try out the pH circuit on a breadboard.  

The Goal

The goal of this post is to match the signals on a breadboard circuit to those created from an LTSpice simulation of the pH Circuit.  I haven’t discussed the LTSpice simulation yet.  I hope to do that soon.  Chris uses LTSpice to simulate circuits he goes over with us in the Contextual Electronics course.  Wow – what an exceptionally useful tool!  Through building a simulation in LTSpice, I was able to significantly increase my knowledge of the inputs and outputs of the ICs.  This helped me better understand more aspects of an op amp.  I say more aspects, because I don’t have a strong grasp on all the varieties of ways an op amp can be hooked up.  There is also a concept or two of the inverted op amp that I still scratch my head about.  The best way for me to learn though is to try out what I know, build on that, and add as needed. 

Thanks To Those That Go Before 

These folks have made a tremendous positive impact helping me learn the electronics concepts and practicalities that I needed to complete this prototype of a pH circuit.

  • @SparkysWidgets –  His phSensor schematic and blog post is all you need to get started.  Because I lack the background in electronics, I didn’t understand much of the post at first.  This got me writing out what I learned here.  This person has been exceedingly thoughtful and open with his knowledge.  Kindly (and I assume patiently!) pointing me in the right direction.  Please consider supporting his efforts.
  • Chris Gammell – our very knowledgable and gifted instructor of Contextual Electronics.  A course I would highly recommend if you are interested in turning your prototypes into PCBs and learning tons about electronics along the way.  Chris’s teaching style is exceptional.  He teaches more like a knowledgable guide.  He does first what he expects us to do, examines his mistakes, and constantly seeks and uses feedback from his students.  Chris is exceptional.  His efforts are another I highly recommend supporting.
  • Mike Engelhardt – thank you for LTSpice.  What an exceptional contribution to circuit designers!
  • Gabriel Anzziani – the creator of a very nicely done oscilloscope for the price.  This is the first time I used a scope.  Chris recommended the XMinilab for the course.  I admire Gabriel’s ability to keep a tool simple. THANK YOU!

Debugging Tools

  • DMM – I used a DMM (Digital MultiMeter) to check the power values across the circuit.
  • Simulation – I used LTSpice IV on Windows to simulate the pH Circuit.  The simulation gave me more confidence on what the values should be at the important pin i/o’s in the circuit. 
  • Oscilloscope – I am new to using a scope.  I started with the BitScope 10 Oscilloscope . I found the UI and features to be overly complex and the user’s guide to not provide me with the easiest information to get me going.  Of course, this is most likely my problem because I do not understand not only the software, but how to use the scope.  Chris recommended the Xminilab XScope.  At first I was skeptical if this simple piece of hardware – more like a kit than a product – would help me.  To my  happy surprise I found the Xminilab to be incredibly easy to use and provides only the amount of information that I needed.  Powerful, yet had training wheels for folks like me.

The Circuit

Here is an image of the schematic I created in LTSpice:

PhCircuitDecouplingCapLTSpiceSchenatic Question

 A sine wave of +/- .414 is input into the non-inverting pin of the first op amp.  The output from the first op amp amplifies the signal by 5.681.  The second op amp takes in the amplified signal on its inverting pin. The output of the second op amp inverts and shifts by 2.5 the values of the sine wave.  This sine wave now has values between 0V and 5V, which will be read by the Arduino script.

Parts

I ordered “breadboard friendly” parts from digikey

Mft number

Digikey number

Qty

$

Description

TL072IP

296-14997-5-ND

1

0.70

8-DIP 2 channel TL072 op amp

MCP1541-I/TO

MCP1541-I/TO-ND

1

0.92

Through hole 4.096V VREF

MAX1044CPA+

MAX1044CPA+-ND

1

3.03

8-DIP charge pump

I had the following parts on hand:

Part Quantity
220K R 3
1K R 1
3.3K R 1
47K R 1
10uF C 2

The breadboard prototype differs from the simulation/SparkysWidgets’ schematic:

  • I did not have 3K resistors so I used 3.3K.
  • I did not put in C1 at this point.  I’ll get back to C1 in a bit.

TL072

The TL072 pin out (data sheet): 

TL072

I wanted to make sure that I wired the chip up correctly.  I created this table to give me a better feel for the purpose of each pin and how it maps to the LTSpice simulation:

Pin i/o name i/o description
1 Out Gain op amp pH_Gain
2 V(in-) Gain op amp V_negFeedback
3 V(in+) Gain op amp AWG (Arbitrary Wave Generator, Future: pH signal)
4 V- wired to to pin 5 of the MAX1044 (V- input)
5 V(in+) Shift op amp 5V with 1K and 3.3KΩ = 5*(1/4.3KΩ) = 1.163V
6 V(in-) Shift op amp output of Gain Loop, wired to pin 1
7 Out Shift op amp pH_Shift
8 V+ wired to Arduino 5V power supply (Future: AREF)

 

 

 

 

MAX1044

MAX1044 Inverted Charge Pump (data sheet):

MAX1044

The diagram shows polarized capacitors being used.  I asked Chris if it mattered whether the caps were polarized or not.  He said no – the reason they were polarized was because about 10 years ago (perhaps less) 10uF caps were not available.  I am using electrolytic caps because I have them on hand.

The description of the MAX1044’s pins: 

Pin i/o name i/o description
1 Frequency Boost Connecting BOOST to V+ increases the oscillator frequency by a factor of six. When the oscillator is driven externally, BOOST has no effect and should be left open.
2 CAP+ Connection to positive terminal of Charge-Pump capacitor
3 GND The positive terminal of the reservoir capacitor is connected to this pin.
4 CAP- Connection to negative terminal of Charge-Pump capacitor
5 VOut Negative output V. Connect negative terminal of reservoir capacitor to this pin.
6 LV Low-Voltage Operation. Connect to GND for supply voltages below 3.5V.
7 OSC Oscillator Control Input Connecting an external capacitor reduces the oscillator requency. Minimize stray capacitance at this pin.
8 V+ Power supply voltage input.

I did not use pins 1, 6, and 7. 

Bread Board Results

Here is the pH circuit on the breadboard:

PHBreadBoardLabeled

 

The important i/o points of the signal are the TL072’s pins:

  • 3 – a sine wave is input into the TL072.  A pH signal’s amplitude is +/- .414V
  • 1 – the output of the first op amp.  This is the pH signal that came in on pin 3 amplified by 5.681
  • 7 – the output that is to be read and interpreted by the Arduino.  This takes the output of pin 1, inverts the signal, and then adds 2.5 to each value so that all values are between 0V and 5V.
Successful results are the values at these pins for the simulation and bread board are close enough to feel comfortable the circuit is working as expected.

Input Signal on pin 3

A YIPPEE MOMENT! I was able to set the incoming sine wave to +/- .414V in the simulation.  With the XScope, I could get to +/- .420V.  Reading pin 3 with the scope shows the “close enough” signal going into the breadboard.

PHSignalLTSpice

pin3AWG

Output Signal on pin 1: Amplify pH signal

The output signal  amplifies the pH_signal by 220K/47K + 1 = 5.681.  e.g.: .414*5.681 = 2.359 and -.414*5.681 = -2.359

…and…ANOTHER YIPPEE MOMENT!…the results shown on the scope of the prototype are close enough to the results of the simulation.

 

PH Gain LTSpice

OutputSignalPin1

Output Signal on pin 7: Shift negative values to be above 0V

And…after a day of frustration…YET ANOTHER YIPPEE MOMENT!  The values that will be read from the Arduino:

Ph 5VLTSpice

OutputPin7

Values at Each pH Level

I created a table of the values I should read off the Arduino’s analog i/o pin: 

pH Signal(s) -(S*Gain) Shift
0 0.414 -2.359 0.159
1 0.359 -2.029 0.489
2 0.309 -1.689 0.829
3 0.249 -1.349 1.169
4 0.189 -1.019 1.499
5 0.129 -0.679 1.839
6 0.069 -0.349 2.169
7 0.009 0.009 2.509
8 -0.069 0.349 2.849
9 -0.129 0.679 3.179
10 -0.189 1.019 3.519
11 -0.249 1.359 3.859
12 -0.309 1.689 4.189
13 -0.369 2.029 4.529
14 -0.419 2.359 4.859

The signal goes into pin 1 of the TL072.  The output is amplified by 5.681.  I then inverted the amplified output in preparation for the value that will be the analog input.  The Shift column adds 2.5 to each value.  The values I should read in from the analog i/o pin range from 0.159 for pH 0 to 4.859 for pH 14.

Frequency Response and the .1uF Low Pass Filter

Earlier I noted the prototype did not include the .1uF capacitor that is in the pH schematic.  I didn’t include this capacitor because – while I got the right results for the op amps’ outputs without the cap – the results were very different when I put the cap in the circuit and ran the simulation.  This image shows the pH signal input (pin 3) and the output of the op amp used to apply a gain of 5.681 (pin 1).  When I put the .1uF cap into the circuit, the hard earned 5.681 magnification of the original pH signal disappeared!

HighFrequencyNoGain

No Gain When .1uF Cap in Circuit

Chris explained to me the relationship between wave frequency and amplification.  As the frequency of a wave increases, the amount of amplification decreases.  There is a rather well known plot – the Bode plot – that is used quite a bit in areas where the frequency response is important – such as audio equipment.  Here is the frequency response (Bode plot) for my circuit when an AC analysis is run with the amplitude set to 1:

PHCircuit Freq 1K Cap BodePlot

The first thing to notice on this plot is the Y Axis (amplification of the signal) uses dB to show gain measurements.  Smart people figured out that a dB value = 20*log(vout/vin) = 20*log(Gain on circuit) = 20*log(5.681) = 15.1dB.  Perhaps the same smart folks or maybe their friends also figured out that the cutoff point in which a wave will not be able to be amplified occurs when the frequency is 3dB less than when the frequency of the wave is at 1Hz.  3dB less than 15 db is 12.  That makes the cutoff frequency to be about 7.6Hz.  In order to realize the gain, the simulation needs to be set to less than 7.6.  Also notice how the gain curve goes slightly down before a significant drop off at around the – 3dB.  Thus the full gain is only fully realized when the frequency is 2Hz or less.  A far cry from the 1KHz I naively used as an input into simulating the pH signal!

In this image, the frequency is set to 2Hz:

PHCircuit Freq 2 Cap

Here, the frequency is set to 150Hz:

PHCircuit Freq 150 Cap

Not letting the x-axis change (because of dramatic increase to the frequency), these simulated runs verify the Bode plot.  When the frequency is way small – shown here at 2Hz – the pH signal is amplified the way I want with the .1uF cap in place.  Once the frequency is increased – in this case to 150Hz – the sine wave isn’t magnified.

Wow – a little bit of insight in how a circuit designer would pick the .1uF circuit based on the expected incoming frequency and the requirement of a 5.681 gain!

What’s Next

Before I move on to testing with a pH probe instead of the AWG, I am going to understand signal noise that is occurring because of the ICs.  Chris just taught us about AC coupling and how to DIY an AC coupler for the XScope.  I’m off to do that.  I need to solder an overwhelming amount (at least for me!) SMTs to the Contextual Electronics PCB that we designed in Session 1A and now are soldering together – component by component.  Then I want to go through the same process with understanding and building an EC circuit.

 

THANK YOU for reading this far.

Please find many things to smile about.

 

Advertisements