Dev Rev 1 of the Healthy EC Shield

Tags

,

 I want to get going on the schematic of the Healthy EC Shield while I wait to get fabricated PCBs of the Healthy pH Shield from OshPark.  The job of the Healthy EC Shield is to read the nutrients in the bath and determine if more nutrients are needed.  If so, pump in the amount of nutrients needed.  Schematics are located in this GitHub repository.  CAUTION – THE DESIGN and LAYOUT ARE NOT FINISHED.

The Goal

The goal is similar to the goal when I posted the design of the Dev-Rev 2 of the Healthy pH Shield (link).  I will walk through the Healthy EC Shield’s circuits.

Thanks to Those That Go Before

I can’t help smiling when I think about how amazing it is to be able to learn something each day.  What has been occurring recently has been like a zap to my head!  Just when I thought I understand something, Chris Gammell or Ryan (SparkysWidgets) – maker of many very cool boards – like the minipH and miniEC) kindly nudge what I think I know into the right direction of how something (in this case an EC Circuit) actually works.  Both Chris and Ryan have been instrumental in my understanding of an EC Circuit and electronics.  I highly recommend the offerings from both!

The Schematics

I am calling this build of the Healthy EC Shield Dev-Rev1.  The (kicad) files for the schematic are located at this GitHub repository.

The design shares design choices with the Healthy pH Shield.  They both

  • use the MCP3901 as the ADC.  This way, the same firmware functions will be needed and I there will be twice as many needed which increases my chances of buying at the less expensive bulk rate.
  • use the same design for pumps.  There is only one pump circuit on the Healthy EC Shield to pump nutrients.
The Healthy EC Shield assumes the Healthy pH Shield is stacked below.  This allows the Healthy EC Shield to use the Healthy pH Shield’s temperature sensor, Wall Wart power source, and RGB LED (for debugging purposes).

The Sub Circuits

As with the Healthy pH Shield, I use Kicad’s hierarchical schematic feature to logically represent the sub circuits.  I’ll only detail the EC circuit since the others are pretty much the same as found on the Healthy pH Shield (link).

EC Circuit

The key thing to know about the EC circuit is the EC probe acts as a variable resistor within the gain loop segment of the EC Circuit.  I’ve walked through this circuit several times (and every time I do – just when I think I understand it, there is something I don’t understand!  Fascinating) (link).

EC Circuit Picture

The EC circuit schematic explains what EC_GND and the AC power source as input into the non-inverting input pin of the op amp (link in GitHub).  I’ll include the “important snippets” below.  But it is perhaps best to look at the schematic to get a better feel for the circuit.

EC_GND is a virtual ground so that a single (5V) power supply can be used for the op amp rails:

EC_GND

The AC signal is generated by shrinking down an AC Signal created by a Wien Bridge Oscillator:

Created AC Signal

 

Calculating the EC Value

I went through how to calculate the EC value in this post.  Looking back at the picture I’ll redraw the R’s and V’s as:

VoltageDivider

where:

  • Vout = EC_Signal
  • R1 = 3K
  • R2 = 1/S = 1/EC

That is, this is part of a variable gain loop in which the only unknown is the value for R2.  Once that is figured out, conductivity (EC) is the inverse of resistance. 

Like I said, the explanation and example calculation are in this post.

Just One More Thing – Changes to Healthy pH Layout Prior to Sending Gerbers

Tags

,

Just sent Dev-Rev2 Gerbers to OshPark for Fabrication (~2PM on 9/15/2014).  But before I did I fixed a few things from my last post.  I have updated all schematic/layout/gerber files on the GitHub repository for Dev-Rev2 of the Healthy pH Shield.  Since I barely (and perhaps that is questionable?) know what I am doing, I crave your thoughts on how I can improve on the design/layout.

The Goal

The goal of this post is to walk through the errors on the Healthy pH Shield Dev-Rev2 layout.

Thanks to Those That Go Before

Every day I am thankful for the many amazing people that I interact with.  

This post would not be possible without the guidance and knowledge shared by Chris Gammell.  Just when I think I understand something, I go over it with Chris…and…whoa – I truly was clueless.  While he has every right to do so, Chris has not laughed at my learning foibles.  Rather he has patiently explained (and re-explained) something I just don’t get.

Results From freeDFM

In the post where I discussed the design and initial layout of the Healthy pH Shield (link), I noted freeDFM – a utility from Advanced Circuits (here is the link) I like to run prior to submitting Gerbers to a fab house – pointed out errors that I couldn’t read.  The first problem I had was the coordinate system.  What the heck origin was freeDFM using?  I mean, I had entered X=2.7” and Y=2.1”….then did freeDFM report an error at X=8.5277987″, Y=-3.2543901”?

