標(biāo)題: 單片機(jī)步進(jìn)電機(jī)仿真89c51+uln2004a [打印本頁]

作者: 1263726410    時(shí)間: 2020-5-9 22:25
標(biāo)題: 單片機(jī)步進(jìn)電機(jī)仿真89c51+uln2004a
  1. #include<reg51.h>
  2. #include<absacc.h>
  3. #define uint unsigned int
  4. #define uchar unsigned char
  5. void delay(uint x);
  6. void out(char state)
  7. {
  8.         code uchar table[]={0x03,0x09,0x0c,0x06}; //反轉(zhuǎn)
  9. //        code uchar table[]={0x03,0x06,0x0C,0x09};//正轉(zhuǎn)
  10.         P1=table[state];
  11. //        PORT=table[state];
  12.         delay(8);
  13. }


  14. uchar phase=0;
  15. //out(uchar x);
  16. void main()
  17. {
  18.         for(;;)
  19.         {
  20.                 out(phase=++phase&0x03);//調(diào)用輸出函數(shù)
  21.         }
  22. }

  23. void delay(uint x)
  24. {
  25.         uchar j;
  26.         while(x-->0)
  27.         {
  28.                 for(j=0;j<125;j++)
  29.                 {;;}
  30.         }
  31. }
復(fù)制代碼


51hei截圖20200509222359.png (105.42 KB, 下載次數(shù): 41)

51hei截圖20200509222359.png

步進(jìn)電機(jī)仿真.zip

38.39 KB, 下載次數(shù): 24, 下載積分: 黑幣 -5






歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1