Searching \ for '[PIC] Servos and PWM' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/ios.htm?key=servo
Search entire site for: 'Servos and PWM'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] Servos and PWM'
2004\10\29@014553 by Sascha

flavicon
face
Hi,

If you want just full left and full right on both servos it's more than
simple to do it with the pic since you have to output a 20ms period signal
with a 1ms pulse width for full left or 2ms width for full right. You just
have to set a timer to generate a 1ms interrupt and drive the outputs from
there.

Regards,
Sascha

{Original Message removed}

2004\10\29@055142 by Jan-Erik Soderholm

face picon face
Konstantin K. wrote :

> Hi,
>
> I have a tank-like bot where each thread is controlled by a servor (2
> servos in total).  This makes a single pic not suitable for driving
> both at the same time without extensive multitasking.

If you look at the problem as a *single* task controling *two* (or more)
servos, you'll see that you don't need any "multitasking" at all.

> The servos are modified for continuous motion.

What is "continuous" here ?

> I only need to be able
> to go forward and backward.  Speed control is not needed.

As far as I know, you never directly control the "speed" of a RC servo,
only the position (using the pulse width).

> So to drive
> the servo forward and backward I only need two different pulse widths.
>
> One of my options is to get a 12F685 for each servo...
> My other idea was to have a 555 timer for each servo...

Both those solutions seems as a major overkill and far to complicated.

> Does anyone have any suggestions on what would be the best way to go
> about it?  Or any other ideas on how to drive 2 or 3 servos from the
> same pic.

Set up a timer as a basic "time base" (interrupt driven).
Create a number of counters and flags to hold the "status"
of each servo output.
At each timer interrupt, check each servo counter and, if needed,
change the output to the servos.

This is normal RC servos (20 ms period 1.5 +- 0.5 ms pulse), right ?
That is a very long time for a PIC... :-)

Jan-Erik.

____________________________________________

2004\10\29@094754 by Konstantin K.

picon face
Thanks a lot for your answers.  I will probably take your advice and
stick with the microcontroller.  However,  it seems as if many people
are abandoning "designing circuits" in favor of microcontrollers.  It
seems reasonable because they are so cheap and easy to use but somehow
it makes me uneasy.

If you think in commercial terms (in my case), a micrcontroller costs
a little over $1 where a 555 timer and a few resistors, capacitors,
and transistors might cost 50c, which is about 3 times as cheap.

Let me know what your thoughts are about this.


On Fri, 29 Oct 2004 11:51:40 +0200 (CEST), Jan-Erik Soderholm
<spam_OUTjan-erik.soderholmTakeThisOuTspamtelia.com> wrote:
{Quote hidden}

> ______________________________________________

2004\10\29@095830 by Dave VanHorn

flavicon
face

>
>If you think in commercial terms (in my case), a micrcontroller costs
>a little over $1 where a 555 timer and a few resistors, capacitors,
>and transistors might cost 50c, which is about 3 times as cheap.

In my AVR application, I controlled eight servos (could have done 16
easily) plus two displays, switches, and a stepper motor.  Each servo needs
only one pin on the micro.
You could control two servos easily with the Tiny-11, which costs $0.25

The processor allows you to do more than analog would, with way less
effort, and to easily reconfigure it on the fly.

____________________________________________

2004\10\29@100859 by Scott Dattalo
face
flavicon
face
On Fri, 29 Oct 2004, Sascha wrote:

> Hi,
>
> If you want just full left and full right on both servos it's more than
> simple to do it with the pic since you have to output a 20ms period signal
> with a 1ms pulse width for full left or 2ms width for full right. You just
> have to set a timer to generate a 1ms interrupt and drive the outputs from
> there.

Or if you end up deciding that you do need more resolution, you could
implement parallel PWM outputs:

http://www.dattalo.com/technical/software/pic/pwm8.asm

