標題: AD5420無輸出問題 附電路原理圖和程序 [打印本頁]

作者: 牛牛牛牛牛牛    時間: 2023-5-24 16:39
標題: AD5420無輸出問題 附電路原理圖和程序
程序使用官方例程,IOut無輸出,原理圖和程序在2樓

作者: xuyaqi    時間: 2023-5-24 17:17
你應該把硬件,軟件告訴大家,才能幫你分析
作者: wangshunda    時間: 2023-5-25 10:36
檢查一下DVCC SELECT試試
作者: 牛牛牛牛牛牛    時間: 2023-5-25 11:50


  1. #define SET_CLEAR() GPIO_SetBits(GPIOD, GPIO_Pin_0) // AD5420_CLEAR -> PD0
  2. #define CLR_CLEAR() GPIO_ResetBits(GPIOD, GPIO_Pin_0)

  3. #define SET_LATCH() GPIO_SetBits(GPIOB, GPIO_Pin_12) // AD5420_LATCH -> PB12
  4. #define CLR_LATCH() GPIO_ResetBits(GPIOB, GPIO_Pin_12)

  5. #define SET_SCL()   GPIO_SetBits(GPIOB, GPIO_Pin_13) // AD5420_SCLK  -> PB13
  6. #define CLR_SCL()   GPIO_ResetBits(GPIOB, GPIO_Pin_13)

  7. #define SET_SDO()   GPIO_SetBits(GPIOB, GPIO_Pin_15) // AD5420_SDIN  -> PB15
  8. #define CLR_SDO()   GPIO_ResetBits(GPIOB, GPIO_Pin_15)


  9. void AD5420_IO_Init(void)
  10. {
  11.     GPIO_InitTypeDef GPIO_InitStructure;
  12.     // SPI_InitTypeDef  SPI_InitStructure;

  13.     RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE);
  14.     RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
  15.     // RCC_APB1PeriphClockCmd(  RCC_APB1Periph_SPI2,  ENABLE );//SPI2時鐘使能

  16.     // input:PD0->CLEAR; PB12->LATCH; PB13->SCLK; PB15->SDIN; output:PB14->SDIO; PD1->FAULT
  17.     // gpio配置
  18.     GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_0;       // PD0->CLEAR
  19.     GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_Out_PP; // 推挽輸出
  20.     GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  21.     GPIO_Init(GPIOD, &GPIO_InitStructure);

  22.     GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_15; // PB12->LATCH; PB13->SCLK; PB15->SDIN;
  23.     GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_Out_PP;                        // 推挽輸出
  24.     GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  25.     GPIO_Init(GPIOB, &GPIO_InitStructure);

  26.     GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_1;    // PD1->FAULT
  27.     GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_Out_OD;//開漏輸出
  28.     // GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_IPU; // 上拉輸入
  29.     GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  30.     GPIO_Init(GPIOD, &GPIO_InitStructure);

  31.     GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_14;   //  PB14->SDO
  32.     GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_IPU; // 上拉輸入
  33.     GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  34.     GPIO_Init(GPIOB, &GPIO_InitStructure);
  35.     GPIO_ResetBits(GPIOB, GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_15);
  36.     GPIO_ResetBits(GPIOD, GPIO_Pin_0);
  37. }
  38. void AD5420_WriteData(uint8_t count, uint8_t *ad5420buf)
  39. {
  40.     uint8_t ValueToWrite = 0;
  41.     uint8_t i            = 0;
  42.     uint8_t j            = 0;

  43.     CLR_LATCH(); // 先拉低LATCH片選線

  44.     for (i = count; i > 0; i--)
  45.     {
  46.         ValueToWrite = *(ad5420buf + i - 1);
  47.         for (j = 0; j < 8; j++)
  48.         {
  49.             CLR_SCL();
  50.             if (0x80 == (ValueToWrite & 0x80))
  51.             {
  52.                 SET_SDO();
  53.             }
  54.             else
  55.             {
  56.                 CLR_SDO();
  57.             }
  58.             delay_ms(50);   
  59.             SET_SCL();
  60.             // delay_us(100);
  61.             ValueToWrite <<= 1;
  62.         }
  63.     }
  64.     CLR_SCL();
  65.     delay_us(500);
  66.     SET_LATCH();
  67.     delay_us(500);
  68.     CLR_LATCH();
  69. }

  70. void Ad5420_Init(void)
  71. {
  72.     ad5420buf[2] = 0x56; // 復位寄存器地址
  73.     ad5420buf[1] = 0x00;
  74.     ad5420buf[0] = 0x01;
  75.     AD5420_WriteData(3, ad5420buf);
  76.     delay_ms(100);

  77.     ad5420buf[2] = 0x55; // 可尋址控制寄存器地址
  78.     // ad5420buf[1] = 0x10;    //OUTEN=1,輸出使能
  79.     ad5420buf[1] = 0x30; // REXT=1,外部電流設置電阻;OUTEN=1,輸出使能;禁能數字壓擺率控制;菊花鏈禁能
  80.     ad5420buf[0] = 0x05; // 4~20mA
  81.     // ad5420buf[0] = 0x06;  //0~20mA
  82.     // ad5420buf[0] = 0x07;  //0~24mA
  83.     AD5420_WriteData(3, ad5420buf);
  84.     delay_us(100);
  85. }
  86. void Write_Ad5420_Data(void)
  87. {
  88.     // Ad5420_Init();
  89.     ad5420buf[2] = 0x01;//數據寄存器
  90.     ad5420buf[1] = 0x00;
  91.     ad5420buf[0] = 0x00;//4mA
  92.     AD5420_WriteData(3,ad5420buf);

  93.     // ad5420buf[2] = 0x01; // 數據寄存器
  94.     // ad5420buf[1] = 0x60;
  95.     // ad5420buf[0] = 0x00; // 10mA
  96.     // AD5420_WriteData(3, ad5420buf);
  97.     delay_us(1000);

  98.     // ad5420buf[2] = 0x01;//數據寄存器
  99.     // ad5420buf[1] = 0xFF;
  100.     // ad5420buf[0] = 0xFF;//20mA
  101.     // AD5420_WriteData(3,ad5420buf);
  102.     // delay_us(2000);
  103.     GPIO_SetBits(GPIOD, GPIO_Pin_0);
  104.     delay_ms(200);

  105.     GPIO_ResetBits(GPIOD, GPIO_Pin_0);
  106.     delay_ms(200);

  107. }
