hamjudo
Posts: 59
Joined: Thu Nov 03, 2011 3:25 pm

Re: Do I need a gertboard to run a servo

Thu Dec 22, 2011 1:41 pm

Quote from Gert van Loo on December 20, 2011, 17:02
We have two PWM channels and they are currently used for audio. So to use them for a servo you have to disable the audio and you need PWM drivers. Alternative (or for more outputs) you can drive the GPIOs from the timer interrupt routine. That gives you ~1KHZ update. That should be enough if servos can indeed run from a lower frequency e.g. 20 Hz.

Many servo users may find the degree of control to be a little too course for their applications.

For an ideal hobby servo, a 1.5 millisecond pulse causes the servo to go to the center position. A 1 millisecond pulse rotates it all of the way to the left, a 2 millisecond pulse rotates it all of the way to right. Real servos aren't so ideal. The end of travel might be at 0.950 milliseconds. If mechanical precision is required, there will be a way to calibrate the servo. One servo control system with 8 bits of resolution uses a 4 microsecond clock, and provides 256 steps. By default, it can produces pulses that are from 1.000 milliseconds to 2.024 milliseconds.

The pulse repetition rate doesn't matter to the servo. However, it will stop holding the position a hundred or more milliseconds after the last pulse. So the pulses have to be repeated several times a second to hold position.

User avatar
Gert van Loo
Posts: 2487
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Do I need a gertboard to run a servo

Thu Dec 22, 2011 2:10 pm

The PWM channels are controlled with 32-bit registers. You can easily get a accuracy of 0.001% with those.

bradburts
Posts: 341
Joined: Sun Oct 02, 2011 7:07 am

Re: Do I need a gertboard to run a servo

Thu Dec 22, 2011 3:00 pm

@Gert
Thanks for the breakdown.
I will be getting the Gert board.

Could not quickly see how I am supposed to control the L6203. Looks like I have some homework to do.
IDK which motor I will have yet, intend to hack an RC, guessing that RC cars use DC brushless?

Welcome to the world of electronic engineering where we manage to make a problem for every solution.
Not sure that I will say thanks for being lured into the dark world of electronics...... ;)

User avatar
Gert van Loo
Posts: 2487
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Do I need a gertboard to run a servo

Thu Dec 22, 2011 5:04 pm

L6203: two inputs. Both A and B low or both high = stop.
A low, B high : rotate one way.
A high, B low: rotate other way.
You can run PWM on either A or B to control the speed.

hamjudo
Posts: 59
Joined: Thu Nov 03, 2011 3:25 pm

Re: Do I need a gertboard to run a servo

Thu Dec 22, 2011 6:09 pm

Quote from Gert van Loo on December 22, 2011, 14:10
The PWM channels are controlled with 32-bit registers. You can easily get a accuracy of 0.001% with those.

The mechanical bits in an average servo are only good to something on the order of 1%. So it should be straightforward to control 2 servos directly off of the R-Pi, without getting into the world of real-time Linux.

In the short term, the easy way to drive multiple servos without doing any research, would be from the PIC on the Gertboard, or an Arduino on a USB cable.

Longer term...
If I count right, there are potentially 17 GPIO pins available. 2 are labeled as UART lines, 5 as SPI lines, 2 are set up as I2C, and the other 8 are designated as GPIO. However, any of them can be used GPIO, if the other functionality isn't needed. Note: on most processors, the PWM channels can be assigned to only a subset of the GPIO pins.

The servo device driver would assign a PWM channel in single shot mode to a GPIO pin. It would configure the pulse length as appropriate from 1.0 ms to 2.0ms, fire off the pulse, then schedule a callback in a few milliseconds. When it gets the callback, it would configure the GPIO pin so it stays as a low output, then go on to the next servo/GPIO pin combination. Repeat for each servo. After the last servo, it would schedule a call back after a suitable interval, to repeat the cycle.

That system is uses the high precision PWM timers, so the servos are unlikely to jitter. It can only be used on GPIO pins that can be configured to use a PWM channel.

I hope to play with the realtime Linux kernel. That would have much worse jitter than the PWM, but probably sufficient for servos, and it can use any GPIO pin. The big disadvantage, is that the realtime kernel has not yet been ported to the Raspbery Pi. It will take months after the R-Pi ships, before the realtime kernel is actually useful. I want to mess with the realtime kernel, for the sake of messing with the realtime kernel.

bradburts
Posts: 341
Joined: Sun Oct 02, 2011 7:07 am

Re: Do I need a gertboard to run a servo

Thu Dec 22, 2011 9:17 pm

