B0100111001000011, USA
Offline
Edison Member
Karma: 0
Posts: 1503
I'm confused. Wait, maybe not..
|
 |
« Reply #30 on: March 30, 2010, 10:58:36 pm » |
Awesome. I may just have to order some then  .
|
|
|
|
|
Logged
|
|
|
|
|
B0100111001000011, USA
Offline
Edison Member
Karma: 0
Posts: 1503
I'm confused. Wait, maybe not..
|
 |
« Reply #31 on: April 17, 2010, 11:57:43 am » |
Followup! I'm looking at your code again, Osgeld. I need to make a digikey order anyways, so I find myself again looking at Digital Pots. Looks like you did pretty well, but I'm still kind of confused. #define sLatch 2 #define sClock 3 #define sOdata 4 [glow]#define commandData B00010001[/glow] // command = write to pot 0
byte data;
void setup() { pinMode(sLatch, OUTPUT); pinMode(sClock, OUTPUT); pinMode(sOdata, OUTPUT); Serial.begin(9600); }
void loop() { for(int i = 0; i < 255; i++) { [glow]data += byte(1)[/glow]; digitalWrite(sLatch, LOW); shiftOut(sOdata, sClock, MSBFIRST, commandData); shiftOut(sOdata, sClock, MSBFIRST, data); digitalWrite(sLatch, HIGH); Serial.println(data, BIN); delay(100); } }
The highlighted bits are the ones I don't understand. First up, the "B00010001". I understand from your code that this is you addressing wiper 0, but what I don't understand is how to address the other pot. Is that somewhere in the datasheet? If so, I don't see it anywhere. Secondly, what is the "data += byte(1)"? What is the function of that? Thanks! PS: I did some more searching and I found this about the WP pin: The WP pin is used to force the non-volatile memory to be write protected. I still don't know if it's active low or active high, but I suppose I can figure it out. PPS: I found this now: High Voltage commands are required to enable and disable the nonvolatile WP bit. So I assume that it is off by default, but could be activated? I suppose it should be left NC then.
|
|
|
|
« Last Edit: April 17, 2010, 12:03:10 pm by Tchnclfl »
|
Logged
|
|
|
|
|
SE USA
Offline
Faraday Member
Karma: 35
Posts: 3650
@ssh0le
|
 |
« Reply #32 on: April 17, 2010, 12:18:44 pm » |
#define commandData B00010001 first go back and look at the generic application note for the family (page 1) http://ww1.microchip.com/downloads/en/AppNotes/00746a.pdflook at figure 1, theres 2 bytes that has to be sent to the digipot when you want to change it, the first byte is the command, the second is data from the left ... the first 2 bits of the command byte doesnt do anything, bit 3 puts the pot in a shutdown mode if high, bit 4 says write data if high bits 5 & 6 are dont care just like bits 1 and 2 bits 7 & 8 choose which pot you want to write to in a dual pot package data += byte(1); byte() is a typecast function, so lets say you have data as B11111110, this would be the same as B111111110 + B000000001 -------------
|
|
|
|
|
Logged
|
http://arduino.cc/forum/index.php?action=unread;boards=2,3,4,5,67,6,7,8,9,10,11,66,12,13,15,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,86,87,89,1;ALL
|
|
|
|
B0100111001000011, USA
Offline
Edison Member
Karma: 0
Posts: 1503
I'm confused. Wait, maybe not..
|
 |
« Reply #33 on: April 17, 2010, 12:21:08 pm » |
Ahhh Ok, I fully get it now. Thanks for the help, I'll be placing an order later today  .
|
|
|
|
|
Logged
|
|
|
|
|
B0100111001000011, USA
Offline
Edison Member
Karma: 0
Posts: 1503
I'm confused. Wait, maybe not..
|
 |
« Reply #34 on: April 21, 2010, 05:52:59 pm » |
Grr. I've received my chips, and everything seemed to be going fine, but I can't seem to write data to potentiometer 0. I'm using your code, Osgeld, which works fine for Potentiometer 1 (B00010010), but for some strange reason when I try the same with Potentiometer 0 (B00010001), it fails to work, and the potentiometer appears to be stuck on 127 (half on/off). Any ideas? Here's the code: #define sLatch 2 #define sClock 3 #define sOdata 4 #define commandData B00010001 // command = write to pot 0
byte data;
void setup() { pinMode(sLatch, OUTPUT); pinMode(sClock, OUTPUT); pinMode(sOdata, OUTPUT); Serial.begin(115200); }
void loop() { for(int i = 0; i < 255; i++) { data += byte(1); digitalWrite(sLatch, LOW); shiftOut(sOdata, sClock, MSBFIRST, commandData); shiftOut(sOdata, sClock, MSBFIRST, data); digitalWrite(sLatch, HIGH); Serial.println(data, BIN); Serial.println(analogRead(0)); delay(50); } }
By the way, I've got the wiper plugged into analog input 0 for debugging purposes, that's why you see an analogRead() thrown in there.
|
|
|
|
« Last Edit: April 21, 2010, 05:53:39 pm by Tchnclfl »
|
Logged
|
|
|
|
|
SE USA
Offline
Faraday Member
Karma: 35
Posts: 3650
@ssh0le
|
 |
