Home        Store        Docs        Blog

Changing Speed Of T100 Thruster


(cteckkai) #1

Hi,

I’m wondering how can I change the speed of the t100, i tried to write the byte, set at max forward but the speed of the t100 maintained at 300 rpm. is there anything I should change or take note ? Btw, I’m using raspberry pi and the code i used are as follow

import smbus

import math

import time

from time import sleep

bus = smbus.SMBus(1)

DEVICE_ADDRESS = 0x29

 

THROTTLE_h = 0x00 #I2c register of the throttle

THROTTLE_l = 0x01

THROTTLE = (THROTTLE_h<<8) | THROTTLE_l

print(“starting…”)

bus.write_byte_data(DEVICE_ADDRESS, THROTTLE, 0)

bus.write_byte_data(DEVICE_ADDRESS, THROTTLE, 32767)


(Jacob) #2

Please post the code that you are using to do this.

-Jacob


(cteckkai) #3

hi thanks for the reply, i have edit my message to include the code


(Rusty) #4

Hi cteckkai,

It looks like you are sending the command to the wrong address. The throttle value address is just 0x00. You don’t need to put two bytes together like you are doing. You should be able to do something like:

bus.write_byte_data(DEVICE_ADDRESS, 0x00, 32767)

That should run it at full speed.

Let us know how it goes.

-Rusty


(cteckkai) #5

Hi Rusty,

I am unable to test it out because out of a sudden, the thruster doesnt spin anymore, but it can still read the voltage, temperature as well as current value. Not too sure what causes this, i have change the raspberry pi but result is still the same.

 


(cteckkai) #6

Hi Rusty,

your suggestion is able to work but what i found out is if i use the exact same python code in a new different file on my raspberry pi, the thruster can work not sure what causes this. And also instead of 32767, all i have to write is 30 then it will spin at at approximately 2000 rpm. Thanks for you help


(Rusty) #7

Hi cteckkai,

That is very strange that a new file with the same contents will not work. Can you post a working file and a non-working file?

The thruster will spin for any input greater than 0. It will spin much faster at full throttle at 32767.

-Rusty


(cteckkai) #8

Hi rusty that’s the 2 python file


(cteckkai) #9

Hi all, Reviving this thread again. I would like to ask did anyone encounter the issue of changing speed ?

i tried to use the same code to run the thruster at throttle value of 32767 but it is not running at the maximum speed and instead only running at 200-300 rpm. Is there anything I did wrong ? Or I have to include some extra codes ??


(Rusty) #10

Teck Kai,

Can you try running at 32766 instead?

-Rusty


(cteckkai) #11

no, it doesn’t work, i have tried a various number of speed. At throttle 30000, its only spinning at 1300 rpm and anything after 30000, speed reduces. However, if running the thruster at throttle 3000 / 4000, it seems to be giving a lot more speed … I did not try any throttle above 4000 because water is splashing everywhere haha… have to clear up the mess first

I tried on another thruster as well but it is behaving in the same way. I have attached the code as below in case there is something wrong with it.

 

import smbus
from time import sleep
import math
bus = smbus.SMBus(1)

you may have to use “SMBus(0)” for older pi’s

DEVICE_ADDRESS = 0x29

I2c address of the motor “0x29” is the default

THROTTLE = 0x00

I2c register of the throttle (it is 16 bit/2 byte so treat it like a “word”)

#print(“starting…”)
bus.write_word_data(DEVICE_ADDRESS, THROTTLE, 0)
bus.write_word_data(DEVICE_ADDRESS, THROTTLE, 30500)

while True:
bus.write_word_data(DEVICE_ADDRESS, THROTTLE, 30500)
RPM_h = bus.read_byte_data(DEVICE_ADDRESS,0x02) #RPM i2c register
RPM_l = bus.read_byte_data(DEVICE_ADDRESS,0x03) #RPM i2c register
VOLT_h = bus.read_byte_data(DEVICE_ADDRESS,0x04) #volt i2c register
VOLT_l = bus.read_byte_data(DEVICE_ADDRESS,0x05) #volt i2c register
TEMP_h = bus.read_byte_data(DEVICE_ADDRESS,0x06) #temperature i2c register
TEMP_l = bus.read_byte_data(DEVICE_ADDRESS,0x07) #temperature i2c register
CURR_h = bus.read_byte_data(DEVICE_ADDRESS,0x08) #current i2c register
CURR_l = bus.read_byte_data(DEVICE_ADDRESS,0x09) #current i2c register

RPM = (RPM_h<<8) | RPM_l
VOLT = (VOLT_h<<8) | VOLT_l
TEMP = (TEMP_h<<8) | TEMP_l
CURR = (CURR_h<<8) | CURR_l

#Formula extracted from bluerobotics blueesc documentation

#RPM Calculation
#RPM is send as pulses since last read, which is the number
#of commutation cycles since the i2c was polled
#N(poles) for T100 is 12 and T200 is 14
#RPS(esc) = RPS(raw)/ ((N(poles) * (change of time))
#RPM(esc) = RPS(esc) * 60
#Change of time calculated is 1.~ seconds which will not significantly
#affect the calculation therefore change of time is omitted