DOH! I have ignored actually LOOKING at the Gerber files, relying on the layout view in Kicad’s PCBNew.  Um..yah, not good.  Considering what actually going on is shown in the Gerbers…. so opening up the Gerber files notice where the origin is:

Gerber Showing Origin

The origin is way to the upper left.  So yes indeed, TP9 (circled) is at X=6.9975″, Y=-4.355″

…and yes, indeed there is a double drill hit:

Double Drill Hit

…and the other based on the coordinates / location in the Gerbers:

2nd Double Drill Hit

 

The second freeDFM error were 5 violations of Insufficient Trace Width.  It turns out an edge of the Arduino GND plane was too close to P1 drill holes:

 

 

Zoom In Insufficient Trace Width

So I appended the GND plane to include more surface area around P1:

More Surface Area ARound P1

OK, resubmitted to freeDFM…and…and…

 

Clean Up

Some uglies I cleaned up:

I had the RGB LED – which uses the 5V+ of the Arduino using digital i/o PWM pins, which was how I’d seen RGB LED examples wired.  The problem with this is it caused me to draw a rather large and ugly track across the board from the 5V+ pin on the Arduino to the digital i/o pins on the other side.  Given this advice (link): 

  • digitalRead() works on all pins. It will just round the analog value received and present it to you. If analogRead(A0) is greater than or equal to 512, digitalRead(A0) will be 1, else 0.
  • digitalWrite() works on all pins, with allowed parameter 0 or 1. digitalWrite(A0,0) is the same as analogWrite(A0,0), and digitalWrite(A0,1) is the same as analogWrite(A0,255)
  • analogRead() works only on analog pins. It can take any value between 0 and 1023.
  • analogWrite() works on all analog pins and all digital PWM pins. You can supply it any value between 0 and 255.The analog pins let you read/write analog values – basically, instead of giving out a voltage of 0 or 5 (as with digital), they can give a range of voltages between 0 and 5 (both as input and output). Note that the voltage during analog output is only the observed voltage with a multimeter. In reality, the analog pins send pulses of 0V and 5V signals to get an output that “looks” analog (this is PWM).

I ended up moving the RGB LED and associated resistors to analog pins close to the 5V pin:

Layout of RGB LED

Then a few smaller uglies.  The through hole size of the WallWart and Barrel Jack parts were too small.  More like the size of a via than a through hole.  Then the GND planes needed fixing up as well as overlapping labels.  The point of all this minutia is the importance of sanity checks – and most ideally – reviewing with someone far more senior who will point out errors.  So much to learn.

 

So now I impatiently wait for the PCBs to return from Osh Park.  Then soldering and…maybe…power!

 

Please find many things to smile about.

Dev – Rev 2 of the Healthy pH Shield

Tags

,

I’ve updated the schematic and board layout of my Healthy pH Shield.  The Healthy pH Shield is an Arduino shield that reads the pH of a bath then adjusts it to the right levels for the plant that is using the bath for nutrients.  For example, growing lettuce hydroponically grows best when the pH level is between 5.5 and 6.5. 

The Goal

The goal of this post is to walk through the Healthy pH Shield and get ready for sending Gerbers off to OshPark.  I also will be documenting where I ordered parts, the time it took to get things done, and the cost.

Thanks to Those That Went Before

Learning – in this case about electronics – brings me endless amounts of joy.  For so many obvious reasons, I would never be able to pick up an IC and figure out what to do with it without the help of someone who knows more.  Whether they wrote a book, an article on a web page, shared their specs, or face-face.  We are blessed to have access to the material sharp folks have willingly provided for us to learn from.  For this section of my projects, I am most thankful for:

  • Chris Gammell – Through Chris’s Contextual Electronics class I was able to make dramatic strides forward in my ability to design a schematic (in kicad), layout the board, solder on the chips, debug.  I also gained a better understanding of the electronics behind the circuits.  Although to be honest, I probably caught the technical details of 20%.  The good news is the material, Chris, and the material make it easy for me to backfill my questionable ability as a “fast” learner.  This is so different than learning in a classroom.  Where once we’re out of the classroom, it is much more difficult to pick up learning where we left off.
  • Ryan – Ryan has created many very useful break out boards – including a pH and EC sensors.  He has also published the schematic and board layout.  I have spent many an hour pouring over his schematic to understand how pH and EC circuits work.  Not only that, but I have been able to reach out to Ryan through twitter @SparkysWidgets – and he has been very helpful.

The Schematics, Board Layout, and BoM

I am on my second build.  I call this the Dev-Rev2 build.  The files for the schematic and board layout are located at this GitHub repository.  They are kicad files.  The BoM is also located there (in the other folder).

The Sub Circuits

I used Kicad’s hierarchical schematic feature to logically represent the sub circuits.

