LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices

Reply
 
Search this Thread
Old 10-20-2011, 03:31 PM   #1
icemetal
LQ Newbie
 
Registered: Oct 2011
Posts: 7

Rep: Reputation: Disabled
Question Controlling a servo with GPIO


I want to improve my skills controlling the GPIO of a linux embedded board, is there a site for beginner or where can I start with basic programs like controlling a servo motor? do I need to create the driver or I can just create the program to control a servo?
 
Old 10-21-2011, 08:03 AM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
As I understand it, GPIO is generally done through an existing generic driver, or by mmap'ing the hardware for direct userspace access. There are probably vendor-supplied kernel drivers or userspace drivers for the GPIO facility on your board. These may be accompanied by documentation and sample code that demonstrates the use of the drivers.
If you are talking about servos like the ones used in model airplanes and model cars, then you have a big obstacle to overcome. Linux is not a real-time OS, so generating accurate pulse-width-modulation (PWM) signals using bit-bashing techniques will almost always fail if done in userspace. That is because your task will be suspended while waiting to flip a bit, and will not be restarted until the optimal time has expired. There is little you can do to prevent this. PWM is almost always better done in hardware. Simple on-off control of discrete bits in non-time-sensitive ways should be fine.

--- rod.
 
1 members found this post helpful.
Old 10-21-2011, 06:12 PM   #3
icemetal
LQ Newbie
 
Registered: Oct 2011
Posts: 7

Original Poster
Rep: Reputation: Disabled
Rod you might an expert on desktop linux, but you are very far from the embedded world. You are posting false information that would confuse people

Last edited by icemetal; 10-21-2011 at 06:19 PM.
 
Old 10-21-2011, 06:33 PM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Okay, I'll eat my words, but please explain where you disagree.
--- rod.
 
Old 10-22-2011, 09:58 AM   #5
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 11,276
Blog Entries: 3

Rep: Reputation: 1446Reputation: 1446Reputation: 1446Reputation: 1446Reputation: 1446Reputation: 1446Reputation: 1446Reputation: 1446Reputation: 1446Reputation: 1446
Hi,

Stepper vs servo

I'll step in here a bit. Just having GPIO is not enough to control a stepper mechanism. You will need a interface to control the windings via the GPIO for single-axis steppers. Your handler must control the interface to control the step direction and rate for a stepper. Many manufactures provide controller chips/controllers that will make things easier for a stepper using single-axis control.

Where a servo mechanism has the motor, control interface(include feed back circuitry) to control motion speed and direction since the servo will be 3 wire. Thus isolation technique should be used, not directly driven. GPIO control for a servo is different and generally easier. Your handler will be simplified for a servo system by uses of a register technique. If you use a gated local register then you can buffer the control bits. In this manner your handler will provide control techniques that will enable the feedback mechanism to be read via interrupt thus positive(continuous)Input/ Output control.

One must know the advantages for a stepper based system (torque) over a finite servo mechanism. Stepper systems are costly at higher torque at the expense of power. Smaller and proportional control with a servo mechanism is very doable. As you increase size for servo mechanism(s) then one must compare between the two types of designs. What you are driving or managing will generally dictate the design.

Plus you need to remember to consider the angle when using a stepper vs servo. Type of controller for each will dictate that measure. How finite the design control will be for control of the drive function.

So if I were to suggest anything, I would experiment with both a stepper based system and a servo based. You will need to keep the load low so you have a fair comparison between the two control techniques. From a experimental sense you will need to have decent monitoring equipment. Been there done that many times!

I know your topic is 'servo' but you really should compare the two techniques. That way the advantages or disadvantages for each can be learned. Real world experimentation will reinforce your theoretical experiences.
HTH!
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Where is the GPIO function? ligang Linux - Embedded & Single-board computer 2 06-07-2010 11:46 PM
GPIO interfacing tomas632 Programming 1 01-13-2010 06:25 PM
Using GPIO (from kernel GPIO support) in MY application DannyGilbert Linux - Kernel 2 03-16-2009 07:52 AM
gpio board FrollyC Linux - General 4 02-09-2008 08:38 AM
Gpio rash_f Linux - Newbie 1 08-31-2006 01:14 PM


All times are GMT -5. The time now is 05:06 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration