Jump to content
  • 0

Pmod DPOT: Digital Potentiometer Communication


Nimams

Question

Hi,

I would like to use Pmod DPOT: Digital Potentiometer with Raspberry Pi3.

I have the following code:

#!/usr/bin/python

import spidev
import time
spi = spidev.SpiDev()
spi.open(0, 0)
spi.mode= 0b00
spi.max_speed_hz= 1000000
spi.bits_per_word= 8
#print spi.bits_per_word
#print spi.mode
spi.cshigh= False
#print spi.cshigh
#frame = bytearray(b'\xA5')
frame = bytearray([0xF5])
try:
    while True:
        resp = spi.xfer2(frame)
        #print resp
        time.sleep(10)
    #end while
except KeyboardInterrupt:
    spi.close()

 

The code is very simple. The python module spidev documentation is here:

http://tightdev.net/SpiDev_Doc.pdf

Everything seems to be okay, as far as the oscilloscope shows: I can confirm data generates properly and the CPOL and CPHL are set to zero. The CS also sets to be active low, and it becomes high when there is no more bit to transfer. I was not able to confirm slew rate and jitters because I have an old 2-channel oscilloscope. However, I really think those are standards by the protocol itself, so I should not worry about them.

Please let me know if you can help me with this issue.

Thank you

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Hi @Nimams,

Not quite sure what your question is? Here is the resources page for the PmodDPOT. I have a non official arduino library/sketch that is in C++ that you should be able to refer to attached below. Unfortunately, we do not have any python code for the RP3 and i haven't used python with the RP3 or with our microcontroller/pmods. 

Here is the spi settings that i used to get the Pmod working in the Arduino IDE.

 SPISettings settingsA(14000, MSBFIRST, SPI_MODE0); //sets the spi mode, speed and most signifigant bit

Have you tried the raspberry pi forums here?

cheers,

Jon

pmodDpot.zip

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...