1200|11

2655

帖子

6

TA的资源

五彩晶圆(初级)

楼主
 

使用MicroPython读取ADX3228的ID [复制链接]

 
 
  • from machine import Pin, SoftSPI
  • import time
  • def ID(agreement):
  • #txbuf 需要将16进制转换为10进制
  • txbuf =bytearray([17])
  • rxbuf = bytearray(3) # create a buffer
  • spi = SoftSPI(baudrate=100000, polarity=1, phase=0, mosi=Pin(4), miso=Pin(16), sck=Pin(2))
  • spi.init(baudrate=125000) # set the baudrate
  • p16 = Pin(17, Pin.OUT) # create output pin on GPIO16
  • p16.value(1) # set pin to on/high
  • time.sleep(1)
  • p16.value(0) # set pin to on/high
  • #给芯片发送SDATAC
  • spi.write(txbuf) # write to MOSI and read from MISO into the buffer
  • txbuf =bytearray([32,0,0])
  • #给芯片发送读取ID的指令并且读取ID
  • spi.write_readinto(txbuf, rxbuf) # write to MOSI and read from MISO into the buffer
  • p16.value(1) # set pin to on/high
  • return rxbuf

以上是MicroPython的代码,

以下是Python代码

  • import time
  • import pyvisa
  • import serial
  • import logging
  • #定义测试步数
  • TestStep=100
  • logging.basicConfig(level=logging.INFO, filename='coder.log', filemode='a',
  • format='%(asctime)s- %(levelname)s: %(message)s')
  • logLevel=logging.StreamHandler()
  • logLevel.setLevel(level="INFO")
  • logger = logging.getLogger('simpleExample')
  • # 连接demo板
  • ESP32 = serial.Serial('COM22', 115200, timeout=2)
  • # Pyserial 必须等待5S
  • time.sleep(3)
  • ESP32.write(b'import ADX3228\r\n')
  • rm = pyvisa.ResourceManager()
  • # 打印资源名称
  • print(rm.list_resources())
  • E_Source=rm.open_resource(' ')
  • print(E_Source.query("*IDN?"))
  • E_Source.write("INST P6V")
  • #设置电压电流
  • E_Source.write("VOLT 5.0")
  • E_Source.write('CURR 0.2')
  • E_Source.write('OUTPut OFF')
  • time.sleep(1)
  • #打开电源
  • E_Source.write('OUTPut ON')
  • while TestStep>0:
  • E_Source.write('OUTPut ON')
  • time.sleep(0.3)
  • TestStep=TestStep-1
  • #读取ID并做记录
  • ESP32.write(b'ADX3228.ID(1)\r\n')
  • Espmessage=ESP32.readlines()
  • print(Espmessage)
  • logger.info(Espmessage)
  • E_Source_Current = E_Source.query("MEASure:CURRent? P6V")
  • E_Source_Voltage = E_Source.query("MEASure:VOLTage? P6V")
  • logger.info("Source Current:"+E_Source_Current)
  • logger.info("Source Voltage:" + E_Source_Voltage)
  • E_Source.write('OUTPut OFF')
  • time.sleep(1)
  • # E_Source_Current = E_Source.query("MEASure:CURRent? P6V")
  • # E_Source_Voltage = E_Source.query("MEASure:VOLTage? P6V")
  • # logger.info("Source Current:"+E_Source_Current)
  • # logger.info("Source Voltage:" + E_Source_Voltage)
  • ESP32.close()

