国产FPGA高云GW1N-4系列开发板测评之——步进电机控制(初版)
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span style="font-size:14.0pt"><span style="font-family:宋体">没怎么玩过步进电机,想做一个步进电机控制升降装置,先搭建一个模型试试吧。首先来学习一下步进电机的基础知识。</span></span></span></span></span></p><p style="text-align:justify"> </p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span style="font-size:14.0pt"><span style="font-family:宋体">选了比较常用的5线4相步进电机28BYJ48示意图如下:</span></span></span></span></span></p>
<p style="text-align:justify"> <span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span style="font-size:14.0pt"><span style="font-family:宋体">驱动方式参数如下:</span></span></span></span></span></p>
<p style="text-align:justify"></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span lang="EN-US" style="font-size:14.0pt"><span style="font-family:宋体">28BYJ48 5V </span></span><span style="font-size:14.0pt"><span style="font-family:宋体">驱动的 4 相5线的步进电机是减速步进电机,减速比为 1:64步进角为 5.625/64度 。 如果需要转动1圈那么需要 360/5.625*64=4096 个脉冲信号。</span></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span style="font-size:14.0pt"><span style="font-family:宋体">该步进电机耗电流为200mA左右,FPGA输出驱动不了如下图所示:</span></span></span></span></span></p>
<p style="text-align:justify"></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span style="font-size:14.0pt"><span style="font-family:宋体">所以需要一个电机驱动器,</span></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span lang="EN-US" style="font-size:14.0pt"><span style="font-family:宋体">ULN2003</span></span><span style="font-size:14.0pt"><span style="font-family:宋体">电机驱动器芯片,是一个16脚PDIP封装的7输入7输出高压大电流达林顿晶体管阵列,最大30v输入、最大50v输出、500mA的额定集电极电流输出,传播延时最大1us,完全能满足要求。</span></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span style="font-size:14.0pt"><span style="font-family:宋体">以下是步进电机驱动真值表:</span></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span style="font-size:14.0pt"><span style="font-family:宋体">器件手册准备差不多了,接下来先搭好电路:</span></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:14.0pt"><span style="font-family:宋体">然后写代码吧,先来实现一个比较简单的功能,实现步进电机安照一定速率正转反转。</span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span style="font-size:14.0pt"><span style="font-family:宋体">由驱动真值表可以看出控制步进电机转起来需要4钟状态切换,所以我使用一个状态机来实现这个功能:</span></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span style="font-size:14.0pt"><span style="font-family:宋体">代码工程附件中,然后写一个testbench用ModelSim 仿真一下如下:</span></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span style="font-size:14.0pt"><span style="font-family:宋体">这个工程比较简单,但写代码的过程中逻辑太多往往会有考虑不到位的情况,所以一般都要先仿真在上板,仿真调试的过程中能快速解决很多逻辑上的问题,这点很重要,仿真通过后就分配管脚添加时钟约束生成bit流:</span></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线"><span style="text-justify:inter-ideograph"><span style="font-size:14.0pt"><span style="font-family:宋体">编译通过后下板看看效果,效果在后面动图中展示:</span></span></span></span></span></p>
<p style="text-align:justify"></p>
<p style="text-align:justify"> </p>
<p style="text-align:justify"> </p>
<p style="text-align:justify"> </p>
<p style="text-align:justify"> </p>
<p style="text-align:justify"> </p>
<p>楼主的ModelSim 仿真玩的不错</p>
页:
[1]