Pages: [1]   Go Down
Author Topic: Maxim MAX5500 DAC with SPI  (Read 1707 times)
0 Members and 1 Guest are viewing this topic.
Belgium
Offline Offline
Newbie
*
Karma: 0
Posts: 38
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm trying to use the MAX5500 with Arduino, but so far it doesn't work.

Here's the code I tried:
Code:
  //spi
  digitalWrite(chipSelectPin, LOW);
  int dac1 = 4095;
  dac1 += 3 << 12; //3 = 0011 -> load input A, update DAC
  SPI.transfer(dac1 >> 8);
  SPI.transfer(dac1 & 255);
  digitalWrite(chipSelectPin, HIGH);
If I understand the data sheet correctly, this should set output A to its max value, but it remains at 0V together with the other outputs.

Does anyone know if there's anything else that needs to be setup in order to make this work?
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 439
Posts: 23728
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You are not sending nearly enough data over:
"The serial input word consists of
two address bits and two control bits followed by 12
data bits (MSB first), as shown in Figure 4."
Each SPI.transfer sends out 1 byte - so you will need 6 4 bytes.

How are the other controls wired up on the chip?
« Last Edit: April 27, 2011, 02:45:19 pm by CrossRoads » Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Belgium
Offline Offline
Newbie
*
Karma: 0
Posts: 38
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

16 bits are 2 bytes, and I'm sending 2 8-bit values.
The first 4 bits are set to 0011 using "dac1 += 3 << 12;"
The other 12 bits are set to one with "dac1 = 4095"
"dac1 >> 8" should send the most significant byte, and "dac & 255" the least significant byte.
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 439
Posts: 23728
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

"Sends and receives a byte from the SPI bus.
Example:
n = Spi.transfer(0x2A);            // sends the byte 0x2A"

You need 4 spi.transfer calls to send 4 bytes of data.
You must send the data bytes out also even if they are don't cares - the data sheet says 4 bytes all the time.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Belgium
Offline Offline
Newbie
*
Karma: 0
Posts: 38
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I read the datasheet again, but I don't see where it says to send out 4 bytes.

I only find these references to 16-bit:
"The serial input word consists of two address bits and two control bits followed by 12 data bits (MSB first)"
(2+2+12=16 bits = 2 bytes)
"The MAX5500/MAX5501 require 16 bits of serial data."
"Data is sent MSB first and can be sent in two 8-bit packets or one 16-bit word"
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 439
Posts: 23728
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yeah, you're right, I was misreading that.

Try a simpler set up to start:
Code:
high_btye = 0x3F;
low_byte = 0xFF;
digitalWrite(chipSelectPin, LOW);
  SPI.transfer(high_byte);
  SPI.transfer(low_byte);
  digitalWrite(chipSelectPin, HIGH);

sometimes the complex directions within directions don't work.
If that works, just manipulate the variables outside of the transfer command.

How is this pin wired?
Pin 6, REFAB, DAC A/DAC B Reference Voltage Input
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Pages: [1]   Go Up
Jump to: