Getting to Healthy EC Dev-Rev2

Tags

,

In a previous post (link) I had quite the D’OH moment.  I had incorrectly designed the Wien Bridge filter.  That mistake must be fixed along with others.

The Goal

The goal of this post is to describe changes from the Healthy EC Dev-Rev1 PCB so that the accuracy of the EC measurements can be tested.  It is also expected the pump circuit will pass a test of turning a pump on and off.

Non Goal

The Healthy EC Shield is dependent on the Healthy pH to provide AGND power and access to a temperature reading.  While the temperature reading is extremely important to adjusting the EC measurement, I can determine the temperature of the bath through another method.  I will use my bench power supply instead of using a power source coming from the Healthy pH Shield.  By keeping the PCBs separate at this stage, the complexity of testing is decreased.  Certainly, I will need to do extensive testing with the two shields working together once they both evolve to a state where core functionality is stable.

Thanks to Those That Went Before

Thanks to Chris Gammell for his exceptional Contextual Electronics courses and his in depth sharing of his knowledge.  Thanks to Chris, I am confident I will be able to get the Shields working.  A year ago, I had no idea how to create a schematic, much less layout a PCB or solder SMTs…While each day is a new opportunity to astound me with how little I understand, unraveling the basics of electronics so that I can grasp key concepts and skills is something Chris has been instrumental in making happen.

Thanks to Ryan of Sparky’s Widgets for his open source minieC EC measurement breakout board, his documentation, and thoughtful answers/quick response to questions.  This effort stands on the shoulders of Ryan’s project.

The Design

Changes to the design for Dev-Rev2 of the Healthy EC Shield include:

  • fix the design of the Wien Bridge Oscillator.  I discussed what I need to fix in this post.
  • be able to test different resistor values for shrinking the AC Waveform generated by the Wien Bridge Oscillator.
  • be able to test different resistor values for the resistor that participates in the gain loop with the EC probe.

Shrink the AC Waveform

Shrinking an AC waveform is not the same as shrinking a family, but this image was the first thing that popped into my head. …

Honey I Shrunk The Kids

When I walked through the design of Ryan’s (Sparky’s Widgets) miniEC, one of the steps included shrinking the Vpp to ~ 200mA.  

ShrinkSignalWithPOT

 

Recall the EC probe reading contributes to a variable gain loop (discussed in this post) the Gain loop might take the Vpp beyond the limits of the power sources/rails of the op amp.  On top of that, VGND raises our relative GND to 2.5V.  This means the AC waveform exiting the op amp used to measure the EC cannot have a Vpp greater than 2.5V.  Just to be sure, the Vpp should probably be 2V or less.  If the AC waveform’s Vpp ~= 200mA, then a Gain of 10 is acceptable.  Any greater gain would cause the AC Waveform to be distorted.  This is a challenge for EC measurements that have a higher connectivity and thus lower resistance, such as a nutrient bath for tomatoes.  In plants that require a nutrient bath with a higher EC reading, the gain goes up to 15 – 20.

For Dev-Rev2, I use a scope to see how much distortion occurs given different EC values for nutrients.  If the range becomes too extreme to handle EC measurements for all varieties of vegetables, herbs, and fruits,  I will focus on growing really great lettuce.  The reasons:

  • when familiarizing myself with an experience such as getting “good enough” EC readings, minimizing variables is extremely helpful in focusing my head around the experience.  Herbs aren’t that much different than lettuce.  Tomatoes are tremendously different – in many ways – not just in EC but also lighting, size, temperature.  It is easier to grow lettuce hydroponically than tomatoes.  Although eventually I will climb that mountain.
  • Lettuce grows great hydroponically.  
  • Each kind of plant will require a different environmental setting, whether that be more light, different growth size, flowering, etc.  I want to evolve the Healthy Shields to be used within a hydroponic system that “just makes lettuce.”  This aligns with my general penchant for laziness.

For this Dev-Rev2, I will put a POT in the resistor responsible for shrinking the AC waveform.  I expect the resistance value to be somewhere less than 50K and more than 20K. Searching Digikey (link), I see this 50K POT should work  

50KPOT

 
 
This will allow me to experiment with different resistance values for the voltage divider with the goal of determining what is “the best” Vpp for the AC Waveform used as input into the non-inverting input of the op amp that measures the EC.

Adjust the Variable Gain

As noted in this post, the ideal EC range for lettuce is .8mS – 1.2mS.  Since R = 1/EC, R for the probe ranges from 1.25K to 830Ω

As shown in the image:

 

GetECMeasurementWithFixedRForVariableGain

the gain will vary based on the EC probe reading.  The gain can be adjusted by changing the resistance of the resistor inside the negative feedback loop.  I want to experiment what value for the resistance is “the best” for calculating the EC measurement by replacing the 3K resistor in the above image with a 5K POT (digikey link).

I’m off to layout the board.  I’m excited to see how much of what I learned about board layout finds its way into this iteration.  As I have said before, I find board layout to be…um..taxing…difficult…hard…

 

