This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] ADS131M03:SPI 问题

Guru**** 1812430 points
Other Parts Discussed in Thread: ADS131M03
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/data-converters-group/data-converters/f/data-converters-forum/1228002/ads131m03-spi-issue

器件型号:ADS131M03

您好!

我正在将 ADS131M03 与 Raspberry PI 3B 搭配使用、并通过 Python 编程。 此 ADC 由一个8.192MHz 外部 MEMS 振荡器计时。 SPI 速率设置为32kSPS (我还尝试了3.2k 和320Hz)。 系统之前 在原型板上工作、但在 PCB 上不工作。 捕获的波形如附文所示(第一个:DRDY、第二个:datain、第三个:SCLK、第四个:数据输出)。 我试图读取增益寄存器、 但它返回255个响应、并且没有任何通道数据(尝试读取0x00寄存器时得到相同的结果)、该数据显然不正确。

一个有趣的现象是、当我尝试探测到 CLKIN 引脚(连接到外部时钟)时、芯片能够输出读取结果、但每次都不同、捕获的波形被附加:(第一:DRDY、第二:CLKIN、第三:SCLK 4th:Dataout)

已附加我正在使用的代码、我在 RESET 引脚中使用0.0000125延迟来同步、但似乎不起作用。

 

import time
import spidev
import RPi.GPIO as GPIO
import sys
# clk is a mini class to generate a Master-Clock signal over a PWM Pin


#and also a function which gets two hex numbers and gives back the "Message" for send
#settings
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_UP)   #Pin 17 --> DRDY Pin
GPIO.add_event_detect(17,GPIO.FALLING)

GPIO.setup(8, GPIO.OUT)                             #Pin 8 --> CS'
GPIO.output(8,1)
GPIO.setup(2, GPIO.OUT)                             #Pin 2 --> RESET/SYNC
GPIO.output(2,1)
spi = spidev.SpiDev()

spi.open(0,0) 
spi.mode=0b01                                       #CPOL=0, CPHA=1; resting state = 0, data read at falling edge

spi.max_speed_hz =32000
spi.bits_per_word = 8
spi.lsbfirst = False



def read():
    GPIO.output(8,0)
##    time.sleep(0.000125)
##    GPIO.output(2,0)
##    time.sleep(0.000125)
##    GPIO.output(2,1)
##    time.sleep(0.000125)
    send_data = [0b10100000,0b10000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000]
    com_reg=spi.xfer2(send_data)
    
  
    if GPIO.event_detected(17):
        send_data = [0b10100000,0b10000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000]
        
    # read null response
        com_reg=spi.xfer2(send_data)
##        com_reg=spi.readbytes(15)
        result1 = (8388608-abs(com_reg[3]*256*256+com_reg[4]*256+com_reg[5]-8388608))*0.00000014
        result2 = (8388608-abs(com_reg[6]*256*256+com_reg[7]*256+com_reg[8]-8388608))*0.00000014
        result3 = (8388608-abs(com_reg[9]*256*256+com_reg[10]*256+com_reg[11]-8388608))*0.00000014
        result1 = str(result1)
        result2 = str(result2)
        result3 = str(result3)
        time1 = time.strftime("%H:%M:%S ")
        print("channel1: "+result1+" V")
        print("channel2: "+result2+" V")
        print("channel3: "+result3+" V")
        print("read2")
        print (com_reg)
        file.write("prototest  ")
     
        file.write(time1)
        file.write("channel1: "+result1+" V  ")
     
        file.write("channel2: "+result2+" V  ")
       
        file.write("channel3: "+result3+" V")
        file.write("\n")
        
        
    GPIO.output(8, 1)
    time.sleep(1)

def Gain_config():
    GPIO.output(8,0)
    if GPIO.event_detected(17):
        datawreg = [0b01100010, 0b00000000,0b00000000,0b00000000, 0b00000000,0b00000000,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]
        com_reg=spi.xfer2(datawreg)
        result1 = (8388608-abs(com_reg[3]*256*256+com_reg[4]*256+com_reg[5]-8388608))*0.00000014
        result2 = (8388608-abs(com_reg[6]*256*256+com_reg[7]*256+com_reg[8]-8388608))*0.00000014
        result3 = (8388608-abs(com_reg[9]*256*256+com_reg[10]*256+com_reg[11]-8388608))*0.00000014
        result1 = str(result1)
        result2 = str(result2)
        result3 = str(result3)
        print("channel1: "+result1+" V")
        print("channel2: "+result2+" V")
        print("channel3: "+result3+" V")
        print("gain")
        print (com_reg)
        
    GPIO.output(8, 1)
    time.sleep(1)   
def send_unlock():
# GPIO.output(18, False)
    GPIO.output(8,0)
    if GPIO.event_detected(17):
        send_data = [0b00000110, 0b01010101,0b00000000,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]       
        com_reg=spi.xfer2(send_data)
        print("unlock")
        print (com_reg)        
    GPIO.output(8, 1)
    time.sleep(1)
def send_null():
    GPIO.output(8,0)
