»ùÓÚSTM32µÄ»úе±ÛÇý¶¯ÏµÍ³Éè¼Æ
Õª Òª
ÓÉÓÚ»úе±ÛÔÚ¸÷Ðи÷ÒµÖеõ½ÁËÓúÀ´Óú¹ã·ºµÄÓ¦Ó㬻úе±Û¿ØÖƵĶàÑù»¯¡¢¸´ÔÓ»¯µÄÐèÒªÒ²ËæÖ®ÈÕÇ÷Ôö¶à¡£×÷Ϊµ±½ñ¿Æ¼¼ÁìÓòÑо¿µÄÒ»¸öÈȵ㣬Ìá¸ß»úе±ÛµÄ¿ØÖƾ«¶È¡¢Îȶ¨ÐÔ¡¢²Ù×÷Áé»îÐÔ¶ÔÓÚÌá¸ßÆäÓ¦ÓÃˮƽÓÐ×ÅÊ®·ÖÖØÒªµÄÒâÒå¡£
±¾¿ÎÌâÖ÷Òª¶ÔËÄ×ÔÓɶȻúе±Û¿ØÖÆÏµÍ³½øÐÐÁËÑо¿ÓëÉè¼Æ¡£×÷ΪÔ˶¯¿ØÖÆÏµÍ³µÄÒ»ÖÖ£¬¸Ã¿ØÖÆÏµÍ³Ö÷ÒªÃæÏòµ×²ã£¬Á¦Õù¿ª·¢³öÒ»Ì×Îȶ¨ÐԸߣ¬¿É¿¿ÐÔÇ¿²¢ÇÒ¶¨Î»×¼È·µÄ¹¤Òµ»úе±Ûϵͳ¡£
Ê×Ïȸù¾Ý»úе±ÛϵͳµÄ¿ØÖÆÒªÇó£¬ÕûÌåÉÏÉè¼Æ³öµ¥ CPU µÄϵͳ¿ØÖÆ·½°¸£¬¼´Í¨¹ý¿ØÖÆÖ÷¿ØÖÆÆ÷Êä³öµÄ PWM ²¨µÄÕ¼¿Õ±ÈʵÏÖ¶Ô¶æ»úת¶¯µÄ¿ØÖÆ£¬½ø¶øÊµÏÖ¸÷¸ö¹Ø½ÚµÄλÖÿØÖÆ¡£ÔÚÓ²¼þ·½Ã棬Ö÷ÒªÂÛÊöÁËÈçºÎÒÔ ARM ΢´¦ÀíÆ÷STM32F103ZET6¡¢MG995¶æ»ú¡¢MG945¶æ»ú¡¢³¬Éù²¨´«¸ÐÆ÷ºÍµçÔ´Ä£¿éΪÖ÷ÒªÆ÷¼þ£¬Í¨¹ý´î½¨Ó²¼þƽ̨ºÍÉè¼ÆÈí¼þ¿ØÖƳÌÐò¹¹½¨¹Ø½ÚÔ˶¯¿ØÖÆÏµÍ³¡£È»ºó°´Õսṹ»¯Éè¼ÆµÄ˼Ï룬ÒÀ´Î¶ÔÒÔÉϸ÷²¿·ÖµÄÔÀíºÍÉè¼Æ·½·¨½øÐÐÁË·ÖÎöºÍ̽ÌÖ£¬¸ø³öÁËʵ¼ÊµÄÔÀíͼºÍµç·ͼ¡£ÔÚÈí¼þÉè¼Æ·½Ã棬°´ÕÕÄ£¿é»¯µÄÉè¼ÆË¼Ï뽫¿ØÖƳÌÐò·ÖΪ³õʼ»¯Ä£¿éºÍÔËÐÐÄ£¿é£¬²¢·Ö±ð¶Ô¸÷¸öÄ£¿éµÄ³ÌÐò½øÐÐÉè¼Æ¡£
ʵÑé±íÃ÷£¬¸Ã»úе±Û¿ØÖÆÏµÍ³²»½ö¾ßÓкܺõĿØÖƾ«¶È£¬»¹¾ßÓкܺõÄÎȶ¨ÐÔ¡¢×¼È·ÐÔ£¬¶øÇÒÔںܴó³Ì¶ÈÉϸÄÉÆÁ˶¨Î»¾«¶È¡£
¹Ø¼ü´Ê£ºËÄ×ÔÓɶȻúе±Û£¬STM32£¬Cortex-M3£¬Âö³å¿í¶Èµ÷ÖÆ
the Design of Manipulator Drive System Based on STM32
Author£ºXXX
Tutor£ºXXX
Abstract
In recent years, robot arm is widely used in industry control, special robot, medical device and home service robots. Research of robot arm control system is a focus in robot area. It is meaningful to increase the performance in accuracy, stability and feasibility.
This paper is the research and design about a control system based on a four degrees freedom¡¯s design. And, we strive to develop a high stability, reliability and accurate control system.
Firstly, according to the control requirements of the robotic system, the overall design of the system control program is based on a single CPU. Turn the steering control to achieve the control of the duty cycle of the PWM wave output by the main controller, so as to realize the position control of each joint. In terms of hardware, the paper mainly discusses how to use the ARM microprocessor STM32F103ZET6, MG995 Servo, MG945 servos, ultrasonic sensors and power supply module as the main components, build a joint motion control system by building hardware platforms and software control program. Then follow the structured design ideas, principles and design methods sequentially over each part is analyzed and discussed, and then give the actual schematic or circuit diagram. In software design, the control program is divided into the run modules and the initialization module and design program of each module separately.
Control system experiments show that the system can significantly improve the precision of control, and improve system stability, accuracy, so that the positioning accuracy of the robot arm has been greatly improved and enhanced.
Key Words: Four Degrees Freedom Robot, STM32, Cortex-M3, Pulse Width Modulation
¶«±±´óÑ§ÇØ»Êµº·ÖУ±ÏÒµÉè¼Æ£¨ÂÛÎÄ£© µÚ XI Ò³
Ŀ ¼
1Ð÷ÂÛ ........................................................................................................................................ 1 1.1»úе±Û¸ÅÊö .................................................................................................................... 1 1.1.1»úе±ÛÑо¿µÄÒâÒå ................................................................................................ 1 1.1.2¹úÄÚÍâ»úе±ÛµÄÑо¿ÏÖ×´¼°·¢Õ¹Ç÷ÊÆ ................................................................ 1 1.1.3»úе±ÛµÄ·ÖÀà ........................................................................................................ 2 1.2»úе±Û¿ØÖƵÄÑо¿ÄÚÈÝ ................................................................................................ 4 1.2.1»úе±ÛµÄÇý¶¯·½Ê½ ................................................................................................ 4 1.2.2»úе±ÛµÄ»úе½á¹¹ ................................................................................................ 4 1.2.3»úе±ÛµÄ¿ØÖÆÆ÷ .................................................................................................... 4 1.2.4»úе±ÛµÄ¿ØÖÆËã·¨ ................................................................................................ 5 1.3ǶÈëʽϵͳ¼ò½é ............................................................................................................ 5 1.4±¾ÎĵÄÖ÷Òª¹¤×÷ ............................................................................................................ 6 2»úе±Û¿ØÖÆÏµÍ³µÄ×ÜÌå·½°¸Éè¼Æ ........................................................................................ 7 2.1»úе±ÛµÄ»úе½á¹¹Éè¼Æ ................................................................................................. 7
2.1.1±Û²¿½á¹¹Éè¼ÆÔÔò ................................................................................................ 7 2.1.2»úе±Û×ÔÓɶȵÄÈ·¶¨ ............................................................................................ 7 2.2¹¤×÷¶ÔÏó¼ò½é ................................................................................................................. 7 2.3»úе±Û¹Ø½Ú¿ØÖƵÄ×ÜÌå·½°¸ ......................................................................................... 8
2.3.1»úе±Û¿ØÖÆÆ÷ÀàÐ͵ÄÈ·¶¨ .................................................................................... 8 2.3.2»úе±Û¿ØÖÆÏµÍ³½á¹¹ ............................................................................................ 9 2.3.3¹Ø½Ú¿ØÖÆÏµÍ³µÄ¿ØÖƲßÂÔ .................................................................................... 9 2.4±¾ÕÂС½á ......................................................................................................................... 9 3»úе±Û¿ØÖÆÏµÍ³Ó²¼þÉè¼Æ .................................................................................................. 11 3.1»úе±Û¿ØÖÆÏµÍ³¸ÅÊö ................................................................................................... 11 3.2΢´¦ÀíÆ÷Ñ¡ÐÍ ............................................................................................................... 11 3.3Ö÷¿ØÖÆÄ£¿éÉè¼Æ ........................................................................................................... 13
3.3.1µçÔ´µç· .............................................................................................................. 13 3.3.2¸´Î»µç· .............................................................................................................. 14 3.3.3ʱÖÓµç· .............................................................................................................. 15 3.3.4 JTAGµ÷ÊÔµç· ................................................................................................... 15 3.4Çý¶¯Ä£¿éÉè¼Æ ............................................................................................................... 16 3.5µçÔ´Ä£¿éÉè¼Æ ............................................................................................................... 17 3.6´«¸ÐÆ÷Ä£¿éÉè¼Æ ........................................................................................................... 19
¶«±±´óÑ§ÇØ»Êµº·ÖУ±ÏÒµÉè¼Æ£¨ÂÛÎÄ£© µÚ XII Ò³
3.7±¾ÕÂС½á ....................................................................................................................... 19 4»úе±Û¿ØÖÆÏµÍ³Èí¼þÉè¼Æ .................................................................................................. 20 4.1³õʼ»¯Ä£¿éÉè¼Æ ........................................................................................................... 20
4.1.1ϵͳʱÖÓ¿ØÖÆ ...................................................................................................... 20 4.1.2 SysTick¶¨Ê±Æ÷ .................................................................................................... 22 4.1.3 TIM¶¨Ê±Æ÷ .......................................................................................................... 23 4.1.4ͨÓÃÊäÈëÊä³ö½Ó¿ÚGPIO .................................................................................... 24 4.1.5³¬Éù²¨´«¸ÐÆ÷Ä£¿é .............................................................................................. 24 4.2ÔËÐÐÄ£¿éÉè¼Æ ............................................................................................................... 25 4.3±¾ÕÂС½á ....................................................................................................................... 26 5 ϵͳµÄÕû»úµ÷ÊÔ ................................................................................................................. 27 5.1Ó²¼þµ÷ÊÔ ....................................................................................................................... 27 5.2Èí¼þµ÷ÊÔ ....................................................................................................................... 28 5.3¹ÊÕÏÔÒò¼°½â¾ö·½·¨ ................................................................................................... 31 5.4±¾ÕÂС½á ....................................................................................................................... 32 ½á ÂÛ ................................................................................................................................. 33 Ö л ................................................................................................................................. 34 ²Î¿¼ÎÄÏ× ................................................................................................................................. 35 ¸½ ¼ ................................................................................................................................. 37 ¸½Â¼A ................................................................................................................................ 37 ¸½Â¼B ................................................................................................................................ 46 ¸½Â¼C ................................................................................................................................ 47