Thanks for reading this far.  Now – as always – please find many things to smile about.  

 

 

Healthy pH Dev-Rev3: Off to Fabrication

Tags

,

A YIPPEE! moment…the Healthy pH Dev-Rev3 Shield’s Gerber files were sent off to OshPark!  The kicad files are located in this GitHub location.

The Goal

The goal of this post is to discuss the changes to the design and layout of the Healthy pH Dev-Rev2 Shield that went into the Healthy pH Dev-Rev3 effort.

Thanks to Those That Went Before

Chris Gammell continues to be a major reason I am able to make progress.  I learned a lot taking his Contextual Electronics courses – and highly recommend them if you are breadboard prototyping circuits and want to take a twirl at building PCBs with SMTs.  This time around, Chris was instrumental in guiding me through the layout choices.

OshPark is a terrific fabrication service.  I am very impressed with their product and their support.  Highly recommended!

Design Changes

After running the test harness (code at this GitHub location) I had written and playing around with the Shield, I had a list of design changes to make: 

RGB LED
Remove TP19,TP10
Remove TP8
add Text and Logo
fix pin layout of voltage regulator (7805)
fix barrel jack drill holes
enlarge TB pins
remove TP17
remove TP2, TP3, TP4, TP5, TP6, TP7
connect 2nd Ard GND pin
remove TP14
move TP12 text
put ‘1’ close to 1st conn of 8 pos TB
remove TP14
remove TP12, TP 15, TP13, TP16
remove TP11
remove TP18
change R15 to 1K
.1 R15 1K
.1 Thermistor
add .1 uF near voltage divider (r3, r4)

I discussed these changes in earlier posts.  It was terrifically exciting to see the software interact with the hardware as well as view the analog signals on a scope!  This gave me a much better idea on what is going on within the circuit(s).  It also gave me insight into how far I am from using the shield in a hydroponic system.  I hope after the next rev I can use the shield…but typically I am overly optimistic…

Layout Changes

Changes to the layout caused many a stumble on my part.  I had a major D’OH NO-NO on my first attempt at the layout for the Healthy pH Dev-Rev3 Shield:

HealthypHDev-Rev3FirstAttemptDOH

I had the power line for the analog circuit going through the middle of the MCP3901.  

I got caught up in not crossing any tracks.  Layout is harder than it looks. For me, layout is like chewing gum, patting my stomach, and spinning a plate on my nose at the same time.  I bet a great video game could be made out of the puzzle and the resource constraints…but I diverge…

Here’s what I ended up with:

Healthy Dev-Rev3 Layout

Both the analog power source (V+_Wallwart) and the digital power source (V+ARD) are wide rivers running through the board and out of the way of the chips in the same way it seems rivers typically don’t run through the middle of a building.  I also placed the decoupling capacitors closer to the chip whose power line it is supposed to be cleaning up.  Other than that – tracks were thickened.  The pump circuit had minor touch ups and most of the test points were removed.

 

It is like anticipating a special gift to wait for the purple mailer from OshPark with the 3 PCBs in it.  I’ll keep busy…next on my list is…SHOPPING!…which I find shopping for parts on digikey.com to be much more fun than shopping for shoes.  But perhaps not as exciting as the impulse buys I can’t seem to stay away from on ebay.com and amazon.com.

 

 

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

Another Look…Wien Bridge Oscillator – Healthy EC Dev-Rev1

Tags

,

 

Simpson DOHI was not able to get Oscillation going on the Healthy EC Dev-Rev1 Shield in prior tests (link).  No wonder – since the circuit is wrong…OOPS! :-)  (I know it’s not funny, but for some reason I find my screw ups to be delightful.  I think because the only thing they “hurt” is my ego).  This is after spending several hours dedicated to understanding the electronics and circuit design of a Wien Bridge Oscillator (link).

Here’s the current design…

HealthyECDev-Rev1WienBridgeFilterParts

The Goal

The goal of this post is to get the Wien Bridge Oscillator to work on the Healthy EC Dev-Rev1 or know the specifics of why it won’t work without changes to the PCB.

Thanks to Those That Went Before

Some things should be thanked for every time.  This is the case with Chris Gammell.  If it wasn’t for his Contextual Electronics course and guidance, I would not be passionately enjoying this incredible learning experience.  I recently listened to a podcast where they noted in 1984 there was a significant drop in women who majored in computer science in the US.  One woman interviewed noted she felt exceptionally strong in math and had confidence going into her freshman year at college – a hopeful computer science major.  She remembers the day when she asked a question and the professor looked at her disdainfully and noted “you should already know this!”  Here confidence plummeted… WOW!  brings back memories…this is the EXACT experience I had with learning STEM subjects “back in the day!”  Now, there are teachers/mentors/professors (these terms merge for me) like Chris who do not make assumptions about a person’s ability.  Who brilliantly understand that most often not knowing/understanding can overwhelmingly be caused by a lack of context rather than an innate ability.  Aha – now to me it is about the mental model…not a judgement of mental incompetence.  Thanks to all those who set the passionate learner’s mental model in the direction of understanding.  Thanks to Chris for the mental model I am developing about electronics.

