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)
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)
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?
The Raspberry Pi has only one hardware PWM, but these libraries provide a way to generate them via software. The downside of software PWMs is that they are often jittery, because they depend on the Operating System to work.
In my experience ServoBlaster had the best performance jitter-wise between all the libraries I tested for software PWM.
The code is fairly standard and does usually work. Can you please share a little about your setup, what you have tried, and where the problem lies?
Also note that the Raspberry Pi gets fairly warm and resourced up controlling 6 thrusters, lights, and everything else. Patrick’s suggestion is really worth consideration.