智能车制作
标题:
光电舵机控制,附上程序
[打印本页]
作者:
moonlight831
时间:
2012-5-29 12:39
标题:
光电舵机控制,附上程序
void main() {
DisableInterrupts;
Init_PLL();
Init_PWM();
Init_PIO();
Init_PIT0();
//Init_Pulse();
//Init_RTI();
// Init_IncPID();
//int addpid;
EnableInterrupts;
for(;;)
{
while(Laser_ok==0) ;
DisableInterrupts;
Laser_ok=0;
chuli();
// qingling();
duoji_speed();
dianji_speed();
EnableInterrupts;
}
}
#pragma CODE_SEG __NEAR_SEG NON_BANKED
void interrupt 66 PIT0(void) // 激光分时发射,频率180Khz
{
static unsigned int count1;
static char laser[12]={1};
DisableInterrupts;
// PORTB=count1;
count1++;
switch (count1)
{
case 1:
PORTB=0x05;
delay10us(1);
laser[0]=PORTK_PK0; //第一个接收管,接在PK1,PK[3:1]均为GPIO(普通IO口)
laser[11]=PORTK_PK3;
break;
case 2:
PORTB=0x0c;
delay10us(1);
laser[1]=PORTK_PK0;
laser[10]=PORTK_PK3;
break;
case 3:
PORTB=0x13;
delay10us(1);
laser[2]=PORTK_PK0;
laser[9]=PORTK_PK3;
break;
case 4: PORTB=0x1A;
delay10us(1);
laser[3]=PORTK_PK1;
laser[8]=PORTK_PK2;
break;
case 5:
PORTB=0x21;
delay10us(1);
laser[4]=PORTK_PK1;
laser[7]=PORTK_PK2;
break;
case 6: PORTB=0x28;
delay10us(1);
laser[5]=PORTK_PK1;
laser[6]=PORTK_PK2;
count1=0;
jiguang[0]=laser[0];
jiguang[1]=laser[1];
jiguang[2]=laser[2];
jiguang[3]=laser[3];
jiguang[4]=laser[4];
jiguang[5]=laser[5];
jiguang[6]=laser[6];
jiguang[7]=laser[7];
jiguang[8]=laser[8];
jiguang[9]=laser[9];
jiguang[10]=laser[10];
jiguang[11]=laser[11];
heidian++;
break;
}
最近因朋友所托在弄光电,程序如上,问题: jiguang[]里面有几个数组 用来控制舵机不好使,但是观察示波器,接受都正常。。。。。这好奇怪啊~~~~希望大神求救~~
欢迎光临 智能车制作 (http://dns.znczz.com/)
Powered by Discuz! X3.2