Searching \ for '[PIC]: PIC16F84/16F877 ISR SERVO CONTROL' 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: 'PIC16F84/16F877 ISR SERVO CONTROL'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: PIC16F84/16F877 ISR SERVO CONTROL'
2001\02\08@113920 by Robert Shady

picon face
I'm working on a project (currently using the
PIC16F84) in which I would like to be able to set the
servo (1-8) to a specific setting (1=Extreme
left/128=center/255=extreme right -- or whatever)
somewhere in the main loop, and have an interrupt take
care of actually maintaining that setting in the
background.  I'm writing this is MPASM/GPASM for speed
& compatibility.

I've looked at a number of servo control source, and I
haven't found anybody else doing it this way (it
appears everyone dedicates a 16f84 to this task).  I
figure this would have to be table driven, but just
can't get this to work.  The timing is something else
I'm having trouble getting just right.  Both chips are
clock externally w/a 20mhz crystal.

I can't believe I am the only person that has ever
wanted to do this, does anybody out there have any
examples I can look at that perhaps I've missed?

I'm not new to programming (just new to PIC's), and
it's killing me that I can't figure this out.  I've
been working it for days now... I can send the code I
have currently if anybody is interested..

-- Rob


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35
a year!  http://personal.mail.yahoo.com/

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\02\08@115812 by David VanHorn

flavicon
face
>
>
>I can't believe I am the only person that has ever
>wanted to do this, does anybody out there have any
>examples I can look at that perhaps I've missed?

I can't help you with pic code, but my AVR code does exactly that, on eight
servos.
I use two timers, One is the opsys tick, which does a lot of other things,
including scheduling the servos, and starting the output pulse. The other
timer is loaded with the output pulse width. When it interrupts, the servo
pulse is shut off.

You can probably do a similar thing on the F84, except that you don't have
the second timer to do the pulse width, so you'd have to do it in some sort
of "sit and spin" loop.

A warning: Not all servos are satisfied by the typical 1-2mS pulse time.
In my code, I have equates for servo types that set the min/max pulse width
appropriately, so all the application needs to do is set a servo position
byte in ram from 0-255 and the result is always the same position (within
reason) even between different servo brands.


--
Dave's Engineering Page: http://www.dvanhorn.org
Where's dave? http://www.findu.com/cgi-bin/find.cgi?kc6ete-9

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\02\08@151711 by Drew Vassallo

picon face
>I'm working on a project (currently using the
>PIC16F84) in which I would like to be able to set the
>servo (1-8) to a specific setting (1=Extreme
>left/128=center/255=extreme right -- or whatever)

I wrote a program that controls a single servo, adjusting the pulse widths
for jitter-free operation at any setting along its range of motion,
controlled with a potentiometer input to the A/D.  With only 3 locations
predefined, it should be fairly simple.  What's your input source to
determine the servo positions?

The only thing you really have to worry about is the resolution.  If you're
off by ~5us in pulse widths, you're going to jitter back and forth.

>figure this would have to be table driven, but just
>can't get this to work.  The timing is something else

At 20MHz, you should be a little better off than I was at 4MHz, as you can
tolerate more variation in the instruction cycle counts for pulse timing.
At 50Hz cycles to the servo, you could just put the delay time for the high
pulse in the table for each of your 3 positions and send the line low for
the remainder.  As for handling 8 servos simultaneously, you'd have to poll
each servo's delay timing to shut it off at the right time.  This is where
you might run into trouble with jitter.  But with 8 servos and 20ms between
cycles for each servo, you could pulse one servo, wait for the 1-2ms high
pulse, then move on to the next servo.  You'd run through all 8 in only
16ms, leaving 4ms for any other calculations you might want to do.  At
20MHz, that's quite a few instructions.  Or, better yet, you can set up an
interrupt to go off at your 1-2ms pulse time and send the line low, if 4ms
isn't enough to do whatever you have to do between pulses.  If you keep the
same values going through the loop (only 3 distinct servo positions), you
probably won't have any problem with jitter.

You should be able to do this with an '84 without a problem, if you don't
want to shell out the expense for the '877.

And if any of this advice doesn't seem right, ignore it... I'm having bad
luck today :)

--Andrew
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\02\08@165344 by Dale Botkin

flavicon
face
I have done exactly this, but in C, not assembler.  I did use some inline
asm code in the ISR for better control of the timing.  I don't think I can
share the source code with you since I did the job for someone else, but I
could possibly help you do something similar if you want.

In application I use a 16F84 to control the servo and do some sonar
ranging and serial communication, all of which uses a little under 50% of
the available program space.

Dale

On Thu, 8 Feb 2001, Robert Shady wrote:

{Quote hidden}

---
The most exciting phrase to hear in science, the one that heralds new
discoveries, is not "Eureka!" (I found it!) but "That's funny ..."
               -- Isaac Asimov

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\02\08@165834 by Dale Botkin

flavicon
face
On Thu, 8 Feb 2001, David VanHorn wrote:

> A warning: Not all servos are satisfied by the typical 1-2mS pulse time.
> In my code, I have equates for servo types that set the min/max pulse width
> appropriately, so all the application needs to do is set a servo position
> byte in ram from 0-255 and the result is always the same position (within
> reason) even between different servo brands.

Amen!  I switched from an Airtronics servo (my project) to Futaba (someone
else's choice) and all the timing went right out the window.  The equates
are a good idea, David...  so you select the servo type at
compile/assembly time, or do you use some means of telling the PIC which
servo he's got and do a table lookup for the timing?

Dale
---
The most exciting phrase to hear in science, the one that heralds new
discoveries, is not "Eureka!" (I found it!) but "That's funny ..."
               -- Isaac Asimov

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\02\08@171515 by David VanHorn

flavicon
face
>
>Amen!  I switched from an Airtronics servo (my project) to Futaba (someone
>else's choice) and all the timing went right out the window.  The equates
>are a good idea, David...  so you select the servo type at
>compile/assembly time, or do you use some means of telling the PIC which
>servo he's got and do a table lookup for the timing?

In the current code, it's assemble time select.
It's on my website, if you're interested, under micros, AVR, near the bottom.

--
Dave's Engineering Page: http://www.dvanhorn.org
Where's dave? http://www.findu.com/cgi-bin/find.cgi?kc6ete-9

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\02\08@172937 by Ashley Roll

flavicon
face
Hi Everyone,

I created a project which did this for the now (seemingly) defunct
Electronics Australia magazine, you can find all the details at
http://www.digitalnemesis.com/ash/projects/picservo

It is controlled via a bit banged serial connection and the servos are
serviced in an interrupt routine. However, after the recent replies, I now
know why I couldn't get full travel out of my futaba servos.. I assume 1-2ms
as the max range... interesting.. I adjusted by allowing the user to set and
"offset" then allow the servo to travel +/-45 degrees from that. It seems
that my futaba servos thought that 1-2ms = 90 degree travel, which kind of
makes sense when you look at the maximum travel you would get out of
something connected to the servo like a rudder or something.

Anyway It may give you something to work from. All the ASM code is there and
well commented, as well as the (simple) circuit and PCB artwork for the
project.

Hope that helps!
Ash.

> {Original Message removed}

2001\02\11@032520 by aipi Wijnbergen

picon face
Hello Rob,

My application uses 2 servo motors, here is what I do and it works well:

in a loop:
- Set high bits bits that act as signals for the servos:
- Wait 1mSec
- Set low the bits of the motors that needs to be on one side.
- Wait 0.5mSec
- Set low the bits of the motors that needs to be on the center.
- Wait 0.5mSec
- Set low the bits of the motors that needs to be on the other side.
- Wait 18mSec.

You can have as many motors as you want (as you have enough bits).
I use one timer to measure the time. The only important issue is to reset
the timer before deciding which bits needs to change, otherwise, the motors
might jitter due to pulse width variations.

If you do this, it can work with 4MHz and only one timer and not interrupts
are needed, so even , a 16c54 could be used.

Chaipi


At 08:18 08/02/01 -0800, Robert Shady wrote:
{Quote hidden}

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\02\11@142759 by David Godbolt

flavicon
face
>>My application uses 2 servo motors, here is what I do and it works well:

>>in a loop:
>>- Set high bits bits that act as signals for the servos:
>>- Wait 1mSec
>>- Set low the bits of the motors that needs to be on one side.
>>- Wait 0.5mSec
>>- Set low the bits of the motors that needs to be on the center.
>>- Wait 0.5mSec
>>- Set low the bits of the motors that needs to be on the other side.
>>- Wait 18mSec.

<<SNIP>>

I didn't realise that you could drive 2 servos with a 16F84, so do you need
to add say 2
hardware timers etc.?

Could you kindly provide some sample code snippets and schematics for a
newbie?

TIA, David

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\02\11@143848 by David VanHorn

flavicon
face
>
>I didn't realise that you could drive 2 servos with a 16F84, so do you need
>to add say 2
>hardware timers etc.?
>
>Could you kindly provide some sample code snippets and schematics for a
>newbie?

One timer.

You update each servo in turn. You're out of servos when you're out of pins :)
(And you can get clever about that)

The servos normally get a pulse about every 20mS.
So, you can output as many as 10 servos without them noticing, simply by
taking turns.
You can do it in paralell too, but that's a little harder.


--
Dave's Engineering Page: http://www.dvanhorn.org
Where's dave? http://www.findu.com/cgi-bin/find.cgi?kc6ete-9

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\02\11@145513 by Bob Ammerman

picon face
----- Original Message -----
From: David VanHorn <spam_OUTdvanhornTakeThisOuTspamCEDAR.NET>
To: <.....PICLISTKILLspamspam@spam@MITVMA.MIT.EDU>
Sent: Sunday, February 11, 2001 2:36 PM
Subject: Re: [PIC]: PIC16F84/16F877 ISR SERVO CONTROL


> >
> >I didn't realise that you could drive 2 servos with a 16F84, so do you
need
> >to add say 2
> >hardware timers etc.?
> >
> >Could you kindly provide some sample code snippets and schematics for a
> >newbie?
>
> One timer.
>
> You update each servo in turn. You're out of servos when you're out of
pins :)
> (And you can get clever about that)