Quote from Gert van Loo on December 22, 2011, 17:04
L6203: two inputs. Both A and B low or both high = stop.
A low, B high : rotate one way.
A high, B low: rotate other way.
You can run PWM on either A or B to control the speed.


Thanks. Thats easy. This is going to be fun.
Software PWM should do I would expect.

tntexplosivesltd
Posts: 72
Joined: Fri Sep 30, 2011 8:08 am
Contact: Website

Re: Do I need a gertboard to run a servo

Thu Dec 22, 2011 9:22 pm

Quote from abishur on December 19, 2011, 04:39
1) The GPIO put out a *very* low current output, so you need something to boost that up to drive a servo or relay.

I may be mistaken, but to drive a servo won't the GPIO outputs be enough? The servo is controlled by pulses through its pulse pin, and these only need a low current? I thought the drive circuitry was inside the servo itself. Could be wrong though.

Bakul Shah
Posts: 322
Joined: Sun Sep 25, 2011 1:25 am

Re: Do I need a gertboard to run a servo

Fri Dec 23, 2011 10:36 pm

Quote from riffraff on December 22, 2011, 01:06
@Bakul Shah
Was checking out data sheets for that series after I saw your post last night. Left me scratching my head how you go about de-muxing all that.

Demuxed through various control registers! Bit i of DDRB selects data direction of port i, ADCSRB enables ADC, etc. Section 23 (page 205) of the datasheet has a cross referenced summary of registers which may help. I couldn't find a good example in a quick search but here is a simple example: http://hlt.media.mit.edu/?p=1653 -- download touch.zip (link on the same page). You can also look at avr-libc sources or on arduino.cc.

User avatar
riffraff
Posts: 307
Joined: Tue Sep 27, 2011 3:17 am
Location: Newnan, Georgia, US

Re: Do I need a gertboard to run a servo

Mon Jan 09, 2012 7:13 pm

Bakul said:


Another idea is to use an Atmel Tiny85 ($2). A versatile 8pin micro with lots of functions multiplexed onto 6 pins! Four 10-bit ADC, 2 PWM, counter/timer, watchdog timer, all 6 are GPIO, I2C, SPI and more. 20Mhz, upto 512B RAM, 8KB Flash, 512B EEROM, on chip osc. etc. Use drivers if you need more than 40mA. You can find plenty of ATtiny85 projects online.



Wow, I was searching web for info on AtTiny series when I need have looked no further than my pocket. I have Electrodroid reference on my phone I was looking under Chip DB reference last night - 4000 series CMOS,  68xx series, 74xx & 74LSxx ... blah...blah... WAIT A MINUTE!!!  Here's pinouts on AtMega and AtTiny series!!!

plugwash
Forum Moderator
Forum Moderator
Posts: 3621
Joined: Wed Dec 28, 2011 11:45 pm

Re: Do I need a gertboard to run a servo

Tue Jan 10, 2012 12:12 am




Of those I would say AC are the most difficult to drive, not something I would recommend a beginner.
Agreed



DC can be done using the L6203 on the Gertboard.


Depending of course on how much current they need.



Stepper motors: I have to read up on those. If I recall it requires three outputs which you have to pulse high/low in a specific order to step forwards/backwards.


There are a few different variants of stepper motor and different ways of stepping individual motors. But all rely on having a circular sequence of output states and moving backwards and forwards between those states to step the motor backwards and forwards.



Servo motors: read this thread.


mmm



Welcome to the world of electronic engineering where we manage to make a problem for every solution.


heh

Of course now we have mentioned different types of motor we should probablly mention where you would use each.

Steppers are great when you need to be able to move something in precision incremenets but they tend to be power hungry and relatively expensive and the positioning is relative so if you need an absoloute position you need to design your mechanics to provide a reset point (for example in a floppy drive there is a switch to tell the drive when it has reach track 0).

servos are used where you need to control position but don't need that much precision and don't need continuous rotation (there are some servos that can do continuous rotation but they are more expensive and more complex to drive).

DC motors are used for general driving where either precision is not required or where you provide precision by external sensing.

User avatar
guru
Forum Moderator
Forum Moderator
Posts: 158
Joined: Thu Sep 01, 2011 1:01 pm
Contact: Website

Re: Do I need a gertboard to run a servo

Tue Jan 10, 2012 2:29 am

As far as experimenting safely with just the Raspi on simple SPI/GPIO type things (LED strings, servos, steppers), are opto-isolaters a simple, effective way to go to drastically reduce the chances of a Raspberry Fried?

My thinking is it's an ideal way to decouple the power system of the Raspi and your experimental circuits while working pretty well with moderate speed signalling.

