Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4909

General discussion • Controlling the digital potentiometer X9C104P with a Raspberry Pi 5.

$
0
0
Hello,
I've tried using a Raspberry Pi 5 to control a digital potentiometer X9C104P. I followed the wiring diagram illustrated in the image below and implemented the provided code, however, I don't notice any change in the potentiometer's output.
:?: :!:

Code:

#!/usr/bin/pythonimport spidevimport timespi = spidev.SpiDev()spi.open(0, 0)spi.max_speed_hz = 976000def write_pot(input):    msb = input >> 8    lsb = input & 0xFF    spi.xfer([msb, lsb])while True:    for i in range(0x00, 0x1FF, 1):        write_pot(i)        time.sleep(.005)    for i in range(0x1FF, 0x00, -1):        write_pot(i)        time.sleep(.005)

N.B: I used

Code:

spi.open(1, 2)
because I'm connecting my potentiometer via SPI1. I've already enabled SPI via raspi-config and added

Code:

dtoverlay=spi1-2cs

in the
/boot/firmware/config.txt file.
[

Here is the wiring I have done:
  • Potentiometer (POT) - Raspberry Pi
    1-INC: GPIO20
    2-UD: GPIO21
    3-Vh: 5V
    4-Vss: GND
    5-Vcc: 5V
    6-CS: GPIO16
    7-Vl: GND
    8-Vw: LED


Image


N.B: I used SPI1. Here is the website where I found more details https://pinout.xyz/pinout/spi

Image

https://www.micro-planet.ma/downloads/x9c104p.pdf
Thank you for your help, I'm really stuck. :cry:

Statistics: Posted by samiabch — Tue Apr 09, 2024 2:37 pm



Viewing all articles
Browse latest Browse all 4909

Trending Articles