Jump to content
43oh

Problems with functions


Recommended Posts

Hello guys, im working with an hexapod robot wich has 18 servomotors, 3 servomotors for leg, and im programming a secuence of movements but I would like to define a function for each leg and movement, I have problems with the functions cause the debugger give me a warning for each function (expression has no effect), im a noob sorry :roll:

 

#include "msp430g2553.h"
unsigned char TxByte=0; 
char posinicial(void);
unsigned paradobajo(void);
unsigned parado (void); 
void main(void)
{

 WDTCTL = WDTPW + WDTHOLD;                
 P1SEL = BIT1 + BIT2 ;                     // P1.1 = RXD, P1.2=TXD               
 P1SEL2 = BIT1 + BIT2;
 UCA0CTL1 |= UCSWRST;						
 UCA0CTL1 |= UCSSEL_2;						//Se fija el reloj a 1.1 MHz
 UCA0BR0 = 0x78;							// Baud rate 1.1 MHz/9600 = 112 (PAG. 435 SLAU144)
 UCA0BR1 = 0x00;     						// (PAG. 435 SLAU144)
   UCA0MCTL = UCBRS2;						// Modulacion UCBRSx =2 (PAG. 435 SLAU144)
 UCA0CTL1 &= ~UCSWRST;                     // Inicializa USCI (PAG. 451 SLAU144)


 while (1)
{ 
posinicial;
__delay_cycles(1000000);

paradobajo;
__delay_cycles(1000000);

for(; {
parado;
}


 }
}
void putc(char c) {
   while(!(IFG2 & UCA0TXIFG)); //Ciclo que se ejecuta hasta que el buffer de TX se encuentra listo para enviar un nuevo byte
   UCA0TXBUF = c; //pone el caracter en el buffer y lo envia
}

void in(unsigned int servo, unsigned int angle)
{
  //bytes al servocontrolador
putc(0x0C);  //numero de dispositivo (12 por default)
putc(servo); //numero de servo
putc(angle&0x7f);
putc(((angle>>7)&0x3f));
}

char posinicial(void) { //posicion inicial
in(2,5000); 
in(5,7000); 
in(8,6000); 
in(11,6000);
in(14,7000);
in(17,5000); 

in(0,4000);
in(3,8000);
in(6,4000);
in(9,8000);
in(12,4000);
in(15,8000);

in(1,4000);
in(4,8000);
in(7,4000);
in(10,8000);
in(13,4000);
in(16,8000); 
//__delay_cycles(4000000);
return 0;
}

unsigned paradobajo(void) { //parado bajo
in(0,5500);
in(3,6500);
in(6,5500);
in(9,6500);
in(12,5500);
in(15,6500);

in(1,6000);
in(4,6000);
in(7,6000);
in(10,6000);
in(13,6000);
in(16,6000);

in(2,5000); 
in(5,7000); 
in(8,6000); 
in(11,6000);
in(14,7000);
in(17,5000); 
//__delay_cycles(2000000);
return 0; }

unsigned parado (void) { //parado
in(0,6500);
in(3,5500);
in(6,6500);
in(9,5500);
in(12,6500);
in(15,5500);

in(1,7000);
in(4,5000);
in(7,7000);
in(10,5000);
in(13,7000);
in(16,5000);

in(2,5000); 
in(5,7000); 
in(8,6000); 
in(11,6000);
in(14,7000);
in(17,5000); 
//__delay_cycles(1000000); 
return 0;
}

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...