Jump to content

[URGENT] PmodIA returns incoherent impedance values!!!


Recommended Posts

Hello to everyone.

I recently purchased an pmodIA board for a project we are conducting at work. The main goal is to obtain some resistivity vs frequency spectra for different objects as part of a object characterization problem involving Oil/Gas stuff.

I already read the guide that digilent guys provide (http://store.digilentinc.com/pmod-ia-impedance-analyzer/) and I found some C libraries for the AD5933 (https://github.com/analogdevicesinc/no-OS/blob/master/Pmods/PmodIA/AD5933.c    and   https://github.com/analogdevicesinc/no-OS/blob/master/drivers/AD5933/AD5933.c). 

I am using a Raspberry Pi 3 Model B to control & communicate with the pmodIA. I based my code on those C libraries I mentioned. In order to use i2c protocol with the raspberry pi I use wiringPi library (http://wiringpi.com/reference/i2c-library/).

In my code I have tested everything I've been able to, from all functionalities of the pmod: I get the temperature readings, set the frequency sweep params, make a freq. sweep measurement, etc. I have attached my code to this post (pmodIA_test.tar). All functionalities I tested seem to be okay, and everything seems to be working: I get the temperature, I can do a frequency sweep and if I connect the outputs of the pmod to an oscilloscope I can see the frequency sweeping (look at this video I recorded) 

Now, the thing is that even though everything seems to be WORKING, the result values I am getting back just make no sense AT ALL!!!

For calibration purposes I am using a 100k resistor. In my code I first set the gain (X1) and range (2Vpp), I configure the sweep params and start it, then I calculate the gainfactor using that 100k resistor (which I later use on all my calculations), and then I ask the user to change the impedance and put the one that they desire to measure.

On the main loop I simply do the frequency sweep, increasing the frequency at each step, calculate the impedance and put this value into an array (Z). I am also using gnuplot to display the results (the values obtained from the pmod are the exact same values that are being plotted using gnuplot, so this is not a display problem, as I checked this).

This is when things get weird. These are the results I got for the following tests:

1) If I leave the 100k resistor for obtaining the impedance magnitude vs frequency I get the following curve ("100kresistor.png"). Just a noisy set of values, all of which are OVER 2 MEGAOHM. How is that possible, if I am using the same resistor I used to calibrate the pmod, that these results, for that same component, are so unaccurate?



2) (After the calibration with the 100k resistor)... If I place a  10uF capacitor in the connectors, I get the following curve ("Capacitor.png"). Now, the impedance of a capacitor should decrease with frequency according to 1/(2*pi*f*C). The curve I obtained, however, says otherwise. On the other side, the initial value of the impedance (2e+06) is almost the same as in the 100k resistor case, which is very suspicious.



And here things get even weirder (at least to me). To connect the pmodIA with my protoboard I am using two SMA pigtails which carry the signals. 


3) If I leave the circuit opened (using the pigtails) I get the following curve ("opencircuit.png"). This curve displays a peak at a certain frequency and then a decay (and at the end, it grows again). With an opencircuit I would expect to see, however, and +INF impedance, or a very high value (impedance of the air between the connectors).



4) If I take off the pigtails and repeat the same experience (open circuit) I get the following curve (opencircuit_NO_PIGTAILS.png). The results is almost identical, except that the values are lower. 



5) If using the pigtails, I make a shortcircuit between the connectors, I get the following curve (shortcirtuit.png). This curve makes sense (at least a little bit, to me) as it is telling me that the pigtails are acting as inductors (because they are wires) and so that their impedance grows with frequency according to 2*pi*L.



6) If I take off the pigtails and shortcircuit the sma connectors in the pmodIA board directly I get the following curve (shortcircuit_NO_PIGTAILS.png). Again, like in the opencircuit case, the curve is almost identical to the one using pigtails, except that the values are a little bit lower.


Some extra information: I am supplying 3V3 to the pmodIA through the raspberry pi. I am NOT connecting the SEL pin to anything (not GND nor VCC).

How is it possible that I am getting these results? Is there something wrong with my code? Is my board broken?? Is maybe my settling time for the sweep configuration not right?
Do I have to connect the SEL pin to GND or VCC?

