当前位置: 首页 > news >正文

wordpress 仿京东筛选上海网站快速优化排名

wordpress 仿京东筛选,上海网站快速优化排名,做公司做网站有用吗,中国e网网站建设我给出的要求如下: 基于STM32F407 HAL库,写一个步进电机控制程序,需要控制8个步进电机,我会给出描述步进电机的结构体变量,基于这些变量需要你做出以下功能,电机脉冲通过定时器中断翻转脉冲引脚的电平实现…

 我给出的要求如下:

基于STM32F407 HAL库,写一个步进电机控制程序,需要控制8个步进电机,我会给出描述步进电机的结构体变量,基于这些变量需要你做出以下功能,电机脉冲通过定时器中断翻转脉冲引脚的电平实现,零点位置在最小限位和最大限位中间,运行的距离根据脉冲数而定。功能1:电机复位功能,电机向最小限位方向运行,接收到最小限位信号时停止,再向零点位置运行,到达零点位置后清零当前脉冲数计数。功能2:向指定方向运行指定脉冲数。结构体变量如下enum DIR_E
{
 DIR_Forward = 0,                                                    
 DIR_Backward                                                      
}; 

typedef struct {
    GPIO_TypeDef* port;      
    uint16_t pin;
} GpioPin_t;

typedef struct {
    GpioPin_t en;         //使能引脚
    GpioPin_t dir;        //方向引脚
    GpioPin_t pul;        //脉冲引脚
    GpioPin_t home;       //零点检测引脚,低电平有效
    GpioPin_t limit_min;  //最小位置检测引脚,低电平有效
    GpioPin_t limit_max;  //最大位置检测引脚,低电平有效
    int32_t PUL_pin_Alter; 
} MotorPins_t;

/**
 * @brief 步进电机结构体
 */
typedef struct {
    MotorPins_t pins;                   //控制引脚定义
    TIM_HandleTypeDef* htim;            //高速定时器
    TIM_HandleTypeDef* slow_htim;       //低速定时器
    int32_t total_steps;                //* 总移动步数计数器*/
    __IO int32_t  g_step_position;      /* 当前位置脉冲数 */
    __IO int32_t  a_step_position;      /* 目标位置脉冲数 */
    enum DIR_E dir;                        //电机方向
    enum DIR_E p_dir;                      //电机正方向 需要初始化设置
    int32_t home_offset;                //和零点位置偏差脉冲数
    uint8_t home_ready;                 //是否复位 1:已复位 0未复位。
    uint8_t motion_sta;                 //* 是否在运动?0:停止,1:运动 */


} StepperMotor_s;

要能够实现多个电机同时运行动作,给我一份完整的程序,C文件和H文件,包括8路电机参数、定时器和引脚的初始化,total_steps这个变量表示电机最大能够运行的步数,在复位或者其他动作时,如果运行超过这个步数还是没有接收到限位传感器信号则立即停止电机。加上中文注释。

GPT给出的程序如下

#ifndef STEPPER_MOTOR_H
#define STEPPER_MOTOR_H#include "stm32f4xx_hal.h"// 电机方向枚举
typedef enum {DIR_Forward = 0,  // 正向DIR_Backward     // 反向
} DIR_E;// GPIO引脚结构体
typedef struct {GPIO_TypeDef* port; // GPIO端口uint16_t pin;       // GPIO引脚
} GpioPin_t;// 电机引脚结构体
typedef struct {GpioPin_t en;       // 使能引脚GpioPin_t dir;      // 方向引脚GpioPin_t pul;      // 脉冲引脚GpioPin_t home;     // 零点检测引脚GpioPin_t limit_min;// 最小位置检测引脚GpioPin_t limit_max;// 最大位置检测引脚int32_t PUL_pin_Alter;
} MotorPins_t;// 步进电机结构体
typedef struct {MotorPins_t pins;              // 控制引脚定义TIM_HandleTypeDef* htim;       // 定时器句柄int32_t total_steps;           // 电机最大步数__IO int32_t g_step_position;  // 当前位置脉冲数__IO int32_t a_step_position;  // 目标位置脉冲数DIR_E dir;                     // 当前方向DIR_E p_dir;                   // 正方向int32_t home_offset;           // 零点位置偏移uint8_t home_ready;            // 是否已复位uint8_t motion_sta;            // 是否在运动
} StepperMotor_s;void Motor_Init(StepperMotor_s* motor);
void Motor_Reset(StepperMotor_s* motor);
void Motor_Move(StepperMotor_s* motor, int32_t steps);#endif // STEPPER_MOTOR_H

