Home        Store        Docs        Blog

Rasbperry pi 3 and t100 thrusters


(morgan) #1

I am using a Raspberry Pi 3, Afro ESC’s, and t100 thrusters. I am a beginner. I am trying to connect the t100 thrusters to my raspberry pi 3. I have the correct physical set up, but i am having a hard time with the python code to make the t100 thrusters power on and perform. we are using dc batteries for the power source. we are having issues finding a python code to control both thrusters together. we want the thrusters to move in forward, reverse, left and right. we also want to control them independently.

Below i have pasted the code we have been editing and working on. why wont this code work?

Servo Control
import time
import wiringpi

use ‘GPIO naming’
wiringpi.wiringPiSetupGpio()

set #18 to be a PWM output
wiringpi.pinMode(18, wiringpi.GPIO.PWM_OUTPUT)

set the PWM mode to milliseconds stype
wiringpi.pwmSetMode(wiringpi.GPIO.PWM_MODE_MS)

divide down clock
wiringpi.pwmSetClock(192)
wiringpi.pwmSetRange(2000)

delay_period = 0.01

while True:
for pulse in range(50, 250, 1):
wiringpi.pwmWrite(18, pulse)
time.sleep(delay_period)
for pulse in range(250, 50, -1):
wiringpi.pwmWrite(18, pulse)
time.sleep(delay_period)


(Rusty) #2

Hi Morgan,

Thanks for the email! It looks like this code (from Adafruit) is meant to sweep a servo back and forth. Since the thrusters require a solid pulse at 1500 µs to initialize, they are probably not initializing properly.

Here’s small modification that should work:

# Servo Control
import time
import wiringpi

# use 'GPIO naming'
wiringpi.wiringPiSetupGpio()

# set #18 to be a PWM output
wiringpi.pinMode(18, wiringpi.GPIO.PWM_OUTPUT)

# set the PWM mode to milliseconds stype
wiringpi.pwmSetMode(wiringpi.GPIO.PWM_MODE_MS)

# divide down clock
wiringpi.pwmSetClock(192)
wiringpi.pwmSetRange(2000)

# PWM pulses for thruster:
# 110 = 1100 µs (full reverse)
# 150 = 1500 µs (stopped + initialize)
# 190 = 1900 µs (full forward)
# initialize thruster
wiringpi.pwmWrite(18, 150)

# wait for initialization (2 seconds)
time.sleep(2.0)

# set to some speed
wiringpi.pwmWrite(18, 170)

Let me know if that works.

-Rusty


Afro ESC's, t100 thrusters, Raspberry pi 3
(christos) #3

I am using a Raspberry Pi 2, Afro ESC’s, and t100 thrusters. I am a beginner. I am trying to connect the t100 thrusters to my raspberry pi 2. I had operated only one thruster with GPIO Pin 18 but I try to connect pins with different GPIO Pin but it isn’t work. I want connect four thruster. What’s happening?

Thanks
Christos

My program:

import time
import wiringpi

wiringpi.wiringPiSetupGpio()
pins = 18

wiringpi.pinMode(pins, wiringpi.GPIO.PWM_OUTPUT)
#wiringpi.pinMode(17, wiringpi.GPIO.PWM_OUTPUT)

wiringpi.pwmSetMode(wiringpi.GPIO.PWM_MODE_MS)
wiringpi.pwmSetClock(192)
wiringpi.pwmSetRange(2000)
print ("program")

while True:
    print ("on 150")
    wiringpi.pwmWrite(pins, 150)
#    wiringpi.pwmWrite(17, 150)
    time.sleep(2.0)
    print ("on 160")
    wiringpi.pwmWrite(pins, 160)
#    wiringpi.pwmWrite(17, 160)
    time.sleep(5.0)
    print ("off 130")
    wiringpi.pwmWrite(pins, 130)
#    wiringpi.pwmWrite(17, 130)
    time.sleep(2.0)
    print ("on 120")
    wiringpi.pwmWrite(pins, 120) 
#    wiringpi.pwmWrite(17, 120)
    time.sleep(2.0)
    print ("stop")
    wiringpi.pwmWrite(pins, 0)
#    wiringpi.pwmWrite(17, 0)

(Jacob) #4

Hi, the Raspberry Pi has only one gpio capable of pwm. If you want more pwm outputs, you will have to add something like the pwm shield.