復制代碼



作者: xuyaqi    時間: 2023-5-25 13:35
牛牛牛牛牛牛 發(fā)表于 2023-5-25 11:50
#define SET_CLEAR() GPIO_SetBits(GPIOD, GPIO_Pin_0) // AD5420_CLEAR -> PD0
#define CLR_CLEAR() GP ...

你AVDD電壓是多少?
作者: xuyaqi    時間: 2023-5-25 13:51
牛牛牛牛牛牛 發(fā)表于 2023-5-25 11:50
#define SET_CLEAR() GPIO_SetBits(GPIOD, GPIO_Pin_0) // AD5420_CLEAR -> PD0
#define CLR_CLEAR() GP ...

量量15腳REFIN電壓。
作者: 牛牛牛牛牛牛    時間: 2023-5-25 15:17
xuyaqi 發(fā)表于 2023-5-25 13:35
你AVDD電壓是多少?

12v的模擬電路供電,3.3v的數字電路供電呀

作者: 牛牛牛牛牛牛    時間: 2023-5-25 15:21
xuyaqi 發(fā)表于 2023-5-25 13:51
量量15腳REFIN電壓。

5v基準電壓,沒問題
作者: 牛牛牛牛牛牛    時間: 2023-5-25 15:23
牛牛牛牛牛牛 發(fā)表于 2023-5-25 11:50

用示波器測了一下這個時鐘和數字引腳沒問題
作者: xuyaqi    時間: 2023-5-25 15:32
你根據什么得出IOut無輸出。
作者: 牛牛牛牛牛牛    時間: 2023-5-25 15:40
xuyaqi 發(fā)表于 2023-5-25 15:32
你根據什么得出IOut無輸出。

萬用表串聯IOUT和模擬地,測電流呀
作者: xuyaqi    時間: 2023-5-25 16:04
牛牛牛牛牛牛 發(fā)表于 2023-5-25 15:40
萬用表串聯IOUT和模擬地,測電流呀

由于電流表內阻太小,造成芯片工作不正常,你串一個200歐電阻再試。
作者: 牛牛牛牛牛牛    時間: 2023-5-25 16:13
xuyaqi 發(fā)表于 2023-5-25 16:04
由于電流表內阻太小,造成芯片工作不正常,你串一個200歐電阻再試。

試了,270歐姆電阻,無輸出,但是可以通過串口讀出來數據寄存器的值,說明寫進去,但是無輸出
作者: xuyaqi    時間: 2023-5-25 16:22
牛牛牛牛牛牛 發(fā)表于 2023-5-25 16:13
試了,270歐姆電阻,無輸出,但是可以通過串口讀出來數據寄存器的值,說明寫進去,但是無輸出

輸出接電阻,用電壓表測,是否電流表有問題。
作者: xuyaqi    時間: 2023-5-25 16:28
牛牛牛牛牛牛 發(fā)表于 2023-5-25 11:50

量20腳BOOST有電壓嗎?是多少?
作者: 牛牛牛牛牛牛    時間: 2023-5-25 16:33
xuyaqi 發(fā)表于 2023-5-25 16:28
量20腳BOOST有電壓嗎?是多少?

跟這個引腳沒啥關系吧
作者: 牛牛牛牛牛牛    時間: 2023-5-25 16:35
xuyaqi 發(fā)表于 2023-5-25 16:22
輸出接電阻,用電壓表測,是否電流表有問題。

萬用表好著呢,按理來說數據寫進到數據寄存器,就不需要管了呀,芯片就會生成數據寄存器的值調出來的電流,現在沒有輸出就很奇怪
作者: xuyaqi    時間: 2023-5-25 16:50
牛牛牛牛牛牛 發(fā)表于 2023-5-25 16:33
跟這個引腳沒啥關系吧

這個腳電壓能知道內部工作電壓是否加上,反饋情況。
作者: xuyaqi    時間: 2023-5-25 16:52
牛牛牛牛牛牛 發(fā)表于 2023-5-25 16:35
萬用表好著呢,按理來說數據寫進到數據寄存器,就不需要管了呀,芯片就會生成數據寄存器的值調出來的電流 ...

你數據是希望輸出多大電流?
作者: 牛牛牛牛牛牛    時間: 2023-5-25 16:59
xuyaqi 發(fā)表于 2023-5-25 16:52
你數據是希望輸出多大電流?

4~20ma 的10ma

作者: 牛牛牛牛牛牛    時間: 2023-5-26 09:27
xuyaqi 發(fā)表于 2023-5-25 16:22
輸出接電阻,用電壓表測,是否電流表有問題。

感謝老哥,還真是這萬用表電流檔有點問題,測不出來,最后串聯了一個電阻,測電壓,然后算電流沒問題,誤差0.02




歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1