久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 1856|回復: 0
打印 上一主題 下一主題
收起左側

STM32 驅動ULN2003步進電機驅動板 + 5V步進電機

[復制鏈接]
跳轉到指定樓層
樓主
STM32 驅動ULN2003步進電機驅動板 + 5V步進電機


step.h

#ifndef  __STEP_H__
#define __STEP_H__

#include "stm32f10x.h"

void Step_Motor_GPIO_Init(void);
/*
        功能:轉1/64圈
        步距角5.625 360/5.625=64 減速比1/64
        故64*64個脈沖轉一圈
        n 圈數
        direction 方向 1正轉 非1反轉
        delay delay時長 >= 2
*/
void motor_circle(int n, int direction, int delay);

#endif







step.C


#include "sys.h"
#include "delay.h"
#include "step.h"

//IN4: PF4  d
//IN3: PF3  c
//IN2: PF2  b
//IN1: PF1  a

u8 forward[4] = {0x03,0x06,0x0c,0x09}; // 正轉
u8 reverse[4]= {0x03,0x09,0x0c,0x06}; // 反轉

//引腳初始化
void Step_Motor_GPIO_Init(void)
{
    GPIO_InitTypeDef GPIO_InitStructure;
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOF, ENABLE);

    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4|GPIO_Pin_3|GPIO_Pin_2|GPIO_Pin_1;
    GPIO_Init(GPIOF, &GPIO_InitStructure);
}

//引腳映射
void SetMotor(unsigned char InputData)
{
        if(InputData == 0x03)
        {
                GPIO_SetBits(GPIOF,GPIO_Pin_1);
                GPIO_SetBits(GPIOF,GPIO_Pin_2);
                GPIO_ResetBits(GPIOF,GPIO_Pin_3);
                GPIO_ResetBits(GPIOF,GPIO_Pin_4);
        }
        else if(InputData == 0x06)
        {
                GPIO_ResetBits(GPIOF,GPIO_Pin_1);
                GPIO_SetBits(GPIOF,GPIO_Pin_2);
                GPIO_SetBits(GPIOF,GPIO_Pin_3);
                GPIO_ResetBits(GPIOF,GPIO_Pin_4);
        }
        else if(InputData == 0x09)
        {
                GPIO_SetBits(GPIOF,GPIO_Pin_1);
                GPIO_ResetBits(GPIOF,GPIO_Pin_2);
                GPIO_ResetBits(GPIOF,GPIO_Pin_3);
                GPIO_SetBits(GPIOF,GPIO_Pin_4);
        }
        else if(InputData == 0x0c)
        {       
                GPIO_ResetBits(GPIOF,GPIO_Pin_1);
                GPIO_ResetBits(GPIOF,GPIO_Pin_2);
                GPIO_SetBits(GPIOF,GPIO_Pin_3);
                GPIO_SetBits(GPIOF,GPIO_Pin_4);
        }
        else if(InputData == 0x00)
        {
                GPIO_ResetBits(GPIOF,GPIO_Pin_1);
                GPIO_ResetBits(GPIOF,GPIO_Pin_2);
                GPIO_ResetBits(GPIOF,GPIO_Pin_3);
                GPIO_ResetBits(GPIOF,GPIO_Pin_4);
        }
}

/*
        功能:轉1/64圈
        步距角5.625 360/5.625=64 減速比1/64
        故64*64個脈沖轉一圈
        n 圈數
        direction 方向 1正轉 非1反轉
        delay delay時長ms >= 2
*/
void motor_circle(int n, int direction, int delay)
{
    int i, j;
    for(i = 0; i < n * 8; i++)
    {
                for(j = 0; j < 4; j++)
                {
                        if(1 == direction)
                        {
                                SetMotor(0x00);
                                SetMotor(forward[j]);
                        }
                        else
                        {
                                SetMotor(0x00);
                                SetMotor(reverse[j]);
                        }
                       
                        delay_ms(delay > 2 ? delay : 2);
                }
    }
}


51hei圖片_20230628091311.jpg (261.03 KB, 下載次數: 97)

接線

接線

51hei圖片_20230628091346.jpg (160.31 KB, 下載次數: 81)

51hei圖片_20230628091346.jpg

51hei圖片_20230628091353.jpg (487.63 KB, 下載次數: 92)

MAIN

MAIN

STM32_ULN2003步進電機驅動板 .zip

3.05 MB, 下載次數: 61, 下載積分: 黑幣 -5

評分

參與人數 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎勵!

查看全部評分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 亚洲一区二区网站 | 欧美日韩高清一区 | 日韩免费在线观看视频 | 免费国产一区 | 久久精品国产99国产 | 羞羞视频在线观看免费观看 | 国产免费一区二区三区 | 综合色在线 | 欧美日韩在线一区二区三区 | 成人福利网 | 亚洲福利网 | 日韩美女一区二区三区在线观看 | 人人玩人人添人人澡欧美 | 久久福利电影 | 国产一区二区三区 | 色五月激情五月 | 91精品国产手机 | 亚洲免费在线观看视频 | av国产精品 | 欧美二区在线 | 中文字幕av高清 | 午夜电影网| 日本黄色的视频 | www国产成人免费观看视频,深夜成人网 | 亚洲视频一区在线观看 | 免费观看成人av | av网站免费在线观看 | 精品久久国产 | 成人在线播放网站 | 亚洲成人在线网 | 欧美精品一区二区在线观看 | 日韩欧美网 | 亚洲欧美在线免费观看 | 韩国av电影网 | 伊人超碰在线 | 中文字幕亚洲区一区二 | 久久精品一 | 免费观看日韩av | 国产激情在线 | www.国产 | 国产区一区二区三区 |