亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? mstep_cr_v2.c

?? LM18245 16細分步進驅動程序 Microstep C program for National Semi LMD18245/PIC microstepping driver board.
?? C
字號:
/* C program for National Semi LMD18245/PIC microstepping driver board.

   IRQ version for Step input.

   ****16F627 version*****

   Embedded Acquisition Systems
   www.embeddedtronics.com
   copyright 2004-2006

   Compiled with PCW PIC Compiler Version 3.242

   July 27, 2006

   Note:
   If you see any errors, please contact me. jimf at embeddedtronics dot com

   Use this code at your own risk, no guarantee that it will work for you.

   This source code is for Non-commercial personal use only.
   If you want to use this code for any other purpose,
   please contact sales@embeddedtronics.com for a commercial license.

   If you modify/enhance this program, please send me a copy.  Thanks.

   Approximate motor performance speeds:
   Microstep10 routine runs about 25% slower due to the longer step calculation routine.
   Microstep10 about 1400RPM.
   Microstep8 about 2000rpm (53Khz step input rate).
   Microstep4 about 3500rpm (46Khz step input rate).
   Halfstep about 3000rpm (20Khz step input rate).
   Tested results with a Superior Electric M091-FD09 at 44volts motor supply. TurboCNC on P2-500 PC.
   Maximum rpm speeds will vary depending on motor type and computer speed.

   Changlog

   April 7, 2005 Added current reduction code, driver output current reduced after 3 minutes.
                 Changed microstep10 pulse routine for faster step rate.

                 Added new sine wave lookup tables, microstep8new and microstep10new.
                 The lookup table is offset by a few degrees. These need to be tested to see if they work better.

   July 27, 2006 Version 2.0
                 There is a internal hardware bug in the LMD18245 chip causing it to switch incorrectly. This makes
                 the motor have less torque in one direction at higher speeds, however the motor does not loose step position.
                 You can only switch the LMD chip direction lines (DIR A and DIR B) when the DAC value is zero. This bug was found by
                 RadekCX, a CNCZONE member and verified by alan@fromorbit.com (PICSTEP)

                 My quick fix is to make a new updated sine table that is sent to the stepper motor when the Direction
                 input line is high.

                 Bug fix only for halfstep_torque, microstep4, microstep8 and microstep10 lookup tables.

                 Removed microstep8new and microstep10new lookup tables since they don't work any better.

 PIC F627 Pin definition.
 pin17 RA0  Motor Driver A, DAC M1 Output
 pin18 RA1  Motor Driver A, DAC M2 Output
 pin1  RA2  Motor Driver A, DAC M3 Output
 pin2  RA3  Motor Driver A, DAC M4 Output
 pin3  RA4  unused

 pin6  RB0  STEP Input
 pin7  RB1  DIR Input
 pin8  RB2  Motor Driver A Direction Output
 pin9  RB3  Motor Driver B Direction Output
 pin10 RB4  Motor Driver B, DAC M1 Output
 pin11 RB5  Motor Driver B, DAC M2 Output
 pin12 RB6  Motor Driver B, DAC M3 Output
 pin13 RB7  Motor Driver B, DAC M4 Output


CS OUT current sense resister
(Vref x D/16) / (250e-6 x R) = A

R=18.75K   1amp
R=9.38K   2amp
R=7.5K    2.5amp
R=6.25K  3amp
1/4 watt
Maximum driver rating 3amps @ 55volts


16bit Timer1 overflow calculation.
For 20Mhz clock prescale is 5,000,000/T1_DIV_BY_X
T1_DIV_BY_8   1.6us  >>>  2^16 * 1.6us = .1049 seconds b4 overflow
T1_DIV_BY_1   200ns  >>>  2^16 * 200ns = .013 seconds b4 overlow
*/


#include <16F627.h>
#use delay(clock=20000000)
#fuses HS,NOWDT,MCLR,NOPROTECT,BROWNOUT,NOLVP
#byte   PORT_A =  5
#byte   PORT_B =  6
static char pos = 0;
static int16 timer_count=0;           // timer1 overflow counter
#define step_input    PIN_B0
#define dir_input     PIN_B1

//Choose step input configuration
//#define fullstep
//#define halfstep
//#define halfstep_torque
//#define microstep4
//#define microstep8
#define microstep10

