News:

Let's find out together what makes a PIC Tick!

Main Menu

Any body use X9C102?

Started by Maxi, Oct 03, 2022, 11:56 AM

Previous topic - Next topic

Maxi

This is digital pot
X9C102 1K
X9C103 10K
X9C104 100K

have any body experience?

charliecoutas

I've used Microchip digital pots (SPI interface) with great success. The ones you show seem very expensive.

Charlie

trastikata

Hi, do you have any specific question pertaining to the devices in question or it is a general inquiry about digital pots?

I've been using MC digital pots for a while in adjustable LDO regulators' feedback divider network to control the voltage output, works quite well.

Maxi

I need a pic controlled variable resistor actually, not potentiometer.
but, never use before digital pot.

for example, 40 ohm, 251 ohm, 380 ohm what I need.
so I need 1K version

can I use this chip like a resistor? (not 3 pin pot)


Gamboa

Maxi,

I have used the Microchip part MCP4011-103E/SN and have had no problems. I show you the routines I used to move the cursor.

'*************************************************************************
'** SUBRUTINA: AumentarPote
'** Aumenta la resistencia del potenciómetro digital tantos pasos como se le ordenen
'**
'** VARIABLE de entrada: PasosPote
'*************************************************************************

AumentarPote:
  CS_POTE = 0
  FOR i = DesdePasosPote TO PasosPote
    UD_POTE = 1
    DELAYUS 20
    UD_POTE = 0
    DELAYUS 20
    UD_POTE = 1
    DELAYUS 20
  NEXT i
  CS_POTE = 1
 
    RETURN

'** FIN SUBRUTINA: AumentarPote

'*************************************************************************
'** SUBRUTINA: DecrementarPote
'** Reduce la resistencia del potenciómetro digital tantos pasos como se le ordenen
'**
'** VARIABLE de entrada: DesdePasosPote, PasosPote
'*************************************************************************

DecrementarPote:
  UD_POTE = 0
  CS_POTE = 0
  FOR i = DesdePasosPote TO PasosPote STEP -1
    UD_POTE = 1
    DELAYUS 20
    UD_POTE = 0
    DELAYUS 20
    UD_POTE = 1
    DELAYUS 20
  NEXT i
  CS_POTE = 1
 
    RETURN

'** FIN SUBRUTINA: DecrementarPote

Regards,
Gamboa
Long live for you

JonW

#5
Some code for the the MCP41XXX series that can be used as a variable resistor (connect the wiper to any other terminal.  DEVICE.  You can parallel these with standard resistors to get a finer resolution for the larger values.  Just be careful with the amount of current you push through the wiper terminal and also be aware that the max voltages on the terminals are related to the VDD (as there are integrated ESD diodes on all pins)

Call the proc with SETRES(BYTEVALUE)


SYMBOL POT_ADDR = $13          ; POT ADDRESS


Dim POT_DAT  As PORTB.5        ; PORT DECLARES
Dim POT_CLK  As PORTB.6
Dim POT_CS    As PORTB.7



'*************************************************************************************
'
' Name:                                  "SETRES MCP41XXX"
' Passes:    Pot VALUE
' Returns:  None
'*************************************************************************************
PROC SETRES(POTVAL AS BYTE)
    POT_CS = 0
    DelayUS 10
    SHOut POT_DAT, POT_CLK, MsbFirst,[POT_ADDR,POTVAL]        ' WRITE TO POT
    DelayUS 10
    POT_CS = 1
EndProc

Stephen Moss

Quote from: Maxi on Oct 04, 2022, 06:16 AMcan I use this chip like a resistor? (not 3 pin pot)
I don't know has I have never tried it but considering that the internal design is essentially as number of series resistors I would think that to use it as a variable resistor would require you to connect your input voltage to the output terminal rather than the top of the resistor chain. So whether or not that would work for long, if at all, would depend on the circuity that connects the selected output tap to the series resistor chain.
Also consider that as a pot the current through each resistor in the chain is relatively fixed by (Vin/Rtotal)/Number of Taps, whereas when using it as a variable resistor you are likely to be changing the current through the resistors, therefore if you not careful you could end up putting too much current through them, thereby destroying the device.

Depending on your end application you could...
Use a servo to turn an actual pot
Use PWM output smoothed to a voltage or a DAC output either directly or added/subtracted from another signal via a differential amplifier or
Use PWM output smoothed to a voltage or a DAC output to drive the Gate of an FET, as a variable resistor changes the current and in FET's there is a correlation between gate voltage and current flow, you just need to a FET with the correct voltage to current characteristic for your needs.  

top204

Here's also a program I wrote for the Microchip MC42XXX, dual, digital resistor chip many years ago for the Amicus18 board. I have adapted it for procedures.

It uses a rolled out software SPI interface, so it will be fast and work with most device families. I remember they were very good devices and were less expensive than the Maxim types at the time, but what devices are not less expensive than Maxim types? ;-)

