- Код: Выделить всё • Развернуть
DDRB&=~(1<<DDB6)|(1<<DDB5);
DDRB&=~(((1<<DDB6)|(1<<DDB5)));
roboforum.ruТехнический форум по робототехнике. |
|
|
DDRB&=~(1<<DDB6)|(1<<DDB5);
DDRB&=~(((1<<DDB6)|(1<<DDB5)));
{
static char current_servo=1;
static unsigned int pause = 18432;
static unsigned int OCR33;
if (current_servo == 9)
{
current_servo = 0;
OCR33 += pause;
OCR3C=OCR33;
pause = 18432;
}
else
{
OCR33+=servo_position[current_servo];
OCR3C=OCR33;
pause -= servo_position[current_servo];
current_servo++;
}
TCCR3C|=(1<<FOC3C);
}
void servo_grad(int grad){
int i=0; //180 = 2300
unsigned int time; //0 = 500
unsigned int time_s = 0; //grad = 1 * 10 +500
unsigned int time_u = 0;
time = grad*10+500;
time_s = 20000 - time;
if(time_s%1000 > 0 ){
time_u = time_s%1000;
time_s = time_s/1000;
}else{
time_s = time_s/1000;
time_u = 0;
}
for(i = 0; i<100; i++){
PORTC.0 = 1;
delay_us(time);
PORTC.0 = 0;
delay_ms(time_s);
delay_us(time_u);
}
}
delay_us(time*1);
delay_us(time_u);
float = c;
int k = 1;
c = (float)k*0.33;
printf("%f \r\n\0", c);
k++;
delay_ms(2000);
interrupt [TIM2_OVF] void timer2_ovf_isr(void)
{
emergency_stop_count++;
if(emergency_stop_count>30)
{
motors_off();
}
}
void motors_off (void)
{
TCCR1A=0x00;
TCCR1B=0x00;
PORTB&=~((1<<PORTB6)|(1<<PORTB7));
PORTC&=~((1<<PORTC7)|(1<<PORTC6));
DDRB&=~((1<<DDB6)|(1<<DDB5));
DDRC&=~((1<<DDC7)|(1<<DDC6));
TCCR2=0x00;
TIMSK&=~(1<<TOIE2);
}
_Bool
bool
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 3