Shop OBEX P1 Docs P2 Docs Learn Events
SHIFTOUT with MCP42 — Parallax Forums

SHIFTOUT with MCP42

gemeyergemeyer Posts: 7
edited 2004-11-12 17:41 in BASIC Stamp
Has anyone been succesful using SHIFTOUT to control a MCP42 digital potentiometer? Reading the specs makes me think it should work but it is not recognizing any commands. The MCP42 is from Microchip and I ordered it from Jameco.

Comments

  • gemeyergemeyer Posts: 7
    edited 2004-11-09 12:16
    I guess this forum is not the best place for help with this. Can anyone suggest where I might go for assistance talking to the MCP42 from a BSp? Thanks!
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-11-09 13:42
    Perhaps you'll get more assistance by attaching a data sheet for that part to your post. As Gerry Maguire said in the movie, "Help me help you...."

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2004-11-09 14:18
    gemeyer -

    You don't state any specific problem you're having, so the following is just a thought or two. Whether you're using the MCP41XX or the MCP42XX you are still required to output all 16 bit (two bytes) to the device. Addiditonally, if your problem involves SHUTDOWN and you are using a Revison A part, you might do well to head for the Microchip web site and retrieve the errata document, which discusses known problems with that aspect of the chip.

    All I can think of in addition to that is to use MSBFIRST, and /16 after your variable name in the SHIFTOUT instruction to ensure that all of the 16 bits necessary are indeed sent out. Since this an SPI device, I'm not sure whether I2COUT can be made to work with it or not, but SHIFTOUT certainly can and will work with it.

    Regards,

    Bruce Bates
  • gemeyergemeyer Posts: 7
    edited 2004-11-10 00:51
    Thanks for the "help me help you" offer!

    The data sheet is at http://www.jameco.com/wcsstore/Jameco/Products/ProdDS/241752MCH.pdf

    I could only print it, sorry.

    My program is....

    '{$STAMP BS2p}
    ' demo program for digital potentiometer MCP42

    MCPword VAR Word
    MCPcmd VAR MCPword.HIGHBYTE
    MCPvalue VAR MCPword.LOWBYTE
    i VAR Byte

    MCPcmd = $11 'send data to pot 1
    MCPvalue = 1

    DEBUG BIN MCPcmd,":"
    HIGH 14 ' hard shutdown disabled
    ' LOW 11
    ' PAUSE 2000
    HIGH 11
    PAUSE 100
    FOR i = 50 TO 250 STEP 25
    MCPvalue = i
    LOW 11
    SHIFTOUT 13,12,MSBFIRST,[noparse][[/noparse]MCPword\16]
    HIGH 11
    DEBUG "i=",DEC i," ",BIN MCPword
    PAUSE 5000
    NEXT
    MCPcmd = $ff
    DEBUG "shutdown ",BIN MCPword," "
    LOW 11
    ' PAUSE 50
    SHIFTOUT 13,12,MSBFIRST,[noparse][[/noparse]MCPword\16]
    ' PAUSE 50
    HIGH 11
    PAUSE 2000
    DEBUG " HARD DOWN "
    LOW 14
    DEBUG "end "
    STOP

    The first SHIFOUT leaves the wiper in the default power on configuration. The soft shutdown SHIFTOUT has no effect either. The HARD DOWN shutdown does shut the chip down.

    Thanks for any help you can offer. My project really depends on a digital potentiometer and this 2 channel version is very appealing.
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2004-11-10 01:33
    gemeyer -

    I suspect you want at least the first initialization of MCPcmd to look more like this:
    MCPcmd = $00010011 or in datasheet notation XXC1C0XXP1P0 with C1C0 indicating the WRITE DATA function. As it stands now I suspect it's just a NOP (no operation).

    Again, if the chip that you have reflects that it's Revision A you need to look at the errata datasheet on the Microchip web site. If you can't find it, send me a note, and I'll send it along to you. All of the problems described therein have to do with SHUTDOWN. If this is not the case, let me know and I'll look further into your program.

    Regards,

    Bruce Bates
    bvbates @ usamailbox.com (remove spaces)
  • gemeyergemeyer Posts: 7
    edited 2004-11-11 00:32
    Thanks Bruce! I think you meant to preceed your MCPcmd assignment with a % not a $. I have tried both and put the debug statement in to make sure that the bits I am sending to the MCP42 are NOT a NOP. So I'm still stuck, but I really appreciate your time to look at my problem. I'll keep trying until I am able to get the chip to react!
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2004-11-11 01:07
    Indeed you are correct, the constant should have been: MCPcmd = %00010011 in binary notation not in hex as I had indicated. In what way are you "stucK" and is this a Revison A part?

    Bruce
  • gemeyergemeyer Posts: 7
    edited 2004-11-11 23:25
    Thanks for your continued interest Bruce! This is not a revision A part and I am not having any problem with shutdown. I am stuck because the wiper stays in the default position no matter what command I send. I have been very careful to put the correct bits in the command and data portion of the 16 bits. And I have added debug statements to confirm that the command matches what is called for in the data sheet. But the wiper does not change. It is hard to debug a device that gives to clue to what I am doing wrong. Probably something stupidly simple that I will stumble on if I keep playing with it. I also need to put in a new chip just on the off chance that I have a dud. Anyway, thanks!
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2004-11-11 23:54
    gemeyer -

    So far we've only really spoken about the command byte. You ARE changing the data byte as appropriate, and setting the proper device designation (P1P0) in that command byte, aren't you?

    Also, make sure that the device you have specified is the one you're checking on the ouput pins. Ergo, if you have specified device P0, make sure you are checking the P0 outputs. In fact, check both just to see if that's a problem. Is the PAUSE 5000 long enough on a BS2p for you to see the electrically changing output? Are the potentiometer output pins tied into a circuit, or are they floating?

    Does the DEBUG output appear the way you expect it to look?

    The data byte, although it may not reflect what you want it to, can't be "wrong" as all 256 bit combinations are valid (0-255).

    I only wish I had one of these chips here so I could work along with you, but I don't.

    Regards,

    Bruce Bates
  • gemeyergemeyer Posts: 7
    edited 2004-11-12 17:41
    Thanks for your continued support Bruce.· It is working now!!· I tried a new chip and I started checking both pots and changed the "don't care" command bits to 1s.· So I'm not sure what made it work (it was late at night and I made too many changes at once).· But it is working and I am happy.· Thanks again for your help and patience.
Sign In or Register to comment.