//Comment out if step multiplier is NOT needed, routine yet not tested.
//#define step_multiply
//#define step_x  2      //Number of steps to multiply.

//

#ifdef fullstep
#define STEPS 4
//full step drive
//200 steps rev
byte PBF[4] = {
0b11111000,
0b00000000,
0b11110100,
0b00001100
};

byte PBR[4] = {
0b11111000,
0b00000000,
0b11110100,
0b00001100
};

byte PA[4] = {
0b0000,
0b1111,
0b0000,
0b1111
};
#endif

#ifdef halfstep
//half step drive without torque compensation
//400 steps rev
#define STEPS 8
byte PBF[8] = {
0b11111000,
0b11111000,
0b00000000,
0b11110000,
0b11110100,
0b11110100,
0b00001100,
0b11111100
};

byte PBR[8] = {
0b11111000,
0b11111000,
0b00000000,
0b11110000,
0b11110100,
0b11110100,
0b00001100,
0b11111100
};

byte PA[8] = {
0b0000,
0b1111,
0b1111,
0b1111,
0b0000,
0b1111,
0b1111,
0b1111
};
#endif

#ifdef halfstep_torque
//half step drive with torque compensation
//400 steps rev
#define STEPS 8
byte PBF[8] = {
0b00001100,
0b10111100,
0b11111000,
0b10111000,
0b00000000,
0b10110000,
0b11110100,
0b10110100
};

byte PBR[8] = {  //fix for LMD bug
0b00001100,
0b10111100,
0b11111100,  //LMD bug fix, changed DIR A to 1
0b10111000,
0b00001000,  //LMD bug fix, changed DIR B to 1
0b10110000,
0b11110000,  //LMD bug fix, changed DIR A to 0
0b10110100
};

byte PA[8] = {
0b1111,
0b1011,
0b0000,
0b1011,
0b1111,
0b1011,
0b0000,
0b1011
};
#endif

#ifdef microstep4
//quarter step drive
//800 steps rev
#define STEPS 16
byte PBF[16] ={
0b00001100,
0b01101100,
0b10111100,
0b11101100,
0b11111000,
0b11101000,
0b10111000,
0b01101000,
0b00000000,
0b01100000,
0b10110000,
0b11100000,
0b11110100,
0b11100100,
0b10110100,
0b01100100
};

byte PBR[16] ={  //fix for LMD bug
0b00001100,
0b01101100,
0b10111100,
0b11101100,
0b11111100,  //LMD bug fix, changed DIR A to 1
0b11101000,
0b10111000,
0b01101000,
0b00001000,  //LMD bug fix, changed DIR B to 1
0b01100000,
0b10110000,
0b11100000,
0b11110000,  //LMD bug fix, changed DIR A to 0
0b11100100,
0b10110100,
0b01100100
};

byte PA[16] = {
0b1111,
0b1110,
0b1011,
0b0110,
0b0000,
0b0110,
0b1011,
0b1110,
0b1111,
0b1110,
0b1011,
0b0110,
0b0000,
0b0110,
0b1011,
0b1110
};
#endif

#ifdef microstep8
//eight step drive
//1600 steps rev
#define STEPS 32
byte PBF[32] ={
0b00001100,
0b00111100,
0b01101100,
0b10001100,
0b10111100,
0b11001100,
0b11101100,
0b11111100,
0b11111000,
0b11111000,
0b11101000,
0b11001000,
0b10111000,
0b10001000,
0b01101000,
0b00111000,
0b00000000,
0b00110000,
0b01100000,
0b10000000,
0b10110000,
0b11000000,
0b11100000,
0b11110000,
0b11110100,
0b11110100,
0b11100100,
0b11000100,
0b10110100,
0b10000100,
0b01100100,
0b00110100
};

byte PBR[32] ={ //fix for LMD bug
0b00001100,
0b00111100,
0b01101100,
0b10001100,
0b10111100,
0b11001100,
0b11101100,
0b11111100,
0b11111100,  //LMD bug fix, changed DIR A to 1
0b11111000,
0b11101000,
0b11001000,
0b10111000,
0b10001000,
0b01101000,
0b00111000,
0b00001000,  //LMD bug fix, changed DIR B to 1
0b00110000,
0b01100000,
0b10000000,
0b10110000,
0b11000000,
0b11100000,
0b11110000,
0b11110000,  //LMD bug fix, changed DIR A to 0
0b11110100,
0b11100100,
0b11000100,
0b10110100,
0b10000100,
0b01100100,
0b00110100
};

