3
\$\begingroup\$

I am using the BGMC2 (http://www.rovertec.com/products-bgmc2.html) to control a gimbal motor (http://www.iflight-rc.com/ipower-motor-gbm5208h-200t-brushless-gimbal-motor-with-as5048a-encoder.html). I am running the following code on my Raspberry pi to send the controller a PWM signal:

import os
import time
os.system("sudo pigpiod") #launch GPIO library
time.sleep(1)
import pigpio

ESC = 4
# white wire to 4 (7)
# black wire to 23 (6)

pi = pigpio.pi();
pi.set_servo_pulsewidth(ESC, 0)

max_value = 2500
min_value = 500

def control():
    print "Starting motor"
    time.sleep(1)
    speed = 1900
    while True:
        pi.set_servo_pulsewidth(ESC, speed)

def arm():
    print "Connect battery and press Enter"
    inp = raw_input()
    if inp == '':
        pi.set_servo_pulsewidth(ESC, 0)
        time.sleep(1)
        pi.set_servo_pulsewidth(ESC, max_value)
        time.sleep(1)
        pi.set_servo_pulsewidth(ESC, min_value)
        time.sleep(1)
        control()

print "Starting..."
arm()

Here is the schematic we built: enter image description here

  I noticed that the controller regularly flashes the RED light labeled D2 and my gimbal motor shakes back and forth while this is happening.  I was wondering how I could go about debugging this problem to prevent the motor from shaking back and forth.

\$\endgroup\$
  • \$\begingroup\$ Can you post a schematic or diagram of how you have things wired? \$\endgroup\$ – ThreePhaseEel Nov 18 '17 at 23:36
  • \$\begingroup\$ @ThreePhaseEel Ok I have added a schematic of the wiring. \$\endgroup\$ – Ryan Jordan Nov 19 '17 at 0:03
  • \$\begingroup\$ What happens if you just do pi.set_servo_pulsewidth(ESC, speed) once instead of continuously? \$\endgroup\$ – Bruce Abbott Nov 19 '17 at 1:25
  • \$\begingroup\$ If your "minimum" pulse width is 250, why are you setting it to zero? \$\endgroup\$ – Ron Beyer Nov 19 '17 at 3:01
  • \$\begingroup\$ @RonBeyer -- (I'm working with him on the project) -- He is following the instructions from this link to control a brushless motor (not gimbal) - instructables.com/id/… - We assumed if we replaced the ESC motor controller with a gimbal motor controller it would work out. I think he sets it to 0, then max, then min to calibrate the motor. \$\endgroup\$ – Tyler H Nov 19 '17 at 14:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.