HealthypHSubcircuit

Arduino

The Arduino sub circuit talks to the Arduino so that firmware can communicate with the other sub circuits.  The main interface is to the SPI bus connected to the ADC (the MCP3901).  There is also an RGB LED that I plan to light different colors depending on tests run by the firmware to detect the health of the circuits. This way I have a visual indication when a sub circuit doesn’t work as it should.  For example, if the firmware can’t get read or write to the MCP3901 over the SPI bus.  At a higher level, if a valid pH reading can be made, etc.   It turns out the least expensive/will work RGB LED is this one.  It is a common anode diode.  So I drew the circuit accordingly.  I need to remember the inverse logic (at least for me) of using a common anode instead of common cathode diode.  The LEDs go on when the signal goes low.  The pumps are controlled by Arduino i/o pins.  

From breadboard prototyping these circuits, I felt the 5V power source of the Arduino would add too much noise to the sensor readings.  This is why there is a barrel jack plug so that a wall wart can be plugged into the shield.  Wallwarts between 6 and 9V should work.  

Wall Wart

The wall wart sub circuit uses a voltage regulator circuit to ensure the amount of voltage to the sensor circuits is a clean (as possible) 5V.  I stuck a green LED on the circuit that will light up when the shield is plugged into the Wall Wart.

pH

Here is where the pH measurements happen.  The schematics reflect this:

When the probe is attached to the BNC connector, the VGND and non-inverting input pins are connected as shown above.  A specific example:  if the pH of the bath = 14, then the voltage across the probe would = -.414V (assume the ideal).  Since VGND is .45,  the input into the non-inverting op amp is .036V.
The BNC connector is not part of the shield.  The BNC connector is connected to the circuit through two wires that are part of the P1 (CONN_8) – see HealthypH.sch.  Input to the MCP non-inverting = output of buffer op amp (the one in the picture above).  Input to the inverting pin of MCP CH0 (or 1) = VGND (i.e.: .45V)

I’ve discussed using a virtual ground to raise up the signal generated by the probe to all positive values such that the op amp has a 0V rail. Also, the op amp I chose had characteristics in the rails and IB (Input Bias) specific to this application. Figuring out which op amp and how to approach virtual ground were the most time consuming aspects of the design. A lot of the time was learning why…. I discuss the op amp choice in previous posts.

Temperature

pH and E.C. values vary depending on the temperature of the bath.  Readings use the MCP3901 (ADC) CH1.  Here is an image of the circuit:

The Thermistor is the top R of a voltage divider. This is explained well in this Arduino playground writeup.  The Thermistor is coated in water proof epoxy connected to two wires so that it can dangle in the bath.  The wires connect to a terminal block (as do the wires for the BNC of the pH probe and the wires for the pumps). Therm+ is input into the CH1+ (non-inverting pin)  Therm- is input into Ch1- (inverting pin).  I used a blue box to identify in the schematic where the 10K Thermistor would be.  I did not want to add a footprint to the board..the two outputs go to the terminal block.

Pumps

The design supports two peristaltic pumps in order to adjust both the pH UP and DOWN (addition/dilution of H+ ions).  Here is a drawing of the wiring:

The pumps use the Arduino as their power source and GND.  An Arduino pin is dedicated to sending digitalWrites() to each pump.  E.g.: Turn pump on for 1 second:

digitalWrite(pHDown_pin, 255);

delay(1000);

digitalWrite(pHDown_pin,0);

The signal is sent to a transistor (data sheet).  The pump has a diode between its wires to handle the reverse kickback from the pump when it is turned off.

The Layout

As most things, laying out a board gets easier with practice.  I have a long way to go before I feel I have a strong grasp on board layout.  I am able to get a board through DRC in kicad and read OshPark’s track width/via size requirements.  

I use two ground planes: one for the ground plane related to the Wall Wart.  The other for the ground plane related to the Arduino’s 5V power source.

Dev-Rev2 Layout

Tracks Through Ground Planes

Is a bad idea since it cuts up the copper.  This “rule of thumb” was used when I went from this layout:

Track Through GND Plane

To this layout:

Track Not In GND Plane

Error Checking

I use kicad’s DRC error checking as the first round.  Once these errors are all gone, I move over to freeDFM provided by Advanced Circuits (link here).  They take and email address – now the marketing is locked and loaded on that email address.  In addition, the Gerbers and drill file are pretty much open to the public.  Since all of this is public domain, I’m ok with that.  There is a small bit of information I have to enter after uploading the Gerbers and drill file such as board width and length, how many layers, and a few others.

FreeDFM Results

The results are located here.  I look at the “Potential Show Stoppers”

freeDFM Potential Show Stoppers