##    time.sleep(0.000125)
##    GPIO.output(2,0)
##    time.sleep(0.000125)
##    GPIO.output(2,1)
##    time.sleep(0.000125)    
    # read null response
##    print("null1")
##    print (com_reg)
    if GPIO.event_detected(17):
        send_data = [0b00000000,0b00000000, 0b00000000,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]
    # read null response
        com_reg=spi.xfer2(send_data)
        
##    com_reg=spi.readb
        print("null")
        print (com_reg)
        print (com_reg[12])
        result1 = (8388608-abs(com_reg[3]*256*256+com_reg[4]*256+com_reg[5]-8388608))*0.00000014
        result2 = (8388608-abs(com_reg[6]*256*256+com_reg[7]*256+com_reg[8]-8388608))*0.00000014
        result3 = (8388608-abs(com_reg[9]*256*256+com_reg[10]*256+com_reg[11]-8388608))*0.00000014
        result1 = str(result1)
        result2 = str(result2)
        result3 = str(result3)
        print("channel1: "+result1+" V")
        print("channel2: "+result2+" V")
        print("channel3: "+result3+" V")
    GPIO.output(8, 1)
    time.sleep(1)
def send_reset():
# GPIO.output(18, False)
    GPIO.output(8,0)
##    time.sleep(0.000125)
##    GPIO.output(2,0)
##    time.sleep(0.000125)
##    GPIO.output(2,1)
##    time.sleep(0.000125)
    if GPIO.event_detected(17):
        send_data = [0b00000000, 0b00010001,0b00000000,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]       
        com_reg=spi.xfer2(send_data)
        print("reset2")
        print (com_reg)        
    GPIO.output(8, 1)
    time.sleep(1)
def send_wakeup():
# GPIO.output(18, False)
    GPIO.output(8,0)
    if GPIO.event_detected(17):
        send_data = [0b00000000, 0b00110011,0b00000000]
        com_reg=spi.xfer2(send_data)
        print (com_reg)
    
    GPIO.output(8, 1)
    time.sleep(1)
def Clock_config():
    GPIO.output(8,0)
    if GPIO.event_detected(17):
        datawreg = [0x61,0x80,0x00,0x07,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]
        dataw=spi.xfer2(datawreg)
        
        print("clock")
        print (dataw)
      
    GPIO.output(8, 1)
    time.sleep(1)

def CFG_config():
    GPIO.output(8,0)
    if GPIO.event_detected(17):

    #data write into the CFG Register (Address: 06h)
    #Value written: 0700h, enables Global Chop and sets Global Chop Delay
    #CRC word added, Value = 1021h
    #datawreg = [0x66,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]
        datawreg = [0b01100011, 0b00000000, 0b00000000, 0x07,0x00,0x00,0x10,0x21,0x00,0x00,0x00,0x00,0x00,0x00,0x00]
        dataw=spi.xfer2(datawreg)
        print("cfg")
        print (dataw)
   
    GPIO.output(8, 1)
    time.sleep(1)

def MODE_config():
    GPIO.output(8,0)
    if GPIO.event_detected(17):
    #data write into the MODE Register (Address: 03h)
    #Value written: 3510h, enables CRC and sets CRC type
    #CRC word added, Value = 1021h
        datawreg = [0b01100001, 0b0000000,0b00000000,0x35,0x10,0x00,0x10,0x21,0x00,0x00,0x00,0x00,0x00,0x00,0x00]
        dataw=spi.xfer2(datawreg)
        print("mode")
        print (dataw)    

    GPIO.output(8, 1)
    time.sleep(1)

##
##GPIO.output(8,0)
if GPIO.event_detected(17):
    GPIO.output(2,0)
    time.sleep(0.0000125)
    GPIO.output(2,1)
##read2()
##time.sleep(0.0125)
##GPIO.output(2,0)
##time.sleep(0.000125)
##GPIO.output(2,1)
##########
file = open('/home/pi/Documents/EMILIE/proto517.txt', 'a+')
##send_unlock()
##send_reset()
####
##send_reset()
##Clock_config()
##Gain_config()
########
####send_wakeup()
send_null()
##MODE_config()
##CFG_config()
##
####send_null()
##Gain_config()
while True:
##    GPIO.output(8,0)
    if GPIO.event_detected(17):
        read()
##        send_reset()
##        send_null()
##        send_wakeup()
##
##send_reset()
##Clock_config()
##Gain_config()
##CFG_config()
##send_wakeup()
##send_null()
##MODE_config()
##GPIO.output(8,0)
##while True:
##    if GPIO.event_detected(17):         # Read conversion data
##        
##       
##
##        data=spi.xfer2([0x00, 0x00, 0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00])
##        print("receive some Data")
##            
##        print(data)
        
            

spi.close()    

原理图附在后:  

期待收到您的建议!

此致、

