ponticellius
Posts: 3
Joined: Mon May 17, 2021 5:43 am

frame rate dropping substantially when servo motor introduced

Mon May 17, 2021 5:47 am

Hi, I am running opencv2 through python and using the pi camera 2 module. It is tracking faces, and runs well. When code to activate a servo motor from a servo controller is introduced however, the frame rate drops substantially. I am wondering if someone would be willing to speculate as to why this could happen. The pi is a rp4. Could it be needing code optimization, or could it be related to power consumption of the servo motor? I can provide code if necessary. This is my first post here, I apologize if anything crucial is missing!

Thanks so much

wolf.z
Posts: 147
Joined: Thu Dec 24, 2015 8:34 pm

Re: frame rate dropping substantially when servo motor introduced

Mon May 17, 2021 3:22 pm

I'm afraid, you provided too little information.

Assuming, your servo controller is connected via UART, you might face an interrupt handling / OpenCV realtime operation conflict.

But it's just guessing....

ponticellius
Posts: 3
Joined: Mon May 17, 2021 5:43 am

Re: frame rate dropping substantially when servo motor introduced

Mon May 17, 2021 5:06 pm

Let me try to provide more information, and thank you for the response.

The servo controller is connected to the 3.3v, GND, and GPIO pins 3 and 5 (i2c: SDA/SCL). I see that the pins 14/15 are UART, so I will venture to say I am not connected via UART, but please correct me if I am mistaken.

I just tried connecting the servo directly to the pi without using the servo controller, and the results were the same as with the servo controller.

What other information could I provide?

ponticellius
Posts: 3
Joined: Mon May 17, 2021 5:43 am

Re: frame rate dropping substantially when servo motor introduced

Tue May 18, 2021 1:12 am

I have since fixed the issue. I had the code for the servo motor default position indented incorrectly. It was being called in a while loop which accounted for a lot of the slowdown. I also had a few other methods that weren't crucial to the program, as well as being ssh'd into the pi. Since removing all of this and running the code directly from the pi itself, the speed is quite good!

Return to “Advanced users”