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:
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.