Ryan (Sparky’s Widgets) embraces the concept of Open Source in a way that makes it possible for me to learn more about the details of pH and EC sensors.  I would not be able to create these shields without Ryan’s Open Source minipH and miniEC projects.  Ryan also makes these available for sale.  I highly recommend buying these.  At least check out his offerings.

There has been a TON of great articles available through the “Google is Our Friend” of today’s Internet.  Thanks for all the information – particularly when stuff doesn’t work!  My biggest challenge is using the right search term.  Something I assume will always be a challenge.

101 – Characteristics of the Wien Bridge Oscillator

I understand the purpose of the Wien Bridge Oscillator – to be an AC power source for the EC probe.  I don’t understand some of the characteristics of a Wien Bridge Oscillator.  Reflecting on why, since I am self teaching, a challenge I run up against is understanding the theory behind a circuit.  Something that is covered in beginning electronics courses.  Well, this lack of knowledge of circuit theory is not the boss of me, so I’m:

  • watching videos on circuit theory.  After watching many on Youtube, I realized my skills in algebra – and sadly calculus also – were weak.  Proving once again, I am by far not smarter than a 5th grader.  OK, calculus is a stretch, after all I proudly point out our junior in high school is taking calculus – no, not 5th grade…I was hoping to find an online course on electronics theory that was as good as the iTunes course from Stanford University on iPhone programming (link).  Sadly, I did not.  Please let me know if you know of one!  I ended up getting the engineer series of downloadable DVDs – from mathtutorDVD.com.  I decided to buy and download all the DVDs in this section.  For many this must seem indulgent.  However, at my age time is more important than money.  For me, watching the DVDs – I’m still in the process… – has been a terrific way to understand fundamental/basic circuit theory – Ohm’s law, Kirchoff’s voltage and current laws, and the Thevenin equivalent circuits (wow – the Thevenin stuff is amazingly insightful.  Let’s hear it for sharp folks that figure this stuff out!).
  • reading as much as I can swallow and understanding a little of what is being written in the art of electronics and Practical Electronics for Inventors.
Based on my random google readings on the Wien Bridge Oscillator (such as this link):
  • The frequency of oscillation is determined by a bandpass filter.  The bandpass filter’s circuit goes between the non-inverting input of the op amp and the output of the op amp.  THIS is where I screwed up with Healthy EC Dev-Rev1.  I split the band pass filter between the inverting and non-inverting ends of the op amp.  As I’ve noted before- for EC measurements, the desired frequency is 1.6KHz. The equation for determining the frequency based on the resistor/capacitor choice (see the kicad EC.sch schematic found at this GitHub location) R14 = R19 = R= 1K and C9 = C11= C=100n…. f = 1/(2∏RC) = 1/(2*3.14*1000*.0000001) ~= 1.6KHz.  If the circuit was set up right, the output frequency should be very close to 1.6KHz.
  • The gain loop circuit goes between the inverting input of the op amp and the output of the op amp.  The “twist” in this gain loop is a way to adjust the gain once the oscillation (AC Waveform) has started in order to keep the oscillation going.

The Wien Bridge Oscillator Circuit without VGND

Here is the schematic of the Wien Bridge Oscillator without introducing VGND.  This means the op amp requires a + and – voltage source.  In the schematic, a +5V and -5V power source is used:

 

WienBridgeWithoutVGND

As I said earlier in this post, the frequency of the AC Waveform is 1.6KHz. 

The Gain Loop

What about the Gain Loop. This is what I *think* is going on based on what I understand.  Please let me know if I need to correct my understanding.

The VROOM-VROOM Stage

I like to get a picture in my mind (hopefully a cartoon that makes me smile) of what is going on.  Thus, I call starting the oscillation the VROOM-VROOM stage because it reminds me of applying gas when getting a car going from steady state to moving.  

VROOM-VROOM-Stage

VROOM – VROOM: Start Your Oscillator: Gain Slightly Greater than 3

When the current initially starts up, it can’t go through the diodes.  I use SparkysWidgets 10K (R6 – above diagram) and 22K (5) design in the minieC  to set the initial gain at 3.2 (Gain = 22K/10K + 1 – 3.2).  3.2 satisfies “some math” – which I take for granted is right because it will take me many (many) hours to understand – which says a gain of slightly greater than 3 is needed to get to VROOM-VROOM oscillation.

The PUTT-PUTT Stage

Once the oscillation has started, I picture it as puttering along (maintaining).  I like to picture this as the PUTT-PUTT stage…like a car moving at a constant speed down the road…in fact, the car I visualize is the one from “Who Framed Roger Rabbit?”

Who Framed Roger Rabbit

PUTT-PUTT Keep Your Oscillator Going