'
'   /\\\\\\\\\
'  /\\\///////\\\
'  \/\\\     \/\\\                                                 /\\\          /\\\
'   \/\\\\\\\\\\\/        /\\\\\     /\\\\\\\\\\     /\\\\\\\\   /\\\\\\\\\\\  /\\\\\\\\\\\  /\\\\\\\\\
'    \/\\\//////\\\      /\\\///\\\  \/\\\//////    /\\\/////\\\ \////\\\////  \////\\\////  \////////\\\
'     \/\\\    \//\\\    /\\\  \//\\\ \/\\\\\\\\\\  /\\\\\\\\\\\     \/\\\         \/\\\        /\\\\\\\\\\
'      \/\\\     \//\\\  \//\\\  /\\\  \////////\\\ \//\\///////      \/\\\ /\\     \/\\\ /\\   /\\\/////\\\
'       \/\\\      \//\\\  \///\\\\\/    /\\\\\\\\\\  \//\\\\\\\\\\    \//\\\\\      \//\\\\\   \//\\\\\\\\/\\
'        \///        \///     \/////     \//////////    \//////////      \/////        \/////     \////////\//
'                                  Let's find out together what makes a PIC Tick!
'
' Interface to an MCP42xxx dual digital resistor
' Implements a very fast (rolled out code) software SPI interface
'
    Device = 18F25K20                   ' Tell the compiler what device to compile for
    Declare Xtal = 64                   ' Tell the compiler what frequency the device will be operating at (in MHz)
'
' Setup USART1
'
    Declare HSerial1_Baud = 9600
    Declare HRsout1_Pin = PORTC.6
'
' Digital Resistor pin declarations
'
    Symbol Res_CS_Pin  = PORTC.0        ' Connects to the MCP42xxx CS pin
    Symbol Res_CLK_Pin = PORTC.1        ' Connects to the MCP42xxx CLK pin
    Symbol Res_SDI_Pin = PORTC.2        ' Connects to the MCP42xxx SI pin
'
' Create a variable for the demo
'
    Dim bResValue As Byte               ' Holds the 8-bit resistor value

'--------------------------------------------------------------------------
' The main program starts here
' Cycle both resistors inside an MC42xxx digital resistor device
'
Main:
    Res_Init()                          ' Setup the ins and outs for the software SPI interface

    Do                                  ' Create a loop
        For bResValue = 0 To 255        ' Create a loop of 256 iterations
            Res_Write1(bResValue)       ' Adjust the resistance of resistor 1
            Res_Write2(bResValue)       ' Adjust the resistance of resistor 2
            HRSOutLn Dec bResValue      ' Display the value on the serial terminal
            DelayMS 100                 ' A small delay
        Next                            ' Close the loop
    Loop                                ' Do it forever

'--------------------------------------------------------------------------
' Clock a bit out
'
$define Res_ClockOut()   '
    PinSet Res_CLK_Pin   '
    DelayCs 1            '
    PinClear Res_CLK_Pin

'--------------------------------------------------------------------------
' Put the current outgoing bit on Res_SDI_Pin
'
$define Res_PutBit(pBitValue) '
    PinSet Res_SDI_Pin        '
    If pBitValue = 0 Then     '
        PinClear Res_SDI_Pin  '
    EndIf

'-----------------------------------------------------------------------------
' Write a value to resistor 1 inside the MCP42xxx digital resistor device
' Input     : pValue (WREG) holds the 8-bit resistance value to send
' Output    : None
' Notes     : Implementation of a fast Software Mode 0-0 Master SPI (out only) interface.
'           : Transmits 16-bits using the SPI protocol mode 0 (MSB first)
'           : SCK is idle-low, and bits are latched on SCK rising. Clocks the bits out individually for extra speed
'
Proc Res_Write1(pValue As WREG)
    PinClear Res_CS_Pin                 ' Enable the SPI interface
