PWM brightness control

Hi,
I wanted to control brightness of “Cree XLamp MK-R” LED via PWM.
This LED has an input voltage of 7-48 V and PWM logic voltage of 3-48 V.

I have a Jetson TX2 board, please guide if this is feasible on this board.
If not please suggest some driver compatible with jetson TX2 board to achieve the same?

Yes, check out this post as well as this one; you can just vary the pwm duty cycle to vary brightness, the solution use the fan gpio to generate pwm signal, there is some limitations to this method but none that you should care about
Regards

Thanks for the reference links.

To be exact i was looking for software PWM generation. Is there any way to do so on a gpio pin?

You could use RPI.GPIO see doc, and follow the guide the activate GPIO.
Here is a simple code to vary brightness :

import RPi.GPIO as GPIO
import time
in1 = 16
def main():
    GPIO.setmode(GPIO.BOARD)
    GPIO.setup(in1, GPIO.OUT)
    pwm = GPIO.PWM(in1,100)
    pwm.start(50)
    for i in range(100):
        pwm.ChangeDutyCycle(i)
        print(i)
        time.sleep(0.1)       
    pwm.stop()
    GPIO.cleanup()

if __name__ == '__main__':
    main()

Regards

Hi,
The link shared for configuring the 40 pin header for PWM, I have already tried that in jetson TX2 board but couldn’t find any option to configure a gpio as a PWM ( Maybe it is available with Jetson Nano board only).

And For the code shared by you is using a RPi library will it work with Jetson TX2.
Also is there any reference in C++ rather than in python?

hello akshata,

may I know which pin you’re used, please access pinmux spreadsheets via download center.
you may change the pinmux configuration applied by the software, please refer to Pinmux Changes session.
thanks

Hi,
I am currently using the default configuration fro J21 header.

I was looking to generate PWM from one of the GPIO pins in that header. Can you please guide me through how to do so as I am new to Jetson TX2 board.

It would be great if can help with some sample code too for the same in c++.

hello akshata,

you may control it via sysnode,
please also refer to below topics about PWM configurations though it’s based-on Nano platform,
for example,
PWM Frequency Upper Limitation with Jetson.GPIO and Nano pwm0 cant work.

Hello Jerry,
Thanks for your reply.

The two topics you mentioned are using a JETSON NANO board but I wanted to do the same in JETSON TX2 board.

In my case as soon as i run the jetson-io.py i do not see any pwm options. Also if I choose configure 40 pin header option, PWM options are not even present.

As you suggested that we can do it by using sysnode please share the steps to do so for JETSON TX2 specifically.

I have been trying to generate PWM on the devkit without any success for the past 2 weeks.

hello akshata,

it’s same, $ cat /sys/kernel/debug/pwm for checking PWM status.
you may enter /sys/class/pwm/ and using $ echo to export PWM using the commands.
for example,

# cd /sys/class/pwm/
# echo 0 > pwmchip0/export
# echo 10000 > pwmchip0/pwm0/period
# echo 2000 > pwmchip0/pwm0/duty_cycle
# echo 1 > pwmchip0/pwm0/enable
# cat /sys/kernel/debug/pwm
...
platform/3280000.pwm, 1 PWM device
pwm-0   (sysfs               ): requested enabled period: 10000 ns duty: 2000 ns polarity: normal

Hi,
Thanks for the reply.
It is somewhat helpful but how can I test it? Is it directed to any GPIO pin on J21 header? How can I connect any led to test it?

hello akshata,

may I know which pin on J21 you would like to used?

please also refer to device tree for the mappings of PWM,
as my above sample, it’s tegra_pwm1: pwm@3280000 {...}.
for example,
$L4T_Sources/r32.5/Linux_for_Tegra/source/public/hardware/nvidia/soc/t18x/kernel-dts/tegra186-soc/tegra186-soc-pwm.dtsi

you should access pinmux spreadsheets to have customization if the default pin settings is not PWM.
you may also check developer guide, Jetson TX2 Series MB1 Platform Configuration,
please refer to [PWM Specific Commands] session for PWM specific commands in MB1-BCT,
thanks

Pin no 11 on J21 header will do

hello akshata,

please access Jetson TX2 Developer Kit User Guide, it’s default configure as GPIO. (i.e. GPIO3_PT.02).
also, according pinmux spreadsheets , there’s no options to configure this pin as PWM.
thanks

hi,
can you suggest any pin on j21 header that can be used for pwm generation?

hello akshata,

please check below topic for reference to control PWMs,
thanks