• 0
Sign in to follow this  
Yacov Cohen

PsuedoDifferential measurements on PmodAD5

Question

Trying to use PsuedoDifferential measurements. See software bellow posted by Anne. By obvious there are some mistakes on original script. 

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);
}

Share this post


Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

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
Sign in to follow this