'
' Send the control byte for resistor 1 (PA0,PW0,PB0)
'
    PinClear Res_SDI_Pin
    Res_ClockOut()
    Res_ClockOut()
    Res_ClockOut()
    PinSet Res_SDI_Pin
    Res_ClockOut()
    PinClear Res_SDI_Pin
    Res_ClockOut()
    Res_ClockOut()
    PinSet Res_SDI_Pin
    Res_ClockOut()
    PinClear Res_SDI_Pin
    Res_ClockOut()
    Res_SendData()                      ' Send the data byte
EndProc

'-----------------------------------------------------------------------------
' Write a value to resistor 2 inside the MCP42xxx digital resistor device
' Input     : pValue (WREG) holds the 8-bit resistance value to send
' Output    : None
' Notes     : Implementation of a fast Software Mode 0-0 Master SPI (out only) interface.
'           : Transmits 16-bits using the SPI protocol mode 0 (MSB first)
'           : SCK is idle-low, and bits are latched on SCK rising. Clocks the bits out individually for extra speed
'
Proc Res_Write2(pValue As WREG)
'
' Send the control byte for resistor 2 (PA1,PW1,PB1)
'
    PinClear Res_CS_Pin             ' Enable the SPI interface
    PinClear Res_SDI_Pin
    Res_ClockOut()
    Res_ClockOut()
    Res_ClockOut()
    PinSet Res_SDI_Pin
    Res_ClockOut()
    PinClear Res_SDI_Pin
    Res_ClockOut()
    Res_ClockOut()
    Res_ClockOut()
    PinSet Res_SDI_Pin
    Res_ClockOut()
    Res_SendData()                  ' Send the data byte
EndProc

'-----------------------------------------------------------------------------
' Send the data byte to the MCP42xxx digital resistor device
' Input     : WREG holds the data to send
' Output    : None
' Notes     : None
'
Proc Res_SendData()
    Res_PutBit(WREG.7)
    Res_ClockOut()
    Res_PutBit(WREG.6)
    Res_ClockOut()
    Res_PutBit(WREG.5)
    Res_ClockOut()
    Res_PutBit(WREG.4)
    Res_ClockOut()
    Res_PutBit(WREG.3)
    Res_ClockOut()
    Res_PutBit(WREG.2)
    Res_ClockOut()
    Res_PutBit(WREG.1)
    Res_ClockOut()
    Res_PutBit(WREG.0)
    Res_ClockOut()
    PinSet Res_CS_Pin               ' Disable the SPI interface
EndProc

'--------------------------------------------------------------------------
' Initialise the SPI I/O lines
'
Proc Res_Init()
    PinHigh Res_CS_Pin
    PinLow Res_CLK_Pin
    PinOutput Res_SDI_Pin
EndProc

'--------------------------------------------------------------------------
' Setup the config fuses for 4x PLL with an external crystal on a PIC18F25K20 device
'
Config_Start
    FOSC = HSPLL        ' HS oscillator, PLL enabled and under software control
    HFOFST = Off        ' The system clock is held Off until the HF-INTOSC is stable
    FCMEN = Off         ' Fail-Safe Clock Monitor disabled
    IESO = Off          ' Two-Speed Start-up disabled
    WDTPS = 128         ' Watchdog is 1:128
    BOREN = Off         ' Brown-out Reset disabled in hardware and software
    BORV = 18           ' VBOR set to 1.8 V nominal
    MCLRE = On          ' MCLR pin enabled, RE3 input pin disabled
    LPT1OSC = Off       ' T1 operates in standard power mode
    PBADEN = Off        ' PORTB<4:0> pins are configured as digital I/O on Reset
    CCP2MX = PORTC      ' CCP2 input/output is multiplexed with RC1
    STVREN = Off        ' Reset on stack overflow/underflow disabled
    WDTEN = Off         ' WDT disabled (control is placed on SWDTEN bit)
    Debug = Off         ' Background debugger disabled' RB6 and RB7 configured as general purpose I/O pins
    XINST = Off         ' Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
    LVP = Off           ' Single-Supply ICSP disabled
    Cp0 = Off           ' Block 0 (000800-001FFF) not code-protected
    CP1 = Off           ' Block 1 (002000-003FFF) not code-protected
    CPB = Off           ' Boot block (000000-0007FF) not code-protected
    CPD = Off           ' Data EEPROM not code-protected
    WRT0 = Off          ' Block 0 (000800-001FFF) not write-protected
    WRT1 = Off          ' Block 1 (002000-003FFF) not write-protected
    WRTB = Off          ' Boot block (000000-0007FF) not write-protected
    WRTC = Off          ' Configuration registers (300000-3000FF) not write-protected
    WRTD = Off          ' Data EEPROM not write-protected
    EBTR0 = Off         ' Block 0 (000800-001FFF) not protected from table reads executed in other blocks
    EBTR1 = Off         ' Block 1 (002000-003FFF) not protected from table reads executed in other blocks
    EBTRB = Off         ' Boot block (000000-0007FF) not protected from table reads executed in other blocks
