Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Interfacing arduino with DAC MAX531

Status
Not open for further replies.

Vlad.

Full Member level 3
Joined
Jun 4, 2012
Messages
179
Helped
3
Reputation
6
Reaction score
4
Trophy points
1,298
Location
Bucharest/Romania
Activity points
2,568
Hello guys, I am trying to interface arduino uno with SPI DAC from Maxim Integrated (MAX531). The cofiguration i use on this DAC is unipolar configuration. Based on how I understand the datasheet I write a code but doesn't work. If can someone help it will be great.

this is my code
Code:
// inslude the SPI library:
#include <SPI.h>

const int slaveSelectPin = 10;  // set pin 10 as the slave select
const int clrPin=9;          //set pin 9   for  clear DAC >> optional
int max_value=4095;             // max  value   for DAC
int min_value=0;                //min value dor DAC
int value;
int AByte = 0;
int command = 0b000000000000; // 0100  Load input and DAC registers from shift register; DAC output updated.
int data = 0b111111111111; //  desired DAC output.
int commandPlusData = command | data;
void setup() {
  Serial.begin(9600);
// set the slaveSelectPin as an output:
  pinMode (slaveSelectPin, OUTPUT); 
  digitalWrite (slaveSelectPin, HIGH);
  
  pinMode (clrPin,OUTPUT);
  digitalWrite (clrPin, HIGH);      // clear DAC
  // initialize SPI:
  SPI.begin(); 
  
}
void loop() {
 
 
  
  SPI.transfer (highByte (commandPlusData));
  SPI.transfer (lowByte (commandPlusData));
  digitalWrite (slaveSelectPin, HIGH);
   delay(80);
}
 

Try this:
digitalWrite (slaveSelectPin, LOW);
SPI.transfer (highByte (commandPlusData));
SPI.transfer (lowByte (commandPlusData));
digitalWrite (slaveSelectPin, HIGH);
delay(80);
 

Hey, I try you're suggestion but doesnt work. can you verify if i am send the correct data to the DAC?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top