Digital Pot


Closed Thread
Results 1 to 7 of 7

Thread: Digital Pot

  1. #1
    Scott's Avatar
    Scott Guest

    Default Digital Pot

    I am looking at building a test board that using a Digital potentiometer such as the Analog devices AD5160 or the Microchip MCP42XXX to simulate a 10k ohm thermistor via software.

    Can someone give me some pointers?
    Has anyone attempted anything like this?

    Any help would be great,
    Scott

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Digital pot is one option BUT there's probably cheaper way to do it depending on how the Thermistor is place in the circuit. Generating a coltage with PWM and a op-amp buffer could do the same job.

    BTW do you have a schematic of the Thermistor section you want to simulate?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Scott's Avatar
    Scott Guest


    Did you find this post helpful? Yes | No

    Default

    Voltage will be supplied by another I/O board. I want to vary the resistance to simulate the changing of the temperature with the digital potentiometer. Does this make sense? I would like to place the board that will be simulating the 10k ohm thermistor in the same location as the real 10k ohm thermistor.

    I am trying to simulate earlier captured data.

    I do not have a schematic for the sensor!

    Thanks,
    Scott

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Sure it make sense no problem. Yes you can use Digital pot for that but you'll be limited to their own position/taps limitation.

    Good luck.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5


    Did you find this post helpful? Yes | No

    Default

    Here's the code I wrote to control 5 digital pots daisy chained together.

    Code:
    DEFINE  LOADER_USED 1   ' Bootloader is being used
    DEFINE  OSC 16          ' Set oscillator frequency, 4MHz (HS_PLL x4)
    DEFINE  HSER_BAUD 9600  ' Baud rate for serial output
    DEFINE  HSER_CLROERR 1  ' Automatically clear over-run errors
    DEFINE  HSER_RCSTA 90h	' Enable USART receive
    DEFINE  HSER_TXSTA 24h	' TXSTA=%00100100. TX enable, BRGH=1 for high-speed
    
    @ __CONFIG _CONFIG1H, _OSCS_OFF_1H & _HSPLL_OSC_1H
    ' Oscillator Switch Disable
    ' Oscillator Type HS PLL    
     
    @ __CONFIG _CONFIG2L, _BOR_ON_2L & _PWRT_ON_2L & _BORV_45_2L
    ' Brown-Out Reset Enabled
    ' Power-Up Timer Enable
    ' Brown-Out Reset Voltage 4.5V
    
    @ __CONFIG _CONFIG2H, _WDT_ON_2H 
    ' Watch Dog Timer Enable
    
    @ __CONFIG _CONFIG4L, _STVR_ON_4L & _LVP_OFF_4L & _DEBUG_OFF_4L
    ' Stack Over/Underflow Reset Enable
    ' Low Voltage ICSP Programming Disabled
    ' Background Debugger Disabled
    
        ADCON1 = %0111              ' Set porta to digital mode
    
        si      var     porte.2
        sclk    var     porte.1
        cs      var     porte.0
    
        pot_value_0 var     byte
        pot_value_1 var     byte
        pot_value_2 var     byte
        pot_value_3 var     byte
        pot_value_4 var     byte
        cmd         var     byte
        position    var     byte
    
        low     sclk    ' Set clock pin low
        high    cs      ' Set chip select low
    
        clear
        
    start:
        gosub pot_5
        gosub pot_4
        gosub pot_3
        gosub pot_2
        gosub pot_1
        goto start                      
    
    pot_5:
        low cs
        cmd = %00010001 : position = pot_value_4 : gosub shout
        cmd = 0 : position = 0 : gosub shout
        cmd = 0 : position = 0 : gosub shout
        high cs
        return
    
    pot_4:
        low cs
        cmd = %00010010 : position = pot_value_3 : gosub shout
        cmd = 0 : position = 0 : gosub shout
        high cs
        return
    
    pot_3:
        low cs
        cmd = %00010001 : position = pot_value_2 : gosub shout
        cmd = 0 : position = 0 : gosub shout
        high cs
        return
    
    pot_2:
        low cs
        cmd = %00010010 : position = pot_value_1 : gosub shout
        high cs
        return
    
    pot_1:
        low cs
        cmd = %00010001 : position = pot_value_0 : gosub shout
        high cs
        return
    
    shout:
        shiftout si,sclk,1,[cmd]
        shiftout si,sclk,1,[position]
        return
    Just set the pot_value_x to whatever you want between 0-255.

  6. #6
    Scott's Avatar
    Scott Guest


    Did you find this post helpful? Yes | No

    Default

    Wow!

    Thanks for the code I'll give it a try this week and let you know.

    Scott

  7. #7


    Did you find this post helpful? Yes | No

    Default

    If you need any help with them just give me a shout.

Similar Threads

  1. Digital Pot
    By TONIGALEA in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd January 2012, 07:54
  2. Controlling a MCP4162 Digital Pot
    By SOTASOTA in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 6th February 2011, 18:51
  3. Digital Pot Advice
    By Tobias in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 22nd October 2007, 20:38
  4. Replies: 4
    Last Post: - 24th January 2007, 22:20
  5. Serial control of a digital pot?
    By TonyA in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 2nd June 2006, 23:49

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