Controlling a Servo Motor - Printable Version +- PINE64 (https://forum.pine64.org) +-- Forum: PINE A64(+) (https://forum.pine64.org/forumdisplay.php?fid=4) +--- Forum: Pine A64 Hardware, Accessories and POT (https://forum.pine64.org/forumdisplay.php?fid=32) +---- Forum: Pi2, Euler and Exp GPIO Ports (https://forum.pine64.org/forumdisplay.php?fid=34) +---- Thread: Controlling a Servo Motor (/showthread.php?tid=4755) |
Controlling a Servo Motor - casmiguefl - 07-13-2017 I'm finding it impossible to work with GPIO and wanted to connect a small servo motor to the Pine64 in order to control it. In this particular case I want to set 2 particular degrees depending on a variable. With an Arduino, this is basic: Servo.attach(#controlpin); Servo.write(#angle); Any tutorials around on how to do it here? RE: Controlling a Servo Motor - Luke - 07-13-2017 (07-13-2017, 01:14 PM)casmiguefl Wrote: I'm finding it impossible to work with GPIO and wanted to connect a small servo motor to the Pine64 in order to control it. Take a look in Marcus' thread history, he has posted a lot about GPIO, etc. RE: Controlling a Servo Motor - pfeerick - 07-13-2017 (07-13-2017, 01:14 PM)casmiguefl Wrote: I'm finding it impossible to work with GPIO and wanted to connect a small servo motor to the Pine64 in order to control it. For the servos, no, I don't think so. Most of the documentation is for simple GPIO stuff like on/off toggling and I/O expansion. Whilst it should be possible drive the servos from the pine64 using soft pwm (based on the ideas from this posts code), I don't know how successful you will be, as SBCs are not that good for accurate timing signals... You are much better off using a dedicated IC (i.e. a ATTny85 programmed to work in conjunction with the pine64, which can provide the necessary accurate PWM signals for the servo, or an Arduino Pro Mini). But if you want to give a go to see what the pine64 can do anyway, that's great too! RE: Controlling a Servo Motor - MarkHaysHarris777 - 07-13-2017 (07-13-2017, 01:14 PM)casmiguefl Wrote: <snip> No; however, I have placed several tutorials on the RPi forum website that do show how to use the RPi ( or any other SBC ) to control motors; this includes steppers, and servos. pfeerick is correct, the best way to control a servo is with an MCU like the arduino or equivalent; however, any SBC can be used. You will want to start with servo theory and learn what it is that makes a servo motor travel a certain number of degrees ( on way or the other ). It has less to do with the timing and more to do with the signal. Steppers are a horse of another color, and very easily controlled by any SBC including the RPi, PineA64, or Rock64. I plan to put a stepper blog on the forum soon, so stay posted. Steppers are also less about timing and more about signal; specifically the right four bits (in parallel) in the right sequence with the proper driver circuit. The key to steppers is using a ULN2803A driver chip; this circuit permits the driving of inductive loads in excess of 500ma without harming the gpio block of your SBC. Remember that inductive loads like relays, servos, and stepper motors can produce large back EMF that will quickly destroy your SBC; always use an ULN2803A or equivalent to drive those loads. The Gertboard comes with the gpio buffers and ULN2803 prewired ; you can still find it a few places; if not, you'll have to make the equivalent yourself; not hard. |