Arduino Forum

Topics => Science and Measurement => Topic started by: LsensorRSH on Feb 13, 2014, 12:57 pm

Title: problems in data measurement
Post by: LsensorRSH on Feb 13, 2014, 12:57 pm
Hi,

Just a brief of the project I am working on. I am trying to connect inductors in circular array which are connected to two MUX acting as a transmitter and receiver which is controlled by arduino UNO. The MUX i am using is ADG508A (data sheet attached, schematics attached). I have written the coding, but i feel it is not working well with the MUX.  I will explain the algorithm and put the code in after it.

The example of how my mux's should work is

Transmitter MUX Selection pin 1(selected): the signal goes to the inductor of value 220uH, The other inductors get induced by the signal, and the receiver mux  from selection pin 2 should be selected and the value to written on the serial monitor. then the receiver should go for the selection pin 3 and write it down, like wise till the Selection pin 8. 

So, it's like this

Output should be like below, only receiver voltage is measured.

transmitter 1 - Receiver 2 3 4 5 6 7  8
transmitter 2 - receiver 3 4 5 6 7 8
TX 3                   - RX           4 5 6 7 8
TX 4                  -  RX           5 6 7 8
TX 5                  -  RX           6 7 8
TX 6                  - RX           7 8
TX 7                   - RX          8
TX 8                   - none



Should follow n(n-1)/2

Code: [Select]
        for(count=0;count<=7;count++)
   {
      i = pin[count];
      a0 = bitRead(i,0);
      a1 = bitRead(i,1);
      a2 = bitRead(i,2);
   
      digitalWrite( 3,a0);
      digitalWrite( 5,a1);
      digitalWrite( 6,a2);
      delay(3000);
     
     }

        while(i==pin[count])
        {
 
         for(count1=count+1;count1<=7;count1++)
          {
          i = pin[count1];
          a00 = bitRead(i,0);
          a11 = bitRead(i,1);
          a22 = bitRead(i,2);
   
          digitalWrite( 6,a00);
          digitalWrite( 7,a11);
          digitalWrite( 8,a22);
          delay(2);
         
   
          }
   
        }
   
    }


Since this code didn't work with the MUX i went for the analogWrite command which has a similar programming
Code: [Select]
  int a0_LH[] = {0, 255, 0, 255, 0, 255, 0, 255};
  int a1_LH[] = {0, 0, 0, 0, 255, 255, 255, 255};
  int a2_LH[] = {0, 0, 0, 0, 255, 255, 255, 255};
  for(i=0;i<=7;i++)
  {

  a0 = a0_LH[i];
  a1 = a1_LH[i];
  a2 = a2_LH[i];
 
analogWrite(3, a0);
analogWrite(5 ,a1);
analogWrite(6 ,a2);
delay(80);

if (i==i)
   for(i1=i+1;i1<=7;i1++)
     {
       int a3_LH[] = {0, 255, 0, 255, 0, 255, 0, 255};
       int a4_LH[] = {0, 0, 0, 0, 255, 255, 255, 255};
       int a5_LH[] = {0, 0, 0, 0, 255, 255, 255, 255};
       a3 = a3_LH[i1];
       a4 = a4_LH[i1];
       a5 = a5_LH[i1];
       
       analogWrite(9,a3);
       analogWrite(10,a4);
       analogWrite(11,a5);
          //analogReference(INTERNAL);
       
        Val = analogRead(analogPin);
        Serial.println( Val);   // prints the values in volts
        delay(10);
     
  }
 
   
  }


This program makes 4 of the selection pins work [s1,s2,s7,s8] and the remaining 4 doesn't work [s3- s8].

Please kindly help to figure out where I have done the mistake.  Is it my logic is wrong or my understanding of the MUX and arduino?


Title: Re: problems in data measurement
Post by: arduinoadrian on Feb 14, 2014, 03:16 am
What signal are you feeding to the coils? Arduino  may have problems reading the voltage levels from the coils without rectification and filtration if it is AC as I guess.
From your code the statement if(i==i) is always true
There are probably better ways to do it; but in the mean time this may help you. At least it compiles. This is from what I interpret from your question on how to drive the multiplexers.

Good luck,

Code: [Select]
//pins 10,11,12 for TX
//pins 7,8,9 for RX
int MaxCoils=8;
int YourReadPin=0;
int YourDelay=10;
int YourOtherDelayIfYouNeed=20;

void setup()
{
for (int k=7;k<13;k++)
{
  pinMode(k,OUTPUT);
}
Serial.begin(9600);
}

void loop()
{
for (int i=0;i<MaxCoils;i++)
{
WriteTXActivationCode(i);
for(int j=i+1;j<MaxCoils;j++)
{
WriteRXActivationCode(j);
int Val=analogRead(YourReadPin);
Serial.println(Val);
}
delay(YourDelay);
}
delay(YourOtherDelayIfYouNeed);
}

void WriteTXActivationCode(int i)
{
  if(i<4)
  {
  digitalWrite(10,LOW);
  }
  else
  {
  digitalWrite(10,HIGH);
  }
 
  if(i==0|i==1|i==4|i==5)
  {
  digitalWrite(11,LOW);
  }
  else
  {
  digitalWrite(11,HIGH);   
  }

  if(i=0|i==2|i==4|i==6)
  {
  digitalWrite(12,LOW);
  }
  else
  {
  digitalWrite(12,HIGH);
  }   
}

