MCP41xxx Digital pot issue


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2004
    Location
    Michigan, USA
    Posts
    305

    Default MCP41xxx Digital pot issue

    I cant seem to get a MCP41100 single digital pot to work. The wiper is always at mid point. I've tried many different things to get this working but just no luck. Can anyone see what the issue might be? There's data out to the pot and timings seem fine so I have no idea what is going wrong at this point.

    On a second look - it seems the SCK pin is going high at the start of data and then low after the 16 bits have been sent. Shouldn't it go high and low for each bit sent?

    Code:
    Define OSC 48
    Define	ADC_BITS	  10	' Set number of bits in result
    Define	ADC_CLOCK	   3	' Set clock source (3=rc)
    Define	ADC_SAMPLEUS  50	' Set sampling time in uS
    Include "modedefs.bas"
    SCK     var     PORTB.1     ' Alias PORTC.3 to SCK (serial data clock)
    SDO     var     PORTA.5     ' Alias PORTC.5 to SDO (serial data out)
    CS      var     PORTB.2     ' Alias PORTC.2 to C_EN (chip enable)
    POT0    var     byte        ' 
    increment var byte
    increment = 0
    
    TRISA = %11011111	' Set PORTA to all input except 5
       ADCON1 = %00000000	' Set PORTA analog and right justify result
       ADCON2.7=1
    TRISB = %00011001
    TRISC = %01000000
    
            HIGH    CS                  'Chip enable high to start
            high    sck                 'Mode 1,1 SCK idles high
    
    loop1
    increment = increment + 1 
    write 0, increment
    
    pot0 = %00010001
           
    GOSUB   write_pots
    goto loop1       
          
    WRITE_POTS:                                 
    
            low     CS                          ' Make chip active
            shiftout    sdo,sck,5,[pot0,increment]     ' Mode 1,1 / Mode 5 PBP - clock idles high, MSB shift out first
            high    CS                          ' 
            
    return
    
    End
    Last edited by jmgelba; - 16th February 2016 at 18:51.

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,520


    Did you find this post helpful? Yes | No

    Default Re: MCP41xxx Digital pot issue

    Hi,
    With MODE 5 the clock should idle high and go low and return high for each bit of data.
    You don't say which PIC this is but you have the Clock output on PortA where analog stuff is normally located. Check and double check that analog functions are turned OFF for the pins used as Clock and data.

    /Henrik.

  3. #3
    Join Date
    Feb 2004
    Location
    Michigan, USA
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: MCP41xxx Digital pot issue

    PIC 18F2550

    There is data from each pin so the pins are correctly set to digital outputs. The clock does idle high and goes low for each bit. I'm stumped. I've followed code I've used before that has worked. No idea what is wrong this time.

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,520


    Did you find this post helpful? Yes | No

    Default Re: MCP41xxx Digital pot issue

    You have ADCON1 = %00000000 which for the 18F2550 means ALL analog inputs enables, that includes PortA.5 where you have your SDO pin - that doesn't look quite right to me. Then, looking at the datasheet for MCP41xxx it's pretty clear that it clocks the data in on the rising edge of the clock so you probably have the wrong polarity selected in the SHIFTOUT command.

    /Henrik.

  5. #5
    Join Date
    Feb 2004
    Location
    Michigan, USA
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: MCP41xxx Digital pot issue

    The mode is correct but I did miss the analog setting. Thank you.

Similar Threads

  1. Digital Pot
    By TONIGALEA in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd January 2012, 07:54
  2. Digital Pot
    By Tastature in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 29th July 2008, 16:20
  3. Controlling A Digital Pot
    By TonyA in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 27th April 2006, 21:30
  4. Digital Pot
    By Scott in forum General
    Replies: 6
    Last Post: - 14th September 2005, 01:31
  5. Microchip MCP41xxx Digital Potentiometer Code Trouble
    By CocaColaKid in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 31st August 2005, 18:21

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts