View Single Post
  #10   Spotlight this post!  
Unread 04-01-2005, 16:59
doyler doyler is offline
Rookie / Programmer
#0900 (Infinity)
Team Role: Programmer
 
Join Date: Oct 2004
Rookie Year: 2005
Location: Durham
Posts: 87
doyler is an unknown quantity at this point
Re: Senior Programmer: advice on training new recruits

this is all i have done so far with a lot of help from someone on cd

Code:
/*******************************************************************************
* FUNCTION NAME: Process_Data_From_Master_uP
* PURPOSE:       Executes every 17ms when it gets new data from the master 
*                microprocessor.
* CALLED FROM:   main.c
* ARGUMENTS:     none
* RETURNS:       void
*******************************************************************************/
void Process_Data_From_Master_uP(void)
{
static unsigned char servo1=0;
static unsigned char servo2=0;
static unsigned char counter=0;
static unsigned char counter2=0;
Getdata(&rxdata); /* Get fresh data from the master microprocessor. */
 
Default_Routine(); /* Optional. See below. */
 
/* Add your own code here. */

 
/*BEGIN SERVO 1 IN PWM 1*/
/*
if (counter < 59)
*/
/*
(counter < n) is the time between each distinct movement of the servo. Where n/59 = the time seconds. For example, 
n= 59 is 1 second, 
n=118 is 2 seconds, 
n=30 = ˝ second
*/
/*
counter++; 
else
{
counter = 0;
if (servo1 < 254)
	servo1++; // servo1 will slowly step through each of it’s positions //servo1++; will make it move slower, but it is default
*/
/*
servo1 += y) is how large a movement the servo will make each time (according to the above). For example, y=1 position and is the smallest movement the servo can make, y=5 moves 5 servo positions and because of this will appear to be 5 times as fast.
You’ll have to change the limit check “if (servo1 < 254)” to match whatever number you use, to make sure servo1 will never end up greater than 255. For instance, 
if y=5 the check should become “if (servo1 < 250)”
if y=10 the check should become “if (servo1 < 240)”
*/
/*
else
	 servo1 = 0; // servo1 will quickly reset to the zero position
}
pwm01 = servo1;
*/

/*SERVO 1 FAST*/
if (counter < 59) // About a second
	counter++;
else
{
	 counter = 0;
	 if (servo1 == 0)
	 servo1 = 255;
	 else
	 servo1 = 0;
}
pwm01 = servo1;

/*BEGIN SERVO 2 IN PWM 8*/
if (counter2 < 59)
counter2+=58; 
else
{
counter2 = 0;
if (servo2 < 254)
	servo2+=253; 
else
	 servo2 = 0;
}
pwm08 = servo2;

printf("PWM OUT 1 = %d, PWM OUT 8 = %d\n",(int)pwm01, (int)pwm08); /*printf EXAMPLE (edited by me to fill my needs)*/

Putdata(&txdata); /* DO NOT CHANGE! */
}
and i understand it somewhat, but im still struggling and i do not understand yours
__________________