I have been befuddled by my lack of knowledge in circuit theory to figure out how the Gain Loop did this.  After searching through the books and googling, I’ve come to the following conclusion:

  • The parallel circuit in the Gain loop includes the diodes.  This circuit won’t contribute to the Gain Loop until the Vpp is around .7V (this is a silicon diode) – the forward Voltage.  So until then, the Gain is 3.2.
  • Once the Vpp of the AC Waveform is around .7V, the diodes + capacitor part of the circuit adds a parallel resistor to the 22K R5.  OK, so what is the resistance contribution of the capacitor?  Bumbling on this gem in section 3.6.5 in Practical Electronics for Inventors - the capacitive resistance = 1/2πfC = 1/(2*π*1600*.0000001) ~= 995ohms.  So now the Gain Loop Circuit looks like this:
GainLoopWithParrallelcircuit
Simplifying the resistors in parallel = (product of resistors)/(sum of the resistors) = (22000*995)/(22000+995) = 952Ω.  
 
So once the diodes kick in, the capacitor’s capacitive resistance is 952Ω, settling the gain loop to 952Ω/10K + 1 = 1.095.  A gain of 1 on an op amp feedback loop builds a buffered copy of the input voltage.  Given the gain is very close to 1, the diodes + capacitor contribute to the gain by backing it off to a gain close to 1 once the Vpp crosses the forward voltage of the diodes (at around .7Vpp).
 
OK – that’s my mental model.  On to the breadboard (once again).  
 

 Back to the Breadboard

Perhaps the equivalent of writing “I will not split the band pass filter between the non-inverting and inverting input” 100 times on a blackboard, I set about below to create the circuit on a breadboard, similar to what I did in this post.

I’ll build up the breadboard in these steps:

  • Implement VGND.  I’m using a VGND in the design of the Healthy EC Shield so that only one power source (+5V) is needed.  VGND is set to ~2.5V
  • Implement bandpass filter so the frequency of the waveform is 1.6KHz.
  • Implement feedback loop so that the AC Waveform putt-putts along.
I use the MCP6244 (data sheet) in the schematic.  The chip I use has a 14-SOIC footprint (digikey link has picture).  Ideally, this would be the op amp I would use on a breadboard.  According to digikey (link), the component does come in a DIP footprint.  Unfortunately, digikey does not have any in stock.  My soldering skills aren’t good enough to dead bug a 14-SOIC, so I turn to Sparkfun’s SOIC to DIP.  Alas – silly me – the width of the MCP6244 is much smaller than that on Sparkfun’s SOIC to DIP:
Sparkfun SOIC to DIP

So I’ll be using the TL072 op amps that I have favored in previous bread boards.  Since I forget the TL072’s pin layout, I’ll post a picture of it here:

TL072 pins

Implement VGND

From the Healthy EC Dev-Rev1 schematic (kicad files available at this GitHub location):

 

VGNDFromHealthyECSchematic

the first op amp is used to implement VGND.
 
 

1st Op Amp is VGND

The bench power source reads 5.1V.  The DMM reads 2.45V at pin 1 – the output pin of the first op amp.  In the “ideal”, the VGND would be 1/2 5.1V, or 2.55V.  Breadboard copper, extremely inexpensive (in this case 1K) resistors make me believe 2.45V is within an expected value for VGND given R17 = R18 = 1K.

Implement Bandpass Filter

The bandpass filter goes from the non-inverting input pin of the 2nd op amp – pin 5 – to the output pin of the 2nd op amp – pin 7.  One 1K R and 100nC are n parallel, and one 1KR and 100nC are in series.  The circuit is tethered to VGND.  I’m finding drawing colored lines showing which components share a wire is useful when implementing on a breadboard:

bandpassFilterWithWireColors

 

Adding the bandpass filter to the breadboard:

bandpassfilteraddedtobreadboard

 

Implement The Gain Loop

The Gain loop goes from pin 6 of the TL072 – the inverting input – to pin 7 – output of the second op amp.

 

SkitchOfWienBridgeGainLoop

 

 

breadboard with Wien Bridge

 

Hooking up my scope, the waveform I see:

ScopeOfWienBridgeWithDC

 

I count 550µS between positive peaks -> frequency = 1/.000550S = 1.8KHz, slightly higher than the expected 1.6KHz, but close enough given the quality of parts used in the prototype.  Here is the results from running the LTSpice simulation:

LTSpiceSimulationWienBridge

in the simulation, Vmax is ~= 2.92V, vMin ~= 2.05V making the Vpp ~= .87V. 

At the VROOM-VROOM stage, the simulation showed this waveform:

WaveForm at VROOM VROOM Stage

the Vpp on the second to last peak/valley ~ = .66V -> when the diodes start letting current through.  It is at this point the waveform gets to a consistent VPP ~= .87V.

 

I *think* hope? I am understanding this correctly!  If not, I anticipate the next rev of the Healthy EC Shield will show this.

 

 

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

 

 

 

 

 

 

 

Weird AC Waveform on VGND? – Healthy pH Dev-Rev2

Tags

,

Well that was (NOT :-) ) exciting.  Why was I seeing this:

ACWaveForm on VGND NO probe attached

when the scope probe was in TP 18 relative to AGND?  Yuk…..

The Goal

