I just bought the explorer hat pro. I know it’s kinda old. But, i’ve search around to learn how to control my tower pro sg90 servo with the explorer hat pro and python code. seems like there’s no demo and no video of anyone actually doing it. Unless, you can’t do that. IF that the case, I’ll have to use arduino. I prefer to use the explorer hat since i’m already use it for my sts pi robot. I think there’s a pi-blaster but i try download it seems having trouble downloading it. Maybe, because i’m using the latest raspbian stretch. Anyone, can help?
Explorer HAT definitely isn’t ideal for any servo, since the protected outputs will invert your signal and require a pull-up resistor to un-invert them again.
Servos are tricky in general since they require a 20ms period, with a (roughly) 1-2ms high pulse that maps to degrees of rotation. Python can approximate this timing, but with a degree of accuracy that results in really nasty jitter. This is why PanTilt HAT has a custom servo driver onboard, to reproduce the pulses with nanosecond accurcy.
Servo Blaster is the way to go, and your servo data signal should ideally be connected directly to a GPIO pin on the Pi (although be careful since the servo will be powered at 5v and you don’t want to fry anything accidentally). Admittedly I haven’t used it on Jessie, what trouble did you have downloading it?
thanks for the reply. I was hoping that i’ll be able to use the explorer hat as an all in one instead of having to get another motor shield or hat for my pi 3. The servo blaster keep saying, i need to update or find the missing files. I thought maybe because i was using the latest raspbian stretch. WHich i read that might not work with older programs. I’ll try to download again. Seems, a bit cumbersome though. Guess, I’ll have to find other ways. Can i put a link to my youtube sts pi robot here?
Explorer HAT doesn’t really offer much for servo driving, but since you can run them directly from the Pi pretty handily there shouldn’t be a need for another HAT. You could just use some of the regular GPIO breakouts on Explorer HAT to directly access a Pi pin.
You could experiment with the PWM pin and try these instructions: https://learn.adafruit.com/adafruits-raspberry-pi-lesson-8-using-a-servo-motor/software
that’s what i’m wondering. I’ve already link the motor1 and motor 2 via the explorer hat. so, i thought just link the 3 servo wires to the 5v, and ground while the data to pwn. And control via python. Although, don’t think you can use python to control at the same time?
Sorry, if i seem a new bird. I’m just a hobbyist learning for fun. I’m actually looking at beagleboard blue which have lots of motors and servos all-in-one for building drone. My next project!
Maybe, pimoroni doing their own all in one board soon?
Thanks for the links! I’ll check 'em out.
By the way, anyone interested to check out my sts pi robot vids here:
That should work. You can actually use Python’s
os.cmd to, somewhat naively, call the
gpio -g pwm 18 <number_of_ms> command.
Although I think the done thing is to use
subprocess.Popen() now, which is a little trickier. From memory something like:
pwm_pulse_ms = 1.5
subprocess.Popen(["gpio", "-g", "pwm", str(int(pwm_pulse_ms * 100))])
Although this requires that you set up PWM as per the Adafruit guide linked above.
hey mate. I followed, your link to adafruit. And, followed the code for python. and it work right off the bat. although, the “wiringpi” module only works in python 2.7. and didn’t work on version 3. Why don’t some of the old code works on the latest python? I always thought, that i was doing something wrong, until i realized that it only works in older python. Why can’t it be backward compatible? Anyway, it’s great to learn and now to be able to control a servo using the explorer hat pro. Cool!
Thanks for the help! :p
i got another question. can we use hy srf05 sensor on the explorer hat pro and using python code? I want to try the autonomous robot. i think vcc is for 5v, GND, TRIG is any of the 4 input and Echo is Output? I’m basing on some sr04 circuits i saw. Might be wrong. Tq
I think we investigated running those sensors off the Explorer HAT and came to the conclusion they’re best run from the GPIO directly with a voltage divider.
bummer. that’s what i’m afraid of. :p