Jump to content
  • 0

PmodAD5 evaluation


Yacov Cohen

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)?

Link to comment
Share on other sites

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

hi @JColvin

Thanks for your valuable and to the point solution to my problem , Sir! but the value of register address should be 0x80060 as according to datasheet? why do we need to give 0x80001?

And also can you please elaborate on "

2 hours ago, JColvin said:

SetAveraging function will implement a first order average for either 1, 2, 8, or 16 samples

as i can give the int filter rate , the values upto 1023 . so what does all these values suggest? what will be the significance of this int filter rate.

in my application i want to capture the real time signals from the geophone which are very small in amplitude (1mV) and frequency (under 500 hz) , so can you please tell me the significance of that filter rate in context of this .

Thanks

Link to comment
Share on other sites

Hi @virk_ps,

I gave that value to get the highest frequency rate possible. If you wish to use an alternate frequency, you will need to calculate the corresponding FS bits by the following equations:

FS[9:0] = 4920000 / (1024 * desired frequency)

The filter rate does not go up to 1023, it only has options of 1, 2, 8, or 16 (0x00, 0x01, 0x10, or 0x11). The filter will only matter if you care about noise, but with a low frequency rate, you likely will not need the filter.

Thanks,
JColvin

Link to comment
Share on other sites

hi @JColvin

thanks for the quick response , but i still have a confusion .

i hereby add two images , and i have a confusion in     

void AD7193::SetAveraging(int filterRate)

what is the meaning of this-

 registerMap[1] &= 0xFFFC00; //keep all bit values except filter setting bits
 registerMap[1] |= filterRate;

and after this we call -

SetRegisterValue(1, registerMap[1], registerSize[1], 1); 

isn't it the same as you told me , to set the data rate to max ~4.8KHz?? (please find the attached images for registerMap[1], registerSize[1] )

Thanks

 

 

SetAveraging_.PNG

SetAveraging.PNG

Link to comment
Share on other sites

Hi @virk_ps,

Oh, I see what you are saying now; I apologize for the confusion. Yes, this function does not perform the way that it should; it is currently controlling the frequency rate rather than the averaging functionality. Digilent did not create this library (I'm not certain who did since there is no accreditation at the top of either library file), but in the interest of keeping of this current function (since it works, just for a different thing) and creating the correct function, I have attached the new library files for this.

Let me know if you have any questions about this.

Thanks,
JColvin

 

 

AD7193.h

AD7193.cpp

Link to comment
Share on other sites

Hello @JColvin

thanks for your timely reply Sir!

i just went through the new library you just provided me , but i found it to be exactly the same as previous one and still i am unable to solve my problem. even after changing the value of mode register to the value you have suggested me , i still get 7-8 samples/sec . 

i have an another option of using raspberry pi instead of arduino but i have no idea how can i interface pmodAD5 with it ? and get my samples running out on terminal.

it would be helpful for me if you can help me and guide me about how can i go forward with running pmodAD5 with pi!

thanks

Link to comment
Share on other sites

Hi @virk_ps,

I'm not sure what happened on those libraries, I'll see if the ones I re-attach are the ones I am clicking on...yep, I was grabbing them from the wrong location. I'll update the previous post as well with this libraries to help prevent confusion on this.

I don't have very much experience with the Raspberry Pi, so I won't be very much help there. It looks there is a forum thread here that seems they perhaps got it working.

AD7193.cpp

AD7193.h

Link to comment
Share on other sites

Trying to use PsuedoDifferential measurements. See software bellow posted by Anne

There are some bugs I tried to repair, here is the modified software  set ground on pin 9 placed +1 volt to pin1 AIN1 ground of voltage source AINCOM (pin9) but could not get results.

Please Help

 

 

the program

/*

AD7193_VoltageMeasurePsuedoDifferential_Example

Configures and calibrates the AD7193 to measure psuedo-differential voltage on channel 6

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 6 Pos     |  J2, Pin 7
 AINCOM            |  J2, Pin 9
-----------------------------------
See Table 24 of AD7193 datasheet for more information


Refer to:
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
  ///////////////////////////////////
 
  AD7193.AppendStatusValuetoData();  //This might be a requirement - functions will be simpler if I can assume this is true 
 
  AD7193.SetPGAGain(1);

  AD7193.SetAveraging(100);

  // sets input to measure across channel input and AINCOM pin
  AD7193.SetPsuedoDifferentialInputs();

  /////////////////////////////////////
  // 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\tChanne1 1 Voltage Measurement: ");
  Serial.println(ch1Voltage, 3); 
  
  delay(100);
}

 

 

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 

Link to comment
Share on other sites

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

 

 

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...