byte PA[32] ={
0b1111,
0b1111,
0b1110,
0b1100,
0b1011,
0b1000,
0b0110,
0b0011,
0b0000,
0b0011,
0b0110,
0b1000,
0b1011,
0b1100,
0b1110,
0b1111,
0b1111,
0b1111,
0b1110,
0b1100,
0b1011,
0b1000,
0b0110,
0b0011,
0b0000,
0b0011,
0b0110,
0b1000,
0b1011,
0b1100,
0b1110,
0b1111
};
#endif

#ifdef microstep10
//ten step drive
//2000 steps rev
#define STEPS 40
byte PBF[40] ={
0b00001100,
0b00101100,
0b01011100,
0b01111100,
0b10011100,
0b10111100,
0b11001100,
0b11011100,
0b11101100,
0b11111100,
0b11111000,
0b11111000,
0b11101000,
0b11011000,
0b11001000,
0b10111000,
0b10011000,
0b01111000,
0b01011000,
0b00101000,
0b00000000,
0b00100000,
0b01010000,
0b01110000,
0b10010000,
0b10110000,
0b11000000,
0b11010000,
0b11100000,
0b11110000,
0b11110100,
0b11110100,
0b11100100,
0b11010100,
0b11000100,
0b10110100,
0b10010100,
0b01110100,
0b01010100,
0b00100100
};

byte PBR[40] ={  //fix for LMD bug
0b00001100,
0b00101100,
0b01011100,
0b01111100,
0b10011100,
0b10111100,
0b11001100,
0b11011100,
0b11101100,
0b11111100,
0b11111100,  //LMD bug fix, changed DIR A to 1
0b11111000,
0b11101000,
0b11011000,
0b11001000,
0b10111000,
0b10011000,
0b01111000,
0b01011000,
0b00101000,
0b00001000,  //LMD bug fix, changed DIR B to 1
0b00100000,
0b01010000,
0b01110000,
0b10010000,
0b10110000,
0b11000000,
0b11010000,
0b11100000,
0b11110000,
0b11110000,  //LMD bug fix, changed DIR A to 0
0b11110100,
0b11100100,
0b11010100,
0b11000100,
0b10110100,
0b10010100,
0b01110100,
0b01010100,
0b00100100
};

byte const PA[40] ={
0b1111,
0b1111,
0b1110,
0b1101,
0b1100,
0b1011,
0b1001,
0b0111,
0b0101,
0b0010,
0b0000,
0b0010,
0b0101,
0b0111,
0b1001,
0b1011,
0b1100,
0b1101,
0b1110,
0b1111,
0b1111,
0b1111,
0b1110,
0b1101,
0b1100,
0b1011,
0b1001,
0b0111,
0b0101,
0b0010,
0b0000,
0b0010,
0b0101,
0b0111,
0b1001,
0b1011,
0b1100,
0b1101,
0b1110,
0b1111
};
#endif


void step(char dir)
    {
#if  !defined (microstep10)
      pos = (steps + pos + dir) & (STEPS-1);  //works only for STEPS of 4,8,32
#else
      pos = (pos + STEPS + dir) % STEPS;    //for microstep10, this one works for any STEPS length value but takes longer to calculate
#endif
      PORT_A = PA[pos];  //output to drivers
      PORT_B = PBF[pos];
    }

void stepper_off()	 //Turn off power to all windings.
	 {
	 PORT_A = 0;
	 PORT_B = 0;
	 }

void init_stepper()	 //Move a few to register correct step position.
	 {
	 int i;
	 for (i=0;i<8;i++){
	 	 step(-1);
		 delay_ms(100);
	 }
	 for (i=0;i<8;i++){
	 	 step(1);
		 delay_ms(100);
	 }
	}

