找回密码
 立即注册
查看: 187|回复: 2

PWM学习进展-使用6个PWM口驱动三个步进电机

[复制链接]
  • TA的每日心情
    开心
    2024-4-17 14:45
  • 签到天数: 9 天

    [LV.3]偶尔看看II

    5

    主题

    7

    回帖

    141

    积分

    注册会员

    积分
    141
    发表于 2024-1-24 14:47:37 | 显示全部楼层 |阅读模式
    本帖最后由 houyawei 于 2024-1-24 17:32 编辑




    使用6个PWM口,6个IO口驱动三个步进电机
    第一步是初始化快速归零
    第二步是慢慢反向旋转
    1. u16 motor_pwm1[48] = {354,374,394,400,410,400,394,374,
    2.                                 354,286,220,184,148,112,82,36,
    3.                                 512,476,430,400,364,328,292,226,
    4.                                 158,138,118,112,102,112,118,138,
    5.                                 158,226,292,328,364,400,430,476,
    6.                                 2,36,82,112,148,184,220,288,};
    7. unsigned char code motor_pwm2[48]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    8.                                                                    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    9.                                                                    0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
    10.                                                                    0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
    11.                                                                    0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
    12.                                                                    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};
    13. unsigned char code motor_pwm3[48]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    14.                                                                    0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
    15.                                                                    0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
    16.                                                                    0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
    17.                                                                    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    18.                                                                    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};
    19. u16 motor_pwm4[48] = {
    20.                                 354,286,220,184,148,112,82,36,//1
    21.                                 512,476,430,400,364,328,292,226,//2
    22.                                 158,138,118,112,102,112,118,138,//3
    23.                                 158,226,292,328,364,400,430,476,//4
    24.                                 2,36,82,112,148,184,220,288,//5
    25.                                 354,374,394,400,410,400,394,374,//6
    26.                                 };
    复制代码

    1. PWMA_CCR1H = (u8)(motor_pwm1[count] >> 8);//设置占空比时间
    2.                 PWMA_CCR1L = (u8)(motor_pwm1[count]);
    3.                 fule_m2=(bit)motor_pwm2[count];
    4.                 fule_m2=(bit)motor_pwm3[count];
    5.                 PWMA_CCR2H = (u8)(motor_pwm4[count] >> 8);//设置占空比时间
    6.                 PWMA_CCR2L = (u8)(motor_pwm4[count]);
    7.                
    8.                 PWMA_CCR3H = (u8)(motor_pwm1[count] >> 8);//设置占空比时间
    9.                 PWMA_CCR3L = (u8)(motor_pwm1[count]);
    10.                 zs_m2=(bit)motor_pwm2[count];
    11.                 zs_m3=(bit)motor_pwm3[count];
    12.                 PWMA_CCR4H = (u8)(motor_pwm4[count] >> 8);//设置占空比时间
    13.                 PWMA_CCR4L = (u8)(motor_pwm4[count]);
    14.                
    15.                 PWMB_CCR5H = (u8)(motor_pwm1[a] >> 8);//设置占空比时间
    16.                 PWMB_CCR5L = (u8)(motor_pwm1[a]);
    17.                 water_m2=(bit)motor_pwm2[a];
    18.                 water_m3=(bit)motor_pwm3[a];
    19.                 PWMB_CCR6H = (u8)(motor_pwm4[a] >> 8);//设置占空比时间
    20.                 PWMB_CCR6L = (u8)(motor_pwm4[a]);
    复制代码



    回复 送花

    使用道具 举报

    该用户从未签到

    550

    主题

    9410

    回帖

    1万

    积分

    管理员

    积分
    13960
    发表于 2024-1-24 15:53:26 | 显示全部楼层


    其实用下面这个这个上传视频按钮很方便,不要链接到外部,
    链接到外部我们还要去观摩,增加很多不必要的麻烦


    截图202401241551181276.jpg

    截图202401241551072284.jpg

    回复 支持 反对 送花

    使用道具 举报

  • TA的每日心情
    开心
    2024-4-17 14:45
  • 签到天数: 9 天

    [LV.3]偶尔看看II

    5

    主题

    7

    回帖

    141

    积分

    注册会员

    积分
    141
     楼主| 发表于 2024-1-24 17:29:59 | 显示全部楼层
    神农鼎 发表于 2024-1-24 15:53
    其实用下面这个这个上传视频按钮很方便,不要链接到外部,
    链接到外部我们还要去观摩,增加很多不必要的 ...

    好滴好滴
    回复 支持 反对 送花

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|手机版|深圳国芯人工智能有限公司 ( 粤ICP备2022108929号-2 )

    GMT+8, 2024-5-13 00:42 , Processed in 0.343175 second(s), 41 queries .

    Powered by Discuz! X3.5

    © 2001-2024 Discuz! Team.

    快速回复 返回顶部 返回列表