使用ESP32+MicroPython 配合Pyvisa等 完成自动化测试,最后收集数据即可,大大提升了工作效率

  • 2023-12-28 11:52:24,378- INFO: [b'import ADX3228\r\n', b'>>> ADX3228.ID(1)\r\n', b"bytearray(b'\\x00\\x00\\x0e')\r\n", b'>>> ']
  • 2023-12-28 11:52:24,623- INFO: Source Current:+1.09928000E-01
  • 2023-12-28 11:52:24,623- INFO: Source Voltage:+4.99952200E+00
  • 2023-12-28 11:52:30,956- INFO: [b'ADX3228.ID(1)\r\n', b"bytearray(b'\\x00\\x00\\x0e')\r\n", b'>>> ']
  • 2023-12-28 11:52:31,203- INFO: Source Current:+1.09928000E-01
  • 2023-12-28 11:52:31,203- INFO: Source Voltage:+4.99952200E+00
  • 2023-12-28 11:52:37,541- INFO: [b'ADX3228.ID(1)\r\n', b"bytearray(b'\\x00\\x00\\x0e')\r\n", b'>>> ']
  • 2023-12-28 11:52:37,785- INFO: Source Current:+1.09928000E-01
  • 2023-12-28 11:52:37,785- INFO: Source Voltage:+4.99952200E+00
  • 2023-12-28 11:52:57,079- INFO: [b'import ADX3228\r\n', b'>>> ADX3228.ID(1)\r\n', b"bytearray(b'\\x00\\x00\\x0e')\r\n", b'>>> ']
  • 2023-12-28 11:52:57,330- INFO: Source Current:+1.09928000E-01
  • 2023-12-28 11:52:57,331- INFO: Source Voltage:+4.99952200E+00
  • 2023-12-28 11:53:03,660- INFO: [b'ADX3228.ID(1)\r\n', b"bytearray(b'\\x00\\x00\\x0e')\r\n", b'>>> ']
  • 2023-12-28 11:53:03,913- INFO: Source Current:+1.09928000E-01
  • 2023-12-28 11:53:03,913- INFO: Source Voltage:+4.99952200E+00
  • 2023-12-28 11:53:10,231- INFO: [b'ADX3228.ID(1)\r\n', b"bytearray(b'\\x00\\x00\\x0e')\r\n", b'>>> ']
  • 2023-12-28 11:53:10,493- INFO: Source Current:+1.10091000E-01
  • 2023-12-28 11:53:10,494- INFO: Source Voltage:+4.99952200E+00
  • 2023-12-28 11:53:16,834- INFO: [b'ADX3228.ID(1)\r\n', b"bytearray(b'\\x00\\x00\\x0e')\r\n", b'>>> ']
  • 2023-12-28 11:53:17,075- INFO: Source Current:+1.09928000E-01
  • 2023-12-28 11:53:17,075- INFO: Source Voltage:+4.99952200E+00

 

查看本帖全部内容,请登录或者注册

最新回复

强啊! 在用这个片子做蓝牙采样,这蓝牙协议设计的什么破玩意,看不明白啊   详情 回复 发表于 2023-12-29 08:56
点赞 关注
个人签名

希望做一些大家觉得好用的东西!

 
 

回复
举报

2655

帖子

6

TA的资源

五彩晶圆(初级)

沙发
 

附上美照,记得要先发Sdatac先才可以读取Id


IMG_20231228_141019.jpg (0 Bytes, 下载次数: 0)

IMG_20231228_141019.jpg
 
 
 

回复

7188

帖子

11

TA的资源

版主

板凳
 

楼主大佬的手机强呀,拍的效果不错。这个是几路的采集,有没有多路的,我有个20*4的,有没有解决方案呀?

点评

这个是8路的  详情 回复 发表于 2023-12-28 16:00
 
 
 

回复

2655

帖子

6

TA的资源

五彩晶圆(初级)

4
 
lugl4313820 发表于 2023-12-28 15:18 楼主大佬的手机强呀,拍的效果不错。这个是几路的采集,有没有多路的,我有个20*4的,有没有解决方案呀?

这个是8路的


点评

8路是spi接口还是i2c接口呀,要是i2c路,采集完需要多少个时间呀。  详情 回复 发表于 2023-12-28 20:43
 
 
 

回复

7188

帖子

11

TA的资源

版主

5
 

