• 0
Yacov Cohen

PmodAD5 evaluation

Question

I ordered 2 PmodAD5 units order date 10/30/2017 #20049599 customer ID 39763

tested the voltage mode on 2 software's. The one  Ad7193_VoltageMeasure_Example and the second one  Code from Hackester.io for voltage measuring  and got similar results

Pmod  AD5 Test

 

Power supply measured voltage        Measured by PmodeAD5          Ratio

0.6                                                                0.288                                          0.48

0.7                                                                 0.38                                            0.542

0.9                                                                0.584                                             0.650

1.0                                                                 0.675                                            0.675

What I need is linear voltage measurement.

Can you help on this please?

Yacov

Mailyacovcohen@gmail.com

 

Question 2

On Hackester.io Martha is suggesting a direct connection of PmodAD5 to Arduino Uno using 5 Volt.

I need a measurement from 0 to 3.5 Volt.

How bad is to use 5 volt (on heavy duty  instrument)?

Share this post


Link to post
Share on other sites

Recommended Posts

  • 0

Hi Jon,

Thank you for your quick response.  

When running the AD7193_VoltageMeasure_Example on Arduino Uno I am getting the following results:
Instead of measuring 0.6 Volt I am getting a reading on serial monitor of 0.288 Volt.
Instead of reading 1 Volt I am getting 0.675 Volt on serial monitor.

What I need is a display of the correct voltage. At the beginning I thought that I have only to multiply the results by a factor but it is not true.

Can you please Help. 

 I prefer to work using 5 Volt as I have to measure 0 to 3.5 Volts and I can not use a simple resistive divider as the source may change internal impedance. So am I taking any risk to burn the device?

Thank u

 

 

 

Share this post


Link to post
Share on other sites
  • 0
8 hours ago, jpeyron said:

Hi @Yacov Cohen,

Could you please elaborate on "What I need is linear voltage measurement?" and "How bad is to use 5 volt (on heavy duty  instrument)?".

thank you,

Jon

Hi Jon,

Thank you for your quick response.  

When running the AD7193_VoltageMeasure_Example on Arduino Uno I am getting the following results:
Instead of measuring 0.6 Volt I am getting a reading on serial monitor of 0.288 Volt.
Instead of reading 1 Volt I am getting 0.675 Volt on serial monitor.

What I need is a display of the correct voltage. At the beginning I thought that I have only to multiply the results by a factor but it is not true.

Can you please Help. 

 I prefer to work using 5 Volt as I have to measure 0 to 3.5 Volts and I can not use a simple resistive divider as the source may change internal impedance. So am I taking any risk to burn the device?

Thank u

Share this post


Link to post
Share on other sites
  • 0

Hello @Yacov Cohen,

I don't know what library files are being used on the "Ad7193_VoltageMeasure_Example", but if it's based on the same set of libraries used in the hackster.io project that you also linked to, what you are encountering is that a number of the settings done by the libraries (mostly the default settings of the AD7193 chip) are not suitable to your application.

With the PGA gain set to 1, you will also want to change the reference select bit (bit 20) in the Configuration Register (pg 27 of the datasheet) so that the Pmod AD5 uses an externally supplied reference voltage (5 V will work in your case) rather than the default internal 2.5 V reference. Note that you will need to remove jumper JP1 if the digital logic levels you are using are not based with 5V as the logic high.

Since you are looking to measure values between 0 and 3.5 V, either unipolar or bipolar mode will work for your application, but I would recommend unipoloar mode to make the conversion of resulting 24-bit data code back to the detected voltage value a bit easier, based on the equations provided on page 33 of the datasheet. To use unipolar mode, bit 3 in the configuration register will need to be set.

If the registers are set correctly, I do not anticipate on any damage being done to the Pmod.

Let me know if you have any further questions.

Thank you,
JColvin

Share this post


Link to post
Share on other sites
  • 0

JColvin,

Thank you for your detailed answer,

Lets omit the issue that I intend to measure 3.5 Volts.

I am running the AD7193_VoltageMeasure_Example using the library as explained on EnginnerZone: https://ez.analog.com/blogs/annem/2017/03/20/ad7193-arduino-tutorial 