I have trouble reading the results.  When I go to the Double Drill Hits link, I am told: Double hits on layer HealthyPH.drl, at X=6.9975″, Y=-4.355”.  Huh?  I put in the dimensions of x = 2.7” and Y = 2.1” – unless input is in mm?  The X and Y dimension field say input should be in inches. Then why these numbers for X/Y?…

hmmm…

I don’t think these errors matter when submitting to OshPark.  However, I’d like to know why I’m getting these errors.  I’ll update this post once I figure this out.

What’s Next

I hope to figure out where the FreeDFM errors are occurring.  I plan to submit the Gerbers to OshPark on Monday.  That means I should start on writing tests for Dev-Rev2.  I also want to give the rectifying portion of the EC breadboard circuit a twirl.  Everything on the breadboard worked fine.  When I got to this step, the output did not look correct.  There are so many reasons a breadboard doesn’t work.  I find this is a very tedious process to debug – particularly as the circuit gets more complex.  I also want to make progress on the EC schematic.

 

 

For now, please find many things to smile about.

 

 

 

Breadboard Prototype of the 2nd Stage of the E.C. Circuit

Tags

,

Finally – I conquered the Wien Bridge bread board prototype that included a VGND of +2.5V (detailed in this post).  Now on to the 2nd stage – reading the E.C voltage.

The Goal

Add the Second stage of the EC circuit to the breadboard prototype.  Measure the output with an oscilloscope and compare results with the LTSpice IV model.

Bread Board View

The Schematic

Here is an image of the LTSpice IV schematic for the EC Circuit with the second stage within the pink area.

LTSpice EC Circuit

 

Wien Bridge Oscillator

Here is the output from the Wien Bridge Oscillator stage:

 

NewImage

YIPPEE!  The frequency is right where it should be at 1.6KHz.

Shrink Vpp

Moving right along…here is the output after the voltage divider (to get the input into the non-inverting pin close to a Vpp of 200mA):

NewImage

 

YIPPEE! The scope’s readings appear close enough…now onto reading the ECv.

Reading ECv

 I’m going to try both a 200Ω and a 1400Ω resistor for R0 (see image above – R0 represents the input of an E.C. probe.  It acts like a variable resistor within a voltage divider similar to a thermistor sensor).  Here’s what I get from the LTSpice IV model:

NewImage

The green line is when R = 200Ω.  The black line is when R = 1KΩ.

When R=200Ω, the Vpp ~= 1.4V.  When R=1KΩ, the Vpp != .46V

I added the op amp and resistors to the breadboard then checked out the results on output of the 2nd op amp.  Here I used a 200Ω R:

 

NewImage

Another YIPPEE!! The Vpp is “close enough” to the model, off by .1V (1.5V on scope versus 1.4 in LTSpice IV model).

NewImage

And the breadboard prototype of the EC circuit through stage 2 seemed to work for a 1K resistor.  

What’s Next

On to the last stage – sending the ECv through a rectifier.  Hopefully I have more op amps and diodes around…

 

Why the Virtual Ground Method used for pH Will Not Work for E.C.

Tags

,

I’ve been bumbling my way through grasping the beauty of using voltage dividers to create virtual grounds so that I can use a single power supply as a power source to the op amps.  In the back of my head, I hear Ryan’s (SparkysWidgets) warning that I’m leaking current into the bath which makes measurement difficult at best and more likely impossible.  But I need to understand all this stuff better, including different configurations for virtual grounds with the goal to use a single power source while handling an AC Signal as it makes its merry way through op amps.

The Goal

The goal of this post is to better understand the impact of design choices on designing virtual grounds

Thanks to Those That Go Before

Every day I think about the things in my life that I am thankful for.  There are so many things.  One is the sharing of knowledge from exceptionally smart and caring folks.  Today’s thank you goes to:

  • Chris Gammell – Chris is an exceptional teacher/guide who tirelessly walks me through electronic design concepts and implementation.  He has a knack for teaching in a way that makes me passionate to learn more.  I do recommend his Contextual Electronic courses.  I took them and learned a lot.
  • Ryan of SparkysWidgets – If it wasn’t for Ryan’s open source design of the minipH and miniEC, I would not be able to make the progress I have made on the pH and EC Circuits I work on.  Ryan has been exceptional in giving me insight and advice on my circuits.  His stuff is great!

Overview

I discussed in this post how I designed for a single power source in order to handle the negative pH readings of the AC Signal.  While this design should work ok for the pH circuit, it will not work for the E.C. circuit.

Why?

The Challenge Using the VGND of the pH Circuit

The major difference between the AC signal – in the case of pH, the pH voltage and in the case of EC, the Wien Bridge Oscillator – is shown in this diagram I found from this site:  

Voltage Divider With Load Explained