8路是spi接口还是i2c接口呀,要是i2c路,采集完需要多少个时间呀。

 
 
 

回复

7188

帖子

11

TA的资源

版主

6
 

看了一下,spi接口的,看来读取速还是非常的快吧。

点评

对,96ksps 最高可以  详情 回复 发表于 2023-12-28 23:09
 
 
 

回复

2655

帖子

6

TA的资源

五彩晶圆(初级)

7
 
lugl4313820 发表于 2023-12-28 20:44 看了一下,spi接口的,看来读取速还是非常的快吧。

对,96ksps 最高可以


 
 
 

回复

1万

帖子

25

TA的资源

版主

8
 

点评

赞  详情 回复 发表于 2023-12-29 08:19
 
 
 

回复

2655

帖子

6

TA的资源

五彩晶圆(初级)

9
 
dcexpert 发表于 2023-12-28 23:16


 
 
 

回复

734

帖子

0

TA的资源

纯净的硅(高级)

10
 

强啊!

在用这个片子做蓝牙采样,这蓝牙协议设计的什么破玩意,看不明白啊

点评

用micropython可能还好?  详情 回复 发表于 2023-12-29 09:05
 
 
 

回复

2655

帖子

6

TA的资源

五彩晶圆(初级)

11
 
极限零 发表于 2023-12-29 08:56 强啊! 在用这个片子做蓝牙采样,这蓝牙协议设计的什么破玩意,看不明白啊

用micropython可能还好?


 
 
 

回复

2655

帖子

6

TA的资源

五彩晶圆(初级)

