Martha MigliacioAlex Wong
Published © GPL3+

Using the Pmod DA4 with Arduino Uno

Application notes for Pmod DA4 and Arduino Uno. In this app, the ourput voltage A to E ranges from 2.5 V to 0.5 V in increments of 0.5 V.

EasyShowcase (no instructions)1 hour274
Using the Pmod DA4 with Arduino Uno

Things used in this project

Hardware components

Pmod DA4
Digilent Pmod DA4
×1
Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Pmod DA4 and Arduino Uno Fritzing file

Fritzing file displaying the connection of the Pmod DA4 to the Arduino Uno.

Pmod DA4 and Arduino Uno Fritzing Image

Fritzing image displaying the connection between the Pmod DA4 and Arduino Uno.
Pmodda4 arduinouno bb kipkl7eb18

Code

Pmod DA4 and Arduino Uno Code

Arduino
Using this code, the output voltage A to E ranges from 2.5 V to 0.5 V in increments of 0.5 V.
/************************************************************************
*
* Test of the Pmod
*
*************************************************************************
* Description: Pmod_DA4
* The output voltage A to E ranges from 2.5V to 0.5V in steps of 0.5 V
*
* Material
* 1. Arduino Uno
* 2. Pmod DA4
*
************************************************************************/

#define CS 10 // affectation of CS pin

#include <SPI.h> // include library

void setup()
{
 SPI.begin(); // initialization of SPI port
 SPI.setDataMode(SPI_MODE0); // configuration of SPI communication in mode 0
 SPI.setClockDivider(SPI_CLOCK_DIV16); // configuration of clock at 1 MHz
 pinMode(CS, OUTPUT);
 digitalWrite(CS, LOW); // activation of CS line
 SPI.transfer(0b00001000); // configuration of converter N/A (configuration of  REF register)
 delay(1);
 SPI.transfer(0);
 delay(1);
 SPI.transfer(0);
 delay(1);
 SPI.transfer(0b00000001); // configuration of converter N/A (internal reference voltage active
VREF=1,25V)
 delay(1);
 digitalWrite(CS, HIGH); // desactivation CS line
 digitalWrite(CS, LOW); // activation of CS line
 SPI.transfer(0b00000011); // configuration of converter N/A (write output of converter)
 delay(1);
 SPI.transfer(0b11110000); // configuration of converter N/A (8 voutput active)
 delay(1);
 SPI.transfer(0);
 delay(1);
 SPI.transfer(0);
 delay(1);
 digitalWrite(CS, HIGH); // desactivation of CS line
}

void loop()
{
 // la sortie A du convertisseur est à 2,5V
 digitalWrite(CS, LOW); // activation of CS line
 SPI.transfer(0b00000011);
 delay(1);
 SPI.transfer(0b00001111);
 delay(1);
 SPI.transfer(0b11111111);
 delay(1);
 SPI.transfer(0);
 delay(1);
 digitalWrite(CS, HIGH); // desactivation of CS line
 // la sortie B du convertisseur est à 2V
 digitalWrite(CS, LOW); // activation of CS line
 SPI.transfer(0b00000011);
 delay(1);
 SPI.transfer(0b00011100);
 delay(1);
 SPI.transfer(0b11001101);
 delay(1);
 SPI.transfer(0);
 delay(1);
 digitalWrite(CS, HIGH); // desactivation of CS line
 // la sortie C du convertisseur est à 1,5V
 digitalWrite(CS, LOW); // activation of CS line
 SPI.transfer(0b00000011);
 delay(1);
 SPI.transfer(0b00101001);
 delay(1);
 SPI.transfer(0b10011010);
 delay(1);
 SPI.transfer(0);
 delay(1);
 digitalWrite(CS, HIGH); // desactivation of CS line
 // la sortie D du convertisseur est à 1V
 digitalWrite(CS, LOW); // activation of CS line
 SPI.transfer(0b00000011);
 delay(1);
 SPI.transfer(0b00110110);
 delay(1);
 SPI.transfer(0b01100110);
 delay(1);
 SPI.transfer(0);
 delay(1);
 // la sortie E du convertisseur est à 0,5V
 digitalWrite(CS, LOW); // activation of CS line
 SPI.transfer(0b00000011);
 delay(1);
 SPI.transfer(0b01000011);
 delay(1);
 SPI.transfer(0b00110011);
 delay(1);
 SPI.transfer(0);
 delay(1);
 digitalWrite(CS, HIGH); // desactivation of CS line
}

Credits

Martha Migliacio

Martha Migliacio

5 projects • 5 followers
Alex Wong

Alex Wong

5 projects • 13 followers
I work in Digilent and like creating projects
Thanks to Lextronics.

Comments

Add projectSign up / Login