Recall the (glass) characteristics of a pH probe mean the AC Signal will act as a high impedance load. SpakysWidgets notes: “A typical probe has an impedance of anywhere between 50Ω and 500MΩ.”    The Wien Bridge is built on the wires and components on a PCB or bread board and so acts as a low impedance load.

The pH probe adds pretty much 0 load to the circuit. This is not true for Wien Bridge Oscillator.  The more load, the less the output voltage will be.

Consider this example where this is no load (as is the case with the pH circuit):

No Load Divider

Ach – the more I learn the less I seem to understand.  But just keep swimming..just keep swimming!

 

 

Assembling the Healthy pH Shield – part 2 – Soldering

Tags

,

Now the moment I’ve been waiting for…soldering with a stencil, solder paste and my hot air gun.  I had the solder paste stored in my refrigerator in a cooling bag.  I had taken it out to get to room temperature a few hours before.

The first thing I did was to tape down the stencil.

Taped Down Stencil

Now, spread the solder…

Spread The Solder

Peel off the stencil…

Peel Off The Stencil

OOPS! Way too much solder paste  This was my problem when I was using a solder iron.  I finally figured out that I needed far less solder than I thought.  I haven’t done stenciling before…but I am assuming reflow will suck the solder up.  OK, I’m hoping.

 

Placed the parts with an attempt to make sure the diodes were placed in the right direction.

TBD: picture of diode next to schematic picture with flow. next to pcbnew picture.

 

 

I set the hot air gun at 249˚C and air at level 4.  I used the bigger of the tips I could find.

Healthy pH Shield After Stencil Solder

 Definitely too much solder paste.  This is especially true with the MCP3901.  Using a magnifying lens, I could only find the MCP3901 with shorted pins.

It was easy to remove excess solder with solder wick on one side.  However, the other side became more difficult than I imagined it should.

MCP3901 After Solder Wick

 What added to this was a few of the pins were bent together!  Not sure how I did that.  Definitely points to being more careful with this chip.  I removed the MCP3901

Removed MCP3901

Before replacing, I tried connecting wires to the power jack – due to my screw up in drawing the footprint (see this post).  Alas, there was not enough exposed copper on the PCB to attach the wires.  Given that I can’t get power to the PCB, I can’t test.  Drat.

What’s Next

Staying calm, the next move is to revisit the schematic and layout and update the power jack footprint as well as double check the circuits.

 
 

Assembling the Healthy pH Shield – part 1 – Part Placement

Tags

,

Post for September 6, 2014

YIPPEE! I received my three PCBs from OshPark yesterday…oh and of course there are the packets of chips that I bought from digikey and the stencil from OshStencil…exciting…

Healthy pH PCB

Now that I have come back from my yoga class, I’m ready to get started assembling the Healthy pH Shield.

Part Placement

After building the PCB in the Contextual Electronics Session 1B, I’m going to start with a process that I learned as I went along….as I go one step beyond clueless…I find when attempting to solder components on a PCB that getting a bit more organized goes a long way in lowering frustration and gives me the best chance of being successful.

The first thing happens during BoM building.  Build the BoM such that one of the columns is the Component number shown on the board layout.  

For example, here is the board layout of the Healthy pH Shield pointing out where the two diodes are:

Healthy pH Board Layout With Diodes Highlighted

Here are columns included in the BoM:

Cmp # MFG MFG Part Number
U1 Microchip Technology MCP6241T-E/OT
P1 On Shore Technology Inc OSTTE080104
U2 Microchip Technology MCP3901A0-I/SS
X1 TXC 9B-4.000MAAJ-B
C1 Kemet T491A106K006AT7280
L5 Taiyo Yuden BK2125HS101-T
R5 Vishay BC Components NTCLE100E3109JB0
U3 Fairchild Semiconductor MC78L05ACHX
D1,D2 Comchip Technology CGRA4004-G

The label on the digikey bag containing the diodes has the manufacturer’s part ID:

Digikey Label

Oh – and when ordering common parts like resistors and capacitors – it’s best to order in larger quantities – say 50.  A discount kicks in and these parts get used up.

Other organization aids revolve around the chips.  As I open the chips, I’m going to:

  • store as many as possible in an SMT storage case (this is the one I got) .  I’ll label the itty bitty storage cases I use using my handy-dandy label maker (here’s the one I got).  Both of these awesome recommendations came from another student in the course.

  • place chips on one of the other Healthy pH Shield PCBs – I’ll refer to this as the placement PCB – so that after I apply the solder, I’ll know where to place the chips on the board I will solder.
  • stay calm and drink coffee…
oh…and adding one more thing – I’m not opening the Digikey box-o-chips until I am ready to put the chips away or use immediately.  I lost a couple of chips…vacuum cleaner?  dogs? cats?…darn it.

