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

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 1993|回復: 0
收起左側

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

[復制鏈接]
ID:1053560 發表于 2023-6-28 09:18 | 顯示全部樓層 |閱讀模式
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圖片_20230628091346.jpg

MAIN

MAIN

STM32_ULN2003步進電機驅動板 .zip

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

評分

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

查看全部評分

回復

使用道具 舉報

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

本版積分規則

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

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 91啦丨九色丨刺激 | 18色av| 亚洲欧美视频 | 欧美综合色 | 亚洲伊人av| 日本理伦片午夜理伦片 | 日韩黄色免费视频 | 亚洲激情一区二区 | 日本一区二区高清 | 五月婷婷激情综合 | 成人国产精品一区二区 | 成人在线观看免费爱爱 | 欧美一级黄色大片 | 亚洲 欧美 日韩 在线 | 天天干在线观看 | 白白色在线观看 | 欧美顶级黄色大片免费 | 国产精品一区二 | 亚洲精品午夜精品 | 久久久久毛片 | 69精品视频 | 亚洲麻豆视频 | 福利看片 | 五月婷婷综合网 | 午夜视频网站 | 丰满少妇高潮在线观看 | 欧美三级韩国三级日本三斤在线观看 | 久久午夜视频 | 黄色一区二区三区 | 少妇精品视频 | 天天躁日日躁bbbbb | 亚洲黄色在线视频 | 国产精品亚洲综合 | 五月色综合 | 在线观看免费毛片 | 视频在线一区 | 日韩色黄大片 | 午夜精品久久久久久久 | 欧美在线不卡 | 日韩欧美精品 | 国产成人免费观看 |