Config_End


Maxi

#8
Thank you dear friends but your digital chips generally 10K
how can I set it for example 40 ohm?

Im trying read datasheets, they are mostly 64 step, 256 step
10K / 256 = 39 ohm per step
maybe I need 45 ohm?

am I think wrong?
so, Im looking 1K chip, today order a x9c102
its 100 step, 1000 ohm / 99 = 10 ohm

maybe I need different solution @Stephen Moss


x9c102.jpg

JonW

These will work as a variable resistor but you must carefully consider your application and circuit design.  The X9C102 can only handle 4mA max through the resistive elements and you should minimise this to limit the temp coef of the resistor.

How are you implementing the resistor in the circuit?


Maxi

Quote from: JONW on Oct 04, 2022, 10:42 AMThese will work as a variable resistor but you must carefully consider your application and circuit design.  The X9C102 can only handle 4mA max through the resistive elements and you should minimise this to limit the temp coef of the resistor.

How are you implementing the resistor in the circuit?



Im just check it (33mA)
this is a car cluster (engine temp gauge)

JonW

If you only require a small number of resistor values, just use fixed resistors and ground them using a BJT or Fet, you can then shunt as much current as the parts require

Maxi

Quote from: JONW on Oct 04, 2022, 11:34 AMIf you only require a small number of resistor values, just use fixed resistors and ground them using a BJT or Fet, you can then shunt as much current as the parts require
it must be variable

top204

Depending on what maximum resistance is required, you could try placing a smaller Ohmage fixed resistor in parallel with the digital resistor. This will reduce its overall resistance and with the right fixed resistor value, its resistance increments and minumum resistance should fall.

It's not something I have tried, but it is acting as a true variable resistor, so parallel calculations should still apply to it.

JonW

#14
Are you wanting to shunt a variable constant current (using the resistance) as this will be easier to implement with higher currents and can be controlled via a DAC or PWM, it can also work >>12V for auto systems.  Remember these resistive devices cannot be used > datasheet VDD

Maxi

just checked
minimum resistor 380 ohm (60C)
mid point 57 ohm (90C)
max 40 ohm (120C)

I give low current voltage but not working well
in the cluster have a controller and input want resistor
(its working with ntc sensor normally)

JonW

You are still limited by the current in the wiper and you stated that the current is 33mA. Is the resistor grounded?  If so what is the voltage across it with applied resistance?  If the resistor is grounded then it should work with a constant current sink. 
 
The only ones that I have come across that can handle relatively high currents are MCP41HVX1,

John Lawton

A little bit more information about your application circuit would be helpful.

John

Maxi

normally cars dashboard cluster engine temp gauges connect to a water temp sensor.
water temp sensor a NTC type thermistor
its installed engine water hose and send resistive data to cluster gauge
it has two pin, other pin connect engine block (like gnd)
(old cars has 2 ntc temp sensor, one is connect to gauge, others to car ecu)

this nissan`s original engine temp sensor "LOST"
I want to make a pic circuit reading engine water temp any other ntc sensor (like bosch brand)
and send this resistive data to cluster (want simulate original temp sensor)

The problem is "how can I send or generate this resistive data to cluster?"
when engine temp 60C I need to send 380 ohm (gauge pointer left side)
when engine temp 120C I need to send 40 ohm (gauge pointer right side)

John Lawton

As JONW said in his post https://protoncompiler.com/index.php?msg=9881 you should look at sinking a current rather than simulating a resistance.

You could power your sensor via a constant current circuit and read the voltage output.
To drive your gauge, you could use a current sink output circuit controlled either by a PIC or directly from your new sensor output with appropriate analogue interface / calibration circuitry.

Using a PIC would make it reasonably straightforward to map the sensor output to the current required for your gauge using a lookup table. You could control the output current via a PWM or a DAC output from the PIC.

I hope that is of some help.

John