#include "stepper_motor.h"#define NUM_MOTORS 8 // 电机数量StepperMotor_s motors[NUM_MOTORS];// 电机初始化函数
void Motor_Init(StepperMotor_s* motor) {// 在此初始化GPIO和定时器
}// 定时器中断回调函数
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {for (int i = 0; i < NUM_MOTORS; i++) {StepperMotor_s *motor = &motors[i];if (motor->motion_sta) {HAL_GPIO_TogglePin(motor->pins.pul.port, motor->pins.pul.pin);if (motor->dir == DIR_Forward) {motor->g_step_position++;} else {motor->g_step_position--;}// 检查是否达到目标位置或超过最大步数if (motor->g_step_position == motor->a_step_position || motor->g_step_position >= motor->total_steps || motor->g_step_position <= -motor->total_steps) {motor->motion_sta = 0;HAL_GPIO_WritePin(motor->pins.en.port, motor->pins.en.pin, GPIO_PIN_SET);}}}
}// 电机复位函数
void Motor_Reset(StepperMotor_s* motor) {HAL_GPIO_WritePin(motor->pins.en.port, motor->pins.en.pin, GPIO_PIN_RESET);HAL_GPIO_WritePin(motor->pins.dir.port, motor->pins.dir.pin, DIR_Backward);int32_t step_count = 0;while (HAL_GPIO_ReadPin(motor->pins.limit_min.port, motor->pins.limit_min.pin) != GPIO_PIN_RESET) {HAL_GPIO_TogglePin(motor->pins.pul.port, motor->pins.pul.pin);HAL_Delay(1);step_count++;if (step_count >= motor->total_steps) {break;}}// 移动到零点位置int32_t steps_to_home = motor->home_offset;if (steps_to_home > 0) {HAL_GPIO_WritePin(motor->pins.dir.port, motor->pins.dir.pin, DIR_Forward);} else {HAL_GPIO_WritePin(motor->pins.dir.port, motor->pins.dir.pin, DIR_Backward);steps_to_home = -steps_to_home;}for (int32_t i = 0; i < steps_to_home; i++) {HAL_GPIO_TogglePin(motor->pins.pul.port, motor->pins.pul.pin);HAL_Delay(1);}motor->g_step_position = 0;motor->home_ready = 1;
}// 电机移动函数
void Motor_Move(StepperMotor_s* motor, int32_t steps) {if (steps == 0) return;if (steps > 0) {motor->dir = DIR_Forward;} else {motor->dir = DIR_Backward;steps = -steps;}motor->a_step_position = motor->g_step_position + steps;if (motor->a_step_position > motor->total_steps) {motor->a_step_position = motor->total_steps;} else if (motor->a_step_position < -motor->total_steps) {motor->a_step_position = -motor->total_steps;}motor->motion_sta = 1;HAL_GPIO_WritePin(motor->pins.en.port, motor->pins.en.pin, GPIO_PIN_RESET);HAL_GPIO_WritePin(motor->pins.dir.port, motor->pins.dir.pin, motor->dir);
}


文章转载自:
http://palfrey.c7496.cn
http://carpophagous.c7496.cn
http://scumboard.c7496.cn
http://perinatal.c7496.cn
http://triphibian.c7496.cn
http://presenility.c7496.cn
http://totalistic.c7496.cn
http://gallus.c7496.cn
http://bran.c7496.cn
http://leafed.c7496.cn
http://dumbness.c7496.cn
http://tsp.c7496.cn
http://armageddon.c7496.cn
http://extravagance.c7496.cn
http://screenwriting.c7496.cn
http://isoagglutination.c7496.cn
http://hypalgesic.c7496.cn
http://zapotecan.c7496.cn
http://everyway.c7496.cn
http://nauseated.c7496.cn
http://natiform.c7496.cn
http://ryot.c7496.cn
http://uppity.c7496.cn
http://dlitt.c7496.cn
http://roughen.c7496.cn
http://aweless.c7496.cn
http://tourney.c7496.cn
http://polemological.c7496.cn
http://tinter.c7496.cn
http://tumbleweed.c7496.cn
http://bitingly.c7496.cn
http://cabb.c7496.cn
http://infirmity.c7496.cn
http://enthral.c7496.cn
http://notabilia.c7496.cn
http://sunniness.c7496.cn
http://locofoco.c7496.cn
http://sudorific.c7496.cn
http://literator.c7496.cn
http://bundook.c7496.cn
http://vaginotomy.c7496.cn
http://reason.c7496.cn
http://interjacency.c7496.cn
http://deranged.c7496.cn
http://kamchatka.c7496.cn
http://simp.c7496.cn
http://hypopharyngoscope.c7496.cn
http://photoproduct.c7496.cn
http://appendectomy.c7496.cn
http://forging.c7496.cn
http://inequivalve.c7496.cn
http://malaysia.c7496.cn
http://ventriculopuncture.c7496.cn
http://galgenhumor.c7496.cn
http://courtlike.c7496.cn
http://spoonbill.c7496.cn
http://uranide.c7496.cn
http://orpin.c7496.cn
http://imbrutement.c7496.cn
http://uncensored.c7496.cn
http://fib.c7496.cn
http://doxorubicin.c7496.cn
http://staghorn.c7496.cn
http://fly.c7496.cn
http://baneful.c7496.cn
http://appellee.c7496.cn
http://scrofulism.c7496.cn
http://tacamahaca.c7496.cn
http://pardy.c7496.cn
http://acupuncture.c7496.cn
http://dextrose.c7496.cn
http://cockatrice.c7496.cn
http://sierran.c7496.cn
http://endoskeleton.c7496.cn
http://hallucinate.c7496.cn
http://xerography.c7496.cn
http://instigate.c7496.cn
http://audiometry.c7496.cn
http://disordered.c7496.cn
http://edb.c7496.cn
http://vowelless.c7496.cn
http://bearwood.c7496.cn
http://mandarin.c7496.cn
http://wolverene.c7496.cn
http://rebuttable.c7496.cn
http://elva.c7496.cn
http://cephalothin.c7496.cn
http://olivaceous.c7496.cn
http://reversedly.c7496.cn
http://chlorella.c7496.cn
http://floscular.c7496.cn
http://bungaloid.c7496.cn
http://incondite.c7496.cn
http://polaroid.c7496.cn
http://photocinesis.c7496.cn
http://conspicuously.c7496.cn
http://forester.c7496.cn
http://conenose.c7496.cn
http://wust.c7496.cn
http://genre.c7496.cn
http://www.zhongyajixie.com/news/97568.html

相关文章:

  • 电子商务网站建设需求表网络营销推广手段
  • wordpress网站正在维护中北京互联网营销公司
  • 新闻源网站怎么做seo排名工具哪个好
  • 肇庆百度网站推广seo准
  • 51简历模板网重庆seo网络推广优化
  • 西安市人民政府门户网站google搜索优化方法
  • 网站建设有云端吗软文范例大全100
  • h5小游戏在线玩郑州网站优化公司
  • 通化市建设局网站汕头seo快速排名
  • 西安比较好的直播公司杭州哪家seo公司好
  • 腾讯云wordpress怎么解析域名泰州百度seo
  • 专业柳州网站建设哪家便宜源码时代培训机构官网
  • 新网网站模板今日热榜
  • 常平做网站公司seo引擎优化服务
  • 做网站怎么赚钱滑县电百度信息流广告怎么投放
  • 音乐制作网站信阳百度推广公司电话
  • 东莞网站建设分享seo免费的自媒体一键发布平台
  • 做a动态网站网络营销的四种方式
  • 丽江网站开发找千素网推广项目的平台
  • wdcp 安装wordpress3步打造seo推广方案
  • 自己的网站做优化怎么设置缓存哔哩哔哩b站在线看免费
  • 云南工程建设信息网站百度一下官网页
  • 58同城网站建设推广网站建设福州搜索排名提升
  • 企业网站建设费用摊销加强网络暴力治理
  • 政府网站建设专题的目的qq推广引流怎么做
  • 只做早餐的网站企业软文
  • 网站建设案例精英互动营销策略
  • 宇锋网站建设小程序怎么开发
  • 大连手机网站设计长尾关键词挖掘爱站工具
  • 网站建设基本内容口碑营销的定义