The goal of this post is to become familiar with the characteristics of the all important VGND – used as the GND for the pH probe readings.  With a VGND, the op amp can use a single power source since all voltage readings will be positive.

Thanks to Those That Went Before

I just can’t thank Chris Gammell enough.  His Contextual Electronics courses and mentorship have given me the ability to rapidly grow my abilities in designing and building PCBs.  Something I find I have quite a passion for when applied to growing healthy food (through hydroponics).  I look back to last year…I am amazed and exceptionally grateful for all I have learned.  This would not have been possible without Chris.

Given my thirst for learning from those that went before, Ryan – of Sparky’s Widgets – is another whom I am hugely thankful for.  Ryan has made some wonderful breakout boards, like the minipH and minieC that I highly recommend.  The circuit design of the Healthy Shields are an evolution of the open source schematics and advice from Ryan.  He truly knows his stuff.  I am very grateful that Ryan open sourced the minipH and minieC hardware.  In addition, Ryan has been extremely thoughtful in response to what must be naive questions from me given his level of expertise!

Observations of VGND

As I noted earlier, I was seeing a strange sine-like waveform when the scope probe was in TP 18 relative to VGND.  Not good…

What was happening – and this took me awhile to figure out and get right (although I am not sure why!) – the probe’s GND was loosely connected AND I had too many external electrical doo-dads and wires running around, under, and above my Healthy pH Shield Dev-Rev2 I was testing.  I let out a sigh of relief after removing the excess electronics and wires, revisiting how the probe’s GND was connected to AGND and saw:

ACWaveForm on VGND  probe attached better

in this case, the Healthy pH Shield is inserted into the Arduino.

Healthy pH Shield With Probes

When the Healthy pH Shield is not plugged into the Arduino, there is (relatively much) less noise:

ACWaveForm on VGND  detached from Arduino

 

More noise occurs when the pH probe is connected through the BNC:

ACWaveFormAnotherWithArduinoAttached

 

Lessons Learned

  • Observations are important but are only as good as the method used to measure.  In this case, I was not seating the scope probe correctly.  AND…I repeatedly was not doing this.  Certainly, slowing down, triple checking is very important when using tools and observing.  Sounds obvious, but something I need to constantly remind myself to do.
  • How well the BNC/probe is attached to the Healthy pH Shield will make a significant difference in the noise picked up on VGND.
  • A capacitor should be added close to the voltage dividers (R3 and R4) to smooth out the noise – especially since the Arduino adds additional noise – even when not plugged in.

 

Well – that’s that!

 

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

Testing the Temperature Reading Using Voltage Values – Healthy pH Dev-Rev2

Tags

, ,

I use a thermistor to calculate the temperature of a bath.  I started testing in a prior post, but ran into an issue because I was using a 10K resistor for R15.  See this link for more details.

The Goal

The goal of this post is to do a litmus test on the temperature that would be calculated prior to conversion of the voltage to digital through the ADC.  While I don’t expect the temperature to be spot on, I do expect the reading to be within the ballpark.  If needed, further improvements will be done to improve readings.

Thanks to Those That Went Before

Thanks to Gerald Rectenwald for his excellent class notes on thermistors.  They were easy to read and useful.

As always – a huge thank you to Chris Gammell.  His Contextual Electronics and additional guidance has made it possible for me to even attempt this effort.

Thanks to the people behind the Wikipedia entry on Thermistors.  The article was very helpful.

The Test

Due to lack of soldering skill on my part, I managed to tear off the pads from R15 – the resistor that acts with the thermistor to divide the voltage.  The kicad files are located at this GitHub location.  OshPark provides 3 boards so I was able to only solder what was needed.  This time, I used a 1K resistor for R15.  Using 1K instead of 10K should read voltage values that can be digitized by the MCP3901 – which can handle voltage values between +/-.79V.

YIPPEE! Simple:

PCBThermistorTest

Measuring Temperature

I noted in the previous post (link), going from a voltage reading to a temperature reading (either in C or F) is a three step process:

1. The thermistor (Rtherm) is a variable resistor.  What is it’s current value?

2. The temperature has a linear relationship with Rtherm.  Use the B parameter method to solve for the temperature in Kelvins.

3. Convert from Kelvins to either C and/or F.

Solving for Rtherm

From the previous post, I first solve for the value of Rtherm (plugged into holes 3 and 4 of the holes for the 8 position terminal block).  In order to do this, I need to measure Vo then use the formula:

Rtherm = R15/(Vs/Vo – 1)

I measured Vs = 5.18V and Vo = .42V relative to AGND.  Plugging into the above equation, Rtherm = 1000/(5.18/.42 – 1) = 11,333.  At least the calculated value was not completely out of range – say if it had been 113,330…

Solving for Temperature in Kelvins

Perhaps you have become friendly with formulas.  Frankly, formulas intimidate me.  But if I take it r-e-a-l SSSSSLLLLLLLOOOOWWWW …..

As noted in the Wikipedia article on thermistors:

T = B/ln(Rtherm/r∞)

It also notes r∞ to be:

r∞ = Roe^(-B/To)

