Hi everyone,
We are having an issue reversing the direction of our T200 thrusters. We are able to go forward just fine, but when we try to move in the reverse direction, it moves like a millimeter in the right direction, but then it just stops. Im not entirely sure what the issue is since I think the code is correct but I would really appreciate some help with this issue ASAP. Below is the code we are using to test the direction. Thanks.
Test program #1:
from adafruit_servokit import ServoKit
import time
# Initialize the PCA9685 servo driver with 16 channels
kit = ServoKit(channels=16)
# Define the channels for the thrusters being tested
THRUSTER_CHANNELS = [0, 1] # Channels 0 and 1
# Function to test multiple thrusters smoothly
def test_thrusters(channels, forward_min=1500, forward_max=1900, reverse_min=1500, reverse_max=1100, step=50):
print(f"\n--- Testing Thrusters on Channels {channels} ---")
# Set thrusters to neutral before testing
for channel in channels:
kit.continuous_servo[channel].throttle = 0.0
time.sleep(2)
# --- TEST FORWARD DIRECTION ---
print("\n>>> Moving Forward <<<")
for pwm in range(forward_min, forward_max + 1, step):
normalized_pwm = (pwm - 1500) / 500 # Normalize PWM range for Adafruit ServoKit
for channel in channels:
print(f"Channel {channel}: Forward PWM {pwm}, Normalized: {normalized_pwm:.2f}")
kit.continuous_servo[channel].throttle = normalized_pwm
time.sleep(1) # Reduced delay for smoother ramp-up
# Stop for a moment
print("\n--- Stopping Thrusters (Neutral) ---")
for channel in channels:
kit.continuous_servo[channel].throttle = 0.0
time.sleep(2)
# --- TEST REVERSE DIRECTION ---
print("\n>>> Moving Reverse <<<")
for pwm in range(reverse_min, reverse_max - 1, -step): # Use negative step for decreasing PWM
normalized_pwm = (pwm - 1500) / 500
for channel in channels:
print(f"Channel {channel}: Reverse PWM {pwm}, Normalized: {normalized_pwm:.2f}")
kit.continuous_servo[channel].throttle = normalized_pwm
time.sleep(1) # Keep it consistent with forward test
# Stop thrusters completely
print("\n--- Stopping Thrusters (Neutral) ---")
for channel in channels:
kit.continuous_servo[channel].throttle = 0.0
print(f"\n### Thruster Test Completed for Channels {channels} ###\n")
if __name__ == "__main__":
try:
test_thrusters(THRUSTER_CHANNELS)
except KeyboardInterrupt:
print("\nTest interrupted! Returning thrusters to neutral...")
for channel in THRUSTER_CHANNELS:
kit.continuous_servo[channel].throttle = 0.0
Test program #2:
import time
from adafruit_servokit import ServoKit
kit = ServoKit(channels=16)
kit.continuous_servo[0].throttle = 0
time.sleep(5)
print("reverse")
kit.continuous_servo[0].throttle = -0.5
time.sleep(1)
kit.continuous_servo[0].throttle = 0