meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
sensor:digipot [2026/04/11 15:32] vamsansensor:digipot [2026/04/11 16:29] (current) – [Renesas X9C series] vamsan
Line 24: Line 24:
   * **Resistance Tolerance:** ±20% end-to-end.   * **Resistance Tolerance:** ±20% end-to-end.
   * **Typical Wiper Resistance:** 40 Ω at 1 mA   * **Typical Wiper Resistance:** 40 Ω at 1 mA
 +
 +{{page>:tarhal}}
  
 {{ :sensor:x9c_1.png |Renesas X9C series block diagram}} {{ :sensor:x9c_1.png |Renesas X9C series block diagram}}
Line 49: Line 51:
   * **Control Interface:** Connect CS, INC, and U/D to any three digital GPIO pins on your microcontroller.   * **Control Interface:** Connect CS, INC, and U/D to any three digital GPIO pins on your microcontroller.
   * **Saving Settings:** To save the current resistance so it persists after power-off, you must pull CS HIGH while INC is already HIGH.    * **Saving Settings:** To save the current resistance so it persists after power-off, you must pull CS HIGH while INC is already HIGH. 
 +
 +==== Arduino example code ====
 +To operate a Renesas X9C series digital potentiometer (such as the X9C103S) with an Arduino, you can either utilise a dedicated library like **DigiPotX9Cxxx** or manually control the pins. Here is a straightforward example that gradually varies the resistance from minimum to maximum without requiring any external library.
 +
 +**Wiring Diagram**
 +
 +|< 100%>|
 +^X9C Module Pin^Arduino Pin^Description|
 +^VCC|5V|Power Supply|
 +^GND|GND|Ground|
 +^CS|Pin 10|Chip Select (Active LOW)|
 +^INC|Pin 9|Increment (Pulse to move)|
 +^U/D|Pin 8|Up/Down (HIGH = Up, LOW = Down)|
 +^VH / VL|5V / GND|To use as a 0-5V voltage divider|
 +^VW|A0|Connect to Analogue Pin 0 to see results|
  
 <code c> <code c>
 +// Pin Definitions
 +const int CS_PIN = 10;
 +const int INC_PIN = 9;
 +const int UD_PIN = 8;
  
 +void setup() {
 +  Serial.begin(9600);
 +  
 +  // Set control pins as outputs
 +  pinMode(CS_PIN, OUTPUT);
 +  pinMode(INC_PIN, OUTPUT);
 +  pinMode(UD_PIN, OUTPUT);
 +
 +  // Initial state: deselect chip and set high idle
 +  digitalWrite(CS_PIN, HIGH);
 +  digitalWrite(INC_PIN, HIGH);
 +  
 +  Serial.println("Starting X9C Sweep...");
 +}
 +
 +// Function to move the wiper 1 step
 +void moveWiper(bool up) {
 +  digitalWrite(UD_PIN, up ? HIGH : LOW); // Set direction
 +  digitalWrite(CS_PIN, LOW);             // Select chip
 +  delayMicroseconds(1);
 +  
 +  digitalWrite(INC_PIN, LOW);            // Falling edge moves wiper
 +  delayMicroseconds(1);
 +  digitalWrite(INC_PIN, HIGH);           // Return to high
 +  
 +  digitalWrite(CS_PIN, HIGH);            // Deselect to end movement
 +}
 +
 +// Function to reset the wiper to 0 (by moving down 100 times)
 +void resetToZero() {
 +  for (int i = 0; i < 100; i++) {
 +    moveWiper(false);
 +  }
 +}
 +
 +void loop() {
 +  resetToZero(); // Start from a known position (0)
 +  Serial.println("At 0% resistance");
 +  delay(2000);
 +
 +  // Gradually increase resistance
 +  for (int i = 0; i < 100; i++) {
 +    moveWiper(true);
 +    int value = analogRead(A0); // Read voltage at wiper
 +    Serial.print("Step: "); Serial.print(i);
 +    Serial.print(" | Analog Value: "); Serial.println(value);
 +    delay(50);
 +  }
 +
 +  Serial.println("At 100% resistance");
 +  delay(2000);
 +}
 </code> </code>
  
-===== Communication topics on lamaPLC ===== +**Key Logic Steps** 
-{{topic>communication}}+ 
 +  * **Selection:** The chip is only active when CS is pulled LOW. 
 +  * **Direction:** The U/D pin indicates whether the resistance increases or decreases. 
 +  * **The "Pulse":** The INC pin is negative-edge triggered. A transition from HIGH to LOW triggers the movement. 
 +  * **No Feedback:** These chips cannot tell the Arduino their current position. The //resetToZero()// function ensures you start at a known point by forcing the wiper down 100 times. 
 + 
 +===== Sensor topics on lamaPLC ===== 
 +{{topic>sensor}}
  
-{{tag>BMP280 AHT20 temperature humidity pressure sensor arduino oled SH1106 arduino_code}}+{{tag>sensor module arduino_code Renesas X9C_series X9C102 X9C103 X9C104 X9C503 XDCP digitally_controlled_potentiometer}}
  
 This page has been accessed for: Today: {{counter|today}}, Until now: {{counter|total}} This page has been accessed for: Today: {{counter|today}}, Until now: {{counter|total}}