Can anyone point towards simple parts/circuits for Optoisolation 101 with GPIO 5v or 3v3 operation?

Edit: Search and ye shall receive, this thread has some good talk about optos and the Raspi.

robohead
Posts: 1
Joined: Sun Jan 15, 2012 2:31 pm

Re: Do I need a gertboard to run a servo

Sun Jan 15, 2012 3:11 pm

There are quite a few ways to drive servos out there ie. you can use a microcontroller such as a PIC,AVR etc. a platform such as an Arduino, brainstem etc. or you can use a dedicated servo controller board. We have used the servo contoller from Designer Systems to control water valves going to multiple ponds in the past which has proved a very simple and controllable solution as it is also possible to control the servo speed. I believe they also do a kit with the controller inserted thouhh we have only used the chip solution to build into our pond management system. Its I2C controlled and supports 16 servos max. I think we paid about £6 for the chip.

Liam

problemchild
Posts: 22
Joined: Thu Oct 06, 2011 8:08 am
Contact: Website

Re: Do I need a gertboard to run a servo

Sun Jan 15, 2012 5:03 pm

The answer is definitely not. Any old controller PIC/AVR/ARM Arduino or what ever will be more than suitable for this task. I bought a load of Arduinos for our Linux group not because they were the best just that they are popular and in my case only £12 from EBAY  inc postage.  Most systems will have a Servo demo so you will be far from alone getting that one working . Using a generic Microcontroller system means you could start programming your solution now rather than waiting for the PI thus saving valuable weeks ++ in your development. Finally  you could take the harder but cheaper option of using the I/O from the 'PI to directly drive the servo control line ( you would maybe require a bit of a transistor to get the right voltages but not that much ).

Get something now and start tinkering

Good luck

problemchild
Posts: 22
Joined: Thu Oct 06, 2011 8:08 am
Contact: Website

Re: Do I need a gertboard to run a servo

Sun Jan 15, 2012 5:07 pm

Nice mention of an opto isolator form "guru". Only 20p or so from RAPID and prety much insulate your 'PI from anything and everything. You could drive 8 servos/selays from the PI via opto-isolators saving a lot of bother

User avatar
Gert van Loo
Posts: 2487
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Do I need a gertboard to run a servo

Sun Jan 15, 2012 8:28 pm

I have been reading Wiki on stepper motors. Seems there are two types: uni-polar and bi-polar. I still I have no idea which one of the two is the most common. My guess would be bi-polar as electronics is cheap and copper windings are expensive.

DavidIO
Posts: 1
Joined: Mon Jan 09, 2012 9:43 am

Re: Do I need a gertboard to run a servo

Mon Jan 16, 2012 10:21 am

robohead said:


There are quite a few ways to drive servos out there ie. you can use a microcontroller such as a PIC,AVR etc. a platform such as an Arduino, brainstem etc. or you can use a dedicated servo controller board. We have used the servo contoller from Designer Systems to control water valves going to multiple ponds in the past which has proved a very simple and controllable solution as it is also possible to control the servo speed. I believe they also do a kit with the controller inserted thouhh we have only used the chip solution to build into our pond management system. Its I2C controlled and supports 16 servos max. I think we paid about £6 for the chip.

Liam


Hi Liam

We will be testing the the DS-RCB [Robotic Control Board] and DS-SCX16S [Servo controller IC] when the R-Pi is released and are confident that they should work together. You are about right about the price, SCX16S is £5.95 and the RCBk [kit] is £13.99 or built £18.99 which includes the SCX16S.

David

bsmulders
Posts: 18
Joined: Wed Nov 23, 2011 6:13 pm

Re: Do I need a gertboard to run a servo

Mon Jan 16, 2012 11:25 am

Maybe a bit extreme, knowing the audio on the Raspberry PI is based on the GPIO, but what about this?

Sound card driven servo motor

Neon22
Posts: 29
Joined: Mon Sep 19, 2011 4:11 am

Re: Do I need a gertboard to run a servo

Mon Jan 16, 2012 11:41 am

Don't forget the world famous OpenServo project. (V2 and V3)

http://openservo.com/

This board can replace the board in your existing 'cheap' servos or you can make your own and get many advantages such as motion profiles and logging and far better and more accurate control.

One of its advantages is the ability to communicate with the servos directly using I2C (or via USB using a USB to I2C converter). So you can control many servos with very low overhead.

So no PWM etc...

Can be purchased from Sparkfun (V2 only) http://www.sparkfun.com/products/9014

or RobotFuzz http://robotfuzz.com/OSv3 (out of stock)

Neon22
Posts: 29
Joined: Mon Sep 19, 2011 4:11 am

Re: Do I need a gertboard to run a servo

