需要帮助缩短程序运行伺服电机。

D

darrellc

Guest
我试图运行此程序代码伺服电机。

I'm using the mikroC basic compiler for PIC.

这是过了极限,无法找到任何方式
, 以缩短程序。有人可以帮助我吗?希望得到帮助。

代码:

/ /伺服电机自动测试模式整合酶;无效的main()(

TRISB = 0;

ADCON1 = 0x07;

PORTB的= 0;做(

为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1300);

PORTB的= 0x00;

Delay_us(18700);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1310);

PORTB的= 0x00;

Delay_us(18690);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1320);

PORTB的= 0x00;

Delay_us(18680);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1330);

PORTB的= 0x00;

Delay_us(18670);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1340);

PORTB的= 0x00;

Delay_us(18660);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1350);

PORTB的= 0x00;

Delay_us(18650);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1360);

PORTB的= 0x00;

Delay_us(18640);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1370);

PORTB的= 0x00;

Delay_us(1.863万);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1380);

PORTB的= 0x00;

Delay_us(18620);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1390);

PORTB的= 0x00;

Delay_us(18610);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1400);

PORTB的= 0x00;

Delay_us(18600);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1410);

PORTB的= 0x00;

Delay_us(18590);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1420);

PORTB的= 0x00;

Delay_us(18580);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1430);

PORTB的= 0x00;

Delay_us(18570);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1440);

PORTB的= 0x00;

Delay_us(18560);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1450);

PORTB的= 0x00;

Delay_us(18550);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1460);

PORTB的= 0x00;

Delay_us(18540);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1470);

PORTB的= 0x00;

Delay_us(18530);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1480);

PORTB的= 0x00;

Delay_us(18520);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1490);

PORTB的= 0x00;

Delay_us(18510);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1500);

PORTB的= 0x00;

Delay_us(18500);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1510);

PORTB的= 0x00;

Delay_us(18490);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1520);

PORTB的= 0x00;

Delay_us(18480);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1530);

PORTB的= 0x00;

Delay_us(1.847万);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1540);

PORTB的= 0x00;

Delay_us(18460);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1550);

PORTB的= 0x00;

Delay_us(18450);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1560);

PORTB的= 0x00;

Delay_us(18440);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1570);

PORTB的= 0x00;

Delay_us(18430);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1580);

PORTB的= 0x00;

Delay_us(18420);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1590);

PORTB的= 0x00;

Delay_us(18410);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1600);

PORTB的= 0x00;

Delay_us(18400);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1610);

PORTB的= 0x00;

Delay_us(1.839万);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1620);

PORTB的= 0x00;

Delay_us(18380);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1630);

PORTB的= 0x00;

Delay_us(18370);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1640);

PORTB的= 0x00;

Delay_us(18360);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1650);

PORTB的= 0x00;

Delay_us(18350);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1660);

PORTB的= 0x00;

Delay_us(18340);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1670);

PORTB的= 0x00;

Delay_us(18330);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1680);

PORTB的= 0x00;

Delay_us(1.832万);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1690);

PORTB的= 0x00;

Delay_us(18310);



为(= 0,我“= 25,我 )(

PORTB的= 0x01;

Delay_us(1700);

PORTB的= 0x00;

Delay_us(18300);



),而(1);


 
嗨。

我不知道这是什么程序是好的,但我可以表明这样的小尺寸的优化:
代码:/ /伺服电机自动测试模式整合酶,焦耳;无效的main()



TRISB = 0;

ADCON1 = 0x07;

PORTB的= 0;做



为(十= 1300; ĵ“= 1700; ĵ = 10)



为(= 0,我“= 25,我 )



PORTB的= 0x01;

Delay_us(十);

PORTB的= 0x00;

Delay_us(20000 - J)的;





),而(1);



 
问题是
, 我无法投入到'Delay_us一个变量()'。我使用的编译器的mikroC知情同意。

 
如何'回合这则:
代码:

/ /伺服电机自动测试模式整合酶,焦耳;(廉政延迟时间无效Delay_10us)



而( -延迟时间“0)



Delay_us(10);



)无效的main()



TRISB = 0;

ADCON1 = 0x07;

PORTB的= 0;做



为(ĵ = 130; ĵ“= 170; ĵ )



为(= 0,我“= 25,我 )



PORTB的= 0x01;

Delay_10us(十);

PORTB的= 0x00;

Delay_10us(2000 - J)的;





),而(1);


 
嗯,错误信息'Delay_10us标识重新定义'。不过,我试图改变函数的名称
, 并设法编译!现在
, 我只是在我的测试车出来以后。

<img src="http://www.edaboard.com/images/smiles/icon_biggrin.gif" alt="很高兴" border="0" />

谢谢!

 

Welcome to EDABoard.com

Sponsor

Back
Top