Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/18/10 21:28
Read: times


 
#172569 - Here is the code...
Responding to: ???'s previous message
Hello Everyone,
Here is the code I wrote using Mr. Ferlemann's suggestions. Am I making a mistake anywhere?
Also, I couldn't understand a word of the code posted by Mr. Murray R. Van Luyn ( unfortunately my knowledge of embedded C is quite poor). Can someone please explain the algorithm of the code or the concept used in his code?

Thanks a lot, in advance.

#include<reg51.h>
#include<stdio.h>
sbit MTRS=P2^0;
sbit MTRE=P2^1;
sbit MTRW=P2^2;
sbit MTRH=P2^3;
static unsigned char ms_tenth;
static unsigned char target1;
static unsigned char target2;
static unsigned char target3;
static unsigned char target4;

void servo(char,char,char,char);
void msdel(unsigned int);



void Timer0_ISR (void) interrupt 1 
{

 MTRS=(ms_tenth < target1);
 MTRE=(ms_tenth < target2);
 MTRW=(ms_tenth < target3);
 MTRH=(ms_tenth < target4);
 if (++ms_tenth == 200)
 ms_tenth = 0;

 TF0 = 0; 
}

void servo(char w,char x,char y,char z)
{
TR0=1;
target1=w;
target2=x;
target3=y;
target4=z;

msdel(8000);

}

void msdel(unsigned int major)
{unsigned int i,j;
for(i=1;i<major;i++)
for(j=1;j<10;j++);
}

void main(void)
{TMOD=0x02;
IE=0x82;
TH0=0xA3;

MTRS=0;
MTRE=0;
MTRW=0;
MTRH=0;

ms_tenth = 0;
target1=0;
target2=0;
target3=0;
target4=0;


{servo(21,10,14,23);

servo(20,12,14,23);

servo(20,14,14,23);

servo(20,17,14,23);

servo(20,17,17,23);

servo(20,14,14,16);


servo(20,10,12,16);

servo(21,10,14,16);

   		   
}
for(;;);
}


 
 



List of 41 messages in thread
TopicAuthorDate
Controlling multiple servo motors            01/01/70 00:00      
   executing code takes time            01/01/70 00:00      
      PWM code            01/01/70 00:00      
         Thanks...now, about the PCA timer..            01/01/70 00:00      
   If SDCC Then Keil            01/01/70 00:00      
      PWM IRQ code in C, bitops, 45 byte            01/01/70 00:00      
         Optimization having no effect.            01/01/70 00:00      
      PWM IRQ code in C, lookup table, 32 byte            01/01/70 00:00      
         I haven't understood the table lookup concept very well...            01/01/70 00:00      
            table lookup            01/01/70 00:00      
         PWM IRQ code in C, lookup table, 30 byte            01/01/70 00:00      
            Compiler specifics            01/01/70 00:00      
               absolutely-locating xdata at 256 byte boundary            01/01/70 00:00      
                  I see.            01/01/70 00:00      
            An example code..            01/01/70 00:00      
               Keil: Specifics and non-specifics            01/01/70 00:00      
                  Not really working...            01/01/70 00:00      
                     Enough power?            01/01/70 00:00      
                        RE: running 32 servo motors            01/01/70 00:00      
      The chip sounds perfect...            01/01/70 00:00      
         not worth it            01/01/70 00:00      
            Servo control will become difficult then...            01/01/70 00:00      
               output            01/01/70 00:00      
               HCT chips have ...            01/01/70 00:00      
                  Eval a concept with a single PCA and 3:8 HCT multiplexer?            01/01/70 00:00      
               Check their website            01/01/70 00:00      
                  Here is the code...            01/01/70 00:00      
                     "sbit MTRS=P2^0;" is not OK here            01/01/70 00:00      
                        Keil syntax?            01/01/70 00:00      
                           "#define" not working.."sbit" works            01/01/70 00:00      
                              Yes, you were correct originally!            01/01/70 00:00      
            Seconded            01/01/70 00:00      
   Servo_0.1.zip            01/01/70 00:00      
      links            01/01/70 00:00      
   Eventually feed the guys at http://servomaster.sf.net ?            01/01/70 00:00      
      servomaster.sf.net FLOSS            01/01/70 00:00      
   Maybe of some use...            01/01/70 00:00      
      Whoops... found a bug            01/01/70 00:00      
         What bug?            01/01/70 00:00      
            Bug            01/01/70 00:00      
   Improved version uploaded            01/01/70 00:00      

Back to Subject List