Start Placing Chips

Equipped with the board layout in the PCBnew editor, I start placing the chips…and the first one I place is the Power Jack Connector.  This brings me to….

Oops!! 

hmmm… the through holes, well – they aren’t through holes on the PCB and they certainly don’t match the through holes on the barrel jack. Yah well…I screwed up.  Luckily, my staying calm strategy is helping me through this boo boo.

 

Moving on…

I start placing the diodes, capacitors and resistors on the placement PCB.  I’m not checking to see which direction a diode should be in since this is just about placement and not current flow.  Like a box of puzzle pieces missing a few pieces, I cannot find U1 (MCP6241), C1 ( 10µF tantalum capacitor), and R3 (10K resistor).  I guess I’ll be putting in another order to digikey.

Parts on Healthy Shield

Next Steps

I’m going to try out the stencil and solder on the SMT parts I have.  I’ll order the missing parts from digikey.

 

Thanks for reading this far.  Please find many things to smile about.

Breadboard Prototyping the EC Circuit

Tags

,

post for September 4, 2014

A few posts ago (this post) I started breadboarding the Wien Bridge Oscillator.  I was having trouble getting it to work…I think I’ve got it working now and can move on to where all the action happens – the second op amp.  Speaking of op amps, as I googled about, I found a pdf that discusses the terms used on an op amp data sheet.  YIPPEE!  That will be helpful.

The Goal

The goal of this post is to bread board the E.C. circuit – at least get past the Wien Bridge Oscillator stage!

Thanks to Those That Went Before

  • Chris Gammell – Chris guides me through learning about this stuff.  You know when you have a great teacher?  How that one person makes such a difference?  Chris is that kind of teacher/guide.  I learned A LOT from his Contextual Electronics courses.

The Problem

While the steps and sub circuits are correct in the earlier post, the +/-V power source for the rails of the op amp were not.  I totally messed this up.  I had +V at +5V and -V at 0V.  I completely ignored -V – which of course doesn’t make sense because this is an AC signal.  Yet, when I went back to LTSpice to model the circuit with the same floating ground I used in the Healthy pH Shield (discussed in this post), the Wien Bridge Oscillator did not work.  Hmmm….DOH!!!!

The Solution  

The solution is to split the power supply into +2.5V and -2.5V.  The AC signal  fits within this range since the Vpp is between .9V and 1V.  And as commonly the case – splitting power involves setting up a circuit that uses a voltage divider:

Split Power Supply LTSpice

the op amp is needed because the load of the E.C. circuit will draw some of the voltage away from the voltage divider.  This means the virtual ground will be lower than .45V.  I discuss this in an earlier post.

Caveat Using LTSpice

Note the op amp using in the LTSpice model above is the LT1006.  This is important for the LTSpice model to work.  A lot of parameters go into defining an op amp in LTSpice…I’m not sure how they all coexist and what changes affect what.  I do know I was using a single supply for the op amp.  The LT1006 is modeled to be a single supply.  The model would not work with op amps that assumed -V.

The Size of the Resistors 

The size of the resistors (R2 and R13) is relative to how much current is needed (V=IR).  The more current, the more energy it takes to run the circuit (P=IV).   Looking at the sub circuit in which voltage goes from +5V to 0V, the amount of resistance is R2 + R13.  So if R2=R3=1KΩ and V=5V, I = 5V/2KΩ = .0025A (2.5mA).  Using R2=R3=1Ω, I = 2.5A.  Using R2=R3=100KΩ I = .000025A (25uA). 

The Amount of Current – Why 1KΩ Resistors?

How much current will be needed for the E.C. circuit?  The biggest current draw are the three op amps.  Let’s say I choose a quad op amp like the MCP6244 (data sheet).  The data sheet notes each op amp uses a supply current of 50uA.  It goes on to note if an op amp is not used – which is the case in this circuit, the amount of supply current used will be minimized.  So 50X4 = 200uA = .2mA.  Even adding in the additional parts, an available current of 2.5mA will be more than enough.

Wien Bridge Bread Board (Revisited)

I set up the circuit using the same wiring I had before (see the images in this post).  This time I added the split power supply circuit to provide VGnd.

Wien Bridge with VGND

I had a TL072 op amp from an earlier prototype so I’m using it in the VGnd circuit.  The TL072 pins (from this data sheet):

TL072 pins

Here’s the AC Signal I measured at the Wien Bridge op amp’s output pin:

 

Wien Bridge Output

Finally – YIPPEE!!! Looks like the breadboard worked.  Since DC coupling is on and VGND = 2.5V, 0V on the scope display is really at 2.5V relative to the +5V power supply.  The Vpp is pretty much the same as the LTSpice model came up with.

