Hardware components | ||||||
| × | 1 | ||||
| × | 1 | ||||
Software apps and online services | ||||||
|
This application note was designed to display the result of the A/D conversion of the AIN1 channel on the serial monitor.
Pmod AD5 and Arduino Uno Code
ArduinoUsing this code will display the result of the A/D conversion of the AIN1 channel on the serial monitor.
/************************************************************************
*
* Test of the Pmod
*
*************************************************************************
* Description: Pmod_AD5
* The result of the A / D conversion of the AIN1 channel is displayed on the serial monitor.
*
*
* Material
* 1. Arduino Uno
* 2. Pmod AD5 (do not touch the jumper and
* dowload library https://github.com/annem/AD7193)
*
************************************************************************/
#include <SPI.h> // Call of libraries
#include <AD7193.h>
AD7193 AD7193; // Creation of the object AD7193
unsigned long valeur;
float tension;
void setup()
{
Serial.begin(9600); // initialization of serial communication
Init_AD7193();
}
void loop()
{
valeur = AD7193.ReadADCChannel(0); // conversion A/N on input 1
valeur = valeur >> 8; // Extraction of value
tension = AD7193.DataToVoltage(valeur); // Recovery of tension
Serial.println("");
Serial.print("Valeur=");
Serial.print(valeur);
Serial.print('\t'); // tabulation
Serial.print("Tension=");
Serial.print(tension);
Serial.println("V");
}
// Initialisation du module Pmod AD5
void Init_AD7193(void)
{
AD7193.begin(); // initialization of Pmod AD5 module
AD7193.AppendStatusValuetoData(); // configuration of Pmod AD5 module
AD7193.SetPGAGain(1);
AD7193.SetAveraging(100);
AD7193.Calibrate();
AD7193.ReadRegisterMap();
}
Thanks to Lextronics.
Comments