Zeyu

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Zeyu:

    欢迎来到 E2E 论坛。  当您向 M03 ADC 发送 RREG 命令以读取内部寄存器数据时、寄存器数据将在下一帧移出。 在第1次计时中、您继续在每一帧中发送 RREG 命令、这就是无法从 M03 ADC 读回寄存器数据的原因。 下面是我在 EVM 上捕获的时序、供您参考、在第一帧中向 M0x ADC 发送 A200h 命令以读取增益寄存器(04h 地址)、在第二帧中显示了增益寄存器数据(1000h)。 请注意、M03 ADC 上增益寄存器的默认值是 ADC 上电后0000h、 实际上、我已经向增益寄存器写入1000h、以提前将 CH2的增益设置为2、以便可以在 DOUT 上看到并检查清晰的寄存器数据。

    对于您的第二个计时、我不知道您是否尝试读取寄存器 、我在您的数据表上看到了一些信号、但请注意、时钟对电容很敏感、电容可能会 受到您的探头的影响。

    此致、

    戴尔

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Dale:

    感谢你的帮助。 我尝试发送两个24位字、并期望在第二个字中看到正确的响应、但响应不正确。 捕获的波形如下所示(第1个 SCLK 第二个数据输出第3个数据输入第4个 CS)。 我这次尝试读取模式寄存器(02)、但响应不是我预期的(0510)。

    我还监控了 DRDY 引脚行为(第二个图中的通道4)、该引脚似乎 意外地保持上升。 由于 DRDY 仅由 ADC 生成、因此我想知道可能的原因是什么吗?

    此致、

    Zeyu

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Zeyu:

    您的 SCLK 频率是多少? 这并不容易看到。 此外、我发现您的/DRDY 在上次计时时始终具有较低的尖峰、 /DRDY 似乎受到系统中干扰信号的影响。

    您的 DOUT 是直接连接到您的控制器还是与其他器件共享? 您能否提供清晰的原理图? 您的 原型板 与该 PCB 之间有何差异? 您是否尝试过其他 ADC 器件?

    谢谢、此致(&R)、

    戴尔

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Dale:

    我将 SPI 速度设置为32kHz、我想知道您对 ADC 有任何建议的 SPI 速度范围吗? 我确实看到 DRDY 在器件上电后每250us 出现一次尖峰、这是否正常?  

    DOUT 直接连接到 MCU、但可以通过长电缆和连接器(约50cm 长的导线)进行连接。 我测量了电缆电阻、它是1欧姆。 我想知道在这种情况下是否需要任何类型的源端接方法? 原型板原理图相同、但导线更短、我尚未尝试任何其他类型的 ADC。

    此致、

    Zeyu

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Zeyu:

    在3.3DVDD 电源上、最大的 SCLK 频率为25MHz。 最小频率取决于数据速率、只要您可以读取所有通道的数据、就可以使用。

    这些/DRDY 尖峰不是   由 ADC 产生的、而是由您的 PCB 或系统引起的。 50cm 的导线相当长。 您能否为您的设置提供照片?

    您在靠近 ADC 的计时中监控这些信号了吗? 如果不是、我建议您使用尽可能靠近 ADC 引脚的探头进行监控。

    此致、

    戴尔

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    知道了、所以我认为100 kHz 到500 kHz 是此应用的安全范围。 此设置的照片随附、PCB 本身具有适用于 SPI 线路的长铜线迹、它使用8位电缆通过连接器板、然后转到用跳线焊接的 FPC 到 DIP 板、最后转到 Raspberry Pi。 我想知道、您认为哪个部件可能会产生大多数噪声问题?

    PCB 设计非常紧凑、因此很难探测 PCB 的 DRDY 引脚。 我从原型板探测 ADC DRDY 引脚(DRDY 引脚在第一条布线中)。 尽管原型板数据输出正确、但在第五个字的传输过程中仍有两个尖峰、我想知道这是否正常?

    此致、

    Zeyu

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Zeyu:

    SPI 信号所需的电缆过长。 我建议您尽量缩短它们的长度。  

    这些尖峰不是"正常"的、它们可能是由您的设置和长电缆引起的。 我在 M04EVM 板上没有看到它们

    您能否发布清晰的原理图、以便我能够检查以防出现任何潜在问题?

    此致、

    戴尔

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    好了、我可以将板载 SPI 布线长度从12cm 减少到10cm、并且如果您推荐、我可以不使用 FFC 电缆、然后更换板载连接器类型到引脚头连接器。 跨接线电缆长度可从30 cm 减少到15 cm。 您是否认为屏蔽电缆或双绞线可以优于常规跳线?

    我使用了外部 MEMS 振荡器 SIT8924B 为 ADC 提供8.192MHz 时钟、该时钟与 ADC 非常接近、如所附的布局屏幕截图所示。 我想知道这个振荡器会不会给 DRDY 带来任何问题、或者让长 SPI 线路成为更主要的问题? 还附上了原理图、其中包括 ADC 振荡器 EMI 屏蔽、请检查。

    此致、

    Zeyu

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的  Zeyu:

    屏蔽电缆或双绞线会很有用、但我确定是否可以解决该问题、因为您的迹线和电缆很长。 尽量缩短它们的长度。

    振荡器和长 SPI 线路都可能导致问题、因为 PCB 板上的空间非常有限、而且长电缆可能会使问题变得更糟。  

    此致、

    戴尔