Help with Explorer Hat and Servos


#1

Background:
I want to build a dog treat dispenser. I bought a Zevro dispenser, and have been following along with tutorials like this one http://www.robpeck.com/2017/11/robs-raspberry-pi-powered-cat-feeders/#.WzFrlS2ZOHp
The main difference between mine and theirs is that I’d like to keep the knob and use a motor and turn it (rather than replace it). I wanted to bolt a plastic disc with a servo to control it.

I’ve got a Raspberry Pi 3b and the Explorer Hat Pro. The hat works fine. I’ve run tests, and everything seems to work. However…

What’s wrong:
I’ve tried to connect up 2 different servos ( [sg90](http://akizukidenshi.com/download/ds/towerpro/SG90.pdf and hs-311 ) and neither of them seems to work, and I feel like I must be doing something wrong. Not sure how to debug.

I’ve got red to 5V, black to GRND, and yellow to the PWM of the Explorer hat.I’ve also installed pi-blaster. When I run ‘echo 18=0.2 > /dev/pi-blaster’ (following this) it returns immediately and nothing happens.

  1. Do I need a resistor?
    I’m not using one right now. If I need to use one, how do I know how strong of a resistor I need?

  2. I have a gear motor working. Why use a servo instead?
    I bought one from Pimoroni, and it works just fine when connected to motor outputs of the Explorer and it works fine. I’m not sure I understand why most people go the servo route. I only want to turn the motor on for a second or two at a time in 1 direction. The gear motor seems pretty powerful.

I’m pretty disappointed by the lack of resources around the Explorer Hat! I think I’m gonna write a post once I get things working.


#2

I think there is more involved after running echo 18=0.2 > /dev/pi-blaster? Did you enter any other commands after that? I do believe that above command gets it ready to do things, but you then have to tell it what to do.
What you use, servo versus motor depends on what you want to do. I built a couple of rovers with Explorer pHats. I want continuous rotation so I used motors. They are actually geared motors in a micro servo shell. I don’t need super accuracy, just stop and go when I tell them too.
If you want accurate repeatable movement, like a robot arm or something, you use a servo. It will move exactly where you tell it too. The large metal gear ones will have lots of torque for heavy lifting moving. The down side is limited movement. The servo arm will only go so far. 180 degrees I think?
There are also continuous rotation servos. You can put wheels of gears on those and get arcuate speed distance movements. trickier to control though.

Have a look at this, https://learn.adafruit.com/adafruits-raspberry-pi-lesson-8-using-a-servo-motor/overview
You’ll have to adjust things for your setup, Your explorer hat is basically the solderless breadboard. The code looks to use the same GPIO PIN 18.


#3

Forgot to mention, you don’t need the Explorer Hat to run a servo. You could do that with just a Pi. The Explorer hat just extends the GPIO pin up for easy access. If you go with a motor, yes, you’ll want to use the H bridge on the Explorer hat to drive it.
For your treat dispenser, using an impeller, I’d go with a motor. Maybe one of these, https://shop.pimoroni.com/?q=micro
The tricky part is picking the right ratio. I think a high ratio with a slow speed is what you want. Timing will be easier the slower the output shaft turns. I think it also gives the motor a bigger mechanical advantage, less chance of a stall.