I tried to compile the servo.c program with the makefile indicated in the
email, but I get a compilation error.
Here is the Makefile:
AXIS_TOP_DIR=/home/giovanni/fox/sdk/sdk-2.01-phrozen-new/devboard-R2_01
TARGET := servo
WARN := -W -Wstrict-prototypes -Wmissing-prototypes
INCLUDE := -isystem
/home/giovanni/fox/sdk/sdk-2.01-phrozen-new/devboard-R2_01/os/linux-2.6/include
CFLAGS := -O2 -DMODULE -D__KERNEL__ ${WARN} ${INCLUDE} -mlinux -DCRISMMU
CC := gcc-cris
PREVENT_RECURSIVE_INCLUDE = 1
PATH=$PATH:/usr/local/cris
${TARGET}.o: ${TARGET}.c
.PHONY: clean
clean:
rm -rf {TARGET}.o
Here is the error:
[EMAIL PROTECTED]:~/fox/sdk/sdk-2.01-phrozen-new/devboard-R2_01/apps/servo$ make
gcc-cris -O2 -DMODULE -D__KERNEL__ -W -Wstrict-prototypes -Wmissing-prototypes
-isystem
/home/giovanni/fox/sdk/sdk-2.01-phrozen-new/devboard-R2_01/os/linux-2.6/include
-mlinux -DCRISMMU -c -o servo.o servo.c
servo.c:29: warning: static declaration for `init_module' follows non-static
servo.c:30: warning: static declaration for `cleanup_module' follows non-static
servo.c: In function `device_open':
servo.c:138: `MOD_INC_USE_COUNT' undeclared (first use in this function)
servo.c:138: (Each undeclared identifier is reported only once
servo.c:138: for each function it appears in.)
servo.c: In function `device_release':
servo.c:158: `MOD_DEC_USE_COUNT' undeclared (first use in this function)
make: *** [servo.o] Error 1
How can I do to make this file compile correctly ?
Best regards,
Giovanni
Ernst Mayerhofer <[EMAIL PROTECTED]> wrote: if
you want to make something which works really well, you have to do it in
the kernel ;-)
I made a kernel module once. As I modified it now for you and didn't test it
on the foxboard, there might be a problem, so feel free to ask me if there
is some problem.
just compile the servo.c attached with the also attached makefile. you have
to change the path of AXIS_TOP_DIR in the Makefile.
once you have compiled it, transfer it to the foxboard and type:
$ insmod servo.o
if you want to see the kernel log messages, type
$ dmesg
then you can make a new device node , eg
$ mknod c /etc/servo c 249 0
and, if you want to set the servo to a specific position, write the value of
T_on in us to /etc/servo:
$ echo 500 > /etc/servo
it should work!
notice that if you want to use it, you have to enable the fast timer api.
greets and pardon for my bad english,
ernst mayerhofer
2007/2/2, Giovanni <[EMAIL PROTECTED]>:
>
> This solution sounds cool.
>
> Did you try it with a real case ?
>
> I would like to run some real working code based on this idea. If you have
> some code ready to run, can you post it ? Otherwise we can collaborate to
> develop some working code and test it.
>
> Best regards,
> Giovanni
>
> spargelzack <[EMAIL PROTECTED] <spargelzack%40yahoo.com>> wrote:
> (sorry if this shows up twice, i'm not familiar with the yahoo groups
>
> interface yet)
>
> Hi Everybody
>
> I found a cheap + fast solution for using servos with the foxboard.
>
> First, there is a way to use the i/o lines not described on the
> acmesystems website (it's well known on the axis developer website
> though). You can use write() on Ports A+B after proper initialization.
>
> The Clock interval is around 5 us, so you have to pass about 4000
> values for a full 2ms period.
>
> But as i found out, the 20ms interval isn't all that important. What
> matters is the length of the pulse.
>
> So, here's my code:
>
> --
> #include <stdio.h>
> #include "stdlib.h"
> #include "unistd.h"
> #include "sys/ioctl.h"
> #include "fcntl.h"
> #include <sys/time.h>
> #include <asm/etraxgpio.h>
>
> int main(int argc, char **argv){
> int fd;
> int i;
> int pos;
> unsigned char mask;
> unsigned char period[4000];
>
> if(argc > 1)
> pos = atoi(argv[1]);
> else
> pos = 100;
>
> // better use memset() here, but this is proof-of-concept code
> for(i=0; i<pos+1; i++){
> if(pos > i)
> period[i] = 0xFF;
> else
> period[i] = 0;
> }
>
> fd = open("/dev/gpiob", O_RDWR);
>
> if(!fd){
> printf("open error\n");
> exit(-1);
> }
>
> mask = 1<<6 | 1<<7; // use pins PB6 and PB7 according to the
> fox pinout
>
> // prepare for write()
> if(ioctl(fd, _IO(ETRAXGPIO_IOCTYPE, IO_CFG_WRITE_MODE),
> IO_CFG_WRITE_MODE_VALUE(1, mask, 1<<1))){
> perror("ioctl error");
> exit(-1);
> }
>
> for(;;){
> write(fd, &period, pos+1); // write the pulse,
> followed by a zero to set the output
> usleep(5000); // let the CPU breathe a bit..
> }
> }
> --
>
> This only works with ports A and B, not with the G line.
>
> Supply any value between 100 and 400 as first argument to set the
> position of two servos connected to PB6 and PB7.
>
> example:
>
> ./motor 180
>
> This uses LESS THAN 1% CPU when running.
>
> This is proof of concept code, so it's UGLY AND NOT USEFUL OUT OF THE
> BOX. Also, my english sucks a bit.
>
> --- In [email protected] <foxboard%40yahoogroups.com>, "zooltheno1"
> <[EMAIL PROTECTED]> wrote:
> >
> > Hi
> > I want to use RC-Servos with the Foxboard, the normal interfall is
> > 1-2ms and 20ms pause.
> > I tried to use udelay for the delay, put the minimum is 40ms,
> > which is far to slow, even normal AC is faster.
> > How could I get the nesasery delay without 100% CPU load ?
> >
> > Bye
> > Ralph
> >
>
>
>
>
>
> ------------------------------------------------
> Resources are limited, Imagination is unlimited.
>
> ---------------------------------
> Want to start your own business? Learn how on Yahoo! Small Business.
>
> [Non-text portions of this message have been removed]
>
>
>
[Non-text portions of this message have been removed]
------------------------------------------------
Resources are limited, Imagination is unlimited.
---------------------------------
Get your own web address.
Have a HUGE year through Yahoo! Small Business.
[Non-text portions of this message have been removed]