I would really appreciate your help as I need to finish this experiment in, at least, 1 month.

Thank you so much for your attention, and let me know if you need more info.

Manu B. Valentin

Link to comment
Share on other sites


Pardon me for asking, but .... why is this marked [URGENT]?  I have no reason to believe that anything [URGENT] will ever be treated any differently from any other request.

I don't personally own a PMod IA.  That said ...

This looks like one of those (common) cases that violates the fundamental assumption in all debugging: that there's only one bug.  :D  I'll start with the first one I see, though ...

Looking at your first chart suggests you have a data interpretation error.  As proof, consider the exceptionally large value within it.  Anything that comes close to this value hits the value.  Likewise there's a not quite so large value (2^23 perhaps?) and anything near it hits the value.  The second chart likewise.  It's as though once the impedence gets large enough, the noise gets out of bounds of either your software, the PMod, or both.  Please double check how you are dealing with the sign bit within your own work.  Be aware that the ARM and the PC have different default signedness for their variables.  (ARM char is unsigned as I recall, PC char is signed.) Judging by the value, I would wager that a 3-byte (24-bit) value is not properly being composed.  I'm also going to wager that a 20k Ohm or lower resistor wouldn't have the problem you are illustrating--not that the problem would be fixed, but rather that you would no longer see it.


Link to comment
Share on other sites


I don't have much in the way of useful advice to offer, but I'm thinking that the SEL pin can probably be left floating since it has a pull-up resistor to Vcc on it, at least according its schematic, so the IC5 is using that 20 Ohm resistor in what kinda looks like a differential amplifier in that lower right hand corner of the schematic. Setting SEL to ground would switch it so that the IC5 is using the 100 kOhm resistor, at least as far as I can tell.


Link to comment
Share on other sites

@D@n, I marked this post as Urgent just to let anyone interested on answering know that it's not a DIY weekend project, but rather that it is important for my work. Sorry if that sounded like I considered this post anyhow more important than the rest of them.

Today I spent the day looking for some inconsistencies or errors in the sign-bit (two complement) conversion as @D@n suggested. This is my updated code: pmodIA_test.tar.

For those who aren't familiar with the pmodIA, in order to calculate the impedance you have to read the values of 4 registers: 2 of them to read the real part of the measure (0x94 and 0x95) and the other 2 to read the imaginary part of the measure (0x96 and 0x97). These values are signed, as explained in the datasheet.  I realized that the original code stored these values into unsigned short variables and I changed that to signed short. Now the computation of the magnitude ( sqrt(Real² + Imag²) )  seems to be correct, as well as the values read from the registers.

Now, I think that the problem I am facing here is related to the conversion between MAGNITUDE (sqrt (real² + imag²)) and IMPEDANCE. In the ad5933 datasheet they say this conversion is achieved by:

IMPEDANCE = (1/ ( gainFactor * MAGNITUDE ) )

Where the gainFactor is calculated using the calibration resistor. I used a 12k resistor (following your advice @D@n) to see if the problem remained. Now, with a 12k resistor the response is not noisy, anymore, however it still shows values that I would never expect to obtain for a 12k resistor.  For this case, the calibration returned: 

Real = -79
Imag = -35
MAGNITUDE = 86.406021
gainFactor = (1/ (MAGNITUDE * CALIBRATION_IMPEDANCE) ) = (1/(86.406021 * 12000) ) = 9.64439e-7

The following curve is the IMPEDANCE response for the 12k resistor. At low frequencies there are quite a lot of spikes and high values. Notice that this curve is actually pretty close to the 'open circuit' ones from my first question in this post.

The following curve is the MAGNITUDE for that same case. 


These spikes are caused by the lower value of Magnitude at low frequencies. 

Now, if I zoom to a range from 15kHz and 1MHz you can see that it actually displays something more reasonable (impedance going from 12k to almost 4k). 



I repeated the test but now using the 200mVpp output range instead of the 2000mVpp I was using, and the noise appeared back (see following curve).


Am I maybe saturating the ADC or something?

@Natsu, thanks for your comment. Take a look at the curve I get when I put SEL to GND:


Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...