Pan/Tilt strange behavior

Discussion related to "under the hood" OpenMV topics.
ScottM
Posts: 91
Joined: Thu May 30, 2019 2:12 pm
Location: Ottawa, Canada

Pan/Tilt strange behavior

Postby ScottM » Mon Mar 09, 2020 2:16 pm

I have a simple script that tests my pan motor. At zero degrees, it is pointing right where I want it. Sometimes, when the program ends, the thing will rotate -79 degrees, twisting my cables around the mounting post, all for no reason. The camera still has power, which means the pan/tilt motors have power. I feed 5V in from a power supply for this board. Why is the servo sometimes doing this unwanted rotation at the end?
User avatar
iabdalkader
Posts: 1193
Joined: Sun May 24, 2015 3:53 pm

Re: Pan/Tilt strange behavior

Postby iabdalkader » Mon Mar 09, 2020 2:56 pm

If there's nothing to block the cam at the end of the script, the cam will soft-reset some peripherals including servos, timers etc.. Just add a while (True): sleep(1000) at the end if you want to maintain that position.
ScottM
Posts: 91
Joined: Thu May 30, 2019 2:12 pm
Location: Ottawa, Canada

Re: Pan/Tilt strange behavior

Postby ScottM » Mon Mar 09, 2020 5:00 pm

Thanks. I'll try it.
ScottM
Posts: 91
Joined: Thu May 30, 2019 2:12 pm
Location: Ottawa, Canada

Re: Pan/Tilt strange behavior

Postby ScottM » Wed Mar 11, 2020 10:15 am

What do you mean by "If there's nothing to block the cam at the end of the script"? Do you mean physically block the servos from spinning around or add the infinite while loop to prevent the servo from receiving any more instructions? I am using the pan/tilt servos to point the camera where I need it to be. If I move the servos and then stop them with "while (True): time.sleep(1000)", then the program cannot move forward to use the camera to capture an image.

Is there anything you can do in your firmware to prevent the soft reset that makes the pan servo (Servo(1) # P7) from rotate 79 degrees occasionally?

From what I've read about servos, best practice is to provide the PWM signal before the servos get power to prevent any rapid jerky motion on startup, but in this case, I'd have to cut the power leads from the shield to the servos and control them with a relay.
User avatar
iabdalkader
Posts: 1193
Joined: Sun May 24, 2015 3:53 pm

Re: Pan/Tilt strange behavior

Postby iabdalkader » Wed Mar 11, 2020 2:41 pm

No I meant infinite loop, you said when the program ends, the soft reset happens if there's nothing blocking the script and it runs to completion.

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 18 guests