Maker Pro
Maker Pro

AVR based 16 Channel RC servo driver

P

Pang Fu

Jan 1, 1970
0
I would like to generate 16 channel R/C (radio control) servo motor signals
(1ms-2ms) with 9 or 10 bits accuracy.
These signals will drive an 16 R/C motors on a walking robot. Is there any C
(AVRgcc or CodeVisionAVR) code to realize this?

Pang Fu

[email protected]
 
R

Rene Tschaggelar

Jan 1, 1970
0
Pang said:
I would like to generate 16 channel R/C (radio control) servo motor signals
(1ms-2ms) with 9 or 10 bits accuracy.
These signals will drive an 16 R/C motors on a walking robot. Is there any C
(AVRgcc or CodeVisionAVR) code to realize this?

A rather simple approach uses a small FPGA for the couters.

Rene
 
J

Johnny

Jan 1, 1970
0
A rather simple approach uses a small FPGA for the couters.


FPGA is not necessary. The AVR has 16 bit timer with two 16bit
compare registers and interrupts. I suggest this application can be
implemented by sorting the array of 16 channels into sequence of pulse
width, and then just reloading the same compare register. The second
16bit comapare register can be used to reload or clear the timer, and
thus determine the timebase. The AVR is plenty fast enough to make
this work, especially the new mega series that process 16MIP/s @
16MHz, but codevision compiler is a bit of a handicap. Imagecraft
make a much more efficient one. Never tried any gcc though.

regards,
Johnny.
 
C

Christopher X. Candreva

Jan 1, 1970
0
: search this page for "8-servo".....

: http://www.omegav.ntnu.no/avr/resources.php3

The link it references - http://members.home.net/daniel.herrington/ no
longer exists. Anyone mirror this ?

Herky Jerky's Pages - Robotics-related information. Includes schematics,
source code, mechanical photos, printed circuit boards for robot. Uses Atmel
AVR microcontrollers for infrared remote decoder, infrared obstacle
detection, sonar rangefinder, 8-servo controller. Also includes linux C
source code for onboard PC.
 
J

Jay

Jan 1, 1970
0
thus determine the timebase. The AVR is plenty fast enough to make
this work, especially the new mega series that process 16MIP/s @
16MHz, but codevision compiler is a bit of a handicap. Imagecraft
make a much more efficient one. Never tried any gcc though.

Can you be specific on why you feel Imagecraft is more efficient
compared to the Codevision compiler? I'm thinking about buying
Codevision and I'd like to hear plus/minuses.

-- Jay.
 
J

Johnny

Jan 1, 1970
0
Can you be specific on why you feel Imagecraft is more efficient
compared to the Codevision compiler? I'm thinking about buying
Codevision and I'd like to hear plus/minuses.

-- Jay.


Write some code and try the demo versions. Using AvrStudio to
simulate the code operation, its easy to time the code execution using
the timer in the 'processor' window. When I tried this, with my
sample code I found the Imagecraft compiled code was smaller and
executed about twice as fast as the some code compiled with
codevision. Imagecraft have 45 day evaulation version, and I think
codevision offer something similar.

AVR studio compatibility is something you should also investigate. I
have heard that Imagecraft is better than the others in this regard,
but only used codevision with Version 3 of avr sudio. Avr Studio
4.07 is not 100% stable though (can say the same for V3.56 also), so
it is difficult to tell if the problem is with the compiler listing
file compatilibility, or some bug in avr studio.

regards,
Johnny.
 
J

Jan-Hinnerk Reichert

Jan 1, 1970
0
Johnny said:
FPGA is not necessary. The AVR has 16 bit timer with two 16bit
compare registers and interrupts. I suggest this application can be
implemented by sorting the array of 16 channels into sequence of
pulse
width, and then just reloading the same compare register. The
second 16bit comapare register can be used to reload or clear the
timer, and
thus determine the timebase. The AVR is plenty fast enough to make
this work, especially the new mega series that process 16MIP/s @
16MHz, but codevision compiler is a bit of a handicap. Imagecraft
make a much more efficient one. Never tried any gcc though.

IMO it is not that simple ;-(

If you start all pulses at ones, you get trouble if some servos have
(almost) equal pulse lengths.

The classic way to avoid this would be to send one pulse after the
other. However, a servo requires a pulse every 20ms. So you can do at
most 10 servos in sequence, no matter how hard you optimize the code.

I would suggest one of the following:

1) One interrupt every 20ms that starts all pulses. Another interrupt
1ms later, here you do a hand-timed loop that stops the pulses one by
one. The drawback is that you are in a loop (with disabled
interrupts) for 1ms, i.e. that you shouldn't use 19.2kBaud or higher
for UART (or SPI).

2) Start pulses in turn every 1ms. Problem here is, that you don't get
pulse lengths near 1ms and near 2ms.

The choice depends on the application.

BTW: Every interrupt (other than pulse generation) has to be
interruptable to achieve the desired accuracy.

Jan-Hinnerk
 
D

Dave VanHorn

Jan 1, 1970
0
You can also do this in software. Below is some pascal psudo code that
I wrote awhile ago while brainstorming this idea. You'll need 2-16 bit
timers and a VERY FAST controller to pull this off.

I have assembler freeware that does this, and a bunch of other bot related
tasks.
I set it up for eight servo outputs, but it could easily be 16.
 
D

Dave VanHorn

Jan 1, 1970
0
Pang Fu said:
Is it possible to read servo positions from a serial port (19200 or
115200kbps) and drive the servo motors in your 8 channel asm. code? Would
you share your code (preferebly 16 channel upgrraded version) with all of
us?

The code as is, is here.
http://groups.yahoo.com/group/AVR-Chat/files/

Interrupt driven serial I/O is in place, as well as the core of a language
interpreter that runs out of EEPROM. You have to define the commands, other
than the basics supplied. One of the basic commands is "set servo".

I think if you look at it, it won't be too hard to make it into what you
want.
Making it sixteen outputs instead of eight would mean using another port for
output, adding eight more positions for step position in ram, and slight
changes in the T1 ISR, and the sequencing.

Trim out the stepper, LCD, and VFD code, morse output, random number
generator, etc.
It's written for the 8515.
 
J

Jan-Hinnerk Reichert

Jan 1, 1970
0
Pang said:
Did you do it within C ? If so yould you share your code with us?

I have thought about servo control some time ago, but have never
produced any code :-(

Jan-Hinnerk
 
Top