For 8 outputs, this pwm routine takes 23 cycles per update. To generate a
servo PWM, you'd probably want to implement the 20mS period interrupt in
which the pwm8.asm (or a simplified version) would run as an isochronous
loop. E.g.:

Every 20 milliseconds:

interrupt_routine:

   ; entry save stuff...

   ; start the pwms:

       movf  pwm_dc0,w
       movwf pwm_cntr0

       movf  pwm_dc1,w
       movwf pwm_cntr1

       clrf  loop_counter    ; loop_counter = 256

   ; Drive the pwm outputs high:

       movlw (1<<bPWM0) | (1<<bPWM1)
       iorwf PWM_PORT,F

       DELAY_US(1000)        ; 1 millisecond for the guard pulse

pwm_loop:
       movlw b'11111111'     ; Assume outputs stay high

       decfsz pwm_cntr0,f
        andlw ~(1<<bPWM0)    ; PWM 0 is over

       decfsz pwm_cntr1,f
        andlw ~(1<<bPWM1)    ; PWM 1 is over

       andwf  PWM_PORT,F     ; Update the outputs

       decfsz loop_counter,F
        goto  pwm_loop


   ; exit interrupt routine



The pwm loop takes 256 iterations * 9cycles/iteration = 2304 cycles. A
midrange pic running from a 20MHz oscillator would take 460.8 uS. Giving
you the shortest pulse of about 1.5 uS and longest pulse of about 460 uS.
There are several ways to increase the pulse width. You can change the
oscillator, you could add some delay in the loop, you can add more PWM's,
you can poll other time critical stuff while in the loop, etc.

Scott
____________________________________________

2004\10\29@104925 by Wouter van Ooijen

face picon face
> If you think in commercial terms (in my case), a micrcontroller costs
> a little over $1 where a 555 timer and a few resistors, capacitors,
> and transistors might cost 50c, which is about 3 times as cheap.
>
> Let me know what your thoughts are about this.

Component (buy) cost is not the only production cost. Placement
(PP-machine-time, and labour time for placement of the reels) and PCB
area must also be taken into account. I did this some time ago, and was
flabbergasted by the cost contribution of simple resistors!

And $1 seems to be unfair for a 555-replacement, a 10F or ATtiny11
reasonable amounts should cost much less.

But of course for using a uC the cost fof programming must be taken into
account. And of course the engineering (one-time, hopefully) cost will
be affected.

Wouter van Ooijen

-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu



____________________________________________

2004\10\29@115317 by Kenneth Lumia

picon face
Don't forget the cost of stocking multiple parts (square footage) and test
cost.

The processor version can probably "self test" its circuit, whereas the
discrete version would need to be tested on a bed of nails to ensure that
all parts were present, they were the correct value, and were truly soldered
down. Typically, labor costs are the biggest portion of the testing cost.
Anything
done to minimize test time (labor time) is a high priority.

Ken
.....klumiaKILLspamspam@spam@adelphia.net


{Original Message removed}

2004\10\29@124323 by Carey Fisher - NCS

face picon face
I've found that the cost of (electro-)mechanical parts - switches,
enclosure, jacks etc take the lion's share of the cost of any product in the
quantities I build (batch size = 100).  A couple dollars extra in electronic
parts is insignificant (especially if it reduces labor costs).
Carey Fisher

  > {Original Message removed}

2004\10\29@132053 by Peter L. Peres

picon face

On Fri, 29 Oct 2004, Jan-Erik Soderholm wrote:

> Konstantin K. wrote :
>
>> Hi,
>>
>> I have a tank-like bot where each thread is controlled by a servor (2
>> servos in total).  This makes a single pic not suitable for driving
>> both at the same time without extensive multitasking.
>
> If you look at the problem as a *single* task controling *two* (or more)
> servos, you'll see that you don't need any "multitasking" at all.
>
>> The servos are modified for continuous motion.
>
> What is "continuous" here ?

