Controlling a Servo Motor
#1
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?
  Reply
#2
(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.

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?

Take a look in Marcus' thread history, he has posted a lot about GPIO, etc.
You can find me on IRC, Discord and Twitter


  Reply
#3
(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.

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?

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! Wink
  Reply
#4
(07-13-2017, 01:14 PM)casmiguefl Wrote: <snip>

Any tutorials around on how to do it here?

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.
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Information Howto: Controlling Pine64 GPIO via the filesystem (sysfs) on linux pfeerick 4 12,776 01-24-2019, 03:36 AM
Last Post: Fifth
  Active Cooling 5v brushless fan with Motor Speed Controller soft PWM MarkHaysHarris777 14 24,625 06-26-2017, 03:16 PM
Last Post: ishwest
  Active Cooling soft PWM follow-on fan motor speed controller driver MarkHaysHarris777 3 7,330 09-02-2016, 11:46 PM
Last Post: MarkHaysHarris777

Forum Jump:


Users browsing this thread: 1 Guest(s)