#INT_EXT             //Pin B0 interrupt service routine for Step input Active low
void ext_isr() {
//read dir input and advance motor
signed int dir,i,temp;

   dir=input(dir_input);

#if  !defined (microstep10)
   if (dir==0){
	   dir=-1;}
#endif

//Step Multiply routine, not fully working. In testing stage.
#ifdef step_multiply
      for (i=0;i<step_x;i++){
         step(dir);
         delay_us(5);   //Note: May need to increase or decrease this delay depending on how slow your motor is.
      }
#else

#if  !defined (microstep10)
    pos = (steps + pos + dir) & (STEPS-1);  //works only for STEPS of 4,8,32
#else
    if(dir==0){            //faster microstep10 routine
        pos = (pos + 1);
        if (pos==40) {
        pos=0;
        }
    }
    else{
        if (pos==0) {
        pos=40;
        }
        pos = (pos - 1);
    }
#endif
   //output to drivers
    if(dir==0){
        PORT_B = PBF[pos];}
    else{
        PORT_B = PBR[pos];
    }
      PORT_A = PA[pos];


#endif

timer_count=0;         //reset timer1 counter
}

#int_timer1                       //This function is called everytime
timer_isr() {                     //the timer1 overflows (2^16).
    timer_count++;
    }

void main() {
   setup_timer_1( T1_INTERNAL | T1_DIV_BY_8 );  //init timer1
   enable_interrupts(INT_TIMER1);  //turn on timer1 interrupt
   setup_counters(RTCC_INTERNAL,RTCC_DIV_2);
   ext_int_edge(H_TO_L);           //init interrupt edge triggering for B0, Active Low
   enable_interrupts(INT_EXT);     //turn on external B0 interrupt
   enable_interrupts(GLOBAL);

   set_tris_a(0x10);  //set port A&B for correct data i/o directions
   set_tris_b(0x03);
   #use fast_io (A)
   #use fast_io (B)

stepper_off();     //No current to motor.
delay_ms(1000);    //1 second turn on delay.
init_stepper();

loop:
if (timer_count>1700){     //Shutdown motor drivers after 3 minutes when no step pulse activity
	   PORT_A = 0b0010;  //Set current level at 12% hold
      PORT_B = (PBF[pos] & 0b00001111) | 0b00100000;
      }
goto loop;    //keep looping, waiting for interrupt request

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产免费成人在线视频| 亚洲精品久久久蜜桃| 国产亚洲欧美色| 亚洲男同性视频| 日本v片在线高清不卡在线观看| 捆绑调教一区二区三区| 亚洲女同一区二区| 国产99久久久国产精品免费看 | 国产精品久久久久久福利一牛影视 | 欧美三区在线视频| 精品久久久久一区二区国产| 欧美一级国产精品| 亚洲日本电影在线| 精品亚洲免费视频| 欧美伊人精品成人久久综合97| 欧美成人bangbros| 一区二区三区毛片| 成人国产精品免费观看动漫| 欧美精品xxxxbbbb| 亚洲欧美韩国综合色| 亚洲欧美国产毛片在线| 国内精品国产三级国产a久久| 91麻豆国产香蕉久久精品| 精品欧美乱码久久久久久| 一区二区三区精品视频| 亚洲视频小说图片| 国产一区二区三区综合| 91精品国产91久久综合桃花| 亚洲国产精品成人久久综合一区| 男人操女人的视频在线观看欧美| 91麻豆免费看| 国产精品久久午夜| 国产成人三级在线观看| 日韩免费视频一区| 日韩精品电影在线| kk眼镜猥琐国模调教系列一区二区 | 最新成人av在线| 国产成人日日夜夜| 久久九九影视网| 日韩电影在线观看电影| 欧美性猛片xxxx免费看久爱| 欧美国产日韩a欧美在线观看 | 国产精品一区二区三区乱码| 亚洲精品在线观看网站| 老司机精品视频一区二区三区| 欧美精品三级日韩久久| 丝袜国产日韩另类美女| 这里是久久伊人| 天天爽夜夜爽夜夜爽精品视频| 一本色道亚洲精品aⅴ| 亚洲精品视频在线看| 欧洲另类一二三四区| 精品国产成人系列| 久久久久久99精品| 99精品国产热久久91蜜凸| 亚洲综合图片区| 欧美福利一区二区| 久久99精品国产麻豆婷婷洗澡| 久久久精品免费网站| 91网站在线观看视频| 日本成人在线看| 国产精品免费久久久久| 欧美性做爰猛烈叫床潮| 极品美女销魂一区二区三区 | 一区二区三区在线影院| 91麻豆精品国产综合久久久久久| 激情文学综合丁香| 亚洲欧美激情小说另类| 欧美xingq一区二区| 99久久婷婷国产综合精品电影| 三级欧美在线一区| 国产精品网友自拍| 91精品蜜臀在线一区尤物| 成人av中文字幕| 日韩成人免费在线| 成人欧美一区二区三区| 精品久久久久久亚洲综合网| 91麻豆国产福利在线观看| 韩国女主播成人在线| 一区二区三区电影在线播| 久久蜜臀精品av| 欧美理论在线播放| 97se亚洲国产综合在线| 久久av资源站| 香蕉成人伊视频在线观看| 国产精品久久久久影院老司| 日韩欧美国产wwwww| 色婷婷久久久久swag精品| 国内精品国产成人国产三级粉色| 亚洲国产一区二区三区| 国产精品入口麻豆原神| 欧美大肚乱孕交hd孕妇| 欧美三级在线看| 91老师国产黑色丝袜在线| 国产高清在线精品| 久久国产精品色婷婷| 天堂成人免费av电影一区| 自拍偷拍国产精品| 国产精品嫩草99a| 久久一区二区三区四区| 日韩视频中午一区| 欧美肥妇bbw| 欧美日韩免费观看一区三区| 91九色02白丝porn| 色诱亚洲精品久久久久久| av中文字幕亚洲| 成人福利视频在线| 盗摄精品av一区二区三区| 国产一区二三区| 狠狠色丁香婷婷综合| 国产在线视频精品一区| 久久狠狠亚洲综合| 久久超碰97人人做人人爱| 日韩成人伦理电影在线观看| 亚洲超丰满肉感bbw| 亚洲在线视频一区| 亚洲电影欧美电影有声小说| 亚洲国产精品久久艾草纯爱| 亚洲成人第一页| 日韩va欧美va亚洲va久久| 久久精品国产成人一区二区三区| 日韩综合小视频| 久久成人免费网| 国产精品一级片在线观看| 国产jizzjizz一区二区| a级高清视频欧美日韩| 91福利小视频| 欧美一级在线观看| 国产欧美精品一区二区三区四区 | 亚洲欧洲另类国产综合| 亚洲欧美国产三级| 午夜婷婷国产麻豆精品| 美女视频黄 久久| 国产盗摄视频一区二区三区| 99精品视频在线观看| 欧美三级中文字幕在线观看| 欧美一区二区三区婷婷月色| 久久久精品国产免费观看同学| 亚洲欧洲在线观看av| 午夜精品一区二区三区免费视频 | av在线播放成人| 日本二三区不卡| 欧美性极品少妇| 欧美吻胸吃奶大尺度电影| 911精品国产一区二区在线| 777a∨成人精品桃花网| 日韩精品中午字幕| 中文字幕在线视频一区| 一区二区在线观看不卡| 亚洲国产综合色| 麻豆精品在线看| 成人h精品动漫一区二区三区| 99久久免费视频.com| 欧美色偷偷大香| 日韩午夜精品电影| 亚洲精品自拍动漫在线| 日本视频一区二区| 国产69精品久久久久777| 91美女视频网站| 91精品国产色综合久久ai换脸| 欧美一区二区三区日韩| 国产日韩成人精品| 国产精品亲子伦对白| 日韩国产精品久久久久久亚洲| 免费高清在线一区| yourporn久久国产精品| 色婷婷久久综合| 久久久精品国产免大香伊| 亚洲免费观看高清在线观看| 日本欧美大码aⅴ在线播放| 99re这里都是精品| 精品美女在线观看| 夜夜精品浪潮av一区二区三区| 日本在线不卡一区| 91国产精品成人| 久久久久99精品一区| 亚洲在线观看免费视频| 国产成人精品免费网站| 日韩精品专区在线| 亚洲一区二三区| 国产91清纯白嫩初高中在线观看 | 午夜精品视频在线观看| jlzzjlzz亚洲女人18| 日韩一区二区不卡| 中文字幕佐山爱一区二区免费| 日日噜噜夜夜狠狠视频欧美人| 色婷婷综合久久久久中文一区二区| www久久精品| 日韩国产精品91| 在线观看av一区二区| 国产精品乱子久久久久| 精品写真视频在线观看| 欧美日韩国产经典色站一区二区三区| 亚洲精品欧美在线| av电影天堂一区二区在线观看| 日韩精品一区二区三区在线观看| 中文字幕亚洲在| 日本精品视频一区二区三区| 国产日产欧美一区二区视频| 久草这里只有精品视频|