« Reply #35 on: April 21, 2010, 06:19:27 pm » |
i dunno, I will go poke at it in a few (eating pizza!)
|
|
|
|
|
Logged
|
http://arduino.cc/forum/index.php?action=unread;boards=2,3,4,5,67,6,7,8,9,10,11,66,12,13,15,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,86,87,89,1;ALL
|
|
|
|
B0100111001000011, USA
Offline
Edison Member
Karma: 0
Posts: 1503
I'm confused. Wait, maybe not..
|
 |
« Reply #36 on: April 21, 2010, 06:39:53 pm » |
OK thanks  . I'm still fiddling around with the code and wiring, trying to make it work.
|
|
|
|
|
Logged
|
|
|
|
|
SE USA
Offline
Faraday Member
Karma: 35
Posts: 3650
@ssh0le
|
 |
« Reply #37 on: April 21, 2010, 06:44:44 pm » |
what happens if you send the last 2 bits of the command byte as 11 (both pots)
|
|
|
|
|
Logged
|
http://arduino.cc/forum/index.php?action=unread;boards=2,3,4,5,67,6,7,8,9,10,11,66,12,13,15,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,86,87,89,1;ALL
|
|
|
|
B0100111001000011, USA
Offline
Edison Member
Karma: 0
Posts: 1503
I'm confused. Wait, maybe not..
|
 |
« Reply #38 on: April 21, 2010, 06:46:18 pm » |
Oh sorry, thought I posted that (I posted it on my blog, not here).
If I send the last two as 11, Pot0 appears to still be on 127, and Pot1 appears to be on 255, and don't change.
|
|
|
|
|
Logged
|
|
|
|
|
SE USA
Offline
Faraday Member
Karma: 35
Posts: 3650
@ssh0le
|
 |
« Reply #39 on: April 21, 2010, 07:33:44 pm » |
Im about to upload the sketch, just wondering have you monitored the outputs with a meter?
analog read should be right but a meter is going to be right, just a random thought that popped in ma head
|
|
|
|
|
Logged
|
http://arduino.cc/forum/index.php?action=unread;boards=2,3,4,5,67,6,7,8,9,10,11,66,12,13,15,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,86,87,89,1;ALL
|
|
|
|
SE USA
Offline
Faraday Member
Karma: 35
Posts: 3650
@ssh0le
|
 |
« Reply #40 on: April 21, 2010, 07:45:41 pm » |
well on my 42xxx its working as expected, the "datasheet" (man I hate their datasheets) has some conflicting information (despite what the majority of their app notes say) about the command structure
I dunno, I will look it over meanwhile its on the datasheet linked on your blog page 47, obiously were looking at the 16 bit data structure
|
|
|
|
|
Logged
|
http://arduino.cc/forum/index.php?action=unread;boards=2,3,4,5,67,6,7,8,9,10,11,66,12,13,15,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,86,87,89,1;ALL
|
|
|
|
B0100111001000011, USA
Offline
Edison Member
Karma: 0
Posts: 1503
I'm confused. Wait, maybe not..
|
 |
« Reply #41 on: April 21, 2010, 08:21:23 pm » |
No, I haven't tried with a DMM yet, but I'll get on it. I'll also check out the Datasheet, but let me know if you find anything interesting. I may try some trial and error guessing while I'm at it  .
|
|
|
|
|
Logged
|
|
|
|
|
SE USA
Offline
Faraday Member
Karma: 35
Posts: 3650
@ssh0le
|
 |
« Reply #42 on: April 21, 2010, 08:34:15 pm » |
I have it just about worked out, its totally different from the 42xxx series but it has some advantages, but kinda irritated that their general guides dont make a clear distinction : 
|
|
|
|
|
Logged
|
http://arduino.cc/forum/index.php?action=unread;boards=2,3,4,5,67,6,7,8,9,10,11,66,12,13,15,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,86,87,89,1;ALL
|
|
|
|
B0100111001000011, USA
Offline
Edison Member
Karma: 0
Posts: 1503
I'm confused. Wait, maybe not..
|
 |
« Reply #43 on: April 21, 2010, 08:35:56 pm » |
Wait so you're close to figuring out the mcp4251? That's impressive considering you don't even have any (or do you?) :O.
|
|
|
|
|
Logged
|
|
|
|
|
SE USA
Offline
Faraday Member
Karma: 35
Posts: 3650
@ssh0le
|
 |
« Reply #44 on: April 21, 2010, 08:40:00 pm » |
nope so stick around ;D
|
|
|
|
|
Logged
|
http://arduino.cc/forum/index.php?action=unread;boards=2,3,4,5,67,6,7,8,9,10,11,66,12,13,15,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,86,87,89,1;ALL
|
|
|
|
|