Author Topic: servo() function  (Read 1724 times)

0 Members and 1 Guest are viewing this topic.

Offline tzankoffTopic starter

  • Robot Overlord
  • ****
  • Posts: 122
  • Helpful? 0
servo() function
« on: September 19, 2010, 09:34:11 AM »
This is driving me up the wall and I cannot find references to what the error messages are trying to tell me.

I am using an Axon II. The code I am trying to run is similar to that in the original Axon Bluetooth video, but there is no reason why this should not be able to work since the code for the original Axon is supported by the Axon II.

Code: [Select]
int gripper=700;
char cByte;

TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart)
{
if (getError()!=0)
{
rprintf("ERROR!\n");
}
else
{
cByte=uart2GetByte();

if (cByte=='x')
gripper=gripper+10;
if (cByte=='y')
gripper=gripper-10;

servo(PORTL,2,gripper);
rprintf("cByteValue: %d GripValue: %d\n", cByte, gripper);
}

return 20000;
}

It's gagging on the servo() line and displays the following errors when trying to build.

Quote
../fergybot.c:101: warning: implicit declaration of function 'servo'
../fergybot.c:101: error: 'PORTL' undeclared (first use in this function)
../fergybot.c:101: error: (Each undeclared identifier is reported only once
../fergybot.c:101: error: for each function it appears in.)

I cannot find a file with the Axon II that has the servo macro. There is one in the Sor_Utils.h with the original Axon, buty I cannot find an equivalent with Axon II. Someone please help me here. I am running out of hair to pull out.

Offline madsci1016

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
    • Personal Website
Re: servo() function
« Reply #1 on: September 19, 2010, 09:40:18 AM »
I think you're mixing code here.

Try using Project Designer and that will setup all your code correctly and give you examples on how to use your servo.

Watch my guide to see how it works.

Axon 2, Webbotlib and Project Designer Tutorial

Offline KurtEck

  • Robot Overlord
  • ****
  • Posts: 217
  • Helpful? 12
Re: servo() function
« Reply #2 on: September 19, 2010, 10:58:40 AM »
As Madsci mentioned, I think you are mixing code here.  From this, it looks like you are using webbotlib.  If so I believe that webbotlib undefined all of the hardware ports and the like as to get you to use his form of definitions...

I did my main program before the project designer was up and running so I have not tried that yet, but will for my next one...

You should look at the servos.h header file in webbotlib and the documention within webbotlib...pdf that is included with each version of the library.

In my Brat program I used a bunch of lines that looked like:
Code: [Select]
SERVO svoTurret = MAKE_SERVO(TRUE, E5, 1500, 875);
You then can setup lists of these servos.  Usually split by which one use hardware timers.
On my Brat these lists looked like:
Code: [Select]
SERVO_LIST servos_PWM[] = {&svoRAnkle, &svoRKnee, &svoRHip, &svoLAnkle, &svoLKnee, &svoLHip, &svoTurret};
SERVO_DRIVER bank1 = MAKE_SERVO_DRIVER(servos_PWM);
To then initialize the servos you can make a call like:
Code: [Select]
servosConnect(&bank1);

Good Luck
Kurt

Offline madsci1016

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
    • Personal Website
Re: servo() function
« Reply #3 on: September 19, 2010, 11:08:18 AM »
In my Brat program I used a bunch of lines that looked like:
Code: [Select]
SERVO svoTurret = MAKE_SERVO(TRUE, E5, 1500, 875);
You then can setup lists of these servos.  Usually split by which one use hardware timers.
On my Brat these lists looked like:
Code: [Select]
SERVO_LIST servos_PWM[] = {&svoRAnkle, &svoRKnee, &svoRHip, &svoLAnkle, &svoLKnee, &svoLHip, &svoTurret};
SERVO_DRIVER bank1 = MAKE_SERVO_DRIVER(servos_PWM);
To then initialize the servos you can make a call like:
Code: [Select]
servosConnect(&bank1);

Project Designer generates all this code for you. It really does make setting up projects easier.

Also; WOOT! 1,000 post!

Offline tzankoffTopic starter

  • Robot Overlord
  • ****
  • Posts: 122
  • Helpful? 0
Re: servo() function
« Reply #4 on: September 19, 2010, 05:05:34 PM »
madsci1016, I'll have you know that...this is EXACTLY what I am looking for!!! Damn, this painfully simple! It did take a little while for me to figure a couple of things out, but I got the hang of it now. Thank you foe recommending this awesome product and by "thank you", I mean...

Thankyouthankyouthankyouthankyouthankyouthankyouthankyouthankyouthankyouthankyouthankyouthankyouthankyou!

Yeah, I know...decaf!
« Last Edit: September 19, 2010, 05:09:32 PM by tzankoff »

Offline madsci1016

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
    • Personal Website
Re: servo() function
« Reply #5 on: September 19, 2010, 05:11:34 PM »
madsci1016, I'll have you know that...this is EXACTLY what I am looking for!!! Damn, this painfully simple! It did take a little while for me to figure a couple of things out, but I got the hang of it now. Thank you foe recommending this awesome product and by "thank you", I mean...

Thankyouthankyouthankyouthankyouthankyouthankyouthankyouthankyouthankyouthankyouthankyouthankyouthankyou!

Yeah, I know...decaf!

Hehe, Glad I could help.

Webbot is the unsung hero for making Project Designer (and the whole library for that matter). I only made the tutorial to teach people how to use it.

Offline tzankoffTopic starter

  • Robot Overlord
  • ****
  • Posts: 122
  • Helpful? 0
Re: servo() function
« Reply #6 on: September 19, 2010, 05:34:59 PM »
Well, I think you did a fine job. I'll click that little "helpful?" link in just a minute. Now to figure out the rest of the programming part...  :D