zoukankan      html  css  js  c++  java
  • 步进电机驱动总结

    步进电机的执行过程具有一个经典过程是:  加速阶段--运行阶段--减速阶段

     参考链接:https://www.cnblogs.com/heyxiaotang/p/5701087.html

    arduino的线性控制简单示例:

    int x;
    int s=110;
    int step_l=7000;
    void setup()
     { 
        pinMode(6,OUTPUT);  // Enable 
        pinMode(5,OUTPUT);  // Step 
        pinMode(4,OUTPUT);  // Direction
        digitalWrite(6,LOW);   // Set Enable low
     }
    
    void loop()
     {
        digitalWrite(4,LOW);   // Set Direction high 正转
        for(x = 400; x > s; x--)   // Loop 200 times  加速阶段
        { 
            digitalWrite(5,HIGH);   // Output high 
            delayMicroseconds(x);   // Wait 1/2 a ms 
            digitalWrite(5,LOW);   // Output low 
            delayMicroseconds(x);   // Wait 1/2 a ms
         } 
        
        for(x = 0; x < step_l; x++)   // Loop 200 times  运行阶段
        { 
            digitalWrite(5,HIGH);   // Output high 
            delayMicroseconds(s);   // Wait 1/2 a ms 
            digitalWrite(5,LOW);   // Output low 
            delayMicroseconds(s);   // Wait 1/2 a ms
         } 
        for(x = s; x < 400; x++)   // Loop 200 times 减速阶段
        { 
            digitalWrite(5,HIGH);   // Output high 
            delayMicroseconds(x);   // Wait 1/2 a ms 
            digitalWrite(5,LOW);   // Output low 
            delayMicroseconds(x);   // Wait 1/2 a ms
         } 
        delay(1000);   // pause one second
    
    
        
        digitalWrite(4,HIGH);       // Set Direction low  反转
        
        for(x = 400; x > s; x--)   // Loop 200 times  加速阶段
        { 
            digitalWrite(5,HIGH);   // Output high 
            delayMicroseconds(x);   // Wait 1/2 a ms 
            digitalWrite(5,LOW);   // Output low 
            delayMicroseconds(x);   // Wait 1/2 a ms
         } 
         
        for(x = 0; x < step_l; x++)   // Loop 200 times  运行阶段
       {
            digitalWrite(5,HIGH);     // Output high 
            delayMicroseconds(s);   // Wait 1/2 a ms
            digitalWrite(5,LOW);      // Output low
            delayMicroseconds(s);   // Wait 1/2 a ms 
        } 
    
        for(x = s; x < 400; x++)   // Loop 200 times  减速阶段
        { 
            digitalWrite(5,HIGH);   // Output high 
            delayMicroseconds(x);   // Wait 1/2 a ms 
            digitalWrite(5,LOW);   // Output low 
            delayMicroseconds(x);   // Wait 1/2 a ms
         } 
        delay(1000);   // pause one second 
    }
  • 相关阅读:
    BZOJ-1625 宝石手镯 01背包(傻逼题)
    BZOJ-2929 洞穴攀岩 最大流Dinic(傻逼题)
    BZOJ3252: 攻略 可并堆
    二逼平衡树 Tyvj 1730 BZOJ3196 Loj#106
    [Noi2016]区间 BZOJ4653 洛谷P1712 Loj#2086
    [NOIP2014]飞扬的小鸟 D1 T3 loj2500 洛谷P1941
    BZOJ4554: [Tjoi2016&Heoi2016]游戏 luoguP2825 loj2057
    BZOJ 2599: [IOI2011]Race 点分治
    POJ1038 Bugs Integrated, Inc 状压DP+优化
    JLOI2015 城池攻占
  • 原文地址:https://www.cnblogs.com/mlh-bky/p/10296447.html
Copyright © 2011-2022 走看看