As I Mentioned previously I am getting non linear Voltage measurement

Power supply measured voltage        Measured by PmodeAD5                            Ratio

0.6                                                                0.288                                          0.48

0.7                                                                 0.38                                            0.542

0.9                                                                0.584                                             0.650

1.0                                                                 0.675                                            0.675
 

Can you please help on this specific issue?
Thanks again

Y.

Share this post


Link to post
Share on other sites
  • 0

Hi @Yacov Cohen,

I took a look through the libraries more thoroughly and it all seems to be performing correctly in terms of register manipulation; we're working on testing the hardware ourselves but a combination of software not working on one computer with the other engineer out of office without the hardware is plaguing us; we hope to test this ourselves early next week.

One question I do have though is which analog inputs are you using on the Pmod AD5? From what I am able to tell in the example code for both the voltage measure example and the thermocouple example tutorial you linked to, the code is using Channel 1, which corresponds to the differential pair A3 and A4 on the Pmod AD5, as opposed to A1 and A2 (Channel 0) which the tutorial shows in their picture.

I'm sorry for the delay in this.

Thank you,
JColvin

Share this post


Link to post
Share on other sites
  • 0

This is the example I am running:

  

Spoiler

 

/*

 

AD7193_VoltageMeasure_Example

 

Configures and calibrates the AD7193 to measure differental voltage on AIN1 and AIN2

 

Tutorial can be found at <TBD>, and uses the PmodAD5 from Digilent.

 

Signal Connections:

-----------------------------------------------------

 Signal Name |  PmodAD Pin  |  Arduino Pin

-----------------------------------------------------

  ~CS        |  J1, Pin 1   |  10

  MOSI       |  J1, Pin 2   |  MOSI or 11 or ICSP-4

  MISO       |  J1, Pin 3   |  MISO or 12 or ICSP-1

  SCLK       |  J1, Pin 4   |  SCLK or 13 or ICSP-3

  GND        |  J1, Pin 5   |  GND

  VCC (3.3V) |  J1, Pin 6   |  3.3V

-----------------------------------------------------

 

-----------------------------------

 Signal Name       |  PmodAD5 Pin   

-----------------------------------

 Channel 1 Pos     |  J2, Pin 3

 Channel 1 Neg     |  J2, Pin 4

-----------------------------------

See Table 24 of AD7193 datasheet for more information

 

Reference:

https://reference.digilentinc.com/reference/pmod/pmodad5/start

https://www.arduino.cc/en/Reference/SPI

 

Created 4 Oct 2016

by Anne Mahaffey

 

This example code is in the public domain

*/

 

 

 

 

 

 

#include <SPI.h>

#include <AD7193.h>

 

 

AD7193 AD7193;

 

void setup() {

 

  ///////////////////////////

  // setup Serial and SPI

  ///////////////////////////

 

  Serial.begin(9600);

  delay(1000);

 

  while (!Serial) {

    ; // wait for serial port to connect. Needed for native USB port only

  }

 

  AD7193.begin();

 

 

  ///////////////////////////////////

  // Device setup

  ///////////////////////////////////

 

  //This will append status bits onto end of data - is required for library to work properly

  AD7193.AppendStatusValuetoData(); 

 

  // Set the gain of the PGA

  AD7193.SetPGAGain(1);

 

  // Set the Averaging

  AD7193.SetAveraging(100);

 

 

  /////////////////////////////////////

  // Calibrate with given PGA settings - need to recalibrate if PGA setting is changed

  /////////////////////////////////////

 

  AD7193.Calibrate();

 

  // Debug - Check register map values

  AD7193.ReadRegisterMap();

 

  //////////////////////////////////////

 

  Serial.println("\nBegin AD7193 conversion - single conversion (pg 35 of datasheet, figure 25)");

}

 

 

void loop() {

 

  unsigned long ch1Data;

  float ch1Voltage;

 

  // Read channel measurement data

  ch1Data = (AD7193.ReadADCChannel(1) >> 8);

 

  Serial.print("  CH1 data: ");

  Serial.print(ch1Data, HEX);

 

  // Convert to voltage

  ch1Voltage = AD7193.DataToVoltage(ch1Data);

 

  Serial.print("\n\t\tChannel 1 Voltage Measurement: ");

  Serial.println(ch1Voltage, 8); 

  

  delay(2000);

}

 

 

 

 

 

 

 

 