Where Ro = the thermistor value that the thermistor is spec’d at.  Mine is a 10K thermistor.

To = 298.15K (25˚C in Kelvin)

B comes from the data sheet.  For the thermistor I am using (link), B  = 3977.

Plugging in, I get:

r∞ = 10000*e^(-3977/298.15) = 0.029259

T (Kelvins) = 3977/ln(11333/298.15) = 295.25

Solving for Temperature in ˚C or ˚F

To go from Kelvins to C, just subtract 273.15.  This gets to: 295.25 – 273.15 = 22.1˚C.

The formula to go from C to F is ˚C*2 – 30, 74.2˚F

While this is not extremely accurate, the temperature where I am at is about 70˚F.  This makes the reading I got with the thermistor about 4˚F higher.  I feel this is good enough to pass my litmus test.  Now I need to better understand:

  • resistor values vary.  How important is precision of R15 or the thermistor?  It seems that thermistor tutorials suggest 5% – which is what I am using.  Should I pay more for 1% precision?  How much do small changes in temperature affect the pH value measurement?
  • How accurate are the voltage measurements for Vs and Vo?  Is there enough noise to cause inaccurate results?  I need to get a better feel for the noise on the voltage line.

Next Time

For this pass, I am focusing on knowing if the results I measure are within a litmus test of expected results.  I am not as concerned with accuracy.  And in this case, I am not sure how accurate I want to be.  Because of the relationship between the pH value and temperature, accuracy will depend on the affect of a small (say 1˚F) change of temperature on the pH value.

 

 

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

Testing Reading the pH – Healthy pH Dev-Rev2

Tags

, ,

 

In a previous post (link), I was happy with the voltage reading results I was able to get from a test environment in which the value being measured – a DC voltage from a voltage divider – had a very low impedance.  As discussed earlier (link), pH probes have a very high impedance.  Too high to be measured with a DMM.  So one handy debugging tool is no longer available…..in this post I will test hooking up a pH probe submersed in 3 pH calibration solutions for pH levels 4, 7, and 10.

HealthypHDev-Rev2pHProbeTest

The Goal

The goal of this post is to determine how close voltage measurements recorded from a pH probe submersed in a pH calibration solution to expected values.  I look at it as a litmus test for whether I should go to more specific pH testing including probe calibration and pH measurement of a bath relative to the minipH and Atlas-Scientific pH stake.

Thanks to Those That Went Before

  • I constantly – and rightly – thank Chris Gammell.  Chris has been an exceptional mentor/guide as well as provides the Contextual Electronics courses that I took.  I have learned more from Chris’s courses, the other students, and Chris than I have through any other learning process.  For a person that loves to learn new things – that says A LOT!
  • Ryan (Sparky’s Widgets) open sourced and provided background on his minipH breakout board.  The Healthy pH Shield is based on Ryan’s work.  In addition, Ryan has kindly answered my questions.  Answering questions from a n00b like me is very time consuming.  It shows the openness and dedication to learning/community.  I highly recommend Sparky’s Widgets.
  • We’ve all benefit from the tremendous amount of shared knowledge folks have posted on the web. This post is no exception.  Google is my friend.  

The Test

I do not expect to get accurate pH readings.  This requires calibration of the pH probe (discussed here) and adjustment for the bath’s temperature.

I do expect to get voltage readings that are within the values I expect for pH 4, pH 7, pH 10.  I need more testing to know if a repeatable reading is “good enough” to determine the pH reading or precise readings are important.  My current knowledge makes me think that given the high impedance of the pH probe and the noise in the circuit, there will be a higher STDEV in results than I would like.  This then goes to the smoothing technique.  My current technique is to take multiple readings multiple times and then average the averages.

In this post (link) I had a table that listed the voltage reading for each pH level.

pH Signal(s)
0 0.414
1 0.359
2 0.309
3 0.249
4 0.189
5 0.129
6 0.069
7 0.009
8 -0.069
9 -0.129
10 -0.189
11 -0.249
12 -0.309
13 -0.369
14 -0.419

I am interested in pH 4, 7, and 10.  Here is a table of results:

pH Expected Volts Measured Volts, n=25 STDEV Measured Volts, n=50 STDEV Measured Volts, n=100 STDEV
4 0.189 0.16 0.1 0.17 0.1 0.17 0.1
7 0 0.03 0.08 0.01 0.09 0.02 0.08
10 -0.189 -0.14 0.09 -0.14 0.09 -0.14 0.09

Plotting the ideal line and drawing a line between the points that were measured:

plot_ideal_phVolts_initial_measured

the measurements appear close!  This is without adjusting for temperature or taking into account the current quality of the probe.  A very very excited YIPPEE! But of course – it is the last 20% of a project that takes 80% of the time and work.  Still, I have a big smile on my face (for at least one minute :-) ).

 Reading just one value would be too noisy so I took a variety of readings.  The first time, I averaged 25, then 50, then 100.

Negative Numbers and 24 Bits

Previous tests assumed adc values would be positive.  pH voltage values range from +/- .414V.  I changed the test code to handle negative values.

