jetson nx fan auto pwm

2023-05-16

参考:Jetson Nano-PWM自动调速_Ay_yzx的博客-CSDN博客

代码:

#!/usr/bin/env python
import os
# import commands

# from the path of this pattern
# path = '/sys/kernel/debug/soctherm/{dev}/temp'
path = '/sys/kernel/debug/bpmp/debug/soctherm/group_{dev}/temp'

# get the temperature from following sensors
# dev = ['cpu', 'gpu', 'mem', 'pll']
dev = ['CPU', 'GPU', 'AUX', 'PLLX']
# the fan PWM factor is 0 ~ 255, make 10 as the min, 255 as the max
# the fan speed will be sliding from 10% ~ 100% according to the temperature
# the greater, the cooler yet noisier, this script will balance it
MIN=80
MAX=255
RANGE=MAX-MIN
# the target file to write PWM factor to control the fan speed
TARGET_PWM = '/sys/devices/pwm-fan/target_pwm'

# defined the lowest temperature (Celsius), fan speed at MIN if temp lower then this
LOWEST=38.0
# defined the highest temperature (Celsius), fan speed at MAX if temp higher then this
HIGHEST=60.0
# the temp at range between HIGHEST and LOWEST, the fan speed is auto ajusted
# to balance the cool and the quiet
TMP_RANGE=HIGHEST-LOWEST

def getTmpFromFile(p):
    '''get temp value in Celsius from a file'''
    with open(p, 'r') as f:
        x = f.read()
        y = int(x)/1000.0
        return y

def getSpeedByTemp(temp):
    '''calculate a fan speed pwm factor from a temperature in Celsius'''
    if temp<=LOWEST-5:
        return 0
    if temp<=LOWEST:
        return MIN
    if temp>=HIGHEST:
        return MAX
    
    rate = (temp-LOWEST)/TMP_RANGE
    return MIN+int(RANGE*rate) if rate<1.0 else MAX
        
def setSpeed(pwm):
    '''write target PWM factor to the target file to set fan speed'''
    with open(TARGET_PWM, 'w') as f:
        f.write(str(pwm))

# get max temperature from all sensors
max_temp = max(map(getTmpFromFile, map(lambda x: path.format(dev=x), dev)))
# print(max_temp)
# calculate the target fan pwm factor
target_speed = getSpeedByTemp(max_temp)
print('{}, {}, {}%'.format(max_temp, target_speed, str(int(target_speed/2.55))))
# set to target file to take effect
setSpeed(target_speed)

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

jetson nx fan auto pwm 的相关文章

