0

Inductive charging set as inductive conductivity sensor?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Inductive charging set as inductive conductivity sensor?

by Camilo on Sat May 17, 2014 2:18 pm

Hi all,

I was looking around the way how to build a inductive conductivity sensor. They are useful to measure the conductivity of a liquid with no direct contact (as direct contact need expensive probes that don't rust, like platinum or gold, and produce errors as proves gets dirtier).
And I wonder if this Inductive charging set can be adapted to that.
What would happen if after protected the coils are submerged in a low conductivity medium like water with a bit of salt?
Will it burn the circuit? Change the output voltage? Or just change the output current?

An inductive water conductivity probe looks like this:
Image

And typical conductivity values are as follow:
Image

I'm interested in the range 1 micro S/cm to 1 milli S/cm

Thanks!!

Camilo
 
Posts: 11
Joined: Sat May 17, 2014 2:01 pm

Re: Inductive charging set as inductive conductivity sensor?

by adafruit_support_bill on Sat May 17, 2014 3:39 pm

The coils themselves are insulated. Though I don't know how well the insulation wold hold up to some of the liquids toward the bottom of your chart. the rest of the circuitry is exposed however, so you would need to protect it from any contact with the liquid.

The output circuit is voltage regulated, so it will attempt to keep a constant voltage. But if you bypass the regulation part of the circuit, I would expect that your output would vary.

adafruit_support_bill
 
Posts: 73584
Joined: Sat Feb 07, 2009 10:11 am

Re: Inductive charging set as inductive conductivity sensor?

by Camilo on Sat May 17, 2014 4:08 pm

That sounds encouraging enough, I order a pair and I hope to do some tests next week. Hope to be able to figure out myself where to hook up to bypass the voltage regulation.

If any one else have more thoughts about this little project I'll appreciate any ideas!!

Camilo
 
Posts: 11
Joined: Sat May 17, 2014 2:01 pm

Re: Inductive charging set as inductive conductivity sensor?

by Camilo on Wed May 21, 2014 5:47 pm

I received the set and did some preliminary tests that turned out pretty encouraging.
I just placed the two coils 2 cm apart in a big container with water together with a professional conductivity meter. And manually register conductivity and voltage on the receiver coil (measured just after what I think is a rectifying diode), as I was adding salt, and afterwards as I was adding fresh water to reduce conductivity.

Voltage and conductivity seem to have a logarithmic relationship (see figure) I will do a new test using an Arduino as power source and data logger to have more points and to better asses relationship, errors and repeateability.

I'm wondering if I can replace the transmitter by the Arduino itself, to be able to control input voltage and frequency. But I would need a bipolar signal output (positive and negative) so the PWM by itself is not enough. I've read that this can be accomplished with a H-bridge (I thought about using a stepper motor controller) or using an Op Amp. What would be the pros and cons of both methods.

Also the whole conductivity range I'm interested in produces just 0.5 volts difference, so I'm trying to find the best way to amplify that signal.

Thanks!!
Attachments
test1.jpg
test1.jpg (18.08 KiB) Viewed 1629 times

Camilo
 
Posts: 11
Joined: Sat May 17, 2014 2:01 pm

Re: Inductive charging set as inductive conductivity sensor?

by adafruit_support_mike on Thu May 22, 2014 6:36 pm

WRT the comparison between an H-bridge and an op amp, how much current are you sending through the coils, and how much control do you need over the voltage?

WRT reading a signal whose range of variation is 0.5v, that isn't too much of a challenge. An Arduino's built-in ADC has a resolution of about 5mV per bit, so half a volt would give you a 0-100 range of digital values.

It would probably be easier to use an ADS1015 12-bit ADC though.. those can do differential readings and have a built-in amplifier that can take the input range down to +/-256mV: http://www.adafruit.com/products/1083

adafruit_support_mike
 
Posts: 57861
Joined: Thu Feb 11, 2010 2:51 pm

Re: Inductive charging set as inductive conductivity sensor?

by Hydra on Sun Oct 18, 2015 4:12 pm

@Camilo stumbled across your post. Just wondered how your experimenting went and whether you came up with any workable solution.

Thanks.

Hydra
 
Posts: 6
Joined: Thu Jul 09, 2015 12:00 pm

Re: Inductive charging set as inductive conductivity sensor?

by Camilo on Sun Oct 18, 2015 4:27 pm

Hi Hydra,

I never finished pursuing that line. In further experiments I found some inconsistent measurement, but probably a better controlled experiment was needed, but I think it is feasible. The other reason I didn't put that much effort on it, was that I found a very easy and reliable way to measure conductivity using electrodes. Generating a square AC signal directly from one of the Arduino's PWM pins using a "false ground", in such way that the liquid media sees a current between -2.5 and +2.5, leading to zero neat current. Otherwise the conductivity would change due to the measurement.
In what kind of application are you thinking?

Camilo
 
Posts: 11
Joined: Sat May 17, 2014 2:01 pm

Re: Inductive charging set as inductive conductivity sensor?

by Hydra on Mon Oct 19, 2015 3:07 pm

Hi Camilo

Appreciate the feedback. I'm wanting to develop a DIY water conductivity test. I'm learning as I'm doing. So far I have learnt that certain PWM frequencies are better than others, lower is better (although not sure whether this implies Hz, kHz or MHz ranges) to determine water salinity and that maybe a low pass filter may help too. Ideally I would like to be able to determine a reliable result without high current draw to allow conductivity sampling to be done periodically using a battery operated microcontroller. So any insights / tips will be greatly appreciated.

Hydra
 
Posts: 6
Joined: Thu Jul 09, 2015 12:00 pm

Re: Inductive charging set as inductive conductivity sensor?

by Camilo on Mon Oct 19, 2015 5:21 pm

Hi Hydra,
I built a sensor that does pritty much that.
The basic principle is to use the PWM pin as a square signal generator, as when you ask it to produce 2.5 v, it in fact produce a square signal from 0 to 5v with a duty cycle of 50%
In the other hand I use a voltage divider to get a virtual ground reference of 2.5v, in that way the 0-5v square signal will be perceived by the conductive liquid as a -2.5 to 2.5 v square signal.
Then to get a conductivity value, you have to measure the whole signal (not just a single value), and get the amplitude of it, some times I got outliers so I implemented something like a median function to get the most typical high and low values and from them get the amplitude. This amplitude is related to the conductivity of the liquid, but it also depends on the probe, so you need to calibrate the probe against a known reference to get the actual conductivity.
It is easy to compute the optimal value of the resistors in the voltage divider depending on the range of conductivity (in fact resistances) you want to measure.

The sketches I have explain it fairly well, but there is a lot more stuff as the unit I made have many other sensors, but I'll copy here the important bits:

In the definitions block I have
Code: Select all | TOGGLE FULL SIZE
/* Conductivity (using a voltage divider):
   ======================================
  pin 6 => Probe central electrode
  pin 7 => 100 KOhm resistor
           connected to node with:
                      =>  Probe perimeter electrode
                      =>  Analog pin 0 (A0)
                      =>  100 KOhm resitor connected to Arduino GND

   DEFINITIONS
   ------------*/
   
  //Pinout
  #define CONDUCTIVITY_WAVE_OUT    6
  #define CONDUCTIVITY_POWER_OUT   7
  #define CONDUCTIVITY_READ        A0

The in the set-up I call the function

void conductivitySetup(){
  pinMode(CONDUCTIVITY_POWER_OUT, OUTPUT);
  pinMode(CONDUCTIVITY_WAVE_OUT, OUTPUT);
  pinMode(CONDUCTIVITY_READ, INPUT);
}

And to get raw readings I use:

int getRawConductivity(){
  int n=sampleNumber(COND);// This justget the number of samples to get
  int stackC[n];
 
  getConductivitySignal(stackC,n);
 
  // The amplitude of the signal is
  int amp=stackC[3*n/4]-stackC[n/4];
  // Now is important to define some concepts
  // resistivity = especific resistivity of the material, an intrinsic material property
  // resistance = the resistance to current flow of a given piece of material in a given geometry, it depend on the geometry and the resistivity of the material
  // conductivity = 1/resistivity
  // conductance = 1/resistance
  // The amplitude amp is related to resistance of the water by
  // Rw = R * (V-amp)/(2*amp)
  // Where R is the value of the resistor in the conductivity voltage divider
  // and V is the max voltage in the same units than amp, so in this case V=1023
 
  // Now the conductance of the water will be
  // cw= 2*amp/(R*(V.amp))
  // Assuming there is a linear relationship between conductance and conductivity (which should be the case and with a zero linear constant)
  // we can say that the conductivity of the water is given by
  // Cw = cw * F + K = (2*amp/(R*(V.amp))) * F + K
  // Where F (and K) are constants dependent of the probe
  // Given this is not a linear relationship, in order to get more accurate results using linear interpolation we can define the relative amplitude A:
  // A = amp/(V-amp);
  // therefore:
  // Cw = (2/R) * A * F + K;
  // In fact we can take any arbitrary value for R (in 2015 design R=100 kOhm), as any difference with the real value will be absorbed by F on the calibration. Wirg R=2 we get
  // Cw = A * F + K;
  // Which is a linear relation, and should lead to more accurate interpolation/extrapolation results using linear interpolation/extrapolation
 
  // In the range 0-120 uS amp will be WELL below amp=993, that correspond to A=32.767 therefore we can store A in the int range multiplying it by 1000
  // We return then A*1000 limiting it to a max value of 32767, which is the maximum value of a 2 bites integer
  // This 1000 factor would lead to a change in A*1000 of one or more for a any change of one in amplitudes of 13 or more, which is well below the range of expected amp
  // therefore there is no loss of accuracy
 
  return int(min(1000.0*amp/(1023.0-amp),32767.0));
}

Which make use of

void getConductivitySignal(int *stackC,int n){
  int sdelay=samplingDelay(COND);
  analogWrite(CONDUCTIVITY_POWER_OUT, 255);
  analogWrite(CONDUCTIVITY_WAVE_OUT, 128);

  delay(sdelay);
  readAnalogPin(CONDUCTIVITY_READ, n, 0, stackC);
 
  analogWrite(CONDUCTIVITY_POWER_OUT, 0);
  analogWrite(CONDUCTIVITY_WAVE_OUT, 0);
}

That also uses

void readAnalogPin(int pin, int n, int sdelay, int *stack){
  for(int i=0; i<n;i++){
    stack[i]=analogRead(pin);
    delay(sdelay);
  }
  sort(stack, n, 0);
}

And you will need a sort function, here is the one I'm using

void sort(int *ar, int n, int *idx){
  // Sort function using the quicksort arlorithm
  // It will sort the elements in ar
  // If idx>0 it will arragnge the elements in idx in the same way that they are in ar
  // As sorting a two colum table based on the elements of one colum
 
  if (n < 2)
    return;
   
  // We choose a pivote p at the middle of the array
  int p = ar[n / 2];
  int *l = ar; // Left pointer, to the start of the array
  int *r = ar + n - 1; // Right pointer, to the end of the array
  // We move all the elements smaller than p to the left and the ones grater than p to the right
  // Therefore the value p ends up in it final position of the sorted array
  while (l <= r) {
    if (*l < p) {
      l++;
    }else if (*r > p) {
      r--;
    }else {
      int t = *l;
      *l = *r;
      *r = t;
      if(idx>0){
        t=*(idx+(l-ar));
        *(idx+(l-ar))=*(idx+(r-ar));
        *(idx+(r-ar))=t;
      }
      l++;
      r--;
    }
  }
  // Iteration stops when l is to de right of r
  // Now from the start to r we have all elements smaller or equal than p
  // And from l to the end we have all elements greater or equal than p
 
  // Now we operate recursively doing the same process in the two sub arrays:
  // start to r
  // l to end
  sort(ar, r - ar + 1,idx);
  if(idx>0){
    sort(l, ar + n - l,idx+(l-ar));
  }else{
    sort(l, ar + n - l,0);
  }
}


Let me know if you have further questions

Cheers
Last edited by adafruit_support_bill on Mon Mar 21, 2016 9:56 am, edited 1 time in total.
Reason: Please use [code] tags when submitting code to the forums

Camilo
 
Posts: 11
Joined: Sat May 17, 2014 2:01 pm

Re: Inductive charging set as inductive conductivity sensor?

by andrebelem on Mon Mar 21, 2016 9:50 am

Camilo...I'm looking to discuss with you about this project. How can we talk ? PVT ?

andrebelem
 
Posts: 1
Joined: Mon Mar 21, 2016 9:46 am

Re: Inductive charging set as inductive conductivity sensor?

by Camilo on Mon Mar 21, 2016 12:14 pm

The best is to do it here, maybe others have the same questions.
Otherwise send me an e-mail to camilorada, gmail, com

Camilo
 
Posts: 11
Joined: Sat May 17, 2014 2:01 pm

Please be positive and constructive with your questions and comments.