0

I am using the 30A BLDC ESC to control a brushless motor from my Raspberry Pi 3 B+. The documentation for the ESC can be found here: ESC pdf

I seem to have successfully calibrated the ESC, but after it is finished arming, it emits a 56712 tone and, indicating the direction of throttle is reversed -- I'm not quite sure what this means and how to fix. I have the right battery for the ESC (11.1V Li-Po battery).

I do not have an additional hat or board for my Raspberry Pi... Should I invest in one? Could this provide throttle control that the Pi is unable to for some reason?

The code I wrote is below (Python 3.8):

# libraries
import os
import sys

# Linux path
sys.path.append('./subsystems')

# RPi path
sys.path.insert(0, '/home/reyna/Airplane/subsystems')

# subsystems
from motor_pigpio import Motor_Pigpio

class Configure():

    def __init__(self):
        ### INSTANTIATE ###
        self.cockpit = Motor_Pigpio()

        ### CALIBRATE ###
        self.cockpit.calibrate(18)

config = Configure()
# libraries
import pigpio
import time

class Motor_Pigpio():

    ### define ###

    # duty cycle
    # frequency

    def __init__(self):
        self.pi = pigpio.pi()
        print(self.pi.connected)
        # successfully prints 'True'

    def max_val(self, pin_num):
        self.pi.set_servo_pulsewidth(pin_num, 2000)

    def min_val(self, pin_num):
        self.pi.set_servo_pulsewidth(pin_num, 700)

    def calibrate(self, pin_num):
        self.pi.set_mode(pin_num, 1)
        self.pi.set_servo_pulsewidth(pin_num, 0)
        time.sleep(1)
        inpt = input()
        if inpt == '':
            self.max_val(pin_num)
            print("Connect BATTERY now. Wait for 2 beeps. Enter.")
            inpt = input()
            time.sleep(1)
            if inpt == '':
                self.min_val(pin_num)
                print("Special tone")
                time.sleep(7)
                print("Just wait...")
                time. sleep(5)
                self.pi.set_servo_pulsewidth(pin_num, 0)
                time.sleep(2)
                print("ARMING")
                time.sleep(1)

    def arm(self, pin_num):
        # minimum throttle
        self.min_val(pin_num)
        time.sleep(1)
        self.max_val(pin_num)
        time.sleep(1)

    def run(self, pin_num, freq, throttle):
#        self.pi.set_PWM_range(pin_num, 255)
        self.pi.set_PWM_frequency(pin_num, freq)
#        self.pi.set_PWM_dutycycle(pin_num, dc)
        self.pi.set_servo_pulsewidth(pin_num, throttle)

    def end_run(self):
        #self.pi.stop()
        pass

I apologize in advance if another thread already exists for this. I have been searching for a few hours to no avail.

Edit: I have tested the code on a servo. Noticed that the servo goes almost to its extrema but not all the way. Is this to be expected or is something off?

  • your links seems broken! – tlfong01 May 26 at 0:42
  • 1
    whoops, you're right! I changed it, thanks – frc_contributor May 26 at 19:08
1

My initial problem seems to be irrelevant. I did not understand what was meant by "throttle" which is more of an RC jargon misunderstanding than it is an issue with raspberry pi. (If you're looking for an answer this link shows it pretty well.)

Sorry for being off-topic! Sometimes it's hard to know when you are working from little experience. :)

| improve this answer | |
  • Please accept your own answer with a click on the tick on its left side. Only this will finish the question and it will not pop up again year for year. – Ingo May 30 at 8:11

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.