Mon Jan 16, 2012 11:51 am

DavidIO said:


robohead said:


There are quite a few ways to drive servos out there ie. you can use a microcontroller such as a PIC,AVR etc. a platform such as an Arduino, brainstem etc. or you can use a dedicated servo controller board. We have used the servo contoller from Designer Systems to control water valves going to multiple ponds in the past which has proved a very simple and controllable solution as it is also possible to control the servo speed. I believe they also do a kit with the controller inserted thouhh we have only used the chip solution to build into our pond management system. Its I2C controlled and supports 16 servos max. I think we paid about £6 for the chip.

Liam


Hi Liam

We will be testing the the DS-RCB [Robotic Control Board] and DS-SCX16S [Servo controller IC] when the R-Pi is released and are confident that they should work together. You are about right about the price, SCX16S is £5.95 and the RCBk [kit] is £13.99 or built £18.99 which includes the SCX16S.

David



Wow - yeah the OOPIC-II - you had an interface to that. I sure miss that excellent device. Look fwd to seeing your stuff again David.

ginge
Posts: 1
Joined: Tue Jan 24, 2012 12:42 am

Re: Do I need a gertboard to run a servo

Tue Jan 24, 2012 12:50 am

Neon22 said:


Don't forget the world famous OpenServo project. (V2 and V3)

http://openservo.com/

This board can replace the board in your existing 'cheap' servos or you can make your own and get many advantages such as motion profiles and logging and far better and more accurate control.

One of its advantages is the ability to communicate with the servos directly using I2C (or via USB using a USB to I2C converter). So you can control many servos with very low overhead.

So no PWM etc…

Can be purchased from Sparkfun (V2 only) http://www.sparkfun.com/products/9014

or RobotFuzz http://robotfuzz.com/OSv3 (out of stock)


Hi, ginge of robotfuzz/openservo here.

The OpenServo communicates via I2C, which the Pi does have one of.

Doing some research, the Pi's I2C bus is 3.3v rated, while the OpenServo is 5v. You can easy get a voltage shifter or do something quick and dirty (http://www.headfuzz.co.uk/node/46).

From what I can tell (correct me if I am wrong) the Pi dosn't have a usable i2c kernel driver yet, but once it does you can drive an OpenServo very easily. There are linux based samples on the OpenServo wiki.

oh, and the "out of stock" on Robotfuzz… the Chinese supplier went bust so I am left high and dry for a little while. I am in talks…

Neon22
Posts: 29
Joined: Mon Sep 19, 2011 4:11 am

Re: Do I need a gertboard to run a servo

Tue Jan 24, 2012 5:20 am

ginge said:


Neon22 said:


Don"t forget the world famous OpenServo project. (V2 and V3)

http://openservo.com/

One of its advantages is the ability to communicate with the servos directly using I2C (or via USB using a USB to I2C converter). So you can control many servos with very low overhead.


Hi, ginge of robotfuzz/openservo here.

The OpenServo communicates via I2C, which the Pi does have one of.

Doing some research, the Pi"s I2C bus is 3.3v rated, while the OpenServo is 5v. You can easy get a voltage shifter or do something quick and dirty (http://www.headfuzz.co.uk/node/46).

From what I can tell (correct me if I am wrong) the Pi dosn"t have a usable i2c kernel driver yet, but once it does you can drive an OpenServo very easily. There are linux based samples on the OpenServo wiki.


Look in this topic for links to a raspberrypi VM to work on. Also someone else (Frank) struggling with I2C on the VM.
http://www.raspberrypi.org/for.....ard#p32768

But we will have real units shortly I am sure

gfwilliams
Posts: 44
Joined: Thu Jun 14, 2012 8:29 am
Location: Cambridge

Re: Do I need a gertboard to run a servo

Thu Jun 14, 2012 9:02 am

Just to draw attention to bsmulders post:
http://hackaday.com/2010/05/26/sound-ca ... rvo-motor/

44100 sample rate for audio = 44 steps in 1ms, which is probably enough for a lot of tasks.

Playing a custom waveform out of the audio connector has got to be a pretty easy way of controlling 2 model servos with minimal soldering. For simple tasks you could even use a command-line sound player (or scratch) with a few sound files that had been created previously and which contained the required 1-2ms pulse.

add1ct3dd
Posts: 18
Joined: Thu May 24, 2012 6:38 pm

Re: Do I need a gertboard to run a servo

Thu Oct 18, 2012 2:33 pm

So are there any good guides to getting a servo working correctly?

I'm a programmer by heart and know basics of electronics, but have just got the Gertboard so have a lot to learn.

Return to “Other projects”