A challenge I had due to my lack of background in computer science, was reading negative numbers.  As pointed out in the MCP3901 data sheet – Section 5.6 – negative numbers are stored in two’s complement.  This would be easy-peasy if I was dealing with a 32 or 16 bit value.  But the adc value is 24 bits.  Perhaps there is an easier way, but I translate a 24 bit negative adc value into a 32 bit value doing the following:

    //start with the 2nd byte since this is a 24 bit number and bit twiddling is needed if the number is negative.

    for (byte i=1;i<4;i++){

        adc_value_bytes[i] = SPI.transfer(0xFF);

    }

#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))

    if (CHECK_BIT(adc_value_bytes[1],7)) {

        adc_value_bytes[0]  = 0xFFFF;

        adc_value_bytes[1] &= ~0x8000;

    }

    adc_value =   (long)adc_value_bytes[0] << 24 | (long)adc_value_bytes[1]<<16 | (long)adc_value_bytes[2] << 8  | (long)adc_value_bytes[3];

See the code at this GitHub location – it includes all of the above in the MCP3901 library.

Reflection

As a litmus test, I am happy with these readings.  While they are not accurate enough to determine the pH level with .1 accuracy, the voltage readings are “close enough” to tell me the voltages are being recorded.  What I do not know is what is causing the voltage readings to be the STDEV they are.  And why the values aren’t equivalent to the expected values.  I am ok with the results for the rev of the Healthy pH Shield.  I will do further testing and refinement in future revs.  I have enough to change in this rev to move incrementally to better results.  This will give me spacing in the testing process to figure out how to improve results

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

Soldering with a Toaster Oven – Healthy EC Dev-Rev1

Tags

, ,

The Healthy EC Dev-Rev1 PCBs came in the other day.  I wanted to know how our old toaster oven would work as a reflow oven without any modifications.  Using an old toaster works well enough that I’ll use this technique again!  The tedious part continues to be -and will always be without a pick and place machine – is the placement of solder and placing of chips.  Although it is a great time to relax and listen to music.

I set the toaster to 475˚F and warmed it up for 10 minutes.  After putting the solder mask and placing the chips, I popped it in the toaster for ~ 90 seconds….and out comes….

Healthy EC Oven Reflow

not bad.  There were two 0805’s that needed to be re-soldered, like the tombstone job on R18:

tombstone Chip

and my old friend the MCP3901 needed cleanup:

 

MCP3901 cleanup

but these were minor – and easy – to clean up.

To evolve my soldering technique, I note:

  • I used too much solder.  I tend to place a glop that covers a pad.  After playing with a stencil, I believe a better method would be a light covering – more like a smear – than a glop.  
  • The paste I am using – as Brent from Osh Stencils noted based on an earlier post on using stencils is very (very) liquid.  I was hoping it was because I had removed the solder paste from the refrigerator an hour before so that it would be at room temperature as Dave (EEVBlog) advised in this video.  No, the paste I am using – Chip Quik Low Melting Lead Free Solder Paste – is liquid.  
Brent suggested Kester EP256 solder paste.  I plan to try this solder paste.
 
After I ran this experiment, I asked the question on the /Ask/Electronics subreddit:
Yesterday I placed chips (on top of solder paste) on a pcb and stuck it in my toaster oven for 90 seconds. Everything seemed to work great. I just turned the toaster to 475F. There was no profile.What are the problems I will run up against with a PCB who has had its chips attached in such a “pop tart” like way?
I got some great advice (link) that I will apply moving forward.  I also ordered a new toaster oven for my family :-).
 
 

 

Noise on VGND – Healthy pH Dev-Rev2 testing

Tags

,

 Chris pointed out to me that the VGND buffer (op amp) – takes every incoming change – including noise – drive low impedance as hard as it can.  Any noise will affect that.  Will this be a problem in the measurement of pH?  Given the below – I don’t think so.  However I do not have the context to know if I am correct.  So I leave this post as something to be evolved as I learn more about noise on the power wires.

 I wanted to quantify  how much noise on the power wires affects the pH measurements.  Here are measurements for the power coming from my test regulated power source.  The first one is run without the Arduino also plugged in.  The second image was taken with the Arduino plugged in.


V+ WallWart

V+ WallWart + Arduino plugged in

 Both Vpp are the same = 160mV.  I was expecting a higher Vpp when the Arduino was plugged in because the power source is coming over USB from my computer.  I would think a measurable amount of noise would be introduced.

I made similar readings on VGND relative to AGND.

VGND

VGND + Arduino plugged in

“zoomed in” a bit
 
 
In this case, the Vpp were pretty much the same at 24mV.  I then ran the test code that turned one of the pumps on and off.  The Vpp only changed when the pump was turned on or off, going to 36mV when switching to on or switching to off.

 

Testing the Pumps on Healthy pH Dev-Rev2

Tags

,

Besides the pH and temperature, the Healthy pH Shield turns two pumps on and off. The purpose of these pumps is to allow the person writing the software the ability to adjust the amount of pH UP or DOWN depending on the pH measurement (adjusted for temperature) and the type of plant being grown.  Different plants are healthiest at different pH values.

