Home        Store        Learn        Blog

T200 Thrusters pwm settings are not working. Pymavlink or code has problem?

from pymavlink import mavutil
from time import sleep
from time import time as TM
from datetime import datetime as dt


pixhawk = mavutil.mavlink_connection('udpin:192.168.2.1:14550')
pixhawk.wait_heartbeat() 
print("heartbeat found!")

def pwm_gonder(channel_id, pwm=1500):
    rc_channel_values = [65535 for _ in range(18)]
    rc_channel_values[channel_id - 1] = pwm
    pixhawk.mav.rc_channels_override_send(
        pixhawk.target_system,                
        pixhawk.target_component,            
        *rc_channel_values)

pixhawk.arducopter_arm()

def on_saniye():
    endtime = TM()+5
    while TM() < endtime:
        pwm_gonder(3,1100)
    endtime = TM()+5
    print("Test11")
    while TM() < endtime:
        pwm_gonder(3,1200)
    endtime = TM()+5
    print("Test12")
    while TM() < endtime:
        pwm_gonder(3,1300)
    endtime = TM()+5
    print("Test13")
    while TM() < endtime:
        pwm_gonder(3,1400)
    endtime = TM()+5
    print("Test14")
    while TM() < endtime:
         pwm_gonder(3,1500)
    endtime = TM()+5
    print("Test15")
    while TM() < endtime:
        pwm_gonder(3,1600)
    endtime = TM()+5
    print("Test16")
    while TM() < endtime:
        pwm_gonder(3,1700)
    endtime = TM()+5
    print("Test17")
    while TM() < endtime:
        pwm_gonder(3,1800)
    endtime = TM()+5
    print("Test18")
    while TM() < endtime:
        pwm_gonder(3,1900)
    endtime = TM()+5
   
  
    
on_saniye()

pixhawk.arducopter_disarm()

I am trying to run my T200 thrusters with pymavlink code. But I am having trouble with thruster speeds.

My Setup
I am using an adapter to give 12V to the Thruster.
Using Windows10 computer, Raspi3b as companion comp.Px4 as autopilot.
A single thruster is connected to mainpin5 on the servo rail.
ardusub firmware latest version (upgraded recently)
I have the basic ESC from bluerobotics. Wires are correctly connected.
Qgroundcontrol can use the thrusters perfectly – Both directions and all speed configs, all 6 motors at once and also with joystick. So I don’t believe power is the problem. It seems that my code has some problem. Any solutions?

Expected behaviour and what happened instead
I started by sending 1100 pwm for 5 seconds and then increased the pwm signal to 1900 – with 5 seconds increments. I was expecting it to start fast in reverse direction, slow down and stop at 1500 and begin speeding up the other way until it reahed 1900.

Instead at 1100 the thrusters didn’t rotate at all, at 1200 the thruster began to spin slowly, 1300 and 1400 had a significant increase in speed (same direction as before), at 1500 the T200 didn’t stop and increased speed even more. From 1500 onwards the thruster speed was relatively stable and still very high. At 1900 the thruster disarmed and the test was over.

Other Tests
I sent a 1500 signal for 10 seconds. The thruster -instead of doing nothing- spun significantly fast.
I tried sending a 1900 pwm signal that gradually dampened to 1500, the motor speed started high and stayed that way.

Hi @VioletCheese,

Just to make sure, you are running ArduSub right ? Double check that and update to the latest stable version if possible.

Just to clarify:

RC_CHANNELS_OVERRIDE at channel 3 will control the vertical thrusters (5 and 6). 1100 should dive fast, 1900 surface fast.
if you don’t want unexpected thrusters to spin (trying to self-level the rov), make sure you are running in manual mode, too.

I am using Ardusub. I have the 6 Thruster motor setup. Its named Vectored,Bluerov2 I believe( 4 sideways at 45angle, 2 vertical)

The vehicle is in Manual mode,
Another test I performed was the manual control command, The thrusters didn’t function there at all.
To check everything again, I deleted all my software(including pymavlink, python itself etc.), QGC and installed them again, same thing happened still.

Indeed, I test the thruster by connecting it to Main out 5 and sending a vertical command (rc3), I also tested it by connecting it to main out 1 and sending a forward command (rc5)
Still no resolution :confused:

Hi @VioletCheese,

Did you flash the default parameters for the vehicle ?

Sorry, but what is flashing?

The default vehicle frame parameters? If so then yes I loaded the default vehicle params. I then calibrated the accelerometer and compass, as my pixhawk is mounted differently than in the default settings.

can you share a dataflash log so we can check what is going on?

The site didn’t let me upload all my log files so I uploaded them to GoogleDrive.
https://drive.google.com/drive/folders/1xorB3PW0lHc7fr6Ttiqeb03LdRHG5yin?usp=sharing
It contains the last 22 log files. I am Also uploading the last 4 here if you would like that. I have recently installed ubuntu and am now trying to solve the problem in linux (also gstreamer is way easier to use :D). I will keep this thread updated if anything new happens or I find the problem. Thanks in advance.
log_18_UnknownDate.bin (5.7 MB)
log_19_UnknownDate.bin (8.1 MB)
log_20_UnknownDate.bin (852 KB)
log_21_UnknownDate.bin (1.2 MB)

Hi @VioletCheese ,

I looked at some of your logs but I can’t really understand what is going on, they don’t seem to match the code snippet you sent earlier. Can you run that once and send me the log of that run? An explanation of what you see happening again would be useful, too.