Daisy Chaining Different SPI Controlled Digital Potentiometers

Working on a project, and I have run into an issue that I'm having trouble wrapping my head around.

I'm in need of a wide range variable resistance to simulate an NTC thermistor. I need to simulate a lot of these, so I'm trying to daisy chain multiple digital pots to get the resistances I need with minimal required CS pins. I'm a little new to SPI, so that may be half the issue.

What I have right now is an Arduino Mega2560 and an Analog Devices AD5262 200K pot and AD5174 10K pot. The AD5262 is dual channel and 255 steps. The 10K is single channel and 1024 steps. The 10K is to fine tune the final resistance value. Datasheets are below:

http://www.mouser.com/ds/2/609/AD5260_5262-246472.pdf http://www.mouser.com/ds/2/609/AD5174-278608.pdf

The AD5262 requires 9 bits. The leading bit is the channel designator (0 for channel A, 1 for channel B), and the remaining 8 bits defines the wiper position. The AD5174 has 4 leading control bits (I'm only interested in the standard operating mode, which is 0001), and 10 bits for wiper position.

As of right now, I realize that the SPI library sends data in 8-bit chunks (sending vars any longer end up getting clipped back down to 8 bits).

The pots are set up with the 200K getting data from the Mega first, and the 10K connected to the MISO line of the 200K. I've had the 200K working fine on it's own, but I can't seem to get things working on either pot when they are daisy chained. I've been using bit-wise shifting to cut the data up into smaller chunks. On the logic analyzer, the data is getting clocked in correctly, but the data on the MISO pin of the 200K doesn't seem to make sense. From what I understand of SPI, if you clock 8 bits in, the previous 8 bits should be pushed out the MISO pin, so if you were to push a value of 100 once, and then 200, you should see a value of 100 coming out.

So it seems like the incoming buffer on the chip is not quite what I'm interpreting it to be. In my mind, it should be a 9 bit buffer, so as long as I push the 14 bits for the 10K through first, then the 9 bits for the 200K, everything should have the right data in place when the CS line goes high again and commits the data. The documentation for diasy chaining the 200K infers that the buffer is 8 bit, but it covers the single channel and dual channel version of the chip, where the single channel has no address bit, and only deals with 8 bits total. The 10K daisy chaining documentation infers that it's 16 bit.

When I had the 200K working by itself, I was sending one byte with the address, followed by the wiper position byte. Worked fine.

Can anyone with more SPI experience take a look at the datasheets and give me an idea as to why my approach to this is not working? Am I just not sending enough data through? Is the address bit of the 200K tripping me up?

Thanks in advance.

I read the datasheet as saying two separate 9 bit transfers are needed for each channel of the AD5262. Each must complete with CS/ going high so the address select bit can be latched in. So you can probably daisy chain, with 18 bits, 9 bits going to one register on each chip.

Or send out 3 bytes (24 bits), with 9+9+6 bits that will be ignored. Send it out twice. Toggle the Address bit in each group of 9 so that both registers get written.

It might only work if you have two of the same device. And it might only work if you have devices which can use 8 bit messages. I can't see how 9 bit messages are going to work very well with spi.

With the scenario which you have described, my advice would be to give up and use two CS lines.

If you had two of the 9bit devices, the instructions are telling you that it will keep the last 18 bits. So, send 3 bytes of data, and the first six bits sent will be disregarded.

The 5174 description says it is fussy about getting 32 bits, not 31 or 33, even though it actually uses less bits than that. It says that, but what it actually requires is exact multiples of 16 bits.

So, I would connect the 5174 closest to the arduino, and the other device after that. And then send 7 dummy bits, and then 9 real bits for the other device, and then 16 bits for the 5174.

That way, the 5174 will see 32 bits passing through so its counting will be happy. The other device will keep the last 9 bits that it gets.

The catch with this, would be activating both channels of the second device. I think the way to deal with this would be to send the whole sequence twice.

can we get spi code library for atmega 1280?

Thanks all for the tips. With what you have said so far, and a little thinking on my part over night, I think it might be set up as follows:

  • The AD5262 does have an 8 bit buffer. It seems that it requires the buffer to be filled twice, once with the address, and again with the data. This is why it works when you send two bytes from the Arduino.
  • The AD5174 might be set up the same way as the AD5262, but with a 16 bit buffer, with the 4 control bits and 2 data bits in the first byte, and the remainder of the data in the second byte.
  • If the above theories are true, then I will have to send 32 bits to the bus to get the data correct through both devices. Right now, I'm only sending 24 bits (3 bytes), and that might be where I'm getting tripped up.

I'll give a few configurations a try, first with the way I have it, but with more bits. If that isn't working, I'll try addressing the AD5174 individually to see what particular quirks it has, and then maybe putting it first in the chain with the AD5262 behind it.

Stay tuned :)

I know it's been a while since I originally posted this question, but over the last month, I have found out a lot and would like to share

  • It looks like the Atmega micros are limited to 8-bit transfers on the hardware SPI port. This makes life difficult when trying to daisy chain devices that don't use buffers in 8-bit multiples
  • With the AD5262, daisy chaining them requires 9-bit transfers. This forces you to bit-bang SPI, which is really easy
  • If anyone is going to use the AD5174 (high resolution pot), you HAVE to have a 2.2K pull up on the SDO line, even if you aren't using it. Took a long time to figure that one out. Little SOB would just sit there and laugh at you no matter what command you send.
  • Once you do add the pull up resistor, make sure you send the enable command. The input buffer is write protected until you send that command.
  • The AD5174 is a Mode 1 device (logic high clock, data clocked in on trailing edge), but it seems that it only needs to see that once. I used the enable message as Mode 1, but sent everything else as Mode 0 (logic high clock, data clocked in on rising edge). Worked fine.
  • If daisy chaining multiple devices, use devices with the same buffer size. Most chips are too smart for their own good, and have internal counters on the input buffer. This messes with the outgoing data (clocked out on the wrong pulses). It's much easier to keep everything the same across all devices.
  • Don't trust the formula that Analog Devices uses in the data sheets for calculating the output resistance. It's not even close. You would be better off running it through each step and recording the resistance yourself. I found the 200K AD5262 to read over 213K at full range. The AD5162 and AD5174 had similar issues.

Hopefully this information will be useful to someone trying to use these digital pots or similar.