Well guess what?  IT JUST WORKS! YIPPEE!!!

The Goal

The goal of this post is to determine if two peristaltic pumps connected to the Healthy pH Shield can be turned off or on.

Thanks to Those that Go Before

It is important to remember who has enabled me to do this stuff.  Thanks to Chris Gammell for his training and mentoring.  I highly recommend his Contextual Electronics course if you want to build PCBs.

The author of this post on a solenoid circuit.  It was clearly written.  This is the circuit I used for the pumps.

The Pump Circuit

The pump circuit can be found in the Pumps.sch kicad schematic at this GitHub location.

Pumps Schematic

The circuit design is basically the one in the image below.  There are two, one for pH UP and one for pH DOWN.  

Solenoid Circuit

I found this article covering the circuit to be extremely useful.  Refer to the article for a walk through of the circuit.

The pumps use connectors 5 through 8 of the 8 connector terminal block.

Pumps Relative To TB

While pins 5 and 6 reference the DownPump and pins 7 and 8 reference the UpPump in the schematic, it doesn’t matter if the DownPump is really hooked up the pH UP solution. I just use the naming convention to keep track of the wires and nodes in the circuit.  

The Tests

  • TP14 – Arduino’s 5V power source relative to Arduino GND.  Measuring this test point = 4.99 – 5V.  The readings would go between these two values.
  • Test the down and up pump circuits.  I attached a peristaltic pump to each and ran a simple sketch.  Here is the sketch for the down pump. The test code is located at this GitHub location.

Down Pump Circuit

  • The voltage across TP12 and TP15 will show that Q1 is drawing power.  Measuring this, on the DMM measurements jump around .4V.  Because of all the noise, I also measured on the scope:

   while (Serial.available () == 0) {

        analogWrite(pump_down,255);

        Serial.println(“Down pump is ON”);

        delay(2000);

        analogWrite(pump_down,0);

        Serial.println(“Down pump is OFF”);

        delay(2000);

    }

Additional Cleanup

  • The Arduino has two GND pins next to each other.  Connect the GND pin that is not connected to the GND net (GND_ARD).
  • The Arduino 5V power source can be checked through the shield’s pins for GND and 5V.  TP14 duplicates this, but is further down the wire.  I don’t think being further down gives additional information, since the schematic/layout will show whether there is copper between the two points.  Given that, TP14 can be removed.
  • TP12 text is underneath D5.
  • I am not sure any of the test points are “interesting.” 
  • Put “1” close to the 1st connector of the 8 terminal block.
  • Along the way…tested the RGB LED.  255,255,255 turns off. 0,0,0 turns on.  This means blue = 255,255,0 but 0,0,255 goes blue as does 0,255,255.  Green does not seem to be working.  I could not determine the pin/wire placement.  This is most likely off.

What’s Next

Just a little more to do – test the RGB LED.  I also need to revisit the thermistor.  Then on to soldering the Healthy EC Dev-Rev1 Shield that arrived today.

Time/Cost for Prototype PCBs

Tags

 

This post is here to record the turn around time and prices I paid for PCB prototypes from OshPark.

Healthy pH Shield Dev-Rev1

Gerbers sent out on Thursday PM.  I received them 15 days later at a cost of $28.50.

3 boards at $28.50 per batch of three. $28.50
Sub total $28.50

United States: Free Shipping $0.00
TOTAL (paid) $28.50

 

Healthy pH Shield Dev-Rev2

I sent the Gerbers in on a Monday in the afternoon.  I wanted to try out the Super Swift Service as well as some for shipping to see what the time difference is.

3 boards at $28.50 per batch of three. $28.50
Super Swift Service $89.00
Sub total $117.50

USPS – Priority Mail $5.00
TOTAL (paid) $122.50

It took 2 days for shipping. I received the boards 9 days later on Wednesday.

According to the great folks at OshPark, panels go out each day at 11AM. If I had been able to submit the Gerbers prior to 11AM Monday, there is a good chance I would have received the boards two days earlier. Perhaps if I paid for overnight shipping I would receive the PCBs on Saturday – a total of 6 day turnaround.

Healthy EC Shield Dev-Rev1

I sent gerbers out on a Tuesday AM.  

3 boards at $28.50 per batch of three. $28.50
Sub total $28.50

USPS – Free Shipping $0.00
TOTAL (paid) $28.50

I got a notice from OshPark of shipment 8 days later.  The boards arrived 10 days after I sent the gerbers.

Healthy pH Shield Dev-Rev3

Gerbers were sent in on a Thursday afternoon.

3 boards at $28.50 per batch of three. $28.50
Sub total $28.50

USPS – Free Shipping $0.00
TOTAL (paid) $28.50

Healthy EC Shield Dev-Rev2

Gerbers were sent in on a Wednesday at 10AM.

Description   Price  
 
 
  1 batch (3 boards)   $28.50  
 
 
  Total   $28.50  
 
 
Follow

Get every new post delivered to your Inbox.