The potentiometer is removed and replaced with a fixed resistor divider.
Then the servo can be used as drive motors having forward - stop - reverse
(it will run with variable speed within certain limits (close to the
'stop' point) forward and reverse as the servo chip implements a type of
pwm when the servo error term is not zero).

You have to refresh the servo at 50Hz (as closely as possible) because
some servos have drastic lockouts for glitches and for control loss and
won't respond outside a 50Hz refresh rate. Also some servos will return
glitches conducted on the data line and can glitch pics. Last, servo start
current is large enough that it will collapse your main supply line if you
start more than one at the same time from a less than perfect battery. You
must account for this.

Peter
____________________________________________

2004\10\29@142038 by Jan-Erik Soderholm

face picon face
Konstantin K. wrote (in one post) :

> Thanks a lot for your answers.  I will probably take your advice and
> stick with the microcontroller.  However,  it seems as if many people
> are abandoning "designing circuits" in favor of microcontrollers.  It
> seems reasonable because they are so cheap and easy to use but somehow
> it makes me uneasy.

But I read your original post as that you was planning to use, not only
*one* processor, but also some more (12Fxxx) processors (or some
555's) in *addition* to the main processor, not ?

> If you think in commercial terms (in my case), a micrcontroller costs
> a little over $1 where a 555 timer and a few resistors, capacitors,
> and transistors might cost 50c, which is about 3 times as cheap.

But, the idea (at least mine) was to cut out the extra processors
(and/or 555's) and not replace them with anything ! Zero extra cost.
Why are you comparing costs ? You already have the PIC, don't you ?

Or are you looking at a solution with no processor at all ?

I must be missing something...

Regards,
Jan-Erik.
____________________________________________

2004\10\29@143419 by Jan-Erik Soderholm

face picon face
Peter L. Peres wrote :

> On Fri, 29 Oct 2004, Jan-Erik Soderholm wrote:
>
> > Konstantin K. wrote :
> >
> >> The servos are modified for continuous motion.
> >
> > What is "continuous" here ?
>
> The potentiometer is removed and replaced with a fixed
> resistor divider.  Then the servo can be used as drive motors
> having forward - stop - reverse.

Oh, I see !
But, that doesn't change it much from the PIC side of it.
The PIC just feeds a 20ms/1-2ms PWM signal and don't care
what the servo actualy does, not ? That is, if it is "positioning"
or "free running".

And that doesn't, in itself, call for some extra PICs or 555's
to drive the servo.

Jan-Erik.
____________________________________________

2004\10\29@173949 by William Chops Westfield

face picon face
On Oct 29, 2004, at 7:47 AM, Wouter van Ooijen wrote:

> and $1 seems to be unfair for a 555-replacement, a 10F or ATtiny11
> reasonable amounts should cost much less.
>
Not in small volumes.  The cheapest 10F is more than $1 at digikey...
(and in high volumes, your 555 gets lower than $0.50, too.)  I was
a little surprised at the 10F pricing; we'll see what happens...
The Tiny11 is a better candidate, but perhaps only due to a marketing
push at the moment...

BillW

____________________________________________

2004\10\30@084101 by Russell McMahon

face
flavicon
face
>> If you think in commercial terms (in my case), a micrcontroller costs
>> a little over $1 where a 555 timer and a few resistors, capacitors,
>> and transistors might cost 50c, which is about 3 times as cheap.

ATtiny11 about $US0.30. Can do some jobs with no glue parts at all.


           RM

____________________________________________


'[PIC] Servos and PWM'
2004\12\04@123115 by Bill & Pookie
picon face
In the real world, time is money.  Much quicker to use a  microcontroller
than design a circuit.  Our gene pool may be lacking the ability to design
because of this.

If you were stranded on a deserted island, could you take a hand full of
sand and fabricate a transistor?  I think not!

Bill
{Original Message removed}

More... (looser matching)
- Last day of these posts
- In 2004 , 2005 only
- Today
- New search...