Flickering PWM frequency

Hi,

I’ve been trying to create a 3D solution using stereoscopic camera on Jetson Orin Nano. Using python, opencv and gstreamer I captured the camera visuals from both the cameras and made the camera visuals to display alternately in specific interval of 9ms. Also I triggered the GPIO pin to toggle HIGH when left frame displayed on the monitor and LOW for the right frame.

It should generate a frequency of 48 Hz on the GPIO, but it generates frequencies like 47.685, 48.247, 49.186 etc. I checked the waveform on DSO and got to know that the time period of pulses are varying, thereby the frequencies are varied. Since the active 3D shutter glasses accepts only specific frequencies like 48, 50 Hz to respond and shutter.

Here are time stamps printed on serial terminal:

Total Elapsed Time: 9.488 ms

Total Elapsed Time: 10.088 ms

Total Elapsed Time: 9.654 ms

Total Elapsed Time: 9.995 ms

The timings were not all uniform.

So I should need to make the time period of pulses uniform and generates 48Hz without decimals for the 3D glasses to see the 3D content .

Please help me to overcome this frequency flickering issue!

Hi user19854,

Are you using the devkit or custom board for Orin Nano?
What’s your Jetpack version in use?

Could you share the steps how you generate PWM signal?

I am using the devkit of Orin Nano.

The Jetpack I’ve used is 5.1.2, as i need to work with stereoscopic camera module.

def start_cameras():
left_camera = CSI_Camera(sensor_id=0)
right_camera = CSI_Camera(sensor_id=1)

cv2.namedWindow("VIDEO_3D", cv2.WINDOW_AUTOSIZE)

left_flag = True

try:
    while cv2.getWindowProperty("VIDEO_3D", 0) >= 0:
        start_time = time.time()

        if left_flag:
            grabbed, frame = left_camera.read()
            if grabbed:
                cv2.imshow("VIDEO_3D", frame)
                GPIO.output(led_pin, GPIO.HIGH)
        else:
            grabbed, frame = right_camera.read()
            if grabbed:
                cv2.imshow("VIDEO_3D", frame)
                GPIO.output(led_pin, GPIO.LOW)

        left_flag = not left_flag

        if (cv2.waitKey(9) & 0xFF) == 27:
            break

        '''elapsed_time = time.time() - start_time
        print("Total Elapsed Time: {:.3f} ms".format(elapsed_time * 1000))
        print("-----------------------------------------------------------------------")''' 

this is how it generates the pwm.

Could you try to use Jetson-GPIO to generate PWM to check if there’s the same issue?
You can refer to the similar steps as Unable to generate PWM with Nvidia Jetson AGX Orin Development Kit - #6 by KevinFFF for the Orin Nano devkit.

Hey,

these are things i’ve used in the code:

import Jetson.GPIO as GPIO

pwm_pin = 15
GPIO.setmode(GPIO.BOARD)
GPIO.setup(led_pin, GPIO.OUT)

BTW pwm was generated but the frequency generated was flickering.
I’ve introduced a 9ms of delay in between the imshows.

Was that due to any memory latency?
Any idea to overcome this issue and make it uniform in time periods?

Hey,

I also tried to develop a simple 48Hz pwm on 15th physical pin (It’s a pin dedicated for pwm).
Even though it flickers between 47.76,47.95,47.55 etc.
Why it’s not stable frequency from the pin of orin nano?

Any solutions for it? Since my hardware needs exact 48Hz to drive the transmitter.

Please comment your thoughts on it.

Do you get the result from oscilloscope?
If so, could you share the waveform you measured?



Are you using pwm1 from PIN15 of 40-pin expansion header?

If so, please share the result of the following commands on your board.

$ sudo su
# cd /sys/kernel/debug/bpmp/debug/clk/pwm1
# cat parent
# cat rate

It seems you want 48Hz PWM signal, do you configure 48Hz as frequency with 50% duty cycle?

Sorry that I’m not clear about your script how to specify 48Hz
Have you tried to generate PWM through sysfs as following?

$ sudo su
# cd /sys/class/pwm/pwmchip0
# echo 0 > export
# cd pwm0
# echo 20833333 > period
# echo 10416667 > duty_cycle
# echo 1 > enable

Could you also share the result of the following command on your board after you configure the pwm1 with 48Hz?

$ sudo busybox devmem 0x03280000

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.