Log in

View Full Version : Digital pot 257 steps - confused!



HankMcSpank
- 9th September 2010, 00:28
Well, after a bit of to-ing & fro-ing, I've managed to get my digital pot controlled via a PIC using SPI.

One puzzlement disappears (how to get SPI working), but another one surfaces ........... I bought a 257 position pot (an MCP44251 - http://ww1.microchip.com/downloads/en/DeviceDoc/22060b.pdf ) *But* check this out.

If I send this...

command = %00000000 (ie a write command)
r_value = %111111111 (ie 'a wiper value of 255' or just 2 away from the 257 step maximu value) I see this...

http://img409.imageshack.us/img409/9480/36257420.jpg (http://img409.imageshack.us/i/36257420.jpg/)

(green trace is the input to the pot, yellow trace is the wiper out)

In other words, the signal is nowhere near maximum?

If I send it this...

command = %00000001
r_value = %10000000

It gets a little bigger...

http://img175.imageshack.us/img175/5715/81977059.jpg (http://img175.imageshack.us/i/81977059.jpg/)


I *can* actually get the wiper output signal to maximum (ie output = to the input signal) by sending this to the pot...

command = %00000010
r_value = %00000000

So bearing in mind the data byte is 8 bits... it appears that this digipot also uses 2 bits from the command byte - that's 10 bits....so how come 257 steps?

What gives?!!

And also the fact that it uses 8 bits in a data (wiper value) byte...but also 2 bits from the command byte (least signifcant bits) ....that's got my head spinning how I approach controlling the pot in practise? (ie with the wiper control bits breaching byte boundaries) What's the std here?!!

HankMcSpank
- 9th September 2010, 01:47
ok, i'M burning the midnight oil - and after spending ages on this problem, almost the minute after I posted here i sorted it. :rolleyes:

Here was the offender (on my PIC)..



SSPSTAT.6 = 0


it should be SSPSTAT.6 = 1 ....... I reckon that due to that setting (clock edge to tx data on) my digipot was therefore missing a data bit ...which essentially offset the data I was sending it. (which didn't cause a knockon effect to the command byte, because the digipot SPI control bits are i the middle of the first byte sent & were all zeros)