12
 
  • import time
  • import pyvisa
  • import serial
  • import logging
  • import random
  • logging.basicConfig(level=logging.INFO, filename='coder.log', filemode='a',
  • format='%(asctime)s- %(levelname)s: %(message)s')
  • logLevel=logging.StreamHandler()
  • logLevel.setLevel(level="INFO")
  • logger = logging.getLogger('simpleExample')
  • rm = pyvisa.ResourceManager()
  • print(rm.list_resources())
  • ESP32 = serial.Serial('COM24', 115200, timeout=2)
  • # Pyserial 必须等待5S
  • time.sleep(5)
  • # 打印资源名称
  • E_Source=rm.open_resource('USB0::0x2A8D::0x1102::MY61002562::INSTR')
  • print(E_Source.query("*IDN?"))
  • E_Source.write("INST P6V")
  • #设置电压电流
  • E_Source.write("VOLT 3.3")
  • E_Source.write('CURR 0.2')
  • E_Source.write('OUTPut OFF')
  • # 设置AVDD 开
  • E_Source.write("INST P25V")
  • #设置电压电流
  • E_Source.write("VOLT 3.3")
  • E_Source.write('CURR 0.2')
  • E_Source.write('OUTPut OFF')
  • time.sleep(1)
  • ESP32.write(b'import ADX3228\r\n')
  • #连接demo板
  • print(ESP32.readlines())
  • E_Source.write('OUTPut ON')
  • time_sleep=2
  • E_Source.write('OUTPut OFF')
  • def ON_AVDD():
  • #设置AVDD 开
  • E_Source.write("INST P6V")
  • E_Source.write("OUTPut ON")
  • def ON_DVDD():
  • #设置DVDD 开
  • E_Source.write("INST P25V")
  • E_Source.write("OUTPut ON")
  • def OFF_ALL():
  • E_Source.write("INST P25V")
  • E_Source.write("OUTPut OFF")
  • E_Source.write("INST P6V")
  • E_Source.write("OUTPut OFF")
  • OFF_ALL()
  • TestStep=0
  • delaytime=random.randint(0,3)
  • while TestStep<20000:
  • ON_AVDD()
  • time.sleep(delaytime)
  • ON_DVDD()
  • time.sleep(delaytime)
  • ESP32.write(b'ADX3228.ID(1)\r\n')
  • Espmessage=ESP32.readlines()
  • print(Espmessage)
  • logger.info(Espmessage)
  • logger.info("1:AVDD 2:DVDD TestStep"+str(TestStep))
  • E_Source_Current = E_Source.query("MEASure:CURRent? P6V")
  • E_Source_Voltage = E_Source.query("MEASure:VOLTage? P6V")
  • logger.info("AVDD Current:"+E_Source_Current)
  • logger.info("AVDD Voltage:" + E_Source_Voltage)
  • E_Source_Current = E_Source.query("MEASure:CURRent? P25V")
  • E_Source_Voltage = E_Source.query("MEASure:VOLTage? P25V")
  • logger.info("DVDD Current:"+E_Source_Current)
  • logger.info("DVDD Voltage:" + E_Source_Voltage)
  • OFF_ALL()
  • time.sleep(delaytime)
  • ON_AVDD()
  • time.sleep(time_sleep)
  • ON_DVDD()
  • time.sleep(delaytime)
  • TestStep = TestStep + 1
  • # 读取ID并做记录
  • ESP32.write(b'ADX3228.ID(1)\r\n')
  • Espmessage = ESP32.readlines()
  • print(Espmessage)
  • logger.info(Espmessage)
  • logger.info("1:DVDD 2:AVDD")
  • E_Source_Current = E_Source.query("MEASure:CURRent? P6V")
  • E_Source_Voltage = E_Source.query("MEASure:VOLTage? P6V")
  • logger.info("AVDD Current:" + E_Source_Current)
  • logger.info("AVDD Voltage:" + E_Source_Voltage)
  • E_Source_Current = E_Source.query("MEASure:CURRent? P25V")
  • E_Source_Voltage = E_Source.query("MEASure:VOLTage? P25V")
  • logger.info("DVDD Current:" + E_Source_Current)
  • logger.info("DVDD Voltage:" + E_Source_Voltage)
  • OFF_ALL()
  • time.sleep(delaytime)
  • ON_DVDD()
  • time.sleep(time_sleep)
  • ON_AVDD()
  • time.sleep(delaytime)
  • # 读取ID并做记录
  • ESP32.write(b'ADX3228.ID(1)\r\n')
  • Espmessage = ESP32.readlines()
  • print(Espmessage)
  • logger.info(Espmessage)
  • logger.info("turn on off time" + str(time_sleep))
  • E_Source_Current = E_Source.query("MEASure:CURRent? P6V")
  • E_Source_Voltage = E_Source.query("MEASure:VOLTage? P6V")
  • logger.info("Source Current:" + E_Source_Current)
  • logger.info("Source Voltage:" + E_Source_Voltage)
  • E_Source_Current = E_Source.query("MEASure:CURRent? P25V")
  • E_Source_Voltage = E_Source.query("MEASure:VOLTage? P25V")
  • logger.info("Source Current:" + E_Source_Current)
  • logger.info("Source Voltage:" + E_Source_Voltage)
  • OFF_ALL()
  • time.sleep(delaytime)
  • # E_Source_Current = E_Source.query("MEASure:CURRent? P6V")
  • # E_Source_Voltage = E_Source.query("MEASure:VOLTage? P6V")
  • # logger.info("Source Current:"+E_Source_Current)
  • # logger.info("Source Voltage:" + E_Source_Voltage)
  • ESP32.close()

随机上下电压力测试

实测1900多次 都没啥问题

 

个人签名

希望做一些大家觉得好用的东西!

 
 
 

回复
您需要登录后才可以回帖 登录 | 注册

查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/10 下一条
有奖直播报名| TI 面向楼宇和工厂自动化行业的毫米波雷达解决方案
【内容简介】TI 60GHz IWRL6432和 IWRL1432毫米波雷达传感器如何帮助解决楼宇和工厂自动化应用中的感应难题
【直播时间】5月28日(周三)上午10:00
【直播礼品】小米双肩包、contigo水杯、胶囊伞、安克充电器

查看 »

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

 
机器人开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网 3

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表