随机推荐

  • keil C数组声明问题

    C语言中 xff0c 我们声明一个一维数组 xff0c 可以用以下几种方法 int buf 3 int buf 61 0 int buf 3 61 1 2 3 但是今天在keil中 使用int buf 61 0 这种方式进行声明 xff0c
  • 初学QML之qmlRegisterType

    qmlRegisterType 是一个可以将C 43 43 实现的类在QML中调用的 xff0c 连接C 43 43 和QML的一个工具 首先来看QtAssistant的介绍 int qmlRegisterType const char u
  • 在IDEA中引入jQuery无效

    在idea开发前端页面中 xff0c 引入jQuery后 xff0c 使用 会出现下划线 xff0c 提示未定义 虽然不影响使用 xff0c 运行后可以得到正常结果 xff0c 但还是看的很不爽 解决办法 xff1a Preferences
  • Asterisk WebRTC 搭建指南

    1 WebRTC简介 WEBRTC是一个开源项目 xff0c 其宗旨是让WEB浏览器通过简单的JavaScript具备实时通信 Real Time Communications RTC 的能力 WEBRTC目前支持JS和HTML5 xff0
  • UDP三种通讯方式

    单播 xff1a 单播用于两个主机之间的端对端通信 组播 xff1a 组播用于对一组特定的主机进行通信 广播 xff1a 广播用于一个主机对整个局域网上所有主机上的数据通信 单播实现 发送端 public class SendDemo pu
  • ArduPilot——如何对飞控LOG进行简易振动分析

    版权声明 xff1a 本文为博主原创博文 xff0c 未经允许不得转载 xff0c 若要转载 xff0c 请说明出处并给出博文链接 首先 xff0c 你得先有一架可以飞的且刷的是ArduPilot飞控代码的无人机和地面站Misson Pla
  • SITL Simulator —— ArduPilot —— Windows

    版权声明 xff1a 本文为博主原创博文 xff0c 未经允许不得转载 xff0c 若要转载 xff0c 请说明出处并给出博文链接 参考网页 xff1a http ardupilot org dev docs sitl native on
  • ArduCopter——ArduPilot——航点导航WPNav(一)

    版权声明 xff1a 本文为博主原创博文 xff0c 未经允许不得转载 xff0c 若要转载 xff0c 请说明出处并给出博文链接 现如今 xff0c 四旋翼飞行器已经从几年前的遥控航模变成真正可以超视距操控的无人机 xff0c 离不开伟大
  • 多频超声波清洗换能器用于高精密清洗系统

    多频超声波清洗换能器因加工方式和工作要求不同 xff0c 超声波换能器的工作方式可分为连续工作和脉冲式工作 xff0c 不同的工作方式对换能器的要求是不同的 连续式工作是不停机工作 xff0c 工作电流不是很大 xff0c 一般使用在清洗方
  • 超声波发生器电源控制电路线路板设计

    超声波发生器电源控制电路线路板是由匹配电容 xff0c 驱动变压器 xff0c 高功率的IGBT功率管 xff0c 匹配电感盒MOS管组成 xff0c 所有的组件一目了然 xff0c 零部件少 xff0c 故障率低 xff0c 造价成本低
  • 洗碗机超声波换能器振子设计

    超声波的声波是一种可以穿透液体和固体的声学化学能量 xff0c 超声波的污染非常小穿透力强 xff0c 所以人们就想到了用它来清洗餐具 xff0c 于是乎超声波洗碗机就应运而生了 洗碗机超声波换能器振子作为超声波洗碗机的三大组件之一 xff
  • 超声波清洗机电路板线路板设计

    在我们日常生活中遇见的超声波清洗设备 xff0c 大多是使用低频率或低功率的超声波 xff0c 而且由于被清洗件尺寸往往较小 xff0c 所以清洗槽的尺寸往往也较小 xff0c 清洗槽内壁高度一般不高于400mm 这类清洗机清洗物品涉及范围
  • 在Mac中开发STM32单片机

    想要在Mac下开发32单片机 xff0c 又不想装虚拟机的同学可以看看 使用工具 xff1a CLion xff08 JetBrains家族一员 xff09 STM32CubeMX xff08 配置芯片 xff0c 生成初始化代码 xff0
  • 超声波电路板驱动线路设计

    超声波电路板驱动线路通电交流电压220V 10 xff0c 电源电压需稳定 体积小 占用空间小 功率大 清洗效果好 自动化程度高 超声波电路板驱动线路驱动超声清洗换能器依次启动低频初洗 中频精洗 换水 高频漂洗 排水等工序 超声波发生器的输
  • 小型超声波PCB电路板设计

    小型超声波PCB电路板通过自动频率跟踪技术 PWM调功控制技术 电容阻抗匹配技术来匹配超声波清洗换能器 小型超声波PCB电路板在驱动负载工作时 xff0c 负载参数会发生变化 xff0c 这就是需要小型超声波PCB电路板能及时捕捉到新的谐振
  • 压电陶瓷超声波换能器设计

    压电陶瓷超声波换能器是值由电能通过压电陶瓷片转化为机械能 xff0c 通过结构件放大传播出去的一种机械运动 压电陶瓷超声波换能器的压电陶瓷片尺寸越大 xff0c 输出的功率越大 xff0c 相应的频率越低 xff0c 而尺寸越小频率相对应的
  • 数字式小型超声波清洗机设计

    数字式小型超声波清洗机可以超声 加热 定时LED数码显示 xff0c 整机为不锈钢结构 使用新型加热方式 xff0c 有效提升加热效果 xff1b 结构工艺上提升防漏水等级 xff0c 同时兼容无效热能导出结构 xff1b 压花处理不锈钢工
  • 超声波清洗振板盒带发生器设计

    超声波清洗振板盒带发生器投入式清洗 xff0c 方便携带移动使用 xff1b 时间可调 xff1a 1 99分钟可调 xff0c 可常开 xff1b 功率可调 xff1a 10 100 可调 xff1b 304外壳 xff1a SUS304
  • PE塑料超声波焊接机设备设计

    聚乙烯 xff08 polyethylene xff0c 简称PE xff09 是乙烯经聚合制得的一种热塑性树脂 在工业上 xff0c 也包括乙烯与少量 烯烃的共聚物 聚乙烯无臭 xff0c 无毒 xff0c 手感似蜡 xff0c 具有优良
  • jetson nx fan auto pwm

    参考 xff1a Jetson Nano PWM自动调速 Ay yzx的博客 CSDN博客 代码 xff1a usr bin env python import os import commands from the path of thi