PPS Module

PPS 类控制可编程电源(PPS),能够提供最高30V和5A的输出。它允许对输出电压和电流进行精确控制,并具有回读实际输出值和模块状态的功能。

支持以下产品:

PPSModule

Micropython Example:

 1# SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
 2#
 3# SPDX-License-Identifier: MIT
 4
 5import os, sys, io
 6import M5
 7from M5 import *
 8from module import PPSModule
 9import time
10
11
12label0 = None
13label1 = None
14label2 = None
15label3 = None
16label4 = None
17label5 = None
18pps_0 = None
19
20
21def setup():
22    global label0, label1, label2, label3, label4, label5, pps_0
23
24    M5.begin()
25    Widgets.fillScreen(0x222222)
26    label0 = Widgets.Label(
27        "Output Voltage:", 20, 40, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18
28    )
29    label1 = Widgets.Label(
30        "Output Current:", 20, 80, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18
31    )
32    label2 = Widgets.Label("Mode:", 22, 120, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
33    label3 = Widgets.Label("label3", 180, 40, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
34    label4 = Widgets.Label("label4", 180, 80, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
35    label5 = Widgets.Label("label5", 180, 120, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
36
37    pps_0 = PPSModule(address=0x35)
38    pps_0.set_output_voltage(5.5)
39    pps_0.set_output_current(1)
40    pps_0.enable_output()
41
42
43def loop():
44    global label0, label1, label2, label3, label4, label5, pps_0
45    M5.update()
46    label3.setText(str(pps_0.read_output_voltage()))
47    label4.setText(str(pps_0.read_output_current()))
48    label5.setText(str(pps_0.read_psu_running_mode()))
49    time.sleep_ms(100)
50
51
52if __name__ == "__main__":
53    try:
54        setup()
55        while True:
56            loop()
57    except (Exception, KeyboardInterrupt) as e:
58        try:
59            from utility import print_error_msg
60
61            print_error_msg(e)
62        except ImportError:
63            print("please update to latest firmware")

UIFLOW2 Example:

example.png

cores3_pps_example.m5f2

class PPSModule

Constructors

class PPSModule(addr=0x35)

创建一个PPS对象以控制可编程电源。

  • addr: PPS设备的I2C地址(默认为`0x35`)。

Methods

PPSModule.set_output(enable: bool)

启用或禁用PPS输出。

  • enable: True表示启用,False表示禁用。

UIFLOW2:

set_output.png

PPSModule.enable_output()

启用PPS输出。

UIFLOW2:

enable_output.png

PPSModule.disable_output()

禁用PPS输出。

UIFLOW2:

disable_output.png

PPSModule.set_output_voltage(voltage: float)

设置PPS的输出电压。

  • voltage: 期望的输出电压,从0.0到30.0伏特。

UIFLOW2:

set_output_voltage.png

PPSModule.set_output_current(current: float)

设置PPS的输出电流。

  • current: 期望的输出电流,从0.0A到5.0A。

UIFLOW2:

set_output_current.png

PPSModule.read_psu_running_mode() int

读取PSU运行模式。

UIFLOW2:

read_psu_running_mode.png

PPSModule.read_output_current() float

读取当前输出电流。

UIFLOW2:

read_output_current.png

PPSModule.read_output_voltage() float

读取当前输出电压。

UIFLOW2:

read_output_voltage.png

PPSModule.read_input_voltage() float

读取输入电压。

UIFLOW2:

read_input_voltage.png

PPSModule.read_data_update_flag() int

读取数据更新标志,每当数据更新一次,此标志将增加1。

UIFLOW2:

read_data_update_flag.png

PPSModule.read_mcu_temperature() float

读取MCU温度。

UIFLOW2:

read_mcu_temperature.png

PPSModule.read_module_id() int

读取模块ID。

UIFLOW2:

read_module_id.png

PPSModule.read_uid() bytearray

读取唯一标识符(UID)。

UIFLOW2:

read_uid.png

PPSModule.get_i2c_address() int

获取设备的当前I2C地址。

UIFLOW2:

get_i2c_address.png

PPSModule.set_i2c_address(new_address: int)

为设备设置新的I2C地址。

  • new_address: 要设置的新I2C地址。

UIFLOW2:

set_i2c_address.png