Trying to reverse T200 directions

Hi everyone,

I am trying to write a python program to test the T200 thrusters using a adafruit. I have the thrusters individually moving forward without any issue but I am trying to reverse the direction as well but am having major issues. I would really appreciate some help. below I have provided the code that I am currently using to test my thrusters. I am using a Raspberry pi 4B:

from adafruit_servokit import ServoKit
import time

Initialize the PCA9685 servo driver with 16 channels

kit = ServoKit(channels=16)

Define the channel for the single thruster being tested

THRUSTER_CHANNEL = 0 # Update to match your thruster’s channel

Function to test a single thruster

def test_thruster(channel, forward_min=1500, forward_max=1900, reverse_min=1500, reverse_max=1100, step=100):
print(f"Testing Thruster on Channel {channel}")
kit.continuous_servo[channel].throttle = 0.0 # Ensure no signal initially
time.sleep(1)

# Test forward direction
print("Testing forward direction...")
for pwm in range(forward_min, forward_max + 1, step):
    normalized_pwm = (pwm - 1500) / 500  # Normalize PWM range for Adafruit ServoKit
    print(f"Channel {channel}: PWM {pwm}, Normalized: {normalized_pwm}")
    kit.continuous_servo[channel].throttle = normalized_pwm
    time.sleep(2)  # Hold each signal for 2 seconds

# Stop for a moment
print("Stopping thruster...")
kit.continuous_servo[channel].throttle = 0.0
time.sleep(2)

# Test reverse direction
print("Testing reverse direction...")
for pwm in range(reverse_min, reverse_max - 1, -step):
    normalized_pwm = (pwm - 1500) / 500  # Normalize PWM range for Adafruit ServoKit
    print(f"Channel {channel}: PWM {pwm}, Normalized: {normalized_pwm}")
    kit.continuous_servo[channel].throttle = normalized_pwm
    time.sleep(2)  # Hold each signal for 2 seconds

# Stop thruster
print("Stopping thruster...")
kit.continuous_servo[channel].throttle = 0.0
print(f"Thruster test completed for Channel {channel}")

if name == “main”:
try:
test_thruster(THRUSTER_CHANNEL)
except KeyboardInterrupt:
print(“Test interrupted. Setting thruster to neutral.”)
kit.continuous_servo[THRUSTER_CHANNEL].throttle = 0.0

Hi @MakanH420 -
Welcome to the forums!
You shared your code and mentioned you’re having issues reversing the thrsuer direction - but not shared what those issues are!

What ESCs are you using with the Raspberry Pi? Do they support bidirectional operation?

You could use an oscilloscope to verify the signal you’re outputting, and seeing if it is changing as you expect. I would suspect that the issues you’re having is connected to the portions of your code where you normalize the servo signal - it really needs to be a value of between 1000 and 2000 us, wtih 1500us corresponding to 0 throttle. When outputting servo signals directly from Raspberry Pi pins, I’ve always preferred pigpiod, but it seems you’re using an adafruit multiplexer?

Hi @tony-white

I think the issue may actually be the esc. I am using 30A RC Brushless Motor Electric Speed Controller ESC 3A UBEC with XT60 & 3.5mm Bullet Plugs. But I saw something that it is bidirectional and other things that say it’s only unidirectional. I think my team is going to just buy esc’s that are clearly bidirectional. We are using an adafruit for this simply to make it easier on our overall system since we are controlling 6 thrusters total.

Hi @MakanH420 -
Given that product name is quite generic and you didn’t list the vendor it was sourced from, there’s not much feedback I can give. It is likely it is unidirectional - you could always try with a servo tester to verify!

The Navigator provides more output channels like the board from Adafruit you’re using, but also provides motion sensors and breakouts for Serial and I2C! Support of ArduSub/ArduRover, as well as use of BlueOS may put your project on the fast track!