文章目录
1 驱动时序
按照SPWM
的驱动方式,驱动时序基本有整步,半步和细分驱动三种,下面简单介绍整步驱动;
A+ | B+ | A- | B- |
---|---|---|---|
1 | 0 | 0 | 0 |
0 | 1 | 0 | 0 |
0 | 0 | 1 | 0 |
0 | 0 | 0 | 1 |
2 仿真架构
这个仿真是matlab
自带的demo
,整步方式来驱动两相四线的步进电机,整体的仿真图如下所示;
3 Matlab Function
function [ap,an,bp,bn] = fcn(clk,dir)
if dir == 0
% back
if(clk == 0)
ap = 1;
an = 0;
bp = 0;
bn = 0;
else
ap = 0;
an = 0;
bp = 1;
bn = 0;
end
else
%forward
if(clk == 0)
ap = 0;
an = 0;
bp = 1;
bn = 0;
else
ap = 1;
an = 0;
bp = 0;
bn = 0;
end
end