With AC coupling turned on the AC signal is centered at 0V:

Wien Bridge Centered

Now the signal is centered on 2.5V = 0V and the Vpp is .9V instead of 1V.  I do not see the Vpp difference as significant.  I am thinking changing state then choosing Auto to automatically adjust the signal reentered the signal.  Perhaps Auto is something I should stay away from.  For now, I just note it…

What’s Next

I’m relieved that progress has been made on the bread board prototype.  Now I want to add in the all important/exciting next step – getting an ECv measurement.

 

As always, thank you and please find many things to smile about.

More on the E.C. Circuit…Calculating E.C. After measuring the Voltage from the E.C. Probe

Tags

 post for September 2, 2014

I’ve been studying electronics since last January.  There is so much I don’t know…it takes many (many, many) iterations before I truly understand something.  This is certainly true when it comes to the EC Circuit

The Goal

The goals of this post  include:

  • insert more context into the stages of an E.C. Circuit.  I discussed my original interpretation (this post) based on SparkysWidgets miniEC and the discussion on the product page.
  • Figure out the E.C. Value based on the voltage value read by the ADC.

Thanks to Those That Went Before

I realize I thank the same people.  This is because they have contributed the most to the knowledge I have gained that has allowed me to make this post.  It is important for me to be thankful each day in my electronics learning process to those that graciously share their knowledge.

  • SparkysWidgets – A major ramp up in my learnings about an E.C. circuit and the electronics behind it came from the miniEC effort and the gracious sharing of knowledge.
  • Chris Gammell – Chris is an amazing mentor/guide.  His Contextual Electronics courses have been instrumental in super charging my knowledge in electronics.  I just wish he had more course offerings.
  • The person behind this post – The post seems to be written awhile back and the author has moved on to other interests.  The information about how an E.C. circuit works is very instructive.  Thank you!

The E.C. Circuit

I’ve gone through this a few times…but what the heck, each time I re-explain, aspects of the circuit become more clear…so here I go again.  Here is an image of an E.C. Circuit:

ECCIrcuit

An AC signal needs to be generated.  This is done by using a Wien Bridge Oscillator.  The AC Signal has a Vpp ~= .9V.  The AC Signal is then shrunk to ~= .2Vpp.  This is to minimize the amount of voltage that is injected into the bath.  Step 3 is where the action is.  The shrunken AC signal is fed into the non-inverting input of the 2nd op amp.  The probe is hooked up to the inverting input, acting as a variable resistor.  The gain loop magnifies the reading so that it stands the best chance of being accurately read by the ADC.  The gain is variable because the probe – acting as a variable resistor (R0 in the LTSpice model) – will change the gain by 1 + R9/R0.

The next step is to calculate the E.C.

Calculating E.C.

Now there is enough information to back calculate the value R0 is at when a ECv is read.  Here are the simulation results for ECv when R0 goes from 200Ω to 1,300Ω in 100Ω increments:

ECv

The voltage when R0 = 200 is ~2.24V.  When R0 = 1300Ω, the voltage ~= .435.

Applying:

  • Gain = VOut/Vin
  • Gain = 1 + R9/R0
We know VOut (ECv) and R9.  We’ll be figuring out R0.  To get to Vin is a constant value that can be measured by taking E.C. readings from a  known concentration. For example, if the known concentration was at .005S, then R0 = 200Ω.  If R0 = 200Ω then Gain = 1+R9/R0 = 1 + 4000/200 = 21.  21 = VOut/Vin  Vin = 2.24V/21 = .107V.  It’s probably a good idea to average values across a few known concentrations.  Once the Vin is know, it is a constant value for all calculations.
 
So we know:
  • Vin = .107V
  • R9 = 4K
Step 1: calculate the Gain based on vOut/VIn.  
Step 2: Use the Gain value calculated in Step 1 to figure out the value of R0.  Gain from Step 1= 1 + 4K/R0
Step 3: Translate to Siemens by taking 1/R0.  Some examples are given in the table below based on the above image:

ECv (vOut)

Gain=  vOut/vIn

R0(Ω)

E.C (S)

2.24

20.93

200.7

.005

1.53

14.3

300.8

.003

.435

4

1,333

.0007

 

2nd Stage of the miniEC – Gain Loop

Tags

,

post for September 1st, 2014

SparkysWidgets has released a newer version of the  miniEC (product page) since I last played with this breakout board.  I ordered some of the newer versions awhile back and am finally getting around to giving the miniEC circuit a twirl!

The Goal

The goals of this post are to identify confusions I have with the 2nd stage (Gain stage) of the miniEC circuit.

Thanks to Those That Go Before

.2 VPP 

Ryan notes in his comments on the minieC