void WriteRXActivationCode(int j)
{
   if(j<4)
  {
  digitalWrite(7,LOW);
  }
  else
  {
  digitalWrite(7,HIGH);
  }
 
  if(j==1|j==4|j==5)
  {
  digitalWrite(8,LOW);
  }
  else
  {
  digitalWrite(8,HIGH);   
  }

  if(j==2|j==4|j==6)
  {
  digitalWrite(9,LOW);
  }
  else
  {
  digitalWrite(9,HIGH);
  }   
}
Title: Re: problems in data measurement
Post by: arduinoadrian on Feb 14, 2014, 10:10 am
By the way, you should have continued with your previous posting
http://forum.arduino.cc/index.php?topic=215869.0 which I have not seen till now and not starting a new one.
Title: Re: problems in data measurement
Post by: LsensorRSH on Feb 18, 2014, 10:38 am
hi arduinoadrian,

Thanks for your help.

Let me give you more explanation on the topic, I am sending AC signals generated by DDS chip and amplify it by 5 times and send a AC voltage of 2.4V at the frequency of 20KHz to the inductors of value 220uH via MUX and the induced voltage at the other inductors are received via mux and transmitted to an Instrumentation amplifier and then a rectifier circuit and the output is read by the arduino.

I tried to use your coding, and I got the same errors when I was doing with my own coding as well.

The error is  when transmitter 1 transmitting signal for all of  -  Receiver 2 3 4 5 6 7  8,  to be read and printed. But the transmitter is not transmitting for the entire period and the receiver reads transmitter 1 signal and send them out as well.  Using for loop, causes this. So I tried an experiment where no for loop is there but the variable 'i' is used to write control signals to MUX.

like this doing below:
Code: [Select]
int i=0; // TX 1
{
WriteTXActivationCode(i);

for(int j=i+1;j<8;j++)
{
WriteRXActivationCode(j);
int Val=analogRead(analogPin);
Serial.println(Val);

}
delay(2000);

}


using this I was able to keep the transmitting signal to be transmitting for the entire loop of the receivers.

but if I use this coding below
Code: [Select]
for (int i=0;i<MaxCoils;i++)
{
WriteTXActivationCode(i);
for(int j=i+1;j<MaxCoils;j++)
{
WriteRXActivationCode(j);
int Val=analogRead(YourReadPin);
Serial.println(Val);
}
delay(2000);
}
delay(3000);
}


the transmitting signal does not stay for the entire period for the receiving signals. which is why I tried to use a conditional statement in between to keep the transmitting signal to be ON for the entire period which did not work well as i thought.

here's another code I tried, but the same error results.

Code: [Select]
   for(count=0;count<=7;count++)
   {
      i = pin[count];

      a0 = bitRead(i,0);
      a1 = bitRead(i,1);
      a2 = bitRead(i,2);
   
      digitalWrite( 3,a0);
      digitalWrite( 5,a1);
      digitalWrite( 6,a2);
      delay(3000);
     
     }

        while(i==pin[count])
        {
 
         for(count1=count+1;count1<=7;count1++)
          {
          i = pin[count1];
          a00 = bitRead(i,0);
          a11 = bitRead(i,1);
          a22 = bitRead(i,2);
   
          digitalWrite( 6,a00);
          digitalWrite( 7,a11);
          digitalWrite( 8,a22);
          delay(2);
         
   
          }
   
        }
   
    }


i wrote the above coding thinking that the transmitting sensor will be transmitting for the entire receiving period, using the while statement. It also produces the same error.

Can you please help me to find where I am going wrong?

thanks



Title: Re: problems in data measurement
Post by: arduinoadrian on Feb 18, 2014, 12:31 pm
Hi:
Please double check your connections correspond to the pins you are driving from the code. The instance i==0 corresponds to (LOW, LOW, LOW) for your mux which means none of the TX outputs is active and maybe that's why it works there and not with other instances of i++. Remember I set my own pins for TX which may not have been the same you were using. Another reason for the problem could be the definition of the TX pins Mode in the setup. If I get any other ideas I'll let you know. Please post your results.
Title: Re: problems in data measurement
Post by: arduinoadrian on Feb 18, 2014, 01:18 pm
Since you have enough memory left (or I guess so) you can try to run the code step by step as we use to do with the Z80 and others back in the day and check the results.

Simply repeat the same thing for several instances of i.

Code: [Select]

