单片机28BYJ-48步进电机控制器仿真IC解密
IC解密单片机源程序如下:
- #include "macro.h"
- typedef unsigned int u16;
- u16 un;
- uchar buf_Direction; //?????????
- uint set_speed; //?????????
- uchar step_motor_loop[8]={0x01,0x03,0x02,0x06,0x04,0x0C,0x08,0x09};//28byj-48电机时序
- //uchar step_motor_loop[4]={0x09,0x06,0x03,0x0c};//42步进时序
- uchar step_index;
- #define CST_STEP_MOTOR_Z 10 //??
- #define CST_STEP_MOTOR_F 20 //??
- #define CST_STEP_MOTOR_ST 0 //?
- #define fosc_12MHz 12
- #define fosc_24MHz 24
- #define fosc_setting fosc_12MHz
- //????1
- #define CST_TIME_MS 200
- #define CST_TH0 (65536-CST_TIME_MS*fosc_setting/fosc_12MHz)/256
- #define CST_TL0 (65536-CST_TIME_MS*fosc_setting/fosc_12MHz)%256
- uchar buf_SpeedString[]=" ";
- //void iniLCD(void);
- //void list_write_HZ_Str( int x1,int y1, uchar *point ) ;
- void delay(u16 num)
- {
- u16 x,y;
- for(x=num; x>0; x--)
- for(y=110; y>0; y--)
- {
- ;//??1ms
- }
- }
- void step_motor_driver(void)
- {
- static uint speed_delay=0;
- speed_delay++;
- if( buf_Direction==CST_STEP_MOTOR_Z)
- {
- P0=step_motor_loop[step_index];
- if(speed_delay >=set_speed )
- {
- speed_delay =0;
- step_index--;
- if(step_index <=0)
- step_index =7;
- //=================================================转1圈
- un++;
- if(un>=3600)
- {
- un=0;
- step_index=3;
- buf_Direction=0;
-
- }
- //=================================================
- }
- }
- else if( buf_Direction==CST_STEP_MOTOR_F)
- {
-
- P0=step_motor_loop[step_index];
- if(speed_delay >=set_speed)
- {
- speed_delay =0;
- step_index++; //??7,????
- if(step_index >7)
- step_index =0;
- //=================================================转1圈
- un++;
- if(un>=4100)
- {
- un=0;
- step_index=3;
- buf_Direction=0;
-
- }
- //============================================
- }
- }
- else
- {
- speed_delay =0;
- un=0;
- step_index=3;
- P0=0x00;
- }
- }

芯片解密