We used /opt/nvidia/jetson-io/ Jetson-io.py to set up the PWM function of pin32,
#!/usr/bin/env python # Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved. # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation # the rights to use, copy, modify, merge, publish, distribute, sublicense, # and/or sell copies of the Software, and to permit persons to whom the # Software is furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. import Jetson.GPIO as GPIO import sys import time def main(): # Pin Setup: # Board pin-numbering scheme GPIO.setmode(GPIO.BOARD) # set pin as an output pin with optional initial state of HIGH GPIO.setup(32, GPIO.OUT, initial=GPIO.HIGH) p = GPIO.PWM(32, 1000) val = 25 incr = 5 p.start(val) print("PWM running. Press CTRL+C to exit.") try: while True: time.sleep(0.08) if val >= 100: incr = -incr if val <= 0: incr = -incr val += incr p.ChangeDutyCycle(val) finally: #GPIO.output(32,GPIO.LOW) p.stop() GPIO.cleanup() if __name__ == '__main__': main()
Above is our control code.
Following the same steps, we can successfully control pwm on the Jetson Xavier NX Devkit using the same steps and running the same script. But not on the ORIN NANO. The following error message will be displayed.
nvidia@nvidia:~$ sudo python3 gpio_test_pwm.py WARNING: Carrier board is not from a Jetson Developer Kit. WARNNIG: Jetson.GPIO library has not been verified with this carrier board, WARNING: and in fact is unlikely to work correctly. Traceback (most recent call last): File "gpio_test_pwm.py", line 54, in <module> main() File "gpio_test_pwm.py", line 33, in main p = GPIO.PWM(32, 1000) File "/usr/local/lib/python3.8/dist-packages/Jetson/GPIO/gpio.py", line 478, in __init__ self._ch_info = _channel_to_info(channel, need_pwm=True) File "/usr/local/lib/python3.8/dist-packages/Jetson/GPIO/gpio.py", line 113, in _channel_to_info return _channel_to_info_lookup(channel, need_gpio, need_pwm) File "/usr/local/lib/python3.8/dist-packages/Jetson/GPIO/gpio.py", line 107, in _channel_to_info_lookup raise ValueError("Channel %s is not a PWM" % str(channel)) ValueError: Channel 32 is not a PWM Exception ignored in: <function PWM.__del__ at 0xffff802afc10> Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/Jetson/GPIO/gpio.py", line 510, in __del__ if _channel_configuration.get(self._ch_info.channel, None) != HARD_PWM: AttributeError: 'PWM' object has no attribute '_ch_info'
We are using the L4T35.3.1 system version.
Note that when I use similar python scripts to control the heights of other GPIOs, it works. And there will be the same warning.
How do I solve it?