本帖最后由 luckyc 于 2015-5-1 01:31 编辑
今晚天气不错,继续调整程序和转速,不过只跟了一会,厚云就上来了,没法继续测试,但基本上可以同步跟踪了,目视用25mm目镜没什么问题了,还差上高倍调试,等天气好了再继续高倍调整,调试有点成果,按键也重新调整了一下,增加了恒星速和月亮速。
4*4键盘用了8个:
减速和加速,每按一次加减速一个档,可以加减到很快和很慢
顺便C代码也贴上,备查- #include <reg52.h>
- #include <intrins.h>
- #define uchar unsigned char
- #define uint unsigned int
- uchar code FFW[8]={0xf1,0xf3,0xf2,0xf6,0xf4,0xfc,0xf8,0xf9};
- uchar code REV[8]={0xf9,0xf8,0xfc,0xf4,0xf6,0xf2,0xf3,0xf1};
- unsigned char key=0xff;
- void readkey();
- void delay(uint e);
- void motor_ffw(uint n);
- void motor_rev(uint n);
- void main()
- {
- uchar t;
- t=105;
- while (1)
- {
- readkey();
- if(key!=0xff)
- {
- switch(key)
- {
- case 0xee:
- motor_ffw(1);
- continue;
- case 0xde:
- motor_rev(1);
- continue;
- case 0xbe:
- motor_ffw(t);
- continue;
- case 0x7e:
- motor_rev(t);
- continue;
- case 0xed:
- t=47;
- delay (200);
- continue;
- case 0xdd:
- t=105;
- delay (200);
- continue;
- case 0xbd:
- t=t+10;
- delay (200);
- continue;
- case 0x7d:
- if (t<10)
- {
- t=1;
- }
- else
- {
- t=t-10;
- }
- delay (200);
- continue;
- }
- }
- motor_rev(t);
- }
- }
- void readkey()
- {
- P1=0xfe;
- key=P1;
- if (key!=0xfe)
- return;
- P1=0xfd;
- key=P1;
- if (key!=0xfd)
- return;
- P1=0xfb;
- key=P1;
- if (key!=0xfb)
- return;
- P1=0xf7;
- key=P1;
- if (key!=0xf7)
- return;
- key=0xff;
- }
- void delay(uint e)
- {
- uint k;
- while(e--)
- {
- for(k=0; k<125; k++)
- { }
- }
- }
- void motor_ffw(uint n)
- {
- uchar i;
- for (i=0; i<8; i++)
- {
- P2 = FFW[i];
- delay(n);
- }
- }
- void motor_rev(uint n)
- {
- uchar i;
- for (i=0; i<8; i++) //一个周期转30度
- {
- P2 = REV[i];
- delay(n); //调节转速
- }
- }
复制代码
|