Edited by JColvin
made into spoiler for visual compactness

Share this post


Link to post
Share on other sites
  • 0

Hi @Yacov Cohen,

I set up the Pmod AD5 with the same code and library that you were using and received the following results:

Voltage supplied     Voltage measured by AD5

0.6 V                                     0.596 V
0.7 V                                     0.696 V
0.8 V                                     0.795 V
0.9 V                                     0.895 V
1.0 V                                     0.994 V

I have attached a picture of my setup as a visual reference with the input voltage on A3 and ground on A4: https://forum.digilentinc.com/gallery/image/120-pmod-ad5-setupjpg/

Is your setup very similar to mine?

Thank you,
JColvin

 

 

Share this post


Link to post
Share on other sites
  • 0

Dear JColvin

It is inbreeding.
I attached that print screen.  You can see I am using the suggested library and running the correct example SnipImage.JPG1SnipImage.JPG1SnipImage.JPG1SnipImage.JPG1

I am sampling 1 volt and this is what I get.

Can you please sent me the file you are using end the exact library?

Please, please help
also I am over

Yacov

 

SnipImage.thumb.JPG.a5bbfb2adc2a5e0a4cf84a69784f7671.JPG 

Share this post


Link to post
Share on other sites
  • 0

Here you can see that I am sampling 1 Volt

Also I am abroad I will be more than happy if you can take control on my computer.  May be I am asking 2 much..................

SnipImage.JPG

Share this post


Link to post
Share on other sites
  • 0

Hi @Yacov Cohen,

I happened to find an Arduino UNO around the office, so now our setups should be the same. However, I still received the same results as I stated before; I even changed which channel I am measuring and still received the expected results. The file I am using is here, with the .cpp library file here and the .h library file here.

However, I did find something that might apply to your setup that could get the results you are seeing. How are you supplying the 1V differential across the pins? Are you supplying 1 V to A3 and 0V (ground) to A4? The thing that you don't want to do is supply any sort of negative voltage, even if it mathematically works out to be 1V (such as supplying 0V to A3 and -1V to A4), since the AD7193 is not equipped to handle negative voltages.

Thank you,
JColvin

Share this post


Link to post
Share on other sites
  • 0

Thank you for the big help you gave!!!!

Now I need to change to external Vref.

As I am beginner it will be very helpful for me if you can write me the code line to change the reference select bit (bit 20)  as you wrote me previously in the Configuration Register (pg 27 of the datasheet) so that the Pmod AD5 uses an externally supplied reference voltage (5 V will work in your case) rather than the default internal 2.5 V reference. Note that you will need to remove jumper JP1 if the digital logic levels you are using are not based with 5V as the logic high.

Share this post


Link to post
Share on other sites
  • 0

Hello @Yacov Cohen

I apologize for the delay. Since you are using an Arduino board which uses a 5V digital IO and are supplying 5V to the chip (both as a digital source and analog source), you won't need to worry about removing JP1; for your reference, it's next to pin 1 on the Pmod header on the physical board.

In terms of changing the reference voltage used, you'll want to change bit 20 in the Configuration register, which will be very similar to the already existing function in the library that changes the gain in the Configuration register.

Let me know if you have any questions.

Thanks,
JColvin

Share this post


Link to post
Share on other sites
  • 0

Hello JColvin,

If JP1 is connected now it means that the A/D gets 2.5 so may be it is right to connect 3.3 Volts instead the Jumper.

What is your opinion.

I am glad that you help.

Yacov

Share this post


Link to post
Share on other sites
  • 0

Hi @Yacov Cohen,

The 2.5V is a reference voltage used by the ADC, it is not the main power source of the ADC. Based on the image you provided, you are providing 5V to both the digital pins and to power the embedded ADC.

Thank you,
JColvin

Share this post


Link to post
Share on other sites
  • 0

 

Hi,