int i=0; // TX 1
{
WriteTXActivationCode(i);
for(int j=i+1;j<8;j++)
{
WriteRXActivationCode(j);
int Val=analogRead(analogPin);
Serial.println(Val);
}
delay(2000);

int i=1; // TX 2
{
WriteTXActivationCode(i);
for(int j=i+1;j<8;j++)
{
WriteRXActivationCode(j);
int Val=analogRead(analogPin);
Serial.println(Val);
}
delay(2000);
// and so on...



Title: Re: problems in data measurement
Post by: LsensorRSH on Feb 18, 2014, 03:57 pm
HI,

Really , Thank you.

I managed to solve the issue on my own. But you were right on the mark, the signal was i=0 instead of i==0; and also I found that the rest of my coding were working properly too.

Managed to get 28 outputs for the 8 sensors the lowest being 0.02mV  and the highest 0.5mV -> this value must be an error. this is too big compared to the other max signals.

Now, I need to use a large gain to amplify the signals and rectify it and feed it to the Arduino. But, i want to go step by step from amplification then rectification and then reading the output.

Since I know arduino adc only reads 0 - 5 V and  using  100,000 gain [ not sure if i can do this] to multiply the signals, if i do, the highest output from the sensor goes to 50V and that will harm the arduino.

I am using Instrumentation amplifier[AD8226] for high gain of 1000 which means i will get the lowest value as 0.02V and the Highest 0.5V .These values are really low to be rectified using 1n4007 as it requires 0.7 Volts for forward biased conduction.

I think that a second stage amplification is needed for rectification. Will try to experiment it.

If you think or feel I might be doing something wrong, kindly correct me.

I wish I can think first and do it rather than do it and think later.....

Title: Re: problems in data measurement
Post by: arduinoadrian on Feb 18, 2014, 07:49 pm
Glad you solved the problem and the code worked.
Check these subjects:
-Precision rectifier
-Input protection diodes.
Quote
Since I know arduino adc only reads 0 - 5 V and  using  100,000 gain [ not sure if i can do this] to multiply the signals, if i do, the highest output from the sensor goes to 50V and that will harm the arduino.

Then you don't need 100000 you need only 10000 to get the 5V you want and not 50.
Check the datasheet of your instrumentation amp to see if the gain can be set to 10000. I'm using right now an AD620 with a gain of 2000 with no problems. On it, the gain can be set to 10000 according to the manufacturer.
For the precision rectifier if you are concern about temp dependency of your whole system transfer function select a low offset temp drift opamp and low temp coefficient resistors. Correcting temp drifts later on will be time consuming and can get pretty ugly.
I still don't understand why you are getting such low voltages with a gain of 1000 already and how could you read them without a precision rectifier??? But I'm not there.
-Are your TX and RX too apart from each other?
-Do the RX coils have enough turns?
-Are you feeding the right power to the TX coils?
-Are the frequencies correct?
With such low voltages and coils as pick ups, if you are anywhere near public broadcasting stations frequencies and/or distances you will have problems isolating your signal from the interference from theirs. Its always better to have a strong clean transducer signal than having to amplify it too much to keep the S/N ratio under control. Maybe you can improve your transducer performance somehow and get a stronger signal so you don't need to amplify that much.
Quote
I wish I can think first and do it rather than do it and think later.....

That's common occurrence for many of us, including myself. The reason being lack of patience... That condition improves a bit as you get older though.


Title: Re: problems in data measurement
Post by: LsensorRSH on Feb 19, 2014, 02:10 pm
I will check on those topics.

I measure the voltages using the oscilloscope for the time being.  The values that I wrote was with a gain of 8.15. After posting this
I increased the gain to 1052 and now getting the values as 0.15 V the lowest [0.02mV  previous]  and 1.5 V [0.24mV] the highest but there is an error which reads one of the peaks to be 5.8V. The reason I am saying this induced voltage as an error because all 8 inductors are of the same value 220uH inductance. So when a near by transmitter is sending a high signal, the voltage received by all others are of 1.5 V except this one.

The inductors are arrange in a circular formation of diameter 32mm and at a distance of 0.5cm from each other. Well, the closest position to each other. I will upload a picture after this post. 

After comparing the outputs for both gains, i feel something is wrong.  from the gain of 8.15, the lowest value is 0.02mV or 20 micro volts but after a gain of 1052  it just went upto 0.15 volts or 150 milli volts.  Is this right?

In theoretical calculations it should be in milli volts. But the practical value I am reading from oscilloscope is in volts much higher than my calculated theoretical values.

So let me answer your questions,

- TX and RX  are of same number of turns and has same inductance of 220uH placed between 4mm or lesser in a circle of 32mm.
- I am feeding the coils AC voltage of 2.4 volts at frequency 20KHz, but the coils are producing the output of 0.8Volts at 20KHz.
to be honest, I need to understand this part as well. I can see this reduction in the voltage is due to the impedance of the inductor, but not sure how to calculate it.
- The frequencies seem to be right between the input and the output.

yeah, I really need to understand my circuits first.

Thanks again.






Title: Re: problems in data measurement
Post by: arduinoadrian on Feb 19, 2014, 05:14 pm
From the AD8226 you are using datasheet page 12: http://www.analog.com/static/imported-files/data_sheets/AD8226.pdf  

With a gain of 1052 ( aprox. 60 dB), If you look at the Graphs (Fig. 25, Fig.26), no matter what Power Supply Voltages are you using, the cutoff freq is way lower than your operating freq of 20KHz. Probably, the reason why you are not getting a linear increase in the output voltage when you increase the Gain to 1052 as you were expecting (It falls in the slope of the Graph).

Possible solution:
-Divide the Gain into multiple stages.

Additionally, check the subject Slew Rate.
You may also be out of range of the device max slew rate (I don't know) and getting a triangular wave at the output not linearly following the input. This is common occurrence when the gain is taken too high and the freq is too high to do that. I haven't checked that in your case; but you need to check it as well and confirm the slew rate is right in your case.

I think you are taking the device off limits in this application.
Title: Re: problems in data measurement
Post by: arduinoadrian on Feb 19, 2014, 09:05 pm
To avoid some head aches, I would try to do this:
-Try to find a different approach and a different sensor, if possible. Its difficult to believe there is only one possible method to measure what you are trying to accomplish; but I don't know what it is.
-If the coils method is the best option:
*Decrease the freq to about 10-15KHz and use a HiFi audio amp (in case the oscillator-driver you are using can't do it) to put more power on the TX coils, 10V for example, That will give a higher induced voltage at the receivers, needing less amplification and making it more immune to noise.That's if the coils can take it without burning, overheating or core saturation. Take the voltage as high as possible without undesirable effects. Careful though as that my produce unacceptable EMI radiation.
-Use caps to tune the thing and make an LC tank (f=1/2PI*sqrt(LC)). That will help filter out undesirable harmonics and reduce distortions and EMI radiation. Same goes for the RX coils to help filtering RF interference.
*Define the temp range you expect for the device to operate  without significant change in the readings at the output. Once you have that, make sure to select the gain resistor with a temp coefficient capable of that, so it will not change the gain with temp inside that range. The same applies to the offset voltage temp drift of any other amps you may need and any other resistors affecting the total gain.
*Keep the gain of any amp stage under 10 or whatever the product Gain*Bandwith limit for the particular device dictates for the operating freq selected. Check the device datasheet for that similar to the previous post. Spread the overall  gain into several stages. Too much gain increases the chances of building an oscillator instead.
*Use the manufacturer's recommended filtration caps on power supplies rails next to the actual opamps or any other places you may need including the input. *Use ferrite cores and make a couple of turns trough them with the power supplies wires feeding the amps at least in the prototyping phase. If not enough and noise persists, place ferrite core coils in series with the power supply wires feeding the amps.
*Use shielded wires to send the coils signal to the amp. Place the amp as close as possible to the coils.
*Make sure the multiplexers can handle the freq in use ( I don't know, never used them).
*Follow ground distribution recommendations from the manufacturer of the Instrumentation Amp.
*If noise is persistent, enclose the amps board in a grounded metal box.
*Use a precision rectifier at the output (if required as there maybe enough voltage already to use simple diodes) and build the right low pass filter to average the envelope of the rectified signal with the right time constant for the application. Check AM Demodulation subject, as I think AM modulation of your 20KHz carrier from the measured variable, is what you get at the end of the day with your sensor approach. The low pass filter must be designed to filter out the carrier freq and keep the envelope which is your original signal.
-Consider using a high quality Audio preamplifier as your first stage, instead of the instrumentation Amp. Similar to the ones used as Needle Preamps in old vinyl record players or a simple Mic Preamp. You will need to reduce the band width though to reduce noise and most likely correct the freq response. If I recall well, their band pass wasn't flat to compensate for freq response problems in the needles or mics. You can build your own using LM382 or similar. Beware when setting the band pass it can not be a super High Quality (Q) filter that excludes useful freq components of your original variable signal (the one you are sensing). The bandwidth if its AM modulation (as I suspect) has to be at least twice your original variable signal max freq and centered to the carrier you use.

I don't know what else could help you. If any thing else comes to my mind I'll let you know.
Title: Re: problems in data measurement
Post by: LsensorRSH on Feb 25, 2014, 12:17 pm
HI,

Multiple amplifier stages worked really great.  :)

Precision rectifier :
The next one I tried is the precision rectifier cirucit, which does not seem to be working at all. The output I am receiveing is AC signal which are amplitude reduced.  I am using a 1N4007 diode and from my observation from the outputs, their amplitudes are reduced 0.7Volts on both positive and negative cycles of the AC signal.  I used the circuits in the following link
http://www.cs.ucf.edu/courses/eel4309/Precision_Rectifier.pdf (http://www.cs.ucf.edu/courses/eel4309/Precision_Rectifier.pdf)

Rectifier on its own:
So, since the amplifier stage didn't work I tried with the DDS chip[AD9833] I am using, The result was still the same, got an AC signal. Since the output from the DDS is always 0.63 volt with 20KHz frequency, probably diode didn't receive enough voltage for forward biasing.
So, I connected the diode to the op-amp amplifying the DDS voltage with gain 4. and the result was an ac signal amplitude reduced by 0.7 volts on both sides of the wave.

I don't understand why there is an AC signal after a diode. It  should be either a half wave rectified signal or the same input signal.

Next, I am planning to connect the precision rectifier to the above stage. So to see if there is any change in the output at all.

If you understand why there is an AC signal at the rectifier output, kindly explain it to me.

Thank you.


Title: Re: problems in data measurement
Post by: arduinoadrian on Feb 25, 2014, 03:30 pm
Quote
The next one I tried is the precision rectifier cirucit, which does not seem to be working at all. The output I am receiveing is AC signal which are amplitude reduced.  I am using a 1N4007 diode and from my observation from the outputs, their amplitudes are reduced 0.7Volts on both positive and negative cycles of the AC signal.  I used the circuits in the following link


In order to attempt finding the reason for that, could you please post the schematic of the actual circuit you have built, including the part number for the OpAmp you have used?.
Normally, for such low current applications the 1N4148 diode is more frequently used.
Title: Re: problems in data measurement
Post by: LsensorRSH on Feb 26, 2014, 01:38 pm
hi,

I have attached the precision rectifier schematics and also the last stage buffer amplifier schematics.

I also thought that the diode might be the case for the precision rectifier not working, So i changed the diodes to 1n914. This did work yesterday,well almost, a few of the AC signals were not rectified and the output was in millivolts.

Since the arduino can't read millivolts I used a buffer amplifier with gain 4 and made it to read the voltages, a few signals were not read and some were zero and there was a huge difference between the output read at the oscilloscope and the serial monitor, it might be due to the addition of amplifier at the last stage or it might be due to the delays given in the coding.  Not sure which is the reason, I might need to use another diode to check if there is a different out come.

I will post if there has been any improvements.

Thank you very much again.
Title: Re: problems in data measurement
Post by: arduinoadrian on Feb 26, 2014, 01:52 pm
I can't open the files format you used. I'm an antiquated computer user, so please just use a different file type like a simple picture file jpg or png if possible. PDF format is also OK.
Title: Re: problems in data measurement
Post by: LsensorRSH on Feb 27, 2014, 10:17 am
Sorry about that.

Should have attached the PDF files the first time.

The files are attached. After this amplifier stage I tried to connect the output from the amplifier to the Arduino adc and opened the serial monitor, compared the observing values in oscilloscope and serial monitor in the arduino, some of the values are not matching. This led me to think may be the rectifier is not working properly or might be something wrong with the capacitor attached to the filter circuit.

When the values are observed in the oscilloscope, they are coming in the U shaped, means for every signal transmitted the result will be in U shaped. I will provide an data of those after i take few more readings this afternoon.

I also tried using analog reference voltage from 1 -3 volts using a voltage divider circuit, but that was not useful. It ended up producing more abnormal values.

I think I need to learn more on this data acquisition circuits.

I thank you again for your guidance.
Title: Re: problems in data measurement
Post by: arduinoadrian on Feb 27, 2014, 02:52 pm
-The OP37E is an excellent choice. BTW, check pages 13 and 14 of its datasheet http://www.analog.com/static/imported-files/data_sheets/OP37.pdf for the Phono and Mic preamps configurations mentioned before. I still think that's a better choice than the Instrumentation Amp config  you are using in this particular case. The reasons for that are the high freq and gain levels you are using.
-Consider using another OP37E instead of the LM741P.  Although I can't find the datasheet for the P version you are using, I suspect, it might introduce more noise and its temp offset drift is probably higher and that will cause problems as explained before. What you are trying to build is uncommonly difficult and requires extreme care and attention to details. If you don't follow already known procedures and techniques you won't get acceptable results.
-I think there is no need for a buffer last stage unless the voltage level is too low; but having so many stages already that's difficult to accept if everything was done right. The low pass filter stage to recover the signal envelope acts as a buffer already. Adding another stage introduces more noise and problems. If there is not enough voltage try to increase the gain of that and previous stages with care not to surpass the Gain Bandwith product and slew rate as advised before. The more active components the more noise is introduced and the more problems are added. Plus added cost
-The 10pF cap used apparently is not right . According to f=1/2PIxRxC, with R=47K and c=10pF the cutoff freq should be 1/(2xPIx47x10^(3)x10^(-11))=1/(2xPIx47x10^(-8))~344KHz that's way above the 20KHz carrier and the cutoff freq. must be way below it for correctly detecting the envelope by averaging and properly measure the voltage. The filter is simply not filtering and the 20KHz half wave carrier is passing through. Arduino is sampling the non averaged signal and since there is no sync between it and the Arduino sampling rate, it gets the reading at any point of the "rectified signal" and therefore the readings are erratic. There could be other problems though, like the amplitude actually getting to Arduino, noise, bad rectification, etc. But lets begin by fixing that. Double check my calculations for accuracy please. I did it quickly and they may be wrong.
-Please post a picture of the "U shaped waveform" you are getting? Sounds like  a clear indication of distortion taking place along the signal path. Troubleshoot with the scope by measuring the signal at different points in its path, that is, at all amplifier stages inputs and outputs and check where that distortion begins to appear. That's the stage introducing it. Must be revised then.
-Please post scope screen pics of the signal waveforms at inputs and outputs where you think there is a problem.
Title: Re: problems in data measurement
Post by: LsensorRSH on Feb 27, 2014, 04:58 pm
Hi,

Thanks for the guidances,

The precision rectifier has stopped working, I need to get some diodes for it to work.  Played with it in the morning and now it stopped. [Me and my hands]

The U shaped curve is obtained by the plotting of the observed values on a graph, sorry if I made you misunderstand that it is appearing on the scope. Its the values of the receiver for each transmitter inductor.

I need to understand a lot about my design and circuit. As you said, Its really difficult, and even a minor mistakes in the circuit stops it from working.

The output  voltage coming from the filter circuit is really less and when fed into arduino nothing other than 0 appears on the screen. So, I had to amplify it at the end.

will update on this tomorrow.

Thank you.
Title: Re: problems in data measurement
Post by: arduinoadrian on Feb 27, 2014, 05:47 pm
I suggest this:
-Take a couple of days of break from the build up and go to the library with your circuits on hand, carefully read the postings and deeply study the subjects recommended. Compare what you learn with what you have actually built. When you have a better picture of the possible mistakes and only then return to the lab to continue with the build up. I honestly have told you everything I consider necessary for your approach to succeed to the best of my knowledge and experience.
-Talk to your project tutor and request some onsite help also. Its hard to figure out the details from reading posts. From short distance, he will have better clues than me.
Title: Re: problems in data measurement
Post by: LsensorRSH on May 25, 2014, 10:02 pm
Hi,

Thanks for all your help. I made it work. But most the times the arduino adc is not working well. Most of the times it gets burned.

Now i am trying to improve the current being sent to the inductor, I am not sure how i can send more current to it. There is a multiplexer stage in-between the sensor and the frequency generator and if i send more than 20 mA current to the multiplexer it will definitely get burned. So clearly I need to send it afterwards.

Currently I am sending ac 10V at 20KHz frequency to my inductor but i want to send 1 Amp current or more to it. how can i Possibly send more ?

Also one more thing i need to ask. I have a inductor of value 220microHenry. I am supplying 10V at 20KHz frequency. The voltage drop across the inductor to 4V. I calculated using different formulas but none of them seems to be correct.
Voltage drop across the inductor = AC voltage / Inductor. => VL = Vac / L
And not sure how to calculate the change in current.

want to seriously improve my knowledge, please help me out.


Thanks

Title: Re: problems in data measurement
Post by: arduinoadrian on May 26, 2014, 12:37 pm
HI:
Glad you made it work somehow.
Quote
Most of the times it gets burned

That means destroyed?
Quote
Now i am trying to improve the current being sent to the inductor, I am not sure how i can send more current to it. There is a multiplexer stage in-between the sensor and the frequency generator and if i send more than 20 mA current to the multiplexer it will definitely get burned. So clearly I need to send it afterwards.

One way could be using relays to switch the signal instead of the multiplexers. You can still use the multiplexers to activate the relays.
Quote
...Voltage drop across the inductor = AC voltage / Inductor. => VL = Vac / L...


Inductive Reactance= w*L=2*PI*freq*L

The voltage drop across the inductor is the voltage you measure across the inductor, either with the multimeter or the oscilloscope. I don't think you need to calculate that; but measure it.

I still think you need to lower the frequency to get better results with the devices you are using. It all depends of the frequency of the original signal you are sampling, that is, the one you are measuring.
Title: Re: problems in data measurement
Post by: LsensorRSH on May 26, 2014, 06:30 pm
Yes the multiplexer pins got destroyed.

I did measure them with the oscilloscope and multimeter but they are very different from each other.
for eg:
When I supply Vac = 10V at 20Khz frequency, to a inductor of 224micro henry, the voltage drop

E = -L di/dt => - 224x10^-6(0.036) => 8.064 micro volts.
I = Vac/ XL = 10 / 2*Pi*20*10^3*224*10^-6 => 0.36;
E volts  I Amp      wL      di/dt
0       0              27.64  0
1        0.036      27.64  0.036
2       0.072      27.64  0.036
………………………………………

10    0.360      27.64  0.036


So the result is in micro volts, but I am seeing milli volt values in the oscilloscope and the multimeter is also showing a different reading. This is one problem.

The other one i noticed when i tried to plot the graph is that voltage drop is always constant when i substitute di/dt = 0.036, but it changes when i substitute the actual current values i.e., I = 0.036, 0.072…0.36 where E ranges from 8.064 microvolts to 80.64 microvolts.

Please let me know what I am doing wrong.
Title: Re: problems in data measurement
Post by: arduinoadrian on May 26, 2014, 09:02 pm
Quote
E = -L di/dt => - 224x10^-6(0.036) => 8.064 micro volts.

That's the instantaneous Voltage (E(t)) across an Inductor (L) through which a current I(t) is circulating. That's not the rms voltage which is what you are after. In order to get the rms voltage you would need to perform complicated calculations with that E(t) including integration in time (http://en.wikipedia.org/wiki/Root_mean_square). If it is a periodic signal then the rms of the signal is equal to that of one period. Since all that is not very practical to do, then what you do, is to measure the rms voltage. To do that with the Oscilloscope, you measure the peak to peak Voltage (Vpp) and Vrms=Vpp/sqrt(2) if it is a sine wave signal, as I suspect. If its not a sine wave, then that's not the equation. Another way is to use a true rms multimeter capable of operating at that frequency (20KHz in your case) and it will read the rms voltage directly for you. That could be the reason for the differences you are observing, depending on which multimeter you are using. You can read the specs and find out if it can operate at that freq. I studied these things long ago and might not remember the details very well though.
Quote
I = Vac/ XL = 10 / 2*Pi*20*10^3*224*10^-6 => 0.36;

That looks somehow true, except for the fact that the 10Vac is applied to the serial combination of the multiplexer and the coil. That creates a voltage drop across the multiplexer also depending on its ON resistance and the current passing through. Therefore the 10Vac is not applied in its totality to the coil, part of it is lost in overheating the multiplexer. If too much, multiplexer blows.
So in reality it looks like:
I=Vac/(ZL+Ron)
and
VL=Vac*ZL/(ZL+Ron)       VL-(Inductor Voltage)      Ron-(Multiplexer ON Resistance)       ZL=R+XL (Inductor Impedance)

The multiplexer datasheet should tell you its ON Resistance. In a normal case, the multiplexer Ron should be way less than the Impedance of the load you are driving through it, so the voltage drop across it is negligible and most of it gets applied to the load where you want it.
Furthermore, you are not considering the Ohm Resistance of the coil and calculating its impedance (Z=R+XL). That could be acceptable, if it is very low compared to its XL at the operating freq; but I have no idea about the wire gauge they are made of and the amount of turns which directly affect its Ohm Resistance.
Anyways, at f=20KHz,  XL=2*PI*20*10^3*224*10^(-6)~28 Ohms. That is low and very well in the same order of magnitude of the inductor Ohm Resistance, therefore its Z may differ substantially from its XL. Please measure the coil resistance with a regular Ohmmeter to check how much it is. Furthermore, that low XL value could be also in the same order of magnitude of the multiplexer ON Resistance (I don't know); please check that also. If that's the case then most of the Vac is lost in the multiplexer and not in your useful load (the coils)
I have the impression the 224 uH value you are mentioning may not be right though. That looks like and odd value (particularly the 4 at the end). Like caps and resistors they are "mostly" manufactured in series of standard values (from what I have seeing). If that's what you are reading on the coil itself, then the 4 may mean the multiplier and the value could be 0.22uH or 22uH  instead (I don't know). If you have not done it yet, I suggest you use an inductance or RLC meter and double check the inductors' real values.  Can you post a picture of the actual coil you are using?

EDIT:
By the way, I made a mistake when explaining to you how to measure the rms voltage with the Oscilloscope .
Quote
To do that with the Oscilloscope, you measure the peak to peak Voltage (Vpp) and Vrms=Vpp/sqrt(2)

Wrong, it should be the "peak voltage" (Vp) and not the "peak to peak voltage" (Vpp). Peak voltage means from zero to peak. Therefore:
Vrms=Vp/sqrt(2).
Sorry about that, too many things going on at the same time, I guess...
Title: Re: problems in data measurement
Post by: arduinoadrian on May 27, 2014, 02:48 am
It is important to mention the difference in circuit analysis in the time domain and the frequency domain. Your equations apparently are mixing them both and that's also part of the problems with your results. Although they are related through the Laplace Transform (fortunately something we don't have to worry about), the time domain analysis will give you instantaneous "behavior" of the variables, that is, at any given instant in time. The frequency domain on the other hand, is used in AC circuits analysis to obtain variables "behavior" with frequency and it is invariant in time. Therefore, if both are mixed it won't work, that's why you can't calculate the rms current (Iac) using instantaneous voltage (E(t)) and reactance. The E(t) is the voltage at any t=timeyouselect instant during the AC signal, while the rms voltage as it is a periodic sine wave signal does not change with time (in the analysis).
Title: Re: problems in data measurement
Post by: LsensorRSH on May 29, 2014, 02:24 pm
HI,
http://www.murata-ps.com/data/magnetics/kmp_2200r.pdf

Please see the above link for the inductor. Its order code is 22r224c. My phone cam got busted and i am unable to take any pics.

I  measured their resistance using a multimeter. It was 0.8 ohms/ 800 milli ohms.

Ron of my Multiplexer is 300 ohm when supplying +15 v.

i will make the calculations and see how it goes.

Whenever i solve problem another seems to arise. This time its the adc.

I made a new circuit of 2 stage amplification, one is the amplification stage and the other is the precision rectification and after that a low pass filter. When i connect the oscilloscope at the filter output, i can clearly see the rectified wave. But when i connect it to thearduinos adc it reverts back to sine wave.

how do i understand what happens here?  I thought the adc is busted and connected it to the potentiometer and varied to check if the readings changes, It does changes but it doesn't work with the circuit i made.
Title: Re: problems in data measurement
Post by: arduinoadrian on May 29, 2014, 07:20 pm
Quote
Please see the above link for the inductor. Its order code is 22r224c

OK good 220uH, confirmed.
Quote
Ron of my Multiplexer is 300 ohm when supplying +15 v.

Kind of high Ron; but you don't have too many options to solve that, I guess. Then you have to live with that for now and increase amplification until something better arises (if needed). The problem is that with XL=28 Ohm most of the energy is lost overheating the multiplexer. Then you need to be careful not to fry it.
Quote
i will make the calculations and see how it goes.

Good. By the way, I made a mistake when explaining to you how to measure the rms voltage with the Oscilloscope (2 replies ago).
Quote
To do that with the Oscilloscope, you measure the peak to peak Voltage (Vpp) and Vrms=Vpp/sqrt(2)

Wrong, it should be the "peak voltage" (Vp) and not the "peak to peak voltage" (Vpp). Peak voltage means from zero to peak. Therefore:
Vrms=Vp/sqrt(2).
Sorry about that, too many things going on at the same time, I guess...
Quote
Whenever i solve problem another seems to arise

That's normal and the reason why its so easily to get frustrated while building these things. Persevere!
Quote
When i connect the oscilloscope at the filter output, i can clearly see the rectified wave

That is a clear indication something is terribly wrong. You can't see the rectified signal if the filter is working properly. The filter must remove the carrier  (cutoff freq<<carrier freq), so what you ought see is your original modulation signal, which should be a slow varying one with a DC level added. In other words, an average of the carrier peak voltage or its envelope. With no signal at the input all you must see is a DC level there corresponding to the amplitude (peak voltage) of the non-modulated carrier.
I think we already checked the 100 pF Cap for the filter was wrong.
Also, place a 1K Resistor as the filter load (connected to ground right before the Arduino input). That way the Arduino ADC input will not be contributing to the impedance "seeing" by the filter at its output significantly (the 1K is almost unaffected by it) and you can control everything better. Furthermore, lower the 6OK resistor to about 1K also. The OPAMP can handle that with no problems and you will have a lower impedance driving the ADC. Then you calculate the Cap for a cutoff freq of about 2 KHz (10 times lower than your carrier for instance) to filter out the 20KHz rectified half wave. Read previous posts for how to do that.
Quote
But when i connect it to thearduinos adc it reverts back to sine wave.

That I don't know why. Solve the filter problem first, please.
You are close already. Keep going.
Title: Re: problems in data measurement
Post by: LsensorRSH on Jun 16, 2014, 11:23 am
Hi,

I made it work finally and properly this time. I used a inductor of 4.5 mH from murata solutions. The circuit only worked with this inductor and not any other. I also managed to integrate a DDS Chip Ad9833 instead of the frequency generator.

i am trying to make it work with a inductor of value 138UH but the ac signal becomes DC when the inductor is loaded to the circuit. Is there a way to correct the loading problems with the circuit?

I have a dds as a source an opamp after that increasing the voltage as the output from the DDS is 0.60 Volts, this opamp is connected to mux ad508 and then the inductor sensor array is connected. Will using RLC circuit solve this problem?

Thank you very much

Title: Re: problems in data measurement
Post by: arduinoadrian on Jun 16, 2014, 02:03 pm
Yes, I think there are several ways to solve that; but all of them will require major changes in your design.
The fact that you are using a pure sine wave to drive the coils is a major limitation, I think. To increase the power applied to the coils  that way, you will need to use linear amplifiers which are difficult to build or expensive to buy. Also that limits your ability to use the multiplexers in the driver circuits and you have to use them to apply the signal to the coils at any power you are using. These muxs, as we already checked,  can't handle to much power and introduce heavy looses in your signal path as your coils reactance is very low and that's a huge limitation for your design. Furthermore, the lower the coil inductance value (L) the worst the situation is regarding to loses in the muxs Ron. Therefore, there is a need to take the muxs out of the equation, in regards to power applied to the coils to get serious improvements to your project.
To achieve AM modulation of your 20KHz carrier it does not really need to be a pure sine wave (I think) and you could use something like a "Chopper" circuit and a square wave as a carrier. Using a square wave instead of the sinusoid will free your design from having to use a linear amp as the final stage to increase power and a simple non linear switching transistor can do the job. This will allow you to use the muxs in the driver stages where they will be submitted to way less power. The transformer configuration created by your coils (Tx/Rx in front of each other) will definitely introduce some distortion to the square wave signal as the whole spectrum will not pass through. Still this could be made to have a negligible effect for you application which may tolerate some THD; but I don't know as that (how much distortion is allowed) depends on the original signal you are using as the modulator (what you are trying to measure). A switching transistor as the final stage will allow you to increase Power by simply increasing the Power Supply voltage. Your modulating signal will still (I believe) affect the amplitude of the induced signal in the RX coil and you will be able to recover it the same way by using AM demodulation. You can try also to tune the coils to the fundamental freq of the square wave carrier by making a tank circuit using a cap in parallel with the coil. That way  the signal will be more like the sine wave you are using now, as it will attenuate most of the other freq components. How effective the tunning is, depends on the Q factor you achieve for the tank.
Another way could be using FM instead of AM, by making the Tx coil part of an oscillator circuit like a "Colpitts" design for instance. Your modulation signal will probably affect the freq (and probably amplitude also) of the signal generated because of changing the properties of the Tx/Rx transformer (coils). The received signal after amplification can be demodulated  using a PLL FM demodulation circuit which is not very difficult to implement using the 4046. What I don't know though, is how linear all that process will be allowing for correct reproduction (undistorted)  of your original signal at the end. That requires testing and/or knowledge I don't have.
Back to the square wave AM circuit, the attached picture (in general terms) is the approach I was mentioning to you. Please be careful when increasing the Power Supply voltage (Vcc) as if it is too much, the current will saturate the coils core with max possible magnetic flux  and any further increase will just be converted to heat and no useful magnetic energy, possibly destroying the coils.
Furthermore you will need to make sure this approach does not produce unacceptable distortions or nonlinearities in your end demodulated signal which has to match the original one.
Hope it helps.
Title: Re: problems in data measurement
Post by: LsensorRSH on Jun 17, 2014, 11:50 am
Hi,

Thanks again for the help.

Actually i am trying to anlayse a open loop gain opamp connection which worked on the last design. I made it by accident.
The transmitter part has a DDS chip sending a waveform of freq =20Khz and voltage 0.60volts to the openloop opamp.
At the output pin 6 i connected oscilloscope, but there was no output and when i connected the inductor array of 4.5mH, the sine waveform was there and voltage/current  was enough to drive the sensor array.

It was amazing, when it started working without a feedback, i always thought that the opamp requires feedback to work properly. but this entirely changed my opinion and I am unable to anlayze what is happening and how was the sine wave produced at the output when inductor was connected.

Attached is the PDF of that part.
Title: Re: problems in data measurement
Post by: arduinoadrian on Jun 17, 2014, 02:04 pm
Probably you have built an oscillator. Open loop OpAmps can have gains of perhaps 300000. "...Too much gain and you are risking building an Oscillator instead..." (mentioned some replies ago). The coil is connected to the output and DGND. There should be a feedback network from the output to the input through the coil somewhere,  probably in the ground loop as you have AGND and DGND or through some of the caps. Sometimes its through a poorly filtered Power Supply (I don't see the low value caps in the Power Supply rails, next to the OpAmp). The tiny feedback voltage drop in the feedback network, with such a huge gain is enough to provide the feedback voltage necessary to sustain the oscillation satisfying the Barkhausen critera. The 4.5mH coil is apparently the only one producing enough feedback voltage to satisfy the criteria and sustain oscillation nor the 220UH neither the 138UH you are trying to use. Lower inductance is equivalent to lower XL producing a lower voltage drop.
This is a very unstable system and the freq of operation depends on factors difficult to control. To confirm this, you can remove the DDS chip (be careful to maintain everything else the same) and observe if the oscillation persists. I would walk away from such "lucky solution" and build something one can have real control of its operation.
Title: Re: problems in data measurement
Post by: LsensorRSH on Jun 20, 2014, 10:38 am
Made it work with a inverting feedback, had problems with the inductor loading effect at the opamp output. But solved it by using a series resistance between the opamp output and the inductor.  :)

Also, used python programming to serially write data and save it in a file.

Now i am planning to supply current value of 200mA to 1 A to the inductor and analyze the difference and reduce the amplification stages in the receiver. My only fear is that the receiver multiplexer might blow when the induced current is more than 20mA.  So I need to find an alternative to multiplexer. if you have any suggestions please do let me know.

I will try to use the pulse signal as well and experiment on it for a while.

Thank you very much.
Title: Re: problems in data measurement
Post by: arduinoadrian on Jun 20, 2014, 01:06 pm
Quote
My only fear is that the receiver multiplexer might blow when the induced current is more than 20mA.

It won't happen, the Rx circuit is conformed by Inductor, mux, and Amp Stage input in series. The Amp Stage Input impedance is too high for the current to go so high at the induced voltage levels you will get. Beware, its the Amp Stage  input impedance in this case, which is affected by the feedback network there is and not the OpAmp open loop input impedance. They are different.
Quote
I will try to use the pulse signal as well and experiment on it for a while.

I would try to do that starting yesterday.