Right before the 2nd stage, this wave is turned into a small signal(about .2VPP via voltage divider) this small signal is passed into the (2nd stage) gain stage where the eC probe forms one leg of the gain divider of the op-amp  By treating the SUT as an unknown resistance in a gain loop the amount of current needed to calculate the conductivity is decreased by several factors(at least a 100x reduction)

However, I checked the chips….

Check the Chips

I am finding a big difference between hardware and software development is when attention to detail kicks in.  With hardware, I find attention to detail is extremely important early on.  For example, soldering an SMT given my skill set.  The extra time I take to clean the pads, place the chip in a way that I don’t have to handle the PCB while trying to put hot solder on a pin/pad, making sure to apply flux, cleaning off the residue after soldering is time well spent.  If I don’t do this, I end up removing and re-soldering…removing and re-soldering…With that said, even with all the prep, there are many times when my soldering needs to be redone…particular on iddy biddy sized parts.

I printed out the analog front end of v1.2 of the minieEC schematic (GitHub repository):

AnalogFrontEndMiniEC1_2

and checked the resistors with their values on the breakout board.  

 

Chips on MinieC

I saw two differences which I verified with my DMM (Extech 330):

miniEC2ndStep

  • R7 on the schematic calls for a 100KΩ resistor.  The value on the board is 47KΩ.
  • R9 is 1KΩ on the schematic but on the board it is 3KΩ.

.2 VPP 

Here I am confused.  R8 / R7 are used as a voltage divider to decrease the voltage going into the op amp.  Given the above, the VPP = .2 However, the LTSpice IV model

Wien Bridge Voltage Out and Stage 2 Voltage in after voltage divide

The green sine wave is the output of the Wien Bridge Oscillator step.  The VPP ~= .9V.  The blue sine wave is the input into the op amp used with the EC probe.  The VPP ~= .08V.  Given the resistor values this makes sense – .9*(4700/(4,700+47,000)) = .08V.  Yet the explanation Ryan gave for this stage noted the VPP into the second op amp should be .2VPP.  I am not sure if:

  • the .2VPP is the important value.  I found another EC Circuit (picture of schematic) that noted .2VPP and uses a 1KΩ R for R8 and a 100KΩ R for R7.  The comment near the non-inverting input of the Gain op amp  notes: “should have about .2Vpp input.  If much higher offset is difficult to null out change [R8] & [R7] as needed”

 When these values are plugged in,

VPP When R8 = 1K and R7 = 100K
 
the VPP into the gain op amp is too small – doing the calculation: .9*(1/101) = .008V!  I think this was a typo.  If the VPP is to be .2V, and R7 = 100K, then a value for R8 that will create a .2VPP is 30KΩ.

RightVPPForStage2

 

 The right answer will depend on the results for the E.C.  Is the value within range of those given by the EZO or TDS meter?  That’s something I need to find out.

Gain

R0 in the LTSpice simulation:

EC Probe in LTSpice

is acting as a value for an E.C. reading (see this post for an explanation). an R value of 200Ω is equal to an E.C. reading of 5mS.

When R9 is 1K, the Gain is 1+ 1000/200 = 6.  

R9 is 1K

which is “close enough” to the LTSpice IV results.

R9 is 3K

R9 = 3K

By knowing the Gain, the E.C. can be back calculated.

When R9 is 3K, the Gain is 1 + 3000/200 or 16.  So 16 = 1+3K/R0  -> R0 = 3000/15 = 200 Ω E.C. = 1/200Ω = 5mS.  Given the relationship between the resistors and the Gain, the variable resistor (R0 – representing the probe in the LTSpice model) means the Gain will vary  based on the conductivity of the bath.  The challenge then is to determine a resistor value for R9 that is within +5V and is “large enough” to get “the best” reading it can.

The question for “large enough” is answered by knowing the range of conductivity(1/R).  Given the E.C. values for vegetables and herbs located here,  The E.C. ranges between .8mS and 5mS.  Given this E.C. range, the resistance range is 1,250 to 200.  Using .step with a list command set for 200 and 1250 (see {R} at R0) and R9 at 4K:

Step with list 1250 and 200

results 4K for R9

I’m thinking a good value for R9 is around 4K.  This way, the Vpp is within 5V.

What’s Next

I need to figure out what the “best” values for the resistors are.  This is probably best done using a bread board prototype.  I’m still having trouble prototyping the Wien Bridge Oscillator.  I think my “big mistake” was using a single power supply.  There is some learning gap that I must bust through to get this going.  I should also receive the Healthy pH Shield PCBs this week.  Once I receive these I will solder on the parts and give this rev of the Shield a twirl.

 

Today as always – please find many things to smile about.

Follow

Get every new post delivered to your Inbox.