Real_RPM = RPM / (12) * 60
print(“RPM Value is:%0.2f” %Real_RPM)

#Voltage Calculation
Real_VOLT = VOLT * 0.0004921
print(“Voltage Value is:%0.2f” %Real_VOLT)

#Temperature Calculation
#Temperature measured by a 10k themistor(NCP18XH103J03RB) and a 3.3k resistor
#calculated using steinhart-hart equation
#1/T = 1/T0 + 1/B * ln(l/T)
thermistornominal = 10000 #thermistor resistance at 25 deg C
temperaturenominal = 25 #temp for nominal resistance
bcoefficient = 3900 #beta coefficient of the thermistor
seriesresistor = 3300 #resistance of other resistor
resistance = seriesresistor / ((65535/TEMP)-1)
steinhart = resistance / thermistornominal #(R/R0)
steinhart = (math.log(steinhart) / bcoefficient

  • 1/(temperaturenominal + 273.15)) #ln(R/R0) * 1/B + 1/T0
    steinhart = 1/steinhart - 273.15
    print(“Temperature Value is:%0.2f” %steinhart)

#Current Calculation
Real_CURR = (CURR-32767)*0.001122
print(“Current Value is:%0.2f” %Real_CURR)

#Power Calculation
Power = Real_CURR * Real_VOLT
print(“Power Value is:%0.2f” %Power)

sleep(1)


(cteckkai) #12

Okay, i tried using arduino to run the example code by bluerobotics this time round

#include <Wire.h>
#include “Arduino_I2C_ESC.h”

#define ESC_ADDRESS 0x29

Arduino_I2C_ESC motor(ESC_ADDRESS);

int signal;

void setup() {
Serial.begin(9600);
Serial.println(“Starting”);

Wire.begin();

// Optional: Add these two lines to slow I2C clock to 12.5kHz from 100 kHz
// This is best for long wire lengths to minimize errors
TWBR = 158;
TWSR |= bit (TWPS0);
}

void loop() {

if ( Serial.available() > 0 ) {
signal = Serial.parseInt();
}

motor.set(0);
motor.set(10000);
motor.update();

Serial.print(“ESC: “);
if(motor.isAlive()) Serial.print(“OK\t\t”);
else Serial.print(“NA\t\t”);
Serial.print(signal);Serial.print(” \t\t”);
Serial.print(motor.rpm());Serial.print(" RPM\t\t");
Serial.print(motor.voltage());Serial.print(" V\t\t");
Serial.print(motor.current());Serial.print(" A\t\t");
Serial.print(motor.temperature());Serial.print(" `C");
Serial.println();

delay(250); // Update at roughly 4 hz for the demo

}

 

This code is able to run the thruster at approximately 2000 RPM but if I set the motor value at 20000 or more, the thruster will be flashing red led while is it running. Not sure why this is happening ?? Also, same throttle value given in raspberry pi and arduino seems to be giving different speed (not talking about the display RPM calculated but visually you can see there is a difference). Can anyone point out what’s wrong with the raspberry pi code as well as the arduino code.


(cteckkai) #13

Another note, running at throttle value of 37000 will also work as well and at greater speed than 32767…

Value after 31950 seems to decrease the speed

Just curious, will the choice of battery affect this ? im using a turnigy 5000mah 3s 20c lipo pack


(Rusty) #14

Hi Teck Kai,

I think the problem with the Raspberry Pi code is how you are sending the throttle value. The value has to be sent as a 16 bit integer. Right now, it is being written as a single byte in this line:


bus.write_word_data(DEVICE_ADDRESS, THROTTLE, 30500)

The value of 30500 doesn’t actually fit into a 8-bit byte, so it’s getting truncated to a much smaller value (30500 >> 8 = 119). That’s why you’re getting unpredictable behavior from different values.

The throttle needs to be sent as 16 bits. For instance:


throttle = 30500
bus.write_i2c_block_data(DEVICE_ADDRESS, THROTTLE, [(throttle&gt;&gt;8),throttle])

I haven’t tested that, but it should split the throttle value into two bytes (16 bits total) and send it properly. This is the same way it is being done in the Arduino_I2C_ESC library.

Let me know if that helps.

Regarding the flashing red light - it flashes while the thruster is running? Is it constantly or sporadic?

-Rusty


(cteckkai) #15

hello rusty, thanks for your help. the code is able to work (phew finally). As for the flashing red light yes, it flashes while running after i upload the ino to the arduino, i can say its flashing constantly, not too sure about this because when it run for about 10s, i removed the power source


(Rusty) #16

Teck Kai,

Okay, can you run it for a bit longer? I would recommend running in the water if that’s possible, otherwise limit the time you run it to 30-45 seconds.

-Rusty


(cteckkai) #17

Hi Rusty,

 

Sorry for the late reply, been trying out the thruster at different throttle but there are some range of the throttle that are rather weird, example at throttle -15564 to -12288, speed is increasing normally from 0 to -11468 then suddenly it starts to drop before returning back to the supposingly correct speed. There are also range of positive throttle whereby, speed decrease before increasing it again. (from throttle 9830 to 12288)

As for the arduino problem, i did not try it again, incase it got damage and I cannot proceed with my research work so I’ll leave it for now.

 

Once again, thanks for your help all these while.