An easy way to get 8 servos out of 4 pins: 74xx138 decoder.

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\02\11@150138 by David VanHorn

flavicon
face
>
>An easy way to get 8 servos out of 4 pins: 74xx138 decoder.

I prefer the HC164, for 8 (or more) out of three pins, provided you don't
mind the odd glitch. :)  For servos, glitches of a couple uS are transparent.
--
Dave's Engineering Page: http://www.dvanhorn.org
Where's dave? http://www.findu.com/cgi-bin/find.cgi?kc6ete-9

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\02\11@155443 by James Newton

face picon face
74xx138 decoder. I also really like that chip I use two of them to map two
data lines to 16. The cool thing is that after I select one of the 8
possible addresses, I can toggle the two pins (or make on an input and
toggle the other) with out having to reload an entire shift register or
whatever. This means that the data lines on the other 7 address sets are
held steady so you can twiddle this over here, then leave it and twiddle
that over there without that disturbing this or this disturbing that or...
confused?

Anyway, it seems like the bulk of what I do needs two pins to twiddle really
fast at the same time. I2C, (SDA, SLC are fast) SPI (SCK, SIO (combined in
and out) are fast and nCS is slow on another address or port pin
) External BUS type devices like memory or parallel ports need an 8 bit
register on a bus and then the 138 provides EN and clock, etc...

James Newton, PICList Admin #3
jamesnewtonspamKILLspampiclist.com
1-619-652-0593 phone
http://www.piclist.com

{Original Message removed}

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