Sorry about missing the description.  I intended to ask if there is a need to  "you'll want to change bit 20 " as by taking out the J1 jumper and connecting to the pin of J1 going to Vref of the 3.5 Volt is not enough ?

Thanks

Yacov 

Share this post


Link to post
Share on other sites
  • 0

Hi @Yacov Cohen,

Ah, I see. No, removing JP1 will not compensate for changing bit 20. JP1 is only there to help prevent any conflicts between voltage sources. The reference voltage (by default internal to the Pmod AD5) restricts what range the ADC can measure, limited to +/-Vref/gain, as shown on page 5 in the datasheet in the specifications table. So if you wanted to measure any value greater than 2.5 V (or less than -2.5V) you will need to change the bit 20 so that you can use pins 10 and 11 on header J2 as your external reference voltage.

Thanks,
JColvin

Share this post


Link to post
Share on other sites
  • 0
On 12/15/2017 at 2:43 AM, JColvin said:

Hi @Yacov Cohen,

Ah, I see. No, removing JP1 will not compensate for changing bit 20. JP1 is only there to help prevent any conflicts between voltage sources. The reference voltage (by default internal to the Pmod AD5) restricts what range the ADC can measure, limited to +/-Vref/gain, as shown on page 5 in the datasheet in the specifications table. So if you wanted to measure any value greater than 2.5 V (or less than -2.5V) you will need to change the bit 20 so that you can use pins 10 and 11 on header J2 as your external reference voltage.

Thanks,
JColvin

hello sir @JColvin,

i am using arduino uno connected with pmodAD5 and using the same library and same voltage measure code as discussed here. but instead of a constant voltage input , i am providing a signal from signal generator as an input to my channel 1 on header J2 , BUT Unfortunately when i plot the digital output generated corresponding to different signals (sine waves with varying frequency) i don't get the same result as the applied input signal. 

so what can be the issue?? is this voltage measure code capable of measuring an alternating signal from signal generator with correct samples?? and how do i change the sampling rate in this code (if it is capable of giving correct outputs). i hereby attach the code and library again.

thanks

AD7193_Voltage_measure_modified.ino

AD7193.cpp

AD7193.h

Edited by virk_ps

Share this post


Link to post
Share on other sites
  • 0

Hi @virk_ps,

What is the frequency rate of the signal you are providing? The code as is has a 1 millisecond delay (as indicated by the delay(1) function at the end of the loop function), so the data collection is currently capped at a rate of 1 kHz. If you removed that delay, you would likely be limited by the Pmod AD5 hardware (the embedded AD7193) to a data rate of 4.8 kHz.

Thanks,
JColvin

 

Share this post


Link to post
Share on other sites
  • 0

hi @JColvin

i have tried different input signals from 1Hz to 60Hz (sine waves , triangular , ramp etc.) as input to the pmodAD5 , i was able to get correct samples at lower frequencies 1-3Hz but at higher frequency the samples when plotted didn't replicate the input signal , maybe because i was not able to set the correct sampling rate. from the data sheet i got to know that sample reate can be changed by mode register value , and by default it is set as 6 samples/sec. So , can you please tell me how can i make changes to value of mode register in the library of AD7193 as attached . and please tell me what is the significance of function SetAveraging(int filter rate) in the library?

Thanks 

AD7193.cpp

AD7193.h

Edited by virk_ps

Share this post


Link to post
Share on other sites
  • 0

Hi @virk_ps,

You can adjust the default data rate by using the SetRegisterValue function. More specifically, using the values defined in AD7193.h:

SetRegisterValue(AD7193_REG_MODE, 0x080001, 4, 1);

Based on the information shown on pages 24, 25, and 43 of the AD7193 datasheet, this should set an output data rate of ~4.8 kHz (based on the equation ODR = 4.92 MHz / (1024 * FS[9:0]) ) with a settling time of about 625 microseconds (based on the equation settling time = 3/ODR). Also from page 24 of the datasheet, the SetAveraging function will implement a first order average for either 1, 2, 8, or 16 samples; this will reduce the output data rate for a